
var videoIsPoppedUp=false;
var video=false;
var currentVideo=1;
//MOVIE SLIDES

var startOffset=196;
var endOffset;
var slideOffset=0;
var setSlideOffset=196;
var amount=0;
var timerId = 0;

function doSlide(direction)
{
	amount=272*direction;
	endOffset=startOffset-(272*numslides);
	document.getElementById("leftClick").style.display = 'block';
	document.getElementById("rightClick").style.display = 'block';

	if (setSlideOffset+slideOffset>startOffset)
	{
		setSlideOffset=startOffset;
		slideOffset=0;
		amount=0;

	}else if (setSlideOffset+slideOffset<endOffset)
	{
		setSlideOffset=endOffset;
		slideOffset=0;
		amount=0;
	}

	var sh=document.getElementById("slideholder");

	if (slideOffset<amount)
	{
		slideOffset+=16;
	}else if (slideOffset>amount)
	{
		slideOffset-=16;
	}

	if (setSlideOffset+slideOffset<=endOffset)
	{
		document.getElementById("rightClick").style.display = 'none';
	}

	if (setSlideOffset+slideOffset>=startOffset)
	{
		document.getElementById("leftClick").style.display = 'none';
	}

	sh.style.marginLeft=setSlideOffset+slideOffset+"px";

	if (slideOffset!=amount)
	{
		timerId=setTimeout ( "doSlide("+direction+")", 10 );
	}
	else
	{
		clearTimeout(timerId);
		setSlideOffset+=slideOffset;
		slideOffset=0;
		
		if (direction==1)
		{
			if (currentVideo>1)
			{
				if	(wasOffScreen)
				{
					if (document.getElementById("video"+currentVideo))
					{
						document.getElementById("video"+currentVideo).style.background= "url('/digitv/cds/Birmingham/Wii/static/slidecover.png')";
					}
				}
				currentVideo--;
				if (wasOffScreen)
				{
					if (document.getElementById("video"+currentVideo))
					{
						document.getElementById("video"+currentVideo).style.background= "url('/digitv/cds/Birmingham/Wii/static/slidecover2.png')";
					}
				}
			}
		}
		else
		{
			if (currentVideo<=numslides)
			{
				if (wasOffScreen)
				{
					if (document.getElementById("video"+currentVideo))
					{
						document.getElementById("video"+currentVideo).style.background= "url('/digitv/cds/Birmingham/Wii/static/slidecover.png')";
					}
				}
				currentVideo++;
				if (wasOffScreen)
				{
					if (document.getElementById("video"+currentVideo))
					{
						document.getElementById("video"+currentVideo).style.background= "url('/digitv/cds/Birmingham/Wii/static/slidecover2.png')";
					}
				}
			}
		}
	}
}

//END MOVIE SLIDES

var winW = 630;
var winH = 460;
winW = window.innerWidth;
winH = window.innerHeight;
var i=0
var myRecentSites;

function popupVideo(stream,link,streamname)
{
	videoIsPoppedUp=true;
	//create z-indexed div id=videocontent to hold generated flash object
	var layer = document.createElement('div');
    layer.style.zIndex = 100;
    layer.id = 'videocontent';
    layer.style.position = 'absolute';
    layer.style.top = '0px';
    layer.style.left = '0px';
    layer.style.paddingTop = '0px';
    layer.style.height = '100%';
    layer.style.width = '100%';
    layer.style.backgroundColor = '#adadad';
    document.body.appendChild(layer);
    
	var vo = new SWFObject("/digitv/cds/Birmingham/Wii/static/videoplayer.swf", "VideoPlayer", "100%", "100%", "7");
	
	if (vo)
	{
		vo.addVariable("isStream", ""+stream);
		vo.addVariable("videoUrl", link);
		vo.addVariable("streamName", streamname);
		vo.addParam("WMode","opaque");
		vo.addParam("scale","exactfit");
		vo.write("videocontent");
	}
	layer=document.getElementById('videocontent');
	var movbutton = document.createElement('div');
	movbutton.className="movieButton";
	//movbutton.id="movieButton";
	//movbutton.style.left = (pageWidth())-61+'px';
 	//movbutton.setAttribute('onmouseup', "alert('hi');document.body.removeChild(document.getElementById('videocontent'));");
    movbutton.onmouseup=function() {document.body.removeChild(document.getElementById('videocontent'));videoIsPoppedUp=false;};
    
    movbutton.onmouseover="roll('videoclose', '/digitv/cds/Birmingham/Wii/static/closevideo2.png')";
    movbutton.onmouseout="roll('videoclose', '/digitv/cds/Birmingham/Wii/static/closevideo.png')";
    movbutton.innerHTML='<img src="/digitv/cds/Birmingham/Wii/static/closevideo.png" border="0" name="videoclose" style="width:100%;height:100%" >';
    layer.appendChild(movbutton);
    //document.getElementById('movieButton').style.zIndex = 200;

}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else
	{ var expires = "";}
	
	document.cookie = name+"="+value+expires+"; path=/;";
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function createRecentLinks()
{

	var myRecentSitesLinks="";
	for (var i=0; i<myRecentSites.length-1; i++)
	{
		var splits=myRecentSites[i].split("###");
		myRecentSitesLinks+="<input type='hidden' id='FDIRlinkPOPUP"+i+"up' value='linkPOPUP"+(i-1)+"' />";
		myRecentSitesLinks+="<input type='hidden' id='linkPOPUP"+i+"ACTION' value='window.location =\""+splits[1]+"\"';/>";
		if (i<myRecentSites.length-2)
		{
			myRecentSitesLinks+="<input type='hidden' id='FDIRlinkPOPUP"+i+"down' value='linkPOPUP"+(i+1)+"' />";
		}
		else
		{
			myRecentSitesLinks+="<input type='hidden' id='FDIRlinkPOPUP"+i+"down' value='dialog-close' />";
			myRecentSitesLinks+="<input type='hidden' id='FDIRdialog-closeup' value='linkPOPUP"+i+"' />";

		}
		if (i%2==0)
		{
			myRecentSitesLinks+=
				"<div id=\'linkPOPUP"+i+"\' class='plugin textl' onmouseup='window.location =\""+splits[1]+"\";'><div class='selector fl'></div><span>"+splits[0]+"</span></div>";
		}else
		{
			myRecentSitesLinks+=
				"<div id=\'linkPOPUP"+i+"\' class='plugin alt textl' onmouseup='window.location =\""+splits[1]+"\";'><div class='selector fl'></div><span>"+splits[0]+"</span></div>";
		}

	}

	return myRecentSitesLinks;
}	

function testPageForCookieEntry(pEntry)
{
	var entryExists=0;
	var urlExists=0;
	var possibleEntry = pEntry.split("###");

	//Search RecentSites
	var whichCookie="RecentSites";
	var x=(readCookie(whichCookie));

	if (x)
	{
		var mySplitResult = x.split("~~~");
		var k=0;
		for (k=0; k<mySplitResult.length; k++)
		{
			var splitNew=(mySplitResult[k].split("###"));

			if (splitNew[0]==possibleEntry[0])
			{
				entryExists=1;
				break;
			}
		}
		if  (entryExists==1)
		{
			mySplitResult.splice(k,1); //remove from current position
			mySplitResult.push(pEntry); //and put on end of list
		}
		else
		{
			if (mySplitResult.length<11)
			{
				mySplitResult.push(pEntry); //put new on end of list
			}
			else
			{
				mySplitResult.shift() //remove first entry
				mySplitResult.push(pEntry);  //put new on end of list
			}
		}

		var newCookieString=mySplitResult.join("~~~");
		createCookie(whichCookie,newCookieString,364);		
	}
	else
	{
		//write to recent places cookie
		createCookie(whichCookie,"~~~"+pEntry,364);
	}

	myRecentSites=(readCookie(whichCookie)).split("~~~").reverse();
}

function roll(img_name, img_src)
{
	if (document[img_name])
	{
   		document[img_name].src = img_src;
   	}
}

function pluginClick(button){
	var objForm = document.forms[0];
	if ((objForm)&&(objForm.buttonPressed))
	{
		if (button == 'contextMenu')
		{
		objForm.buttonPressed.value='menu';
		}else if (button == 'contextHelp')
		{
			objForm.buttonPressed.value='help';
		}else
		{
			objForm.buttonPressed.value=button;
		}
		objForm.submit();
	}
}

function navClick(which) {
	if ((which == 'left') || (which == 'right') || (which == 'submit')) {
		var objForm = document.forms[0];
		if ((objForm)&&(objForm.buttonPressed))
		{ 
			objForm.buttonPressed.value=which;
			objForm.submit();
		}
	}else if (navArray[which]) {
		document.location.href = navArray[which][0];	
	}
}

var firstup=true;
var firstdown=true;
var firstleft=true;
var firstright=true;
var aWasPressed=false;
var bWasPressed=false;

var wasOffScreen=false;
var wasOnscreen=true;

var currentFocus;
var current;

var cleared=1;
function clearMe()
{
	document.getElementById("flashcontent").innerHTML = '';
	cleared=1;
}
function playWiiSound(soundnumber)
{
	if (cleared==1)
	{
		cleared=0;
		var so = new SWFObject("/digitv/cds/Birmingham/Wii/static/wiisounds.swf", "test", "0", "0", "7");
		if (so)
		{
			so.addVariable("playsound", soundnumber);
			so.write("flashcontent");
		}
		setTimeout("clearMe();", 400);
	}
}

function focusPageChange(qNumber)
{
	document.getElementById('startFocus').value=('quest'+qNumber+'line1');
	document.getElementById("FDIRmenubutdown").value=('quest'+qNumber+'line1');
	document.getElementById("FDIRazdown").value=('quest'+qNumber+'line1');
	document.getElementById("FDIRhelpbutdown").value=('quest'+qNumber+'line1');
	document.getElementById("FDIRfavbutdown").value=('quest'+qNumber+'line1');
	currentFocus='';
}
function fireFieldFocus(fld)
{
	if( document.createEvent )
	{
  		evObj = document.createEvent('MouseEvents');
  		evObj.initEvent( 'mousedown', true, false );
  		fld.dispatchEvent(evObj);
  		evObj.initEvent( 'mouseup', true, false );
  		fld.dispatchEvent(evObj);
	}
}
function fireMouseUpFieldFocus(fld)
{
	if( document.createEvent )
	{
  		evObj = document.createEvent('MouseEvents');
  		evObj.initEvent( 'mouseup', true, false );
  		fld.dispatchEvent(evObj);
	}
}
function clearFocus()
{

	if (document.forms[0])
	{
		for(i=0; i<document.forms[0].elements.length; i++)
		{
			if (document.forms[0].elements[i].type=="select-one")
			{
				document.forms[0].elements[i].blur();
				if (document.getElementById(document.forms[0].elements[i].id+"ACTIVE"))
				{
					document.getElementById(document.forms[0].elements[i].id+"ACTIVE").value="";
				}
			}
		}
	}
	
	roll('menubutimg', '/digitv/cds/Birmingham/Wii/static/icomenu.png');
	roll('azbutimg', '/digitv/cds/Birmingham/Wii/static/icoaz.png');
	roll('helpbutimg', '/digitv/cds/Birmingham/Wii/static/icohelp.png');
	roll('favbutimg', '/digitv/cds/Birmingham/Wii/static/icofav.png');

	if (currentFocus)
	{
		if (current.className=="menubuttonbackdropFocus")
		{
			current.className="menubuttonbackdrop";
			current.style.color=WiiMenuTextColor;
		}
		switch (currentFocus)
		{
			case 'menubut':
			case 'azbut':
			case 'helpbut':
			case 'favbut':
				//current.className="tt fl";
				colorFade(currentFocus+'img','background',activeColor,normalColor,6,3); //fadeOut
			break;
			case 'rightbut':
				//document.getElementById('rightbutTip').className="tt fr";
				colorFade(currentFocus,'background',activeColor,normalColor,6,3); //fadeOut
			break;
			case 'leftbut':
				//document.getElementById('leftbutTip').className="tt fl";
				colorFade(currentFocus,'background',activeColor,normalColor,6,3); //fadeOut
			break;
			case 'dialog-close':
				document.getElementById('dialog-close').className="dialog-close";
			break;
			case 'slideholder':
			if (document.getElementById("video"+currentVideo))
			{
				document.getElementById("video"+currentVideo).style.background= "url('/digitv/cds/Birmingham/Wii/static/slidecover.png')";
			}
			break;
			default:
				if  ((currentFocus.substring(0,4)=="link")||(currentFocus.substring(0,5)=="quest"))
				{
					if (current.className.match("alt"))
					{
						current.className="plugin alt textl";
					}
					else
					{
						current.className="plugin textl";
					}
				}
				else if (currentFocus.substring(0,6)=="Ffield")
				{
					current.className="nohighlight";
				}
				else
				{
					if (currentFocus.substring(0,6)!="Letter")
					{
						colorFade(currentFocus,'background',activeColor,normalColor,6,3); //fadeOut
					}else
					{
						if (current.className!="atozclick")
						{
							current.className="atoz";
						}
					}
					
				}
		}
	

			currentFocus="";
			current="";
	}
}
function setInitalFocus()
{

	currentFocus=(document.getElementById('startFocus').value); // startFocus must be present
	current=document.getElementById(currentFocus);
	if (!current)
	{
		//alert("focusNotFound");
		currentFocus="menubut";
		current=document.getElementById(currentFocus);
	}
	if (current.className=="menubuttonbackdrop")
	{
		current.className="menubuttonbackdropFocus";
		current.style.color=WiiMenuTextFocusColor;
	}
	if (currentFocus=="slideholder")
	{
		if (document.getElementById("video"+currentVideo))
		{
			document.getElementById("video"+currentVideo).style.background= "url('/digitv/cds/Birmingham/Wii/static/slidecover2.png')";
		}
	}else
	{
					
		if (currentFocus != 'menubut')
		{
			if  ((currentFocus.substring(0,4)!="link")&&(currentFocus.substring(0,5)!="quest"))
			{
				if (currentFocus.substring(0,6)!="Ffield")
				{
					if (currentFocus.substring(0,6)!="Letter")
					{

						colorFade(currentFocus,'background',normalColor,activeColor,6,3); //fade in
					}
					else
					{
						if (current.className!="atozclick")
						{
							current.className="atozhover";
						}
					}
				}
				else
				{
					current.className="highlight";
				}
			}else
			{
				if (current.className.match("alt"))
				{
					current.className="pluginFocus alt textl";
				}
				else
				{
					current.className="pluginFocus textl";
				} 				
			}
		}
		else
		{
			//document.getElementById('menubut').className="focusMe fl";
			colorFade('menubutimg','background',normalColor,activeColor,6,3); //fade in
			roll('menubutimg', '/digitv/cds/Birmingham/Wii/static/activemenubut.png');
		}
	}
}
function wiiData()
{
	/*
	TESTING IF ZOOM CAN BE DETECTED
	document.getElementById("Zoomlevel").innerHTML = (window.innerHeight+" : "+screen.height);
	as should only activate on screen buttons when not zoomed in.
	var s = document.getElementById("leftcol");
	if (window.innerHeight!=screen.height)
	{
		//alert(window.innerHeight+" : "+screen.height);
	}
	if (window.innerHeight!=s.offsetHeight)
	{
		//alert(window.innerHeight+" : "+s.offsetHeight);
	}
	*/
	RemoteData = Wiimote.readData(0);
	if(RemoteData[Wiimote.ENABLED])
	{
		
		if (RemoteData[Wiimote.X_COORD]==0 && RemoteData[Wiimote.Y_COORD]==0) //OFF SCREEN
		{ 

			wasOffScreen=true;
			Wiimote.defaultActions(false); //NO SCROLLING JUST FOCUS CHANGE

			if (!popup)
			{			
				if (wasOnscreen)
				{
					if (document.forms[0])
					{
						for(i=0; i<document.forms[0].elements.length; i++)
						{
							if (document.forms[0].elements[i].type=="select-one")
							{
								//document.forms[0].elements[i].blur();
								if (document.getElementById(document.forms[0].elements[i].id+"ACTIVE"))
								{
									document.getElementById(document.forms[0].elements[i].id+"ACTIVE").value="";
								}
							}
						}
					}

					wasOnscreen=false;
				}

				if (!currentFocus)
				{
					setInitalFocus()
				}
				
				if (currentFocus)
				{
					if (currentFocus.substring(0,6)=="Ffield")
					{
						current.className="highlight";
					}
				}
			}
			else
			{
				//Was a popup
				if (wasOnscreen)
				{
					if (document.getElementById('linkPOPUP0'))
					{
						currentFocus='linkPOPUP0';
						current=document.getElementById(currentFocus);
						if (current.className.match("alt"))
						{
							current.className="pluginFocus alt textl";
						}
						else
						{
							current.className="pluginFocus textl";
						} 

					}
					else if (document.getElementById('dialog-close'))
					{
						currentFocus='dialog-close';
						current=document.getElementById(currentFocus);
						document.getElementById('dialog-close').className="dialog-closeFocus";
						//colorFade(currentFocus,'background',normalColor,activeColor,6,3); //fade in
						//colorFade(current,'background',normalColor,activeColor,6,3); //fade in
					}
					
					wasOnscreen=false;
				}

				if ((currentFocus) && (currentFocus.substring(0,9)!="linkPOPUP") && (currentFocus!="dialog-close"))
				{
					if (document.getElementById('linkPOPUP0'))
					{
						clearFocus();
						currentFocus='linkPOPUP0'; // startFocus must be present
						current=document.getElementById(currentFocus);
						if (current.className.match("alt"))
						{
							current.className="pluginFocus alt textl";
						}
						else
						{
							current.className="pluginFocus textl";
						}
					}
				}
			}
		
			if(!RemoteData[Wiimote.BUTTON_A])
			{
				if (aWasPressed)
				{
					aWasPressed=false;
					if (videoIsPoppedUp)
					{
						if (document.getElementById('videocontent'))
						{
							document.body.removeChild(document.getElementById('videocontent'));
						}
						videoIsPoppedUp=false;
					}else if (currentFocus)
					{
					
						if ((video)&&(currentFocus=="slideholder"))
						{
							if (document.getElementById('videocontent'))
							{
								document.body.removeChild(document.getElementById('videocontent'));
							}
							else
							{
								if (document.getElementById("video"+currentVideo))
								{
									eval(document.getElementById("video"+currentVideo+"ACTION").value);
								}
							}
						}else
						{
						
							if (currentFocus.substring(0,6)!="Ffield")
							{
								if (document.getElementById(currentFocus+"ACTION"))
								{
									eval(document.getElementById(currentFocus+"ACTION").value);
								}
							}else
							{
								if (current.type=="select-one")
								{
									if (document.getElementById(currentFocus+"ACTIVE"))
									{
										if (document.getElementById(currentFocus+"ACTIVE").value=="active")
										{
											document.getElementById(currentFocus+"ACTIVE").value="";
										}
										else
										{
											document.getElementById(currentFocus+"ACTIVE").value="active";
										}
									}
								}
								fireFieldFocus(current);
							}
						}
					}
				}
			}
			else
			{
				aWasPressed=true;
			}
			
			if(!RemoteData[Wiimote.BUTTON_B])
			{
				if (bWasPressed)
				{
					bWasPressed=false;

					if (popup)
					{
						fadeDialog(0);//close popup
						clearFocus();
						setInitalFocus();
					}
					if ((video)||(videoIsPoppedUp))
					{
						if (document.getElementById('videocontent'))
						{
							document.body.removeChild(document.getElementById('videocontent'));
						}
						videoIsPoppedUp=false;
					}
				}
			}
			else
			{
				bWasPressed=true;
			}
			
			if (!videoIsPoppedUp)
			{
				if(RemoteData[Wiimote.BUTTON_UP]) //UP=RIGHT
				{
					if (firstright)
					{
						if ((video)&&(currentFocus=="slideholder"))
						{
							doSlide(-1);
						}
						else
						{
							setFocus('right');
						}
						firstright=false;
					}
				}
				else
				{
					firstright=true;
				}
				
				if(RemoteData[Wiimote.BUTTON_DOWN]) //DOWN=LEFT
				{
					if (firstleft)
					{
						if ((video)&&(currentFocus=="slideholder"))
						{
							doSlide(1);
						}
						else
						{
							setFocus('left');
						}
						firstleft=false;
					}
				}
				else
				{
					firstleft=true; //Ready for next loop
				}
				
				if(RemoteData[Wiimote.BUTTON_LEFT]) //LEFT=UP
				{
					if (firstup)
					{
						setFocus('up');
						firstup=false;
					}
				}
				else
				{
					firstup=true; //Ready for next loop
				}
				
				if(RemoteData[Wiimote.BUTTON_RIGHT]) //RIGHT=DOWN
				{
					if (firstdown)
					{
	
						setFocus('down');
						firstdown=false;
					}
				}
				else
				{
					firstdown=true; //Ready for next loop
				}
			}
			
		}
		else //ON SCREEN
		{
			Wiimote.defaultActions(true); //NO FOCUS CHANGING
			aWasPressed=false;

			if ((wasOffScreen)&&(currentFocus))
			{
			
				wasOffScreen=false;
				wasOnscreen=true;
				clearFocus();
			}
		}
	}
	setTimeout("wiiData()", 20);
}

function setFocus(direction)
{
	if (currentFocus)
	{
		if ((video)&&(document.getElementById("video"+currentVideo)))
		{
			document.getElementById("video"+currentVideo).style.background= "url('/digitv/cds/Birmingham/Wii/static/slidecover.png')";
		}


		if(current.type=="select-one")
		{
			if (document.getElementById(currentFocus+"ACTIVE"))
			{
				if (document.getElementById(currentFocus+"ACTIVE").value=="active")
				{
					if ((direction=="down")&&(current.selectedIndex<(current.length-1)))
					{
						current.selectedIndex+=1;
					}if ((direction=="up")&&(current.selectedIndex>0))
					{
						current.selectedIndex-=1;
					}
					return;
				}
			}
		}

		if (document.getElementById("FDIR"+currentFocus+direction))
		{

			var newFocus=document.getElementById("FDIR"+currentFocus+direction).value;

			if (newFocus=="unknown")
			{
				if (document.getElementById("firstSelect"))
				{
					newFocus=document.getElementById("firstSelect").value;
				}
			}
			else if (newFocus=="menuunknown")
			{
				if (document.getElementById("firstMenuSelect"))
				{
					newFocus=document.getElementById("firstMenuSelect").value;
				}
			}
			if (newFocus && document.getElementById(newFocus))//may have gone out of bounds so not element of that name exists
			{
				playWiiSound('1');
			
	roll('menubutimg', '/digitv/cds/Birmingham/Wii/static/icomenu.png');
	roll('azbutimg', '/digitv/cds/Birmingham/Wii/static/icoaz.png');
	roll('helpbutimg', '/digitv/cds/Birmingham/Wii/static/icohelp.png');
	roll('favbutimg', '/digitv/cds/Birmingham/Wii/static/icofav.png');
	
				switch (newFocus)
				{
					case 'menubut':
					case 'azbut':
					case 'helpbut':
					case 'favbut':
						if ((currentFocus != 'menubut') && (currentFocus != 'azbut') && (currentFocus != 'helpbut') && (currentFocus != 'favbut'))
						{
							if (currentFocus!="slideholder")
							{
								if  ((currentFocus.substring(0,4)!="link")&&(currentFocus.substring(0,5)!="quest")&&(currentFocus.substring(0,6)!="Ffield"))
								{
									if((currentFocus.substring(0,6)!="Letter")&&(currentFocus!='dialog-close'))
									{
										colorFade(currentFocus,'background',activeColor,normalColor,6,3); //fade out
									}else
									{
										if (current.className!="atozclick")
										{
											current.className="atoz";
										}
									}
				  				}
			  				}
			  			}
			  			else
			  			{
				  			colorFade(currentFocus+'img','background',activeColor,normalColor,6,3); //fade out
				  			//current.className="tt fl";

			  			}
			  			//document.getElementById(newFocus).className="focusMe fl";
			  			
			  			if (newFocus=='menubut')
			  			{
			  				roll(newFocus+'img', '/digitv/cds/Birmingham/Wii/static/activemenubut.png');
						}
						else if (newFocus=='azbut')
						{
							roll(newFocus+'img', '/digitv/cds/Birmingham/Wii/static/activeazbut.png');
						}
						else if (newFocus=='helpbut')
						{
							roll(newFocus+'img', '/digitv/cds/Birmingham/Wii/static/activehelpbut.png');
						}
						else
						{
							roll(newFocus+'img', '/digitv/cds/Birmingham/Wii/static/activefavbut.png');
			  			}
			  			
			  			colorFade(newFocus+'img','background',normalColor,activeColor,6,3); //fade in 
		  			
		  			break;
					case 'dialog-close':
						if ((currentFocus != 'menubut') && (currentFocus != 'azbut') && (currentFocus != 'helpbut') && (currentFocus != 'favbut'))
						{
							if  ((currentFocus.substring(0,4)!="link")&&(currentFocus.substring(0,5)!="quest")&&(currentFocus.substring(0,6)!="Ffield"))
							{
								if((currentFocus.substring(0,6)!="Letter")&&(currentFocus!='dialog-close'))
								{
									colorFade(currentFocus,'background',activeColor,normalColor,6,3); //fade out
								}else
								{
									if (current.className!="atozclick")
									{
										current.className="atoz";
									}
								}
			  				}
			  			}
			  			else
			  			{
			  				colorFade(currentFocus+'img','background',activeColor,normalColor,6,3); //fade out
			  				//current.className="tt fl";
			  			}
						document.getElementById(newFocus).className="dialog-closeFocus";
					break;
					case 'rightbut':
						//document.getElementById('rightbutTip').className="focusMe fr";
						if ((currentFocus != 'menubut') && (currentFocus != 'azbut') && (currentFocus != 'helpbut') && (currentFocus != 'favbut'))
						{
							if  ((currentFocus.substring(0,4)!="link")&&(currentFocus.substring(0,5)!="quest")&&(currentFocus.substring(0,6)!="Ffield"))
							{
								if((currentFocus.substring(0,6)!="Letter")&&(currentFocus!='dialog-close'))
								{
									colorFade(currentFocus,'background',activeColor,normalColor,6,3); //fade out
								}else
								{
									if (current.className!="atozclick")
									{
										current.className="atoz";
									}
								}
			  				}
			  			}
			  			else
			  			{
			  				colorFade(currentFocus+'img','background',activeColor,normalColor,6,3); //fade out
			  				//current.className="tt fl";
			  			}
			  			colorFade(newFocus,'background',normalColor,activeColor,6,3); //fade in
		  			break;
		  			
					case 'leftbut':
						//document.getElementById('leftbutTip').className="focusMe fl";
						
						if ((currentFocus != 'menubut') && (currentFocus != 'azbut') && (currentFocus != 'helpbut') && (currentFocus != 'favbut'))
						{
							if  ((currentFocus.substring(0,4)!="link")&&(currentFocus.substring(0,5)!="quest")&&(currentFocus.substring(0,6)!="Ffield"))
							{
								if((currentFocus.substring(0,6)!="Letter")&&(currentFocus!='dialog-close'))
								{
									colorFade(currentFocus,'background',activeColor,normalColor,6,3); //fade out
								}else
								{
									if (current.className!="atozclick")
									{
										current.className="atoz";
									}
								}
							}
			  			}
			  			else
			  			{
			  				colorFade(currentFocus+'img','background',activeColor,normalColor,6,3); //fade out
			  				//current.className="tt fl";
			  			}
			  			colorFade(newFocus,'background',normalColor,activeColor,6,3); //fade in
		  			break;				
					default:
						if ((currentFocus != 'menubut') && (currentFocus != 'azbut') && (currentFocus != 'helpbut') && (currentFocus != 'favbut'))
						{
							if  ((currentFocus.substring(0,4)!="link")&&(currentFocus.substring(0,5)!="quest")&&(currentFocus.substring(0,6)!="Ffield"))
							{
								if((currentFocus.substring(0,6)!="Letter")&&(currentFocus!='dialog-close'))
								{
									colorFade(currentFocus,'background',activeColor,normalColor,6,3); //fade out
								}else
								{
									if (current.className!="atozclick")
									{
										current.className="atoz";
									}
								}
							}
			  			}
			  			else
			  			{
			  				colorFade(currentFocus+'img','background',activeColor,normalColor,6,3); //fade out
			  				//current.className="tt fl";
			  			}
			  			if (newFocus!="slideholder")
			  			{
							if  ((newFocus.substring(0,4)!="link")&&(newFocus.substring(0,5)!="quest"))
							{
							
								if (newFocus.substring(0,6)!="Ffield")
								{
									if (newFocus.substring(0,6)!="Letter")
									{
										colorFade(newFocus,'background',normalColor,activeColor,6,3); //fade in
									}else
									{
										if (document.getElementById(newFocus).className!="atozclick")
										{
											document.getElementById(newFocus).className="atozhover";
										}
									}
								}
								else
								{
									document.getElementById(newFocus).className="highlight";
								}
							}
							else
							{
								if (document.getElementById(newFocus).className.match("alt"))
								{
									document.getElementById(newFocus).className="pluginFocus alt textl";
								}
								else
								{
									document.getElementById(newFocus).className="pluginFocus textl";
								}
							}
						}else
						{
							if (document.getElementById("video"+currentVideo))
							{
								document.getElementById("video"+currentVideo).style.background= "url('/digitv/cds/Birmingham/Wii/static/slidecover2.png')";
							}
						}
				}
				if (current.className=="menubuttonbackdropFocus")
				{
					current.className="menubuttonbackdrop";
					current.style.color=WiiMenuTextColor;
				}
				
				if  (currentFocus == 'rightbut')
				{
					//document.getElementById('rightbutTip').className="tt fr";
				}
				else if  (currentFocus == 'leftbut')
				{
					//document.getElementById('leftbutTip').className="tt fl";
				}
				else if (currentFocus == 'dialog-close')
				{
					document.getElementById('dialog-close').className="dialog-close";
				}
				else if  ((currentFocus.substring(0,4)=="link")||(currentFocus.substring(0,5)=="quest"))
				{
					if (current.className.match("alt"))
					{
						current.className="plugin alt textl";
					}
					else
					{
						current.className="plugin textl";
					}
				}
				else if (currentFocus.substring(0,6)=="Ffield")
				{
					
					current.className="nohighlight";
					if(current.type!="select-one")
					{
						current.blur();
					}
				}
				else if (currentFocus.substring(0,6)=="Letter")
				{
					if (current.className!="atozclick")
					{
						current.className="atoz";
					}
				}

				currentFocus=newFocus;
				current=document.getElementById(currentFocus);
				if (current.className=="menubuttonbackdrop")
				{
					current.className="menubuttonbackdropFocus";
					current.style.color=WiiMenuTextFocusColor;
				}
			}
		}
	}
}
