var theCurrentTutorState = '';
// grab from cookie
//var theLastTutorState = GetCookie('theLastTutorState');
var theLastTutorState = '';

// these help with timeouts... got this from Jason J. Jaeger:
//	http://greengeckodesign.com/blog/2007/10/how-to-clear-all-timeouts-in-javascript.html
var tutorTimeOuts= new Array();   

function ClearAllTimeouts() {   
	for(key in tutorTimeOuts ){   
		clearTimeout(tutorTimeOuts[key]);   
	}   
}  

function CloseTutorBox() {
	ShowMenu('tutorbox',-400,100);
}

var theCurrentPlayer;
var currentVideoCuesChecker;
var theCurrentPlayerElapsedTime = 0;
var theCurrentPlayerMaxTime = 0;
var currentPlayerElapsedTimeIncrementer;

function GetVideoPlayerObject() {
	// grab the correct video player object
	if (pop_ns4 || pop_dom) {
		var outPlayer = GetObject('video_object_obj');
	}
	else {
		var outPlayer = GetObject('video_object_embed');
	}
	return outPlayer;
}

function VideoPlayerStatusObject(inParamToReturn) {
	var playerFailed = false;
	if (theCurrentPlayer == null) {
		playerFailed = true;
	}
	else {
		if (theCurrentPlayer.controls == null) {
			playerFailed = true;
		}
	}
	if (playerFailed) {
		this.amIReal = "no";
		if (theCurrentPlayerMaxTime + 5 <=  theCurrentPlayerElapsedTime) {
			// "stopped"
			this.playState = 1;
		}
		else {
			// "playing"
			this.playState = 3;
		}
		this.theCurrentPosition = theCurrentPlayerElapsedTime;
	}
	else {
		this.amIReal = "yes";
		this.playState = theCurrentPlayer.playState;
		this.theCurrentPosition = theCurrentPlayer.controls.currentPosition;
	}
	switch(inParamToReturn) {
		case 'amIReal':
			return this.amIReal;
			break;
		case 'playState':
			return this.playState;
			break;
		case 'theCurrentPosition':
			return this.theCurrentPosition;
			break;
		default:
			return "";
			break;
	}
}

function TestVideoPlayerCommunicate(inParamToAlert) {
	// some test crap for communicating b/t WMV embedded object and this Javascript environment
	//var theCurrentPlayer = GetVideoPlayerObject();
	switch(inParamToAlert) {
		case 'playState':
			alert('playState is : ' + VideoPlayerStatusObject('playState'));
			break;
		case 'elapsedTime':
			alert('current elapsed time is : ' + VideoPlayerStatusObject('theCurrentPosition'));
			break;
		default:
			break;
	}
}

function FlashObjectBackgroundColor(inObjectName, inOddColor, inEvenColor) {
	// should always end on odd color
	var toggleCount = 12; 
	var oddColor = inOddColor; //'#eef5fb'
	var evenColor = inEvenColor; //'#efefef'
	for (var f = 0; f <= toggleCount; f++) {
		if (f % 2 == 0) {
			setTimeout('SwitchColor(\'' + inObjectName + '\', \'' + evenColor + '\');',(f * 500));
		}
		else {
			setTimeout('SwitchColor(\'' + inObjectName + '\', \'' + oddColor + '\');',(f * 500));
		}
	}
	// when done flashing, set timeout to turn back to original color and turn off the background
	setTimeout('SwitchColor(\'' + inObjectName + '\', \'' + oddColor + '\');',((f + 1) * 500));
}
