//From master_shared.js

//Function for Print Button in Header
function printPage() {
	if ((navigator.appVersion.indexOf("Mac") != -1) && (navigator.userAgent.indexOf("MSIE") != -1)) {
		alert("The print button you just clicked will not work on a Macintosh running Internet Explorer.  Please click your browser's print button to print this page.");
	} else {
	window.print();
	}
}

function launchTranscript() {
			howTall = (screen.availHeight - 450)/2;
			howWide = (screen.availWidth - 600)/2;
			tempArray = document.location.href.split("/");
			exampleNumber = tempArray[tempArray.length-1];
			exampleNumber = exampleNumber.slice(0,exampleNumber.length-4);
			
			noteWindow = window.open(exampleNumber+'_transcript.htm','transcript','width=600,height=400,screenX=100,screenY=100,top='+howTall+',left='+howWide+'menubar=yes,resizable=no,noresize,titlebar=no,status=no,toolbar=no,scrollbars=yes');

		}

function newWindow(page) {
			howTall = (screen.availHeight - 450)/2;
			howWide = (screen.availWidth - 600)/2;
			studentWindow = window.open(page+'.htm','new','width=720,height=445,screenX=100,screenY=100,top='+howTall+',left='+howWide+'menubar=yes,resizable=yes,titlebar=no,status=no,toolbar=no,scrollbars=yes');
		}
		
		
function selectedHighlight(intSelectedHL) {
    
    		allOff();
    		
    		var WhichOne="highlight" + intSelectedHL;
    		var WhichOneNumber="highlight" + intSelectedHL + "Number";
    		
    		/*Old code, not compliant with Safari
    		document.all[WhichOne].style.backgroundColor = "#FFED8F";
    		document.all[WhichOneNumber].style.backgroundColor = "#FFED8F"; 
    		*/
    		
        	//New code, tested on Safari v. 1.2.3
        	document.getElementById(WhichOne).style.backgroundColor = "#F8ECA4";
			document.getElementById(WhichOneNumber).style.backgroundColor = "#F8ECA4";
			
		}
		
		
		function allOff() {
		
			//howManyHighlights = document.all.highlightTable.rows.length;
			howManyHighlights = document.getElementById('highlightTable').rows.length;

		
			for (i=1;i<howManyHighlights;i++) {
				var turnOff="highlight" + i;
				var turnOffNumber="highlight" + i + "Number";
    	
    			/* Old code, not compliant with Safari
    			document.all[turnOff].style.backgroundColor = "#ffffff";
    			document.all[turnOffNumber].style.backgroundColor = "#ffffff";
    			*/
    			
    			//New code, tested on Safari v. 1.2.3    			
    			document.getElementById(turnOff).style.backgroundColor = "transparent";
				document.getElementById(turnOffNumber).style.backgroundColor = "transparent";
   			}    		
    		
    		
		}
		
function highlightThisDarkenOthers(divname) {
	var divlist = new Array();
	
	//this function is supposed to specify which highlight div to trigger, while all other divs from the page's local divlist that don't match 'divname' get shut off
	if(document.divlist) { //check to see if there is an array called "divlist" on the calling page.
		divlist = document.divlist;  //if so, create a local variable to utilize this list.
		//alert("document.divlist exists");
		for (i=0; i< divlist.length; i++) {
			
			var thisElement = document.getElementById(divlist[i]);
			//alert("thisElement is " + thisElement);
			if ((divlist[i]) == (divname)) {
				thisElement.className = "highlighted";
			} else {
				thisElement.className = "highlight";
			}
		}
	}
}

function stopVideoAtTimeCode(timecode) {
	t=setTimeout("stopVideoAtTimeCode()",250);
	checkHighlights(document.video.GetTime());
	if (document.video.GetTime() == timecode) {
		alert("Timecode is " + timecode);
		document.video.Stop();
	}
}


//From getVideoLocation.js
/*
function getVideoLocation(pathtovid, vidname) {


    var allcookies = document.cookie 

    var bws = allcookies.indexOf("bws=");    

		var bwSuffix = "";

    if (bws != -1) {

        var start = bws + 4;

        var end = allcookies.indexOf(";", start);

        if (end == -1) end = allcookies.length;
        
        bwsValue = allcookies.substring(start, end);
        
        if(bwsValue != "" && bwsValue != "hi") {

        	bwSuffix = "_" + bwsValue;
        }

    }
//CHANGED PATH TO ACCOMODATE FLAT FILE STRUCTURE ~CN
	//return "media/" + pathtovid + "/" + vidname + bwSuffix + ".mov";
	return "media/" + vidname + bwSuffix + ".mov";

}
*/

function embedVideoWrapper(width, height, zoom) {
        
    //name="video";
    whichCourse = ""; 
	tempArray = document.location.href.split("/");
	//alert("(1) tempArray is " + tempArray);
	temp = tempArray[tempArray.length-1];
	//alert("(1) temp is " + temp);
	tempArray = temp.split("#");
	//alert("(2) tempArray is " + tempArray);
	temp = tempArray[0];
	//alert("(2) temp is " + temp);
        tempArray = temp.split("?");
		//alert("(3) tempArray is " + tempArray);
        temp = tempArray[0];
		//alert("(3) temp is " + temp);
	whichCourse = temp.slice(0,(temp.lastIndexOf('_')));
		//alert("whichcourse is " + whichCourse);

       if (zoom) {
		fileName = temp.slice(0, temp.length-9);
		//alert("(1) fileName is " + fileName);
	}
	else {
		fileName = temp.slice(0, temp.length-4);
		//alert("(2) fileName is " + fileName);
	}

        document.write('<embed type="video/quicktime" name="video" width="' + width + '" height="' + height + '"  loop="False" kioskmode="True" autoplay="false" scale="tofit" src="');
        //document.write(getVideoLocation(whichCourse, fileName) + '" />');
		document.write('media/' + fileName + '.mov" />');
        
}

function embedVideoWrapper2(videoFileName, width, height, zoom) { //allows you to force the video file name - good for pages with multiple videos, 
																	// where cutting the page name doesn't fly. 
																	//DO NOT APPEND SUFFIX. Function "getVideoLocation()" (above) does this for us.
        
    name="video";
    whichCourse = ""; 
	tempArray = document.location.href.split("/");
	temp = tempArray[tempArray.length-1];
	tempArray = temp.split("#");
	temp = tempArray[0];
	whichCourse = temp.slice(0,(temp.lastIndexOf('_')));


		fileName = videoFileName;
	

        document.write('<embed type="video/quicktime" name="video" width="' + width + '" height="' + height + '"  loop="False" kioskmode="True" autoplay="false" scale="tofit" src="');
        //document.write(getVideoLocation(whichCourse, fileName) + '" />');
		document.write('media/' + fileName + '.mov" />');
        
}

function embedVideoWrapper3(videoFileName, width, height, zoom) { //FOR QUICKTIME VIDEO ONLY
																	//allows you to force the video file name AND SUFFIX - good for pages with multiple videos, 
																	// where cutting the page name doesn't fly. 
																	//WITH THIS ONE YOU NEED TO APPEND SUFFIX.
        
    name="video";
    whichCourse = ""; 
	tempArray = document.location.href.split("/");
	temp = tempArray[tempArray.length-1];
	tempArray = temp.split("#");
	temp = tempArray[0];
	whichCourse = temp.slice(0,(temp.lastIndexOf('_')));

		fileName = "media/" + videoFileName;
	

        document.write('<embed type="video/quicktime" name="video" width="' + width + '" height="' + height + '"  loop="False" kioskmode="True" autoplay="false" scale="tofit" src="');
        document.write(fileName + '" />');
        
}