isCached = false;
curBG = "1";

function doCache() {
	// define OFF images
	imgWakeupOff = new Image();
	imgWakeupOff.src = "/images/menu_wakeupcall_off.gif";
	imgAboutOff = new Image();
	imgAboutOff.src = "/images/menu_about_off.gif";
	imgMarketOff = new Image();
	imgMarketOff.src = "/images/menu_market_off.gif";
	imgGameOff = new Image();
	imgGameOff.src = "/images/menu_game_off.gif";
	imgTVOff = new Image();
	imgTVOff.src = "/images/menu_tv_top.gif";
	imgStokoffOff = new Image();
	imgStokoffOff.src = "/images/menu_stokoff_off.gif";
	
	// define ON images
	imgWakeupOn = new Image();
	imgWakeupOn.src = "/images/menu_wakeupcall_on.gif";
	imgAboutOn = new Image();
	imgAboutOn.src = "/images/menu_about_on.gif";
	imgMarketOn = new Image();
	imgMarketOn.src = "/images/menu_market_on.gif";
	imgGameOn = new Image();
	imgGameOn.src = "/images/menu_game_on.gif";
	imgTVOn = new Image();
	imgTVOn.src = "/images/menu_tv_top_on.gif";
	imgStokoffOn = new Image();
	imgStokoffOn.src = "/images/menu_stokoff_on.gif";

	isCached = true;

}

function imgOn(imgName) // MOUSEOVER
{
	if (isCached)
	{
		document.getElementById("img"+imgName).src = eval("img"+imgName+"On").src;
	}		
}

function imgOff(imgName) // MOUSEOUT
{
	if (isCached)
	{
		document.getElementById("img"+imgName).src = eval("img"+imgName+"Off").src;
	}		
}

function setbg(bgNum,ele)
{
	if (curBG != "")
	{
		document.getElementById("bgbar"+curBG).className = "bgbarcell_off";
	}
	document.getElementById("main_content").style.background = "url('/images/bg_"+bgNum+".gif') no-repeat";
	document.getElementById("bgbar"+bgNum).className = "bgbarcell_on";
	curBG = bgNum;
}

function loadVideo(intVIndex)
{
	$.post('/js/getClipID.php', {intIndex: intVIndex}, function(data) {
		var objData = eval("(" + data.replace(/\n/g,'') + ")");
		
		var objPlayer = swfobject.getObjectById('vPlayer');
		objPlayer.loadVideo(objData.intClipID);
		
		$('#clips > div').removeClass('clip_selected');
		$('#clips > div:eq(' + objData.intIndex + ')').addClass('clip_selected');
		moveScroller(objData.intIndex);
	});
}

function moveScroller(intIndex)
{
	document.getElementById('clips').scrollTop = intIndex * $('.clip').height() + (intIndex * 5);
}

function launchTerms(strType)
{
	pageName = "/terms.php";

	if (strType != "")
	{
		switch(strType){
			case "challenge":
				pageName = "/terms_danceChallenge.php";
				break;
			case "wakeup":
				pageName = "/terms_wakeupCall.php";
				break;
		}
	}

	strHeight = 500;
	strWidth = 700;
	launcher = window.open(pageName,"wndPopUp","height=" + strHeight + ",width=" + strWidth + ",status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes");
}

/************************************************************************************************************************
	Hide the "86" button when clicked or when intro video is complete (called from the Flash homepage video player)
************************************************************************************************************************/
function hide86() {
	document.getElementById("div86thehost").style.visibility = "hidden";
}

