//Site-wide functions

sfHover = function() {
	var sfEls = document.getElementById("topNav").getElementsByTagName("li");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

function start_slideshow(start_frame, end_frame, delay) {
    setTimeout(switch_slides(start_frame,start_frame,end_frame, delay), delay);
}
                        
function switch_slides(frame, start_frame, end_frame, delay) {
    return (function() {
        Effect.Fade('slideshow' + frame);
        if (frame == end_frame) { frame = start_frame; } else { frame = frame + 1; }
        setTimeout("Effect.Appear('slideshow" + frame + "');", 850);
        setTimeout(switch_slides(frame, start_frame, end_frame, delay), delay + 850);
    })
}

function subHover(sectionName, sectionLink, boxBg, textCol) {
	$('infoText').update(sectionName);
	$('subLink').href = sectionLink;
	if (boxBg != '') {
		$('subSectionInfo').style.backgroundImage = 'url(/images/'+boxBg+'.png)'
	}else{
		$('subSectionInfo').style.backgroundImage = 'url(/images/boxout_empty.png)'
	}
	$('infoText').style.color = textCol;
}

function showImage(ContentId, ImgNum) {
	$('mainImage').src = '/images/content_'+ContentId+'_'+ImgNum+'.jpg';
}

function showRCImage(RaceCarId, ImgNum) {
	$('mainImage').src = '/images/racecar_'+RaceCarId+'_'+ImgNum+'.jpg';
}


