//begin spotlight code
//initial load
var ini = 0;
//start pointer: for timer
var start = null, to = null; 
// showState: 0 for playing/active; 1 for pausing/inactive
var showState = 0;

//An array for holding all sub divs of hero-div
var aryContents = new Array();
//find all the a (link) elements that are inside elements w class="ptslide" that ate inside a div named as "hero_div"
var aryLinks = $$('div#hero_div .ptslide a');
//deal with sub div ids
var aryIds = $$('div#hero_div .ptslide');
var nContents = aryIds.length;
for (var i=0; i<nContents; i++){
	aryContents[i] = aryIds[i].id;
	//document.writeln("Sub div Id: ", aryContents[i], "<br>");		
}	

// pointer of the current content
var thisContent = 0;

function replaceHero(newContent) {
	$('hero_div').appendChild($(aryContents[thisContent]));
	$('hero_display').appendChild($(aryContents[newContent]));
	thisContent = newContent;
}
	

// NEW func for onLoad()
function loadContent0() {		
	if (navigator.userAgent.indexOf("Netscape") != -1){
		document.getElementById("spotlightControls").style.visibility = "hidden";
		document.getElementById("leftBtn").style.visibility = "hidden"; 
		document.getElementById("playBtn").style.visibility = "hidden";
		document.getElementById("rightBtn").style.visibility = "hidden";
	}
	else{	
		showState = 0;
		newContent = thisContent;
		$('togglebtn').value = "Pause";
			
		if ( nContents > 1 && (thisContent == nContents - 1 ) ){
			newContent = 0;	    	
		}
		else if ( nContents > 1 && ini != 0 && thisContent >= 0 ){
			newContent++;
		}
		else if ( nContents > 1 && ini == 0 && thisContent == 0 ){
			// in this case: we want to thisContent stays at 0 to show the 1st one
			ini = 1; //not initial load any more
			$('hero_display').innerHTML = '';
		}
		replaceHero(newContent);
		setCurrNum(thisContent);
		clearTimeout(to);
		if(thisContent % nContents == 0)
			to = setTimeout("loadContent0()",4000); //first image timer
		else if(thisContent % nContents == 1)
			to = setTimeout("loadContent0()",4000); //second image timer
		else if(thisContent % nContents == 2)
			to = setTimeout("loadContent0()",4000); //third image timer
		else if(thisContent % nContents == 3)
			to = setTimeout("loadContent0()",4000); // fourth image timer
		else 
			to = setTimeout("loadContent0()",4000); // default timer if above timers don't work
	}
}

function doPrevious() {
	//NEXT & PREVIOUS actions change the PLAY state to PAUSE
		if ( showState == 0 ) showState = 1;
		// have to turn off the timer
		clearTimeout(to);
	newContent = thisContent;
	if ( nContents > 1 && thisContent >= 1 ){
		newContent--;	   
	}	    
	else if ( thisContent == 0 ) {
		newContent = nContents -1;
	}
	//replace the content of 'hero_display' by that of aryContents[thisContent]	
	replaceHero(newContent);
	setCurrNum(thisContent);
	$('togglebtn').value = "Play";
	$('togglebtn').src = 'spotlight-play-btn-up.gif';
}

function doNext() {
		if ( showState == 0 ) showState = 1;
		clearTimeout(to);
	newContent = thisContent;
	if ( nContents > 1 && (thisContent == nContents - 1 ) ){
		newContent = 0;	    	
	}
	else if ( nContents > 1 && thisContent >= 0 ){
		newContent++;
	}
	replaceHero(newContent);
	setCurrNum(thisContent);
	$('togglebtn').value = "Play";
	$('togglebtn').src = 'spotlight-play-btn-up.gif';
}


function setCurrNum(x) {	
	//x is the index of an array, so plus one for its real position
	var pos = x+1;
	$('currNum').innerHTML = pos;
}
	
function pauseOrPlay() {
if ($('togglebtn').value == "Play")
{
	$('togglebtn').value = "Pause";
	$('togglebtn').src = 'spotlight-play-btn-down.gif';
	showState = 0;
	to = setTimeout("loadContent0()",750); //this timer is when start up the rotator again after having it paused
}else{
	$('togglebtn').value = "Play";
	$('togglebtn').src = 'spotlight-play-btn-up.gif';
	showState = 1;	
	clearTimeout(to);
} 	

	
}
//end spotlight code



//begin show hide div code
function show(c) { 
if (document.getElementById && document.getElementById(c)!= null) 
node = document.getElementById(c).style.display=''; 
else if (document.layers && document.layers[c]!= null) 
document.layers[c].display = ''; 
else if (document.all) 
document.all[c].style.display = ''; 
} 

function hide(c) { 
if (document.getElementById && document.getElementById(c)!= null) 
node = document.getElementById(c).style.display='none'; 
else if (document.layers && document.layers[c]!= null) 
document.layers[c].display = 'none'; 
else if (document.all) 
document.all[c].style.display = 'none'; 
}

///////////////////
//video functions//
///////////////////

//video one//
function vidOneLeft() {
 hide('vidControlsOne');
 show('vidControlsThree');
 hide('vidBodyOne');
 show('vidBodyThree');
}
function vidOneRight() {
 hide('vidControlsOne');
 show('vidControlsTwo');
 hide('vidBodyOne');
 show('vidBodyTwo');
}

//video two//
function vidTwoLeft() {
 show('vidControlsOne');
 hide('vidControlsTwo');
 show('vidBodyOne');
 hide('vidBodyTwo');
}
function vidTwoRight() {
 show('vidControlsThree');
 hide('vidControlsTwo');
 show('vidBodyThree');
 hide('vidBodyTwo');
}

//video three//
function vidThreeLeft() {
 show('vidControlsTwo');
 hide('vidControlsThree');
 show('vidBodyTwo');
 hide('vidBodyThree');
}
function vidThreeRight() {
 show('vidControlsOne');
 hide('vidControlsThree');
 show('vidBodyOne');
 hide('vidBodyThree');
}

///////////////////
//girls functions//
///////////////////
function girlsOneLeft() {
 hide('theGirlsControlsOne');
 show('theGirlsControlsThree');
 hide('theGirlsBodyOne');
 show('theGirlsBodyThree');
}

function girlsOneRight() {
 hide('theGirlsControlsOne');
 show('theGirlsControlsTwo');
 hide('theGirlsBodyOne');
 show('theGirlsBodyTwo');
}

function girlsTwoLeft() {
 hide('theGirlsControlsTwo');
 show('theGirlsControlsOne');
 hide('theGirlsBodyTwo');
 show('theGirlsBodyOne');
}

function girlsTwoRight() {
 hide('theGirlsControlsTwo');
 show('theGirlsControlsThree');
 hide('theGirlsBodyTwo');
 show('theGirlsBodyThree');
}

function girlsThreeLeft() {
 hide('theGirlsControlsThree');
 show('theGirlsControlsTwo');
 hide('theGirlsBodyThree');
 show('theGirlsBodyTwo');
}

function girlsThreeRight() {
 hide('theGirlsControlsThree');
 show('theGirlsControlsOne');
 hide('theGirlsBodyThree');
 show('theGirlsBodyOne');
}
//end show hide div code


//jump menu function
function autochannels() {
	if (document.vidJumpMenu.destination.options[document.vidJumpMenu.destination.selectedIndex].value) {
		top.location = document.vidJumpMenu.destination.options[document.vidJumpMenu.destination.selectedIndex].value
	}
}

//today's date script
// current date - from http://rainbow.arch.scriptmania.com/scripts
// Array of day names
function writeDate() {
	var dayNames = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
	var monthNames = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
	var dt = new Date();
	var y  = dt.getYear();
	// Y2K compliant
	if (y < 1000) y +=1900;

	document.write(monthNames[dt.getMonth()] + " " + dt.getDate() + ", " + y);
}


