function updateGoogleAnalytics(action){
	//alert(action);
	pageTracker._trackEvent('Videos', action, nameVar);
}
function getcookie(cookie_name) {
	var nameEQ = cookie_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 bookmarksite(title, url){
  if (document.all)
  	window.external.AddFavorite(url, title);
  else if (window.sidebar)
  	window.sidebar.addPanel(title, url, "")
}
function popUp(URL,w,h,scrollbar) {
  w = typeof(w) != 'undefined' ? w : 800;
  h = typeof(h) != 'undefined' ? h : 600;
  scrollbar = typeof(scrollbar) != 'undefined' ? scrollbar : 0;
  id = URL.replace(new RegExp( "[:/.?&=_-]", "g" ),'');
	eval("var window" + id + " = null");
	eval("window" + id + " = window.open(URL, id, 'toolbar=0,scrollbars=" + scrollbar + ",location=0,statusbar=0,menubar=0,resizable=0,width=" + w + ",height=" + h + "');");	
	eval("if ( window" + id + " && window" + id + ".open && !window" + id + ".closed ) { window" + id + ".focus() } else { document.getElementById('hideAllContentDiv').style.display='block'; document.getElementById('popupconfirmBox').style.display='block'; }");
}

/* FSCOMMAND SUPPORT FOR ALL FLASH MOVIES ------------------------------------------------------------- */
var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;

function player_DoFSCommand(command, args) {
	var playerObj = isInternetExplorer ? document.all.player : document.player;
	if(command=="alert"){		
		if (document.getElementById('alert_box')) {
  		document.getElementById('alert_box').value = args + "\n" + document.getElementById('alert_box').value;
		}
	}
}
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<script language=\"VBScript\"\>\n');
	document.write('On Error Resume Next\n');
	document.write('Sub player_FSCommand(ByVal command, ByVal args)\n');
	document.write('	Call player_DoFSCommand(command, args)\n');
	document.write('End Sub\n');
	document.write('</script\>\n');
}
function scoreboard_DoFSCommand(command, args) {
	var scoreboardObj = isInternetExplorer ? document.all.scoreboard : document.scoreboard;
	if(command=="alert"){		
		if (document.getElementById('alert_box')) {
  		document.getElementById('alert_box').value = args + "\n" + document.getElementById('alert_box').value;
		}
	}
}
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<script language=\"VBScript\"\>\n');
	document.write('On Error Resume Next\n');
	document.write('Sub scoreboard_FSCommand(ByVal command, ByVal args)\n');
	document.write('	Call scoreboard_DoFSCommand(command, args)\n');
	document.write('End Sub\n');
	document.write('</script\>\n');
}
function scorecard_DoFSCommand(command, args) {
	var scorecardObj = isInternetExplorer ? document.all.scorecard : document.scorecard;
	if(command=="alert"){
		
		if (document.getElementById('alert_box')) {
  		document.getElementById('alert_box').value = args + "\n" + document.getElementById('alert_box').value;
		}
	}
}
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<script language=\"VBScript\"\>\n');
	document.write('On Error Resume Next\n');
	document.write('Sub scorecard_FSCommand(ByVal command, ByVal args)\n');
	document.write('	Call scorecard_DoFSCommand(command, args)\n');
	document.write('End Sub\n');
	document.write('</script\>\n');
}
/* END FSCOMMAND SUPPORT ------------------------------------------------------------- */
/* Flash Functions -----------------------------------------------------*/
function thisMovie(movieName) {
  if (navigator.appName.indexOf("Microsoft") != -1) {
    return window[movieName]
  } else {
    return document[movieName]    
  }
}

function updatePointTotals(pointsEarned) {
  thisMovie("scoreboard").updatePointTotals(pointsEarned);
} 
function storeEmailAddress(emailAddress) {
  //alert(emailAddress);
  thisMovie("player").storeEmailAddress(emailAddress);
}  

function show_assignment_button(){
//alert("Show Assignment Throbber? " + show_assignment_throbber );
    return (show_assignment_throbber);
}
function show_user_type(){
	//alert("PLL User Type " + pll_user_type );
    return (pll_user_type);
}

function skipWelcomeMovie() {
 var skip = document.URL.indexOf('sw=1');
 if (skip != -1){
    	return "Yes";
 }else{
	return "No";
 }
}
 
function getFlashcookie() {
	var cookie_name = "flashCookies";
	var nameEQ = cookie_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;
//	return "welcome:Yes";
}
/* End Flash Functions ------------------------------------------------ */

/* Functions for the Assignment Warnings ------------------------------*/

var assignment_in_progress = 0;

function alertUserAboutAssignment(location,whichCaseDisplay) {
 if (getcookie("id") != '') {
 	switch (whichCaseDisplay){
	case "1" :
		showAssignmentBox("This is an assignment.  You must complete <b>ALL</b> questions to receive full credit.  <p style='text-align:center;'/>Are you sure you want to continue?",location,"start_assignment");
		break;
	case "2" :
		showAssignmentBox("Leaving this assignment without answering <b>ALL</b> of the questions will result in partial credit. You will not be able to restart it. <p style='text-align:center;'/>Are you sure you want to stop?",location,"stop_assignment");
		break;	
	default:
		//Do nothing	
	}
  }else{
  	return(true);
  }
}
function showAssignmentBox(insertText,location,start_or_stop){ 
  document.getElementById("hideAllContentDiv").style.display = "block";
  document.getElementById("confirmAssignmentBox").style.display = "block";
  document.getElementById("insertAssignmentText").innerHTML  = insertText;
  //document.getElementById("continueAssignmentBtn").setAttribute('onclick', 'continueAssignment(\"' + location + '\")');
 document.getElementById('continueAssignmentBtn').onclick = new Function("continueAssignment('" + location + "','"+start_or_stop+"');");
 
}
function hideAssignmentBox(){
	document.getElementById("hideAllContentDiv").style.display = "none";
	document.getElementById("confirmAssignmentBox").style.display = "none";
}
function continueAssignment(location,start_or_stop) {
  if(location.toLowerCase() == "apply" && start_or_stop == "start_assignment"){
   	thisMovie("player").jsContinueMovie(location);
	assignment_in_progress = 1;
  }else if(location.toLowerCase() == "apply" && start_or_stop == "stop_assignment"){
    thisMovie("player").jsFinalizePoints(location,"1");
    thisMovie("player").stopMovieTimer();
  }else if(location.toLowerCase() == "try"){
    thisMovie("player").jsFinalizePoints(location,"1");
    thisMovie("player").stopMovieTimer();
  }else if(location.toLowerCase() == "watch"){
    thisMovie("player").jsFinalizePoints(location,"1");
    thisMovie("player").stopMovieTimer();
  } else{
    thisMovie("player").jsFinalizePoints(location,"2");
    thisMovie("player").stopMovieTimer();
  }  
  hideAssignmentBox();
} 

function set_assignment_started(value){
 	assignment_in_progress = value;
}
/* End Assignment Warnings----------------------------------------------- */

/* Functions for the Points Warnings ------------------------------------ */
var unsaved_points = 0;
var clicked_link = "";
var topic_or_section = "";
var section_name = "";

function checkApplyStatus(section) {
if(assignment_in_progress > 0){
	alertUserAboutAssignment(section,"2");
}else{
 	if (( unsaved_points > 0) && (getcookie("id") != '')) {
 		showConfirmBox(section);
		topic_or_section = "section";
		section_name = section;
	  }else{
	  	return(true);
	  }
  }
}

function set_unsaved_points ( unsaved_points_value ) {
  unsaved_points = unsaved_points_value;
}

function checkForUnsavedPoints (topicName,links) {
	if(assignment_in_progress > 0){
		alertUserAboutAssignment(links,"2");
	}else{
	  if (( unsaved_points > 0) && (getcookie("id") != '')) {
	    showConfirmBox(topicName);
		clicked_link = links;
		topic_or_section = "topic";
		return(false);
	  }else{
		thisMovie("player").stopMovieTimer();
	  	return(true);
	  }
	}
}

function showConfirmBox(insertText){
  var userAgent = navigator.userAgent;
  document.getElementById("hideAllContentDiv").style.display = "block";
  document.getElementById("confirmBox").style.display = "block";
  document.getElementById("insertText").innerHTML  = insertText;
}
function hideConfirmBox(){
	document.getElementById("hideAllContentDiv").style.display = "none";
	document.getElementById("confirmBox").style.display = "none";
}

function sendToFlash(i) {
  thisMovie("player").jsContinueMovie(i);
  hideConfirmBox();
} 
function confirmContinue(){
  if(topic_or_section == "section"){
  	sendToFlash(section_name);
  }else{
  	location.href=clicked_link;
  }
}
/* End Points Warnings ----------------------------------------------------- */



function showTutorialPage ( tutorial ) {
  for ( var pageCounter = 0; pageCounter < tutorialArray.length; pageCounter++ ) {
  	for ( var topicCounter = 0; topicCounter < tutorialArray[pageCounter].length; topicCounter++ ) {
  		if ( tutorialArray[pageCounter][topicCounter] == tutorial ) {
  			for ( var nextPage = tutorialPage; nextPage < pageCounter; nextPage++ ) {
  				gotopage(1);
  			}
  		}
  	}
  }
}
function refreshpage() {
  	var loopCounter;
  	for ( loopCounter = 0; loopCounter < tutorialArray[0].length; loopCounter++ ) {
  		//document.getElementById("tutorial_button" + tutorialArray[0][loopCounter]).style.display = "block";
  		fixPNG(document.getElementById("tutorial_button_img" + tutorialArray[0][loopCounter]),"false");
		//fixPNG(document.getElementById("free_preview" + tutorialArray[0][loopCounter]),"true");
  	}
}
function gotopage ( pagenumber ) {
  if ( pagenumber == "1" ) {
  	var loopCounter;
  	for ( loopCounter = 0; loopCounter < tutorialArray[tutorialPage].length; loopCounter++ ) {
  		document.getElementById("tutorial_button" + tutorialArray[tutorialPage][loopCounter]).style.display = "none";
  	}
  	tutorialPage++;
  	var loopCounter;
  	for ( loopCounter = 0; loopCounter < tutorialArray[tutorialPage].length; loopCounter++ ) {
  		document.getElementById("tutorial_button" + tutorialArray[tutorialPage][loopCounter]).style.display = "block";
  		fixPNG(document.getElementById("tutorial_button_img" + tutorialArray[tutorialPage][loopCounter]),"false");
		//fixPNG(document.getElementById("free_preview" + tutorialArray[tutorialPage][loopCounter]),"true");
  	}
  } else if ( pagenumber == "-1" ) {
  	var loopCounter;
  	for ( loopCounter = 0; loopCounter < tutorialArray[tutorialPage].length; loopCounter++ ) {
  		document.getElementById("tutorial_button" + tutorialArray[tutorialPage][loopCounter]).style.display = "none";
  	}
  	tutorialPage--;
  	var loopCounter;
  	for ( loopCounter = 0; loopCounter < tutorialArray[tutorialPage].length; loopCounter++ ) {
  		document.getElementById("tutorial_button" + tutorialArray[tutorialPage][loopCounter]).style.display = "block";
  		//fixPNG(document.getElementById("tutorial_button_img" + tutorialArray[tutorialPage][loopCounter]),"false");
  	}
  }
  
  if ( tutorialArray.length <= ( tutorialPage + 1 ) ) {
  	document.getElementById("nextpage").style.display = "none";
  	if(tutorialPage > 0){
  		document.getElementById("previous_page_spacer").style.display = "none";
  		document.getElementById("previous_page").style.display = "block";
  	}else{
  		document.getElementById("previous_page").style.display = "none";
  		document.getElementById("previous_page_spacer").style.display = "block";
  	}
  } else {
  	document.getElementById("nextpage").style.display = "block";
  	if(tutorialPage > 0){
  		document.getElementById("previous_page_spacer").style.display = "none";
  		document.getElementById("previous_page").style.display = "block";
  	}else{
  		document.getElementById("previous_page_spacer").style.display = "block";
  		document.getElementById("previous_page").style.display = "none";
  	}
  }

}
function fixPNG(myImage,scaleMe)
{
    if (myImage != null)
    {
      var arVersion = navigator.appVersion.split("MSIE")
  	  var version = parseFloat(arVersion[1])
  	  if ((version >= 5.5) && (version < 7) && (document.body.filters)) 
  	  {
  	       var imgID = (myImage.id) ? "id='transformed" + myImage.id + "' " : ""
		   var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : ""
		   var imgTitle = (myImage.title) ? 
			             "title='" + myImage.title  + "' " : "title='" + myImage.alt + "' "
		   var imgStyle = "display:block;" + myImage.style.cssText
		   var strNewHTML = "<span " + imgID + imgClass + imgTitle
	                  + " style=\"" + "width:" + myImage.width 
	                  + "px; height:" + myImage.height 
	                  + "px;" + imgStyle + ";"
	                  + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
					  if(scaleMe == "false"){
	                  strNewHTML = strNewHTML + "(src=\'" + myImage.src + "\', );\"></span>"
					  }else{
					   strNewHTML = strNewHTML + "(src=\'" + myImage.src + "\' sizingMethod='scale');\"></span>"
					  }
					  
		   myImage.outerHTML = strNewHTML	  
	    }
    }
}