
// -- use this while debugging
var disableAutoLogOut;
disableAutoLogOut = false; //true; //false; //true; //false

var sizeImageTimerID;
var autoLogoutTimerID;
var longAutoLogoutTimerID;
var oneMinuteAutoLogoutTimerID;
//var responseTextTimerID;
var failSafeTimerID;
var timedNextTimerID;
var timedPreviousTimerID;
var takeActionTimerID;
var timedReloadAudioTimerID;
var timedSeekProblemTimerID;
var StartAutoAdvanceTimerTimerID;
var flashResponseTextDivTimerID;
var checkForTeacherAlertTimerID;
var flashingBackgroundTimerID;
var sizeImageTimerID;
var swfImageDelayTimerID;
var globalOldImageHeight = 0;
var globalNewImageHeight = 0;
var globalLastHigginsYouTubeRadioValue = '';
var globalBrowseHelpDivWidth = 0;
var globalRightMainDivWidth = 0;
var videoTagSupport = !!(document.createElement('video').canPlayType);
var audioTagSupport = !!(document.createElement('audio').canPlayType);
//-- Note: click next and auto next have absolutely nothing to do with one another! ---
var globalNextClick = '';
var globalNextClickData = '';
var globalNextClickData2 = '';
var globalWaitingForImageToLoad = false;
var globalWaitingForBrowseHelpToLoad = false;

var globalRosterContents
var globalAutoNext = false;
var globalImageName = '';
var globalVideoName = '';
var globalBrowseArray = new Array();
var globalRosterArray = new Array();
var globalFrame = 0; //used for deciding whether or not to show the text (if not shown, it's read by the audio file) --
//var globalImageFrame = 0; //for when you globalFrame=0 but you want to show the previous image
var globalLastBrowseType = -9; 
var globalLanguage = 'english';
var globalLastAudioFileRoot = '';
var globalLastAudioWithLanguageFileRoot = '';
var globalPreviousNextTimerOperating = false;
//var globalReloadAudioTimerOperating = false;
var globalLoadedMediaArray = new Array();
var globalFlashSupported = false;
var globalNextAudioFile = '';
var globalNextImageFile = '';
var globalglobalAudioFileNameRoot = '';
var globalMaxState = 'normal'; //corresponds with initial css color
var globalAudioState = 'on';//corresponds with initial css color
var globalTextState = 'off';//corresponds with initial css color
var globalTextToggleEnabled = false;
var globalResponseTextHTML;				
var globalTopLinkHTML;
var globalButtonHTML;
var globalMainTextHTML;
var globalMainSpanTextHTML;
var globalSuffixFileRoot;
var globalSuffixText;
var globalSuffixSpanText;
var globalPrefixFileRoot;
var globalPrefixText;
var globalPrefixSpanText;
var	globalProblemSelectHTML;
var globalTopBlurb;
var	globalAudioFileNameRoot; 
var globalForceShowText = 1; //forces the display of mainTextHTML regardless of the UI setting for showing text (changed in Update)
var globalTeacherDataType = '';
var globalStudentRecordActive = false;

var globalBasicTeacherTopLinkHTML = '';
var globalBasicTeacherButtonHTML = '';		
var globalBasicTeacherTopBlurb = '';
var globalAudioPlaying = false;
var globalOGCourseID = 0; //start doing this with js vars instead of hidden vars
var globalOGPretestID; //start doing this with js vars instead of hidden vars
globalOGPretestID = 0;
var globalActiveTab = '';		
var globalSessionID = '' //a string, not an integer
var globalTeacherID = 0;
var globalRosterClassRadioHTML = '';
var globalRosterClassName = '';
var globalLoadingMenuItem = false;
var globalWaitingForStuRecToLoad = false;
var globalClickingInProgress = false;
var globalFlashingStatus = 'off';
var globalTeacherAudioAlerts = 'off';
var globalLastTeacherAudioAlertTime = 0; 
var globalPassHasFocus = false;
var globalUsernameValue = '';
var globalViewportW = GetViewportWidthIncludingScrollBar();
var globalViewportH = GetViewportHeightIncludingScrollBar();


//responseTextTimerID = setInterval("GiveResponseTextFocus()",1000); //this baby runs from dawn to dusk

function GetViewportWidthIncludingScrollBar(){
 	if($(window).height() < document.documentElement.scrollHeight){ 
		  //-- got vertical scroll bars --------
   globalViewportW = $(window).width() + scrollbarWidth();			
		}else{
			 globalViewportW = $(window).width();	
		}
		return globalViewportW;
}

function GetViewportHeightIncludingScrollBar(){
 	if($(window).width() < document.documentElement.scrollWidth){ 
		  //-- got horizontal scroll bars --------
    globalViewportH = $(window).height() + scrollbarWidth();			
		}else{
			 globalViewportH = $(window).height();	
		}
	//	document.title = globalViewportH;
		return globalViewportH;
}

function ClickedGEDPracticeArrow(leftOrRight){
	 var currentScreen = document.getElementById('gedpractestvar').value;
			alert(leftOrRight + '  ' + currentScreen)
		switch(true){
			  case(leftOrRight == 'right')&&(currentScreen=='splash'):
					  //-- load the intro video ---
					  LoadGEDPracticeTestScreen('introvideo'); 
							break;
			  case(leftOrRight == 'right')&&(currentScreen=='introvideo'):
					  //-- load the intro video ---
					  LoadGEDPracticeTestScreen('clock');
							break;							
		}
}


function LoadGEDPracticeTestScreen(screenToLoad){  
		var cc = GetCookie('cc');
		var u = document.getElementById('geduser').value;
		var p = document.getElementById('gedpass').value;
		var mygetrequest=new ajaxRequest();
		mygetrequest.onreadystatechange=function(){
		if (mygetrequest.readyState==4){
				if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
						//----------- Here is where all the info comes back -------				
					var htmlCode = mygetrequest.responseText;
					if(htmlCode != ''){					  
							document.getElementById('maindiv').innerHTML = htmlCode;
					//	alert(htmlCode);
							var oGedVideo = document.getElementById('gedhtml5video');
							if(oGedVideo != null){													
									oGedVideo.onended = function(e) {
											GEDVideoEnded();
									}
									oGedVideo.onplaying = function(e) {
											GEDVideoOnPlaying();
									}
									oGedVideo.focus(); //this is so the control bar won't stay hidden until it's cursored over
							}								
		     var oGedAudio = document.getElementById('gedhtml5audio');
		     if(oGedAudio != null){
         oGedAudio.onended = function(e) {
				       GEDAudioEnded();
         }
	  	     oGedAudio.onplaying = function(e) {
			  	   GEDAudioOnPlaying();
         }
		     }																	
					}
				}//if (mygetrequest.status==200
			}//if (mygetrequest.readyState==4){
		}
		var urlString = "screen="+screenToLoad+"&cc="+cc+"&u="+u+"&p="+p;
	//	alert(urlString)
		mygetrequest.open("GET", "GetGEDPracticeTestCode.php?"+urlString+"&qwert="+new Date().getTime(), true);
		mygetrequest.send(null);					
}

function GEDVideoEnded(){
	 var currentScreen = document.getElementById('gedpractestvar').value;
	 switch(currentScreen){
			 case 'introvideo':
	     document.getElementById('arrowrightdiv').style.backgroundImage="url('gedpracticetest/arrow_right_red.png')";
			   document.getElementById('gedarrowtextright').style.fontStyle = 'italic';			
						break;
		}
}
function GEDVideoOnPlaying(){
	 var currentScreen = document.getElementById('gedpractestvar').value;
	 switch(currentScreen){
			 case 'introvideo':	
	     document.getElementById('arrowrightdiv').style.backgroundImage="url('gedpracticetest/arrow_right.png')";
		    document.getElementById('gedarrowtextright').style.fontStyle = 'normal';
						break;
		}			
}

function GEDAudioEnded(){
	 var currentScreen = document.getElementById('gedpractestvar').value;
	//	alert(currentScreen)
	 switch(currentScreen){
			 case 'ssssss':
	     document.getElementById('arrowrightdiv').style.backgroundImage="url('gedpracticetest/arrow_right_red.png')";
			   document.getElementById('gedarrowtextright').style.fontStyle = 'italic';			
						break;
		}
}
function GEDAudioOnPlaying(){
	 var currentScreen = document.getElementById('gedpractestvar').value;
	//	alert(currentScreen + '  ddd')
	 switch(currentScreen){
			 case 'dddddd':	
	     document.getElementById('arrowrightdiv').style.backgroundImage="url('gedpracticetest/arrow_right.png')";
		    document.getElementById('gedarrowtextright').style.fontStyle = 'normal';
						break;
		}			
}
function scrollbarWidth() {
	  //-- this uses jQuery --
    var div = $('<div style="width:50px;height:50px;overflow:hidden;position:absolute;top:-200px;left:-200px;"><div style="height:100px;"></div>');
    // Append our div, do our calculation and then remove it
    $('body').append(div);
    var w1 = $('div', div).innerWidth();
    div.css('overflow-y', 'scroll');
    var w2 = $('div', div).innerWidth();
    $(div).remove();
    return (w1 - w2);
}





//--- I didn't know you could do this (prototypes!)---
//--- Good old left trim, right trim and trim -------

function ajaxRequest(){
	//window.status = window.status + '- 110 '
 //-- this saves the trouble of MAKING a different request object for each use! -----	
 var activexmodes=["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"]; //activeX versions to check for in IE
 if (window.ActiveXObject){ //Test for support for ActiveXObject in IE first (as XMLHttpRequest in IE7 is broken)
  for (var i=0; i<activexmodes.length; i++){
   try{
    return new ActiveXObject(activexmodes[i]);
   }
   catch(e){
    //suppress error
   }
  }
 }
 else if (window.XMLHttpRequest) // if Mozilla, Safari etc
  return new XMLHttpRequest();
 else
  return false;
}

function popup(mylink, windowname)
{
	//window.status = window.status + '-130'
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
   href=mylink;
else
   href=mylink.href;
window.open(href, windowname, 'width=400,height=200,scrollbars=yes,');
return false;
}

function SizeAndPositionShadowInfoDiv(){
	 return;
		//window.status = window.status + '-144'
	  oMain = document.getElementById('maininfodiv');
			oShadow = document.getElementById('shadowmaininfodiv');
   oShadow.style.top = oMain.offsetTop + 'px';		
			oShadow.style.left = oMain.offsetLeft + 'px';	
			oShadow.style.height = oMain.offsetHeight + 'px';
			oShadow.style.width = oMain.offsetWidth + 'px';
			
			//---- smack it thrice for good measure --
			oShadow.style.height = oMain.offsetHeight + 'px';
			oShadow.style.width = oMain.offsetWidth + 'px';			
			oShadow.style.height = oMain.offsetHeight + 'px';
			oShadow.style.width = oMain.offsetWidth + 'px';			
			oShadow.style.height = oMain.offsetHeight + 'px';
			oShadow.style.width = oMain.offsetWidth + 'px';						
}

function GiveResponseTextFocus(){
	//window.status = window.status + '-162'
	  //-- keep em on task! ----
			//-- The 'try' business is because IE throws a fatal error if the div is hidden ---
		try{
			oResponseText = document.getElementById('responsetext');
			oResponseText.focus();
		}
		catch(e){
			 //-- IE requires some meat in here ---
			 var x = document.getElementById('i');
				//-- if it doesn't run no problem --
		}				
}

function CheckForAutoUserGen(){
	//window.status = window.status + '-177'
	 //-- the the first name is in place but there is no username yet, one is auto generated --
		var firstName = document.getElementById('stufirst').value;
		var userName = document.getElementById('stuuser').value;
		if((Trim(firstName) != '') && (Trim(userName) == '')){
			 StuAutoUserGen();
		}
}

function ChangedAnswer(sentFrame){  
  return; /// not needed no more
		//window.status = window.status + '-188'
			var specChar = '~**~'; // must be the same as in trackfuncitons js ClickedSendAns and GetProblemsHTML() and GradeStudentAnswer.php
			var origFullString = document.getElementById('needgrading').value;	
			// -- this was an independent single answer text box -- 
			var textBoxID = 'stuans' + sentFrame;						
			newValue = Trim(document.getElementById(textBoxID).value);			    
			currentValue = ChangedAnswerDetail(sentFrame,newValue,origFullString,specChar);						
			document.getElementById('needgrading').value = currentValue;
	

}

function ChangedStuContractDropDown(){  
//window.status = window.status + '-200'
		var courseID = document.sturecform.stucontract.value; 
		var mygetrequest=new ajaxRequest();
		mygetrequest.onreadystatechange=function(){
		if (mygetrequest.readyState==4){
				if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
						//----------- Here is where all the info comes back -------				
						var docsHTML = mygetrequest.responseText;
						
						document.getElementById('stucontractdocsdiv').innerHTML = docsHTML;
						
				}//if (mygetrequest.status==200
			}//if (mygetrequest.readyState==4){
		}
		var urlString = "c="+courseID;
		mygetrequest.open("GET", "GetContractDocsLinks.php?"+urlString+"&qwert="+new Date().getTime(), true);
		mygetrequest.send(null);					
}

function ChangedAnswerDetail(sentFrame,newValue,origFullString,specChar){
	//window.status = window.status + '-221'
			var frameItem = specChar+sentFrame+specChar;
			var framePos = origFullString.indexOf(frameItem);
			var firstSpecCharPos = origFullString.indexOf(specChar,framePos+1);
			var secondSpecCharPos = origFullString.indexOf(specChar,firstSpecCharPos+1);
			var startPos = firstSpecCharPos + specChar.length;
			var sectionLength = secondSpecCharPos - startPos;
			var origTextValue = origFullString.substr(startPos,sectionLength);
			var valueItem = specChar + origTextValue + specChar;
			var deletePart = specChar + sentFrame + specChar + origTextValue;
			currentValue = origFullString.replace(deletePart,'');
			//--- add on the revised frame and value to the end ---
			currentValue = currentValue + sentFrame + specChar + newValue + specChar;
			return currentValue;		
}

function ClickedPF(passOrFail,assignment,studentID,teacherID,docType){
	//window.status = window.status + '-238'
	//-- the teacher clicked the pass or fail button on the student's test grade --------
	//-- This function name is intentionally obscured ----------------------------------
		var mygetrequest=new ajaxRequest();
		mygetrequest.onreadystatechange=function(){
		if (mygetrequest.readyState==4){
				if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
						//----------- Here is where all the info comes back -------				
						//alert(mygetrequest.responseText)
						ClickedCurrentStudentWorkForTeacher(studentID,teacherID); //reload 			
						
				}//if (mygetrequest.status==200
			}//if (mygetrequest.readyState==4){
		}
		var urlString = "s="+studentID+"&a="+assignment+"&z="+passOrFail+"&i="+teacherID+"&d="+docType;
		mygetrequest.open("GET", "SetAsPF.php?"+urlString+"&qwert="+new Date().getTime(), true);
		mygetrequest.send(null);			
}


function ClickedRFID(studentID){
	//window.status = window.status + '-259'
  if(typeof(rfidInputTimeoutTimerID) != "undefined"){
			  //--- the rfid control is waiting for input and the rfid label/button is flashing --
						OpenRfid();
		}else{
			  //-- the rfid control is NOT waiting for input and the rfid label/button is NOT flashing --
					OpenRfid();
		}
			//	if ($("#iamteachermatcheck").length > 0){/
		//	checkForEndOfAudioTimerID = setInterval("CheckForEndOfAudio()",100);
		//	clearInterval(checkForEndOfAudioTimerID);	
			
}

function OpenRfid(){
	//window.status = window.status + '-274'
  //-- will start a timer and while it's running (unless you dumbly click on another text box in the interim) that will receive the rfid info --	
	
			var currentClass = $("#rfidlabel").attr("class"); //rfidon or rfidoff
			if(currentClass == 'rfidon'){
						var newClass = 'rfidoff';
			}else{
						var newClass = 'rfidon';
			}			
			$('#rfidlabel').attr('class', newClass);
			rfidInputFlashTimerID = setInterval("RfidFlash('')",500);
			rfidInputTimeoutTimerID = setInterval("CloseRfid()",5000);
	 	document.getElementById('rfidtext').value = '';
			document.getElementById('rfidtext').focus();			
			
}

function KeyPressRfid(e){
//window.status = window.status + '-292'
		var key;
			if(window.event)
								key = window.event.keyCode; //IE
			else
								key = e.which;     //firefox    
		if (key == 13){
			  //-- the enter key was 'pressed' --
					CloseRfid();
		}
	
}

function CloseRfid(){
//window.status = window.status + '-306'
	 if(typeof(rfidInputFlashTimerID) != "undefined"){
	   clearInterval(rfidInputFlashTimerID);
		}
	 if(typeof(rfidInputTimeoutTimerID) != "undefined"){
	   clearInterval(rfidInputTimeoutTimerID);
		}			
		//--- show if there is any value in for rfidtext in there or not --
		if(document.getElementById('rfidtext').value != ''){
			  $('#rfidlabel').attr('class', 'rfidon');	
		}else{
			  $('#rfidlabel').attr('class', 'rfidoff');	
		}
		
}

function RfidFlash(action){	  
//window.status = window.status + '-323'
	  switch(action){
				  case 'on':
						  break;
						case 'off':
						  break;
				  default:
						  //-- flash it --
						  var currentClass = $("#rfidlabel").attr("class"); //rfidon or rfidoff
								if(currentClass == 'rfidon'){
									  var newClass = 'rfidoff';
								}else{
									  var newClass = 'rfidon';
								}
        $('#rfidlabel').attr('class', newClass);								
						  break;
				
			}//switch action
}

function TakeContractAction(userType, sentAction, studentID, teacherID, courseID, assignment){
	//window.status = window.status + '-344'
	  switch(sentAction){
				  case 'starttest':						
						  AssignStuProblems('t',studentID, assignment);
								if(userType == 'teacher'){
										ClickedCurrentStudentWorkForTeacher(studentID,teacherID); //reload 						 
								}else{
										ClickedGetStudentCurrentWork(studentID,userType); //reload 
								}
						  break;
			}
}


function AssignStuProblems(track,studentID, assignment){
	//window.status = window.status + '-359'
		var mygetrequest=new ajaxRequest();
		mygetrequest.onreadystatechange=function(){
		if (mygetrequest.readyState==4){
				if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
						//----------- Here is where all the info comes back -------				
					//	alert(mygetrequest.responseText)
					//window.status = "AssignStuProblems loaded  ";
				}//if (mygetrequest.status==200
			}//if (mygetrequest.readyState==4){
		}
		mygetrequest.open("GET", "AssignStuProblems.php?s="+studentID+"&t="+track+"&a="+assignment+"&qwert="+new Date().getTime(), true);
		mygetrequest.send(null);		
}



function GetProblemsHTML(sentAssignment,studentID,trackOfInterest,initialFrame,groupOfInterest,userType,teacherID){
	//window.status = window.status + '-377'
//	alert(studentID+'.........'+trackOfInterest+'.........'+initialFrame)
	 //--- Loads the student's data into the main viewport area --
		//alert('ut coming in='+userType)
		var mygetrequest=new ajaxRequest();
		mygetrequest.onreadystatechange=function(){
		if (mygetrequest.readyState==4){
				if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
						//----------- Here is where all the info comes back -------				
					//	alert(mygetrequest.responseText)
			   problemsHTML = mygetrequest.responseText;						
					//	if(entireSectionCorrect == 1){
							  // -- all in this subsection are correct --									
							//		ClickedGetStudentCurrentWork(studentID); //reload and get the checkmark 									
					//	}else{
							  //-- all in this subsection are not correct --										
									document.getElementById('currentworkproblemscontentdiv').innerHTML = problemsHTML;
									//window.status = "GetProblemsHTML loaded  ";
					//	}											   
				//		SizeImageAndCenterMainDivDetail();
				}//if (mygetrequest.status==200
		 }//if (mygetrequest.readyState==4){
		}
		//alert("GetProblemsHTML.php?s="+studentID+"&t="+trackOfInterest+"&f="+initialFrame)
		mygetrequest.open("GET", "GetProblemsHTML.php?a="+sentAssignment+"&s="+studentID+"&t="+trackOfInterest+"&f="+initialFrame+"&gs="+globalSessionID+"&ut="+userType+"&i="+teacherID+"&qwert="+new Date().getTime(), true);
		mygetrequest.send(null);				
}

function ApplyPretestToContract(studentID, teacherID){
	//window.status = window.status + '-406'
		var mygetrequest=new ajaxRequest();
		mygetrequest.onreadystatechange=function(){
		if (mygetrequest.readyState==4){
				if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
						//----------- Here is where all the info comes back -------				
						//window.status = "ApplyPretestToContrac loaded  ";
				 //alert(mygetrequest.responseText)
				}//if (mygetrequest.status==200
			}//if (mygetrequest.readyState==4){
		}
		var urlString = "s="+studentID+"&gs="+globalSessionID+"&i="+teacherID;
	//	alert(urlString);
		mygetrequest.open("GET", "ApplyPretestToContract.php?"+urlString+"&qwert="+new Date().getTime(), true);
		mygetrequest.send(null);	
}


function ClickedSendGroupAnswer(assignment, track, studentID, group, userType, teacherID){
	//window.status = window.status + '-425'
	//-- THIS IS USED FOR TEST GRADING BY THE TEACHER OR byt the student doing a pretest---
		var specChar = '~**~';//must be the same that's used in GradeStudentAnswer --		
		var jqueryClassRef = '.' + 'testgroupprobans'; //note: the dot shows it's a class
		var oTextInputArray = $(jqueryClassRef);
		var textValueArray = new Array;	
		var frameString = '';
		for (var i = 0; i < oTextInputArray.length; i++){ 	
				textValueArray[i] = oTextInputArray[i].value;
		}
		var stuReply = textValueArray.join(specChar);		
//alert('stureply=' + stuReply)
		var mygetrequest=new ajaxRequest();
		mygetrequest.onreadystatechange=function(){
		if (mygetrequest.readyState==4){
				if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
						//----------- Here is where all the info comes back -------				
				//alert(mygetrequest.responseText)
				//window.status = "ClickedSendGroupAnswer loaded  ";
			 if(userType == 'teacher'){
						 ClickedCurrentStudentWorkForTeacher(studentID,teacherID); //reload 						 
				 }else{
						 ClickedGetStudentCurrentWork(studentID,userType); //reload 
							//--- update the current doing blurb which will be verbose and have info (number remaining, etc) you don't want to mess with --
							//document.getElementById('currentworkdoingblurbdiv').innerHTML = '';
					} 
					
			 /*			UpdateSubSection(assignment,studentID,track,initialFrame,'');
							if(userType == 'student'){
								  document.getElementById('currentworkdoingblurbdiv').innerHTML = '';
							}
				 		GetProblemsHTML(assignment,studentID,track,initialFrame,group,userType,teacherID);	*/
						SizeImageAndCenterMainDivDetail();					
					
				}//if (mygetrequest.status==200
			}//if (mygetrequest.readyState==4){
		}
		var frameString = ''; //not used
		var frame = 0; //not used
		var urlString = "s="+studentID+"&t="+track+"&a="+assignment+"&r="+stuReply+"&f="+frame+"&fs="+frameString+"&g="+group+"&gs="+globalSessionID+"&ut="+userType+"&i="+teacherID;
//	alert(urlString);
		mygetrequest.open("GET", "GradeStudentAnswer.php?"+urlString+"&qwert="+new Date().getTime(), true);
		mygetrequest.send(null);		
}

function ClickedSendAnswer(group, initialFrame, assignment, track, studentID, frame, userType, teacherID){	 
//window.status = window.status + '-471'
     //ClickedSendAnswer(   0,       137,           0,        'r',     78,    '137','teacher',887324156)
     //  CClickedSendAnswer(0,       1,           0,         'r',     361,     '1',   'teacher',887324156)
  if(group == 0){
    var textBoxID = 'stuans' + frame;						
	   var stuReply = Trim(document.getElementById(textBoxID).value);
				frameString = ''; //not used since frame calls the shots
		}else{
			  //-- this is a group so we have to send all the current answers in the group --
					var specChar = '~**~';//must be the same that's used in GradeStudentAnswer --
					frame = 0; //not used since group calls the shots
					var className = 'g' + group;
					var jqueryClassRef = '.' + className; //note: the dot shows it's a class
					var oTextInputArray = $(jqueryClassRef);
					var textValueArray = new Array;	
					var frameString = '';
					for (var i = 0; i < oTextInputArray.length; i++){ 	
					  textValueArray[i] = oTextInputArray[i].value;
					}
					var stuReply = textValueArray.join(specChar);
		}
		initialFrame = document.getElementById('initialframe').value; 		
		//alert(studentID + ' ----- ' + assignment + ' ----- ' + track + ' ---- ' + initialFrame + ' --- ' + stuReply)
		var mygetrequest=new ajaxRequest();
		mygetrequest.onreadystatechange=function(){
		if (mygetrequest.readyState==4){
				if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
						//----------- Here is where all the info comes back -------				
					 	returnVal = mygetrequest.responseText;
							//window.status = "ClickedSendAnswer loaded  ";
      // alert(returnVal);
							if (returnVal == 'okfornext'){						
									if(userType == 'teacher'){
											ClickedCurrentStudentWorkForTeacher(studentID,teacherID); //reload 						 
									}else{
											ClickedGetStudentCurrentWork(studentID,userType); //reload 						
									}
							}
			 			UpdateSubSection(assignment,studentID,track,initialFrame,'');
							if(userType == 'student'){								 
								  document.getElementById('currentworkdoingblurbdiv').innerHTML = '';
							}
				 		GetProblemsHTML(assignment,studentID,track,initialFrame,group,userType,teacherID);	
						
				}//if (mygetrequest.status==200
			}//if (mygetrequest.readyState==4){
		}
		mygetrequest.open("GET", "GradeStudentAnswer.php?s="+studentID+"&t="+track+"&a="+assignment+"&r="+stuReply+"&f="+frame+"&fs="+frameString+"&g="+group+"&gs="+globalSessionID+"&ut="+userType+"&i="+teacherID+"&qwert="+new Date().getTime(), true);
		mygetrequest.send(null);					
}

function KeyPressSingleIProb(e,assnum,track,stu,framenum,ut,t){	
//window.status = window.status + '-523'
		var key;
			if(window.event){
								key = window.event.keyCode; //IE
			}else{
								key = e.which;     //firefox    
			}			
		if (key == 13){
    //-- it's like pressing the button next to the text input --
				ClickedSendLoneAnswer(assnum,track,stu,framenum,ut,t);
		}
}

function ClickedSendLoneAnswer(assignment, track, studentID, frame, userType, teacherID){
	//window.status = window.status + '-537'
  //--- student cliced the send answer button on a single problem (eg, instructional) for from GetStudentCurrentWork.ph p --
		if(userType == 'student'){
		  var textBoxID = 'stuans' + frame;						
		  var stuReply = Trim(document.getElementById(textBoxID).value);
		}else{
			 var stuReply = '';  //doesn't matter.  The fact a teacher clicked it means it's OK  
		}
		var mygetrequest=new ajaxRequest();
		mygetrequest.onreadystatechange=function(){
		if (mygetrequest.readyState==4){
				if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
						//----------- Here is where all the info comes back -------				
					//	alert(mygetrequest.responseText)
					//window.status = "ClickedSendLoneAnswer loaded  ";
					if(userType == 'teacher'){
						 ClickedCurrentStudentWorkForTeacher(studentID,teacherID); //reload 						 
					}else{
						 ClickedGetStudentCurrentWork(studentID,userType); //reload 
       //document.getElementById('currentworkdoingblurbdiv').innerHTML = '';							
					}
				}//if (mygetrequest.status==200
			}//if (mygetrequest.readyState==4){
		}
		var frameString = ''; //not used
		var group = ''; //not used
		mygetrequest.open("GET", "GradeStudentAnswer.php?s="+studentID+"&t="+track+"&a="+assignment+"&r="+stuReply+"&f="+frame+"&fs="+frameString+"&g="+group+"&gs="+globalSessionID+"&ut="+userType+"&i="+teacherID+"&qwert="+new Date().getTime(), true);
		mygetrequest.send(null);		
}



function AssignProbsAndRefreshCurrent(assignment,nextAssignment,track,studentID,useNextAssignment,userType,teacherID){
	//window.status = window.status + '-570'
		var mygetrequest=new ajaxRequest();
		mygetrequest.onreadystatechange=function(){
		if (mygetrequest.readyState==4){
				if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
						//----------- Here is where all the info comes back -------			
						//alert(mygetrequest.responseText)
						//-- this will do the reload ---
						//window.status = "AssignProbsAndRefreshCurrent loaded  ";
						if(userType == 'teacher'){
							  ClickedCurrentStudentWorkForTeacher(studentID,teacherID)
						}else{
							  ClickedGetStudentCurrentWork(studentID,'student'); 
						}										
					//	alert('did it');
				}//if (mygetrequest.status==200
			}//if (mygetrequest.readyState==4){
		}
//	alert("si="+studentID+"&t="+track+"&ass="+assignment);
		mygetrequest.open("GET", "AssignProbsAndRefreshCurrent.php?si="+studentID+"&t="+track+"&ass="+assignment+"&na="+nextAssignment+"&use="+useNextAssignment+"&gs="+globalSessionID+"&ut="+userType+"&ti="+teacherID+"&qwert="+new Date().getTime(), true);
		mygetrequest.send(null);			 
}


function MakeContractStatusStrings(){
	//window.status = window.status + '-595'
	 // -- makes strings to assist in saving to mysql and to compare new with old to see if any changes were made --
		if(document.getElementById('contractassignments') != null){
			  //-- why this can sometimes get corrupted I don't know (debugging  work?) ---
		 	oContractAss = document.getElementById('contractassignments');
				var clearString = '';
				var preOKString = '';
				var testOKString = '';
			//	var helpOKString = '';		
				var help1okString = '';	
				var help2okString = '';	
				var hwReqString = '';
				var skipString = '';		
				for (var i = 0; i < oContractAss.options.length; i++){ 		
						var assNumAndNameArray = oContractAss.options[i].value.split('@');
						var assnum = assNumAndNameArray[0];
						switch(oContractAss.options[i].className){
									case '':
								//	case 'todo':
									case 'nexthelp':
											clearString = clearString + assnum + '@';
											break;
									case 'preok':
											preOKString = preOKString + assnum + '@';
											break;									
									case 'testok':
											testOKString = testOKString + assnum + '@';
											break;									
									case 'help1ok':
											help1okString = help1okString + assnum + '@';
											break;				
									case 'help2ok':
									case 'nexttest':
											help2okString = help2okString + assnum + '@';
											break;											
									case 'hwreq':
									case 'nexthw':
											hwReqString = hwReqString + assnum + '@';
											break;									
									case 'skip':
											skipString = skipString + assnum + '@';
											break;											
						}
				}		
				var comboStringArray = clearString+'%'+preOKString+'%'+testOKString+'%'+help1okString+'%'+help2okString+'%'+hwReqString+'%'+skipString;
				return comboStringArray;	
		}
}

function SaveOriginalContractStatusStrings(){
	//window.status = window.status + '-645'
	//alert('646')
		if(document.getElementById('contractassignments') != null){
			  //-- why this can sometimes get corrupted I don't know (debugging  work?) ---	
				var comboString = MakeContractStatusStrings();
				//alert(comboString)
				var comboStringArray = comboString.split('%'); 
				if(comboStringArray.length > 0){
				///	alert('if')
						var clearString = comboStringArray[0]; 
						var preOKString = comboStringArray[1];
						var testOKString = comboStringArray[2];
						var help1okString = comboStringArray[3];
						var help2okString = comboStringArray[4];
						var hwReqString = comboStringArray[5];
						var skipString = comboStringArray[6];
						document.getElementById('clearString').value = clearString;
						document.getElementById('preOKString').value = preOKString;
						document.getElementById('testOKString').value = testOKString;
						document.getElementById('help1okString').value = help1okString;
						document.getElementById('help2okString').value = help2okString; 
						document.getElementById('hwReqString').value = hwReqString;
						document.getElementById('skipString').value = skipString;  
				}
		}
}

function SaveStudentContract(studentID, courseID){
	//window.status = window.status + '-668'
  // -- all the info comes from the contract select control --
	 var comboString = MakeContractStatusStrings();
		var comboStringArray = comboString.split('%'); 
		var clearString = comboStringArray[0]; 
		var preOKString = comboStringArray[1];
		var testOKString = comboStringArray[2];
		var help1okString = comboStringArray[3];
		var help2okString = comboStringArray[4];
		var hwReqString = comboStringArray[5];
		var skipString = comboStringArray[6];
		
		var origClearString = document.getElementById('clearString').value;
		var origPreOKString = document.getElementById('preOKString').value;
		var origTestOKString = document.getElementById('testOKString').value;
		var orighelp1okString = document.getElementById('help1okString').value;
		var orighelp2okString = document.getElementById('help2okString').value;
		var origHwReqString = document.getElementById('hwReqString').value;
		var origSkipString = document.getElementById('skipString').value; 		
		
		//-- if the values haven't changed, we send an empty string and forego an unnecessary mysql call --
		if(clearString == origClearString){
			 clearString = '';
		}
		if(preOKString == origPreOKString){
			  preOKString = '';
		}		
		if(testOKString == origTestOKString){
			 testOKString = '';
		}	
		if(help1okString == orighelp1okString){
			 help1okString = '';
		}	
		if(help2okString == orighelp2okString){
			 help2okString = '';
		}			
		if(hwReqString == origHwReqString){
			 hwReqString = '';
		}	
		if(skipString == origSkipString){
			 skipString = '';
		}	
		
		var mygetrequest=new ajaxRequest();
		mygetrequest.onreadystatechange=function(){
		if (mygetrequest.readyState==4){
				if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
						//--- Here is where all the info comes back which ain't nothing in this case-------	
						//alert ('it is: ' +mygetrequest.responseText); 	
						//window.status = "SaveStudentContract loaded  ";
				}//if (mygetrequest.status==200
		}//if (mygetrequest.readyState==4){
	}//mygetrequest.onreadystatechange=function()		
	mygetrequest.open("GET", "SaveStudentContract.php?i="+studentID+"&c="+courseID+"&clearString="+clearString+"&preOKString="+preOKString+"&testOKString="+testOKString+"&help1okString="+help1okString+"&help2okString="+help2okString+"&hwReqString="+hwReqString+"&skipString="+skipString+"&gs="+globalSessionID+"&qwert="+new Date().getTime(), true);
	mygetrequest.send(null);	
}

function FillOutStudentContract(studentRecordArray,studentCourseID){
	//window.status = window.status + '-726'
  var stuFirstName = studentRecordArray[11];  
		var tchrID = studentRecordArray[1];
		if(tchrID > 0){
			  var teacherOrVisitor = 1;
		}else{
			  var teacherOrVisitor = -1;
		}
		//HighlightNextTestOrHelp(stuFirstName,teacherOrVisitor);	
}



function ChangeSelConAssStatus(studentID, stuFirstName, newStatus, teacherID){
 	//window.status = window.status + '-740'
  var oContractAss = document.getElementById('contractassignments');
  //-- finds the selected item and changes its class --
		var assignmentString = '';
		var first = true;
  for (var i = 0; i < oContractAss.options.length; i++){ 	
		  if(oContractAss.options[i].className == 'nexttest'){
				 oContractAss.options[i].className = 'help2ok';
				}else{
		    if(oContractAss.options[i].className == 'nexthelp'){
				    oContractAss.options[i].className = '';
					}						  
				}	 				
		  if (oContractAss.options[i].selected){				 
				   //oContractAss.options[i].className = newStatus;
							var assNumAndNameArray = oContractAss.options[i].value.split('@');
							if(first == false){
								  assignmentString = assignmentString + '@';
							}
							first = false;
							assignmentString = assignmentString + assNumAndNameArray[0];
				} 								
  } 
		var mygetrequest=new ajaxRequest();
		mygetrequest.onreadystatechange=function(){
		if (mygetrequest.readyState==4){
				if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
						//--- Here is where all the info comes back which ain't nothing in this case-------	
						//alert (mygetrequest.responseText); 					
						//window.status = "ChangeSelConAssStatus loaded  ";
						ClickContract(studentID,teacherID); //to refresh the page
				}//if (mygetrequest.status==200
		}//if (mygetrequest.readyState==4){
	}//mygetrequest.onreadystatechange=function()		
	mygetrequest.open("GET", "ChangeSelectedContractAssignmentStatus.php?i="+studentID+"&ns="+newStatus+"&as="+assignmentString+"&qwert="+new Date().getTime(), true);
	mygetrequest.send(null);			
	//	HighlightNextTestOrHelp(studentID, stuFirstName, teacherOrVisitor);		
}


function ClickedContractTask(newStatus,assignment,teacherID,studentID){
	//window.status = window.status + '-781'
 	var mygetrequest=new ajaxRequest();
		mygetrequest.onreadystatechange=function(){
		if (mygetrequest.readyState==4){
				if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
						//--- Here is where all the info comes back which ain't nothing in this case-------	
						//alert (mygetrequest.responseText); 					
						//window.status = "ClickedContractTask loaded  ";
						ClickContract(studentID,teacherID); //to refresh the page
				}//if (mygetrequest.status==200
		}//if (mygetrequest.readyState==4){
	}//mygetrequest.onreadystatechange=function()		
	mygetrequest.open("GET", "ChangeSelectedContractAssignmentStatus.php?i="+studentID+"&ns="+newStatus+"&as="+assignment+"&qwert="+new Date().getTime(), true);
	mygetrequest.send(null);			
}

function CheckGlobalNextClick(){	
//window.status = window.status + '-798'
	 if(globalNextClick != ''){
    switch(globalNextClick){
					  case 'restoreMainText':
							  globalNextClick = 'restoreMainText2'; //nothing done because the click to take action will fire immediately after to here
					    break;		
					  case 'restoreMainText2':
							  document.getElementById('maintextdiv').innerHTML = globalNextClickData;
									document.getElementById('mainalertdiv').innerHTML = globalNextClickData2;
									globalNextClick = '';
									globalNextClickData2 = '';
					    break;							
					  case 'restoreMainAlert':
							  globalNextClick = 'restoreMainAlert2'; //nothing done because the click to take action will fire immediately after to here
					    break;		
					  case 'restoreMainAlert2':
							  document.getElementById('mainalertdiv').innerHTML = globalNextClickData;
									globalNextClick = '';  
					    break;											
						case 'restoreMainAlertFirstNextClick':		//this one is software initiated so the first click the user makes WILL be for this						 
							 document.getElementById('mainalertdiv').innerHTML = globalNextClickData;
								globalNextClick = '';  
								break;			
				}//switch			
				if(globalVideoName != ''){
					 //-- watching a movie, so get the other stuff out of there --
			   switch(globalNextClick){
					    case 'restoreMainText':
									case 'restoreMainText2':
									  ClearGetUserPass();
									  break;
						} //switch
				}//globalvideoname
		}//if
}
	

function ConstructionStartUp(){
	//window.status = window.status + '-836'
	  ///-- used with indexConstructionLockOut.html (which will be temporarily named as index.html) ---
		globalDocsForBrowseHelp = false;
  SizeImageAndCenterMainDivDetail(); 
		SizeImageAndCenterMainDivDetail(); 			
}


function StartUp(keepBrowseHelp){
	//window.status = window.status + '-845'
  //--- clear any existing text -------------	
  globalDocsForBrowseHelp = false;
  oResponseText = document.getElementById('responsetext');
		if (oResponseText != null){
    oResponseText.focus(); 
		}
		var password = 'p';
  var username = 'u';
		SetUpPageForLogin();	
  if(keepBrowseHelp != 'keepbrowsehelp'){
		  LoadBrowseHelpContents(-1,'student'); 				
		}
		//-- gotta kick it twice at the beginning!--
  SizeImageAndCenterMainDivDetail(); 
		SizeImageAndCenterMainDivDetail(); 
		globalRightMainDivWidth = document.getElementById('mainrightdiv').offsetWidth;
		
		//-- give the username the focus --
   StartUserFocus();
		
		//-- to be used upon logout --
		document.getElementById('defaultmainlogindiv').innerHTML = document.getElementById('maindiv').innerHTML;
		
		
/*	
	//	document.getElementById('defaultpagetitle').innerHTML = document.getElementById('').innerHTML; //hard coded in index.html
	 document.getElementById('defaultmainleftdiv').innerHTML = document.getElementById('mainleftdiv').innerHTML;
		document.getElementById('defaulttoplinks').innerHTML = document.getElementById('mainrightdiv1').innerHTML;
		document.getElementById('defaultalert').innerHTML = document.getElementById('mainalertdiv').innerHTML;
		document.getElementById('defaulttext').innerHTML = document.getElementById('maintextdiv').innerHTML;
		document.getElementById('defaultresponsetext').innerHTML = document.getElementById('responsetextdiv').innerHTML;
		document.getElementById('defaultbuttons').innerHTML = document.getElementById('mainbuttondiv').innerHTML; 
	*/	
}

function AreCookiesEnabled(){
	 //window.status = window.status + '-882'
			var cookieEnabled = false;
			if (typeof document.cookie == "string") {
							if (document.cookie.length == 0) {
											document.cookie = "test";
											cookieEnabled = (document.cookie == "test");
											document.cookie = "";
							} else {
											cookieEnabled = true;
							}
			}
			return cookieEnabled;
}


function WhoDat(){
	  
}

function WhoDat2(){
	  
}

function SetUpPageForLogin(){	  
//window.status = window.status + '-906'
 // document.getElementById('maintextdiv').innerHTML = "<p>Select a video or interactive lesson from the list on the left.Or sign-in to continue with interactive help you started earlier.</p><p>" +IconExplanationBlurb() + '</p>';	
	globalDocsForBrowseHelp = false;
  document.getElementById('mainimagediv').innerHTML = '';
		globalImageName = '';
		//document.getElementById('mainalertdiv').innerHTML = '<b>Welcome to Working Teacher Help</b>';
		oUserText = document.getElementById('user');
		document.getElementById('i').value = '';				
	//	if (oUserText != null){
			//	oUserText.focus(); //causes error in IE because at this point it is invisible
	//}
}


function ClearGetUserPass(){
	// document.getElementById('responsetextdiv').innerHTML = '';
  //document.getElementById('mainbuttondiv').innerHTML = '';
}

function ToggleMaxState(sentParameter){
		//-- the colors here should match what's in the css (for the initial condition set up) --
		/*
		if(globalMaxState == 'normal'){
	   globalMaxState = 'max';
	   SetMaxIcon('max');				
 }else{
	   globalMaxState ='normal';
	   SetMaxIcon('normal');
 }
  // --- call Size and center function --
		// -- you have to hit it twice because the text or alert may scale after the first re-sizing ---
		if(sentParameter == ''){
    SizeImageAndCenterMainDivDetail();
		  SizeImageAndCenterMainDivDetail();
		}
		*/
}

function SetMaxIcon(maxOrNormal){
	/*
 	var oMaxIcon = document.getElementById('maxicondiv');
	 if(maxOrNormal == 'max'){
			 oMaxIcon.style.backgroundColor = 'yellow';
		}else{
			 oMaxIcon.style.backgroundColor = '#CCCCCC';
		}
		*/
}


function SetAudioIcon(onOrOff){
	/*
	 var oMaxIcon = document.getElementById('audioicondiv');
		if(onOrOff == 'on'){
		  oMaxIcon.style.backgroundColor = 'yellow';
		}else{
			 oMaxIcon.style.backgroundColor = '#CCCCCC';
		}
		*/
}

function ToggleAudioState(sentParameter){
		//-- HAVE TO ADD THE GLOBALAUDIOSTATE TO THE EXISTENCE OF A FILE NAME FOR DECIDING IF AUDIO IS TO BE ADDED --
		//-- the colors here should match what's in the css (for the initial condition set up) --
		//window.status = window.status + '-970'
		if(globalAudioState == 'off'){
				globalAudioState = 'on';
				SetAudioIcon('on');
				// --- insert audio using global audio var --
		}else{
				globalAudioState ='off';
				SetAudioIcon('off');			
				// -- remove audio from audio div -------
		}
		if(globalLastAudioFileRoot != ''){
	   AudioPlayer(globalLastAudioFileRoot);
		}else{
			 if((globalAudioFileNameRoot != '')&&(globalAudioFileNameRoot != null)){
			   AudioPlayer(globalAudioFileNameRoot);
				}
		}
		// -- you have to hit it twice due to reszing --
		if(sentParameter == ''){
    SizeImageAndCenterMainDivDetail();
		  SizeImageAndCenterMainDivDetail();
		}
	}
		
function ToggleTextState(sentParameter){
	//window.status = window.status + '-995'
		//-- the colors here should match what's in the css (for the initial condition set up) --
		if ((globalTextToggleEnabled == true) &&(globalForceShowText != 1)){
				if(globalTextState == 'off'){
						globalTextState = 'on';
						if(globalLanguage == 'english'){
						  document.getElementById('maintextdiv').innerHTML = globalMainTextHTML;
						}else{
							 document.getElementById('maintextdiv').innerHTML = globalMainSpanTextHTML;
						}
						SetTextIcon('on');
				}else{
						globalTextState = 'off';
						document.getElementById('maintextdiv').innerHTML = '';
						SetTextIcon('off');
				}		 
		}
		// -- you have to hit it twice due to reszing --
		if(sentParameter == ''){
    SizeImageAndCenterMainDivDetail();
		  SizeImageAndCenterMainDivDetail();
		} 
}

function SetTextIcon(onOrOff){
	return;
	/*
	  var oTextIcon = document.getElementById('texticondiv');
	  if(onOrOff == 'on'){
				  oTextIcon.style.backgroundColor = 'yellow';
			}else{
				  oTextIcon.style.backgroundColor = '#CCCCCC';
			}
			*/
}

function IconExplanationBlurb(){
	//window.status = window.status + '-1032'
	//-- this is in js and not php to avoid an extra php page call --
	var blurb = "<ul id='helpkeyul'><li><span class='googlebullet'>&nbsp;&nbsp;&nbsp;&nbsp;</span>&nbsp;Video Search (Google)</li><li><span class='wsbullet'>&nbsp;&nbsp;&nbsp;&nbsp;</span>&nbsp;Worksheet & Web Page Links</li><li><span class='wtvbullet'>&nbsp;&nbsp;&nbsp;&nbsp;</span>&nbsp;Video (in class recorded)</li></ul>";
	return blurb;	
}

function ccKeyPressUser(e){
	//window.status = window.status + '-1039'
  var unicode=e.keyCode? e.keyCode : e.charCode
		var actualKey=String.fromCharCode(unicode)
	
}

//onkeyup=\"ClickedSendLoneAnswer(event,".$singleAssignment.",'m',".$studentID.",".$singleFrame.",'".$userType."',".$teacherID."

				
																											
function KeyPressUser(e,assnum,track,framenum,ut,t){
	//window.status = window.status + '-1050'
		var key;
			if(window.event){
								key = window.event.keyCode; //IE
			}else{
								key = e.which;     //firefox    
			}
			
		if (key == 13){
		/*
			 //--- check if it's a bunch of numbers because that could be an rfid input so we want to shoot it out for checking ---
				var user = document.getElementById('user').value;
				if (isNaN (user)){
					  //-- can't be an rfid because it's not a number --
		    oPassText = document.getElementById('pass');
			   oPassText.focus(); 					
				}else{
					  //-- it is a number -----
							UpdateMainPage('login',user, '',0,0,0);
				}
				globalUsernameValue = '';
			*/
		}else{
			  //-- it's not the enter key but maybe you have a lame rfid reader that doesn't attach a carriage return --
					//-- If it's exactly 10 characters long (that's what rfid codes have) and it's a number, check it out as an RFID submission
					//-- You have go through all this globalUsername stuff (building it up from key strokes) because username.value isn't updated
					//-- until AFTER the last key is pressed and it doesn't include the last key!!! ---
					//-- For RFID readers that HAVE the automatic carriage return at the end, the test for key=13 will do the job --
				  // -- BUT THIS LAME CODE WILL MAKE IT DO IT TWICE FUCKHEAD! --- Anyway, fuck devices w/o the carriage insertion--
				
     var unicode=e.keyCode? e.keyCode : e.charCode
		   var actualKey=String.fromCharCode(unicode)
		   								
						if (isNaN (actualKey)){
									globalUsernameValue = '';
						}else{
									//-- it is a number -----
									globalUsernameValue = globalUsernameValue + actualKey;
									if(globalUsernameValue.length == 10){ 
									  UpdateMainPage('login',globalUsernameValue, '',0,0,0);
											globalUsernameValue = '';
									}
						}
						
		}
		
}


function KeyPressFastLogOut(e){
	//window.status = window.status + '-1100'
		var key;
			if(window.event)
								key = window.event.keyCode; //IE
			else
								key = e.which;     //firefox    
		if (key == 13){
			  var inputValue = document.getElementById('fastlogout').value;
					if(inputValue == ''){
						  //-- the enter key alone was pressed --
								UpdateMainPage('logout','','',0,0,0);
					}else{								
								if (isNaN (inputValue)){
										//-- the enter key was 'pressed' --
										UpdateMainPage('logout','','',0,0,0);
								}else{
											//-- a number was typed in so it's probably either the same person trying to logout or a new one trying to log in --
											var rfid = document.getElementById('temps').value;
											if(rfid == inputValue){
														//-- this is the same guy who just logged in --
														UpdateMainPage('logout','','',0,0,0);
											}else{
														//-- this is possibly a new student ----
														//--- This is continued on function KeyPressFastLogOutPart2() --
														KeyPressFastLogOutPart2(inputValue);
											}
								}
					}
		}else{
  //////////////////////////			
			  //-- it's not the enter key but maybe you have a lame rfid reader that doesn't attach a carriage return --
					//-- If it's exactly 10 characters long (that's what rfid codes have) and it's a number, check it out as an RFID submission
					//-- You have go through all this globalUsername stuff (building it up from key strokes) because username.value isn't updated
					//-- until AFTER the last key is pressed and it doesn't include the last key!!! ---
					//-- For RFID readers that HAVE the automatic carriage return at the end, the test for key=13 will do the job --
     var unicode=e.keyCode? e.keyCode : e.charCode
		   var actualKey=String.fromCharCode(unicode)
		   								
						if (isNaN (actualKey)){
									globalUsernameValue = '';
						}else{
									//-- it is a number -----
									globalUsernameValue = globalUsernameValue + actualKey;
									if(globalUsernameValue.length == 10){ 
									  //------------------
											//-- a number was typed in so it's probably either the same person trying to logout or a new one trying to log in --
											var rfid = document.getElementById('temps').value;
											if(rfid == globalUsernameValue){
														//-- this is the same guy who just logged in --
														UpdateMainPage('logout','','',0,0,0);
											}else{
														//-- this is possibly a new student ----
														//--- This is continued on function KeyPressFastLogOutPart2() --
														KeyPressFastLogOutPart2(globalUsernameValue);
											}																						
											//--------------
											globalUsernameValue = '';
									}
						}								
		/////////////////////////	
		}
}

function xxxKeyPressFastLogOut(e){
	//window.status = window.status + '-1164'
		var key;
			if(window.event)
								key = window.event.keyCode; //IE
			else
								key = e.which;     //firefox    
		if (key == 13){
			  var inputValue = document.getElementById('fastlogout').value;
					if(inputValue == ''){
						  //-- the enter key alone was pressed --
								UpdateMainPage('logout','','',0,0,0);
					}else{			
								if (isNaN (inputValue)){
										//-- the enter key was 'pressed' --
										UpdateMainPage('logout','','',0,0,0);
								}else{
											//-- a number was typed in so it's probably either the same person trying to logout or a new one trying to log in --
											var rfid = document.getElementById('temps').value;
											if(rfid == inputValue){
														//-- this is the same guy who just logged in --
														UpdateMainPage('logout','','',0,0,0);
											}else{
														//-- this is possibly a new student ----
														//--- This is continued on function KeyPressFastLogOutPart2() --
														KeyPressFastLogOutPart2(inputValue);
											}
								}
					}
		}	
}


function KeyPressFastLogOutPart2(inputValue){
	//window.status = window.status + '-1197'
	 //-- since this ajax business is asymmetrical, this CONTINUES what started in function KeyPressFastLogOut ---
	 var cc = GetCookie('cc');
		var mygetrequest=new ajaxRequest();
		mygetrequest.onreadystatechange=function(){
		if (mygetrequest.readyState==4){
				if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
						//--- Here is where all the info comes back which ain't nothing in this case-------		
						//window.status = "KeyPressFastLogOutPart2 loaded  ";
							var validOrInvalid = mygetrequest.responseText;																	
							if(validOrInvalid == 0){
										//-- it was just garbage numbers for the rfid --
										UpdateMainPage('logout','','',0,0,0);
							}else{
									 UpdateMainPage('login',inputValue, '',0,0,0);									
							}
				}//if (mygetrequest.status==200
		}//if (mygetrequest.readyState==4){
	}//mygetrequest.onreadystatechange=function()		
			mygetrequest.open("GET", "CheckForValidRFID.php?r="+inputValue+"&cc="+cc+"&qwert="+new Date().getTime(), true);
	mygetrequest.send(null);	
}

function KeyPressPass(e){
	//window.status = window.status + '-1221'
		var key;
			if(window.event)
								key = window.event.keyCode; //IE
			else
								key = e.which;     //firefox    
		if (key == 13){
					var user = document.getElementById('user').value;
					var pass = document.getElementById('pass').value;
			  UpdateMainPage('login',user, pass,0,0,0);	
		}
}



function LoginFromButton(){
	//window.status = window.status + '-1237'
	  var user = document.getElementById('user').value;
			var pass = document.getElementById('pass').value;
			UpdateMainPage('login',user, pass,0,0,0);	
}




function GetRadioValue(radioName,numButtons){
	//window.status = window.status + '-1247'
		objectArray = document.getElementsByName(radioName);
		var radioVal = ''; 
  for (var i = 0; i <numButtons; i++) {
			 if(objectArray[i]){
						if (objectArray[i].checked == true){
									radioVal = objectArray[i].value;
									break;
							}				
				}
   }
			return radioVal;
}
	
function SetRadioValue(radioName,sentValue,numButtons){
	//window.status = window.status + '-1262'
		objectArray = document.getElementsByName(radioName);
		var radioVal = ''; 
  for (var i = 0; i <numButtons; i++) {
			 if(objectArray[i]){
					  if (objectArray[i].value == sentValue){
					    objectArray[i].checked = true;
									break;
							}				
				}
   }
}	



function WhySignInFirst(){  
//window.status = window.status + '-1278'
  if((globalNextClick != 'restoreMainText')&&(globalNextClick != 'restoreMainText2')){
				globalNextClickData = document.getElementById('maintextdiv').innerHTML; 
				document.getElementById('maintextdiv').innerHTML = "For most interactive help, you will be be given problems to do along with the explanation. If you're in class, someone else may need to use the computer, and so having you sign in provides a way for you to break off and then come back when you have the answer.  Also, for lengthly sessions, it lets you stop when you want and then resume your study at a later time (or place).";
				globalNextClick ='restoreMainText';
		}
}


function ClickedLogOut(studentID){
	//window.status = window.status + '-1288'
	 globalDocsForBrowseHelp = false;
		document.getElementById('verticalmenudiv').innerHTML = '';
		UpdateMainPage('logout','','',0,0,studentID);		
}


function CheckForEndOfAudio(){
	//window.status = window.status + '-1295'
	 //-- this works solely for the purpose of preventing multiple audio instantiations (the many voices problem) --
		if(document.getElementById('audioplayerdiv').innerHTML != ''){
					if(audioTagSupport == true){
								var oAudioPlayer = document.getElementById('audioplayer');
								if(oAudioPlayer.currentTime >= oAudioPlayer.duration){
											//-- audio player is at end of file ---
											globalAudioPlaying = false;
											clearInterval(checkForEndOfAudioTimerID);											
								}else{
											//-- audio player is playing --
								}				
					}else{
								//----eg, audioTagSupport = false ----
								if(niftyplayer("niftyPlayer1").getState() == 'playing') {
										// -- nifty is playing ---											
								}else{
										//-- nifty is not playing ---
										globalAudioPlaying = false;
										clearInterval(checkForEndOfAudioTimerID);
								}
					}
		}else{				
				// -- no audio loaded or audio is turned off --
				globalAudioPlaying = false;
				clearInterval(checkForEndOfAudioTimerID);	
		}  		
}


function PlayBackgroundAudio(sentAudioFileNameRoot){
	//window.status = window.status + '-1326'
			if(audioTagSupport == true){							
						var audioPlayerCode = "<audio id='audioplayer' autoplay autobuffer preload controls><source src='"+sentAudioFileNameRoot+".ogg"+"'/><source src='"+sentAudioFileNameRoot+".mp3"+"'/></audio>";
			}else{
			  var audioPlayerCode = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0'width='165' height='37' id='niftyPlayer1' align=''><param name=movie value='niftyplayer.swf?file="+sentAudioFileNameRoot+".mp3"+"&as=1'><param name=quality value=high><param name=bgcolor value=#FFFFFF><embed src='niftyplayer.swf?file="+sentAudioFileNameRoot+".mp3"+"&as=1' quality=high bgcolor=#FFFFFF width='165' height='37' name='niftyPlayer1' align=''type='application/x-shockwave-flash' swLiveConnect='true' pluginspage='http://www.macromedia.com/go/getflashplayer'></embed></object></audio><audio autobuffer preload><source src='"+sentAudioFileNameRoot+".ogg"+"'/><source src='"+sentAudioFileNameRoot+".mp3"+"'/><object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0' width='0'height='0' id='niftyPlayer2' align=''><param name=movie value='niftyplayer.swf?file="+sentAudioFileNameRoot+".mp3"+"&as=0'><param name=quality value=high><param name=bgcolor value=#FFFFFF><embed src='niftyplayer.swf?file="+sentAudioFileNameRoot+".mp3"+"&as=0' quality=high bgcolor=#FFFFFF width='165' height='37' name='niftyPlayer2' align='' type=    'application/x-shockwave-flash' swLiveConnect='true' pluginspage='http://www.macromedia.com/go/getflashplayer'></embed></object>";
		}				
		document.getElementById('audioplayerdiv').innerHTML = audioPlayerCode;
}




function AudioPlayer(sentAudioFileNameRoot){    
//window.status = window.status + '-1326'
	  //-- a blank file name means remove ---
			if(sentAudioFileNameRoot == ''){
					document.getElementById('languagebuttondiv').innerHTML = '';
					document.getElementById('audioplayerdiv').innerHTML = '';			
					
			}else{
					if(globalAudioPlaying == false){			
							if (globalAudioState == 'on'){
									globalAudioPlaying = true;
									checkForEndOfAudioTimerID = setInterval("CheckForEndOfAudio()",100);
									globalLastAudioFileRoot = sentAudioFileNameRoot;
									if(globalLanguage == 'spanish'){
											sentAudioFileNameRoot = sentAudioFileNameRoot + 'span';					
											var flagType = 'english';
											globalLastAudioWithLanguageFileRoot = sentAudioFileNameRoot + 'eng';
									}else{
											var flagType = 'spanish';
											globalLastAudioWithLanguageFileRoot = sentAudioFileNameRoot + 'span';
									}			
									if ((sentAudioFileNameRoot =='')||(globalAudioState == 'off')){
											document.getElementById('audioplayerdiv').innerHTML = '';
											document.getElementById('languagebuttondiv').innerHTML = '';
									}else{
												if(audioTagSupport == true){
															var audioPlayerCode = "<audio id='audioplayer' autoplay autobuffer preload controls><source src='"+sentAudioFileNameRoot+".ogg"+"'/><source src='"+sentAudioFileNameRoot+".mp3"+"'/></audio>";
												}else{
															var audioPlayerCode = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0'width='165' height='37' id='niftyPlayer1' align=''><param name=movie value='niftyplayer.swf?file="+sentAudioFileNameRoot+".mp3"+"&as=1'><param name=quality value=high><param name=bgcolor value=#FFFFFF><embed src='niftyplayer.swf?file="+sentAudioFileNameRoot+".mp3"+"&as=1' quality=high bgcolor=#FFFFFF width='165' height='37' name='niftyPlayer1' align=''type='application/x-shockwave-flash' swLiveConnect='true' pluginspage='http://www.macromedia.com/go/getflashplayer'></embed></object></audio><audio autobuffer preload><source src='"+sentAudioFileNameRoot+".ogg"+"'/><source src='"+sentAudioFileNameRoot+".mp3"+"'/><object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0' width='0'height='0' id='niftyPlayer2' align=''><param name=movie value='niftyplayer.swf?file="+sentAudioFileNameRoot+".mp3"+"&as=0'><param name=quality value=high><param name=bgcolor value=#FFFFFF><embed src='niftyplayer.swf?file="+sentAudioFileNameRoot+".mp3"+"&as=0' quality=high bgcolor=#FFFFFF width='165' height='37' name='niftyPlayer2' align='' type=    'application/x-shockwave-flash' swLiveConnect='true' pluginspage='http://www.macromedia.com/go/getflashplayer'></embed></object>";
												}						
												document.getElementById('languagebuttondiv').innerHTML = MakeLanguageFlagCode(flagType);
												document.getElementById('audioplayerdiv').innerHTML = audioPlayerCode;						
												
												if(globalAutoNext == true){
													StartAutoAdvanceTimerTimerID = setInterval("StartAutoAdvanceTimerAfterNewAudioStarts()",300);
												}
											//document.getElementById('audioplayerdiv').innerHTML = "<img src='fakeaudioplayer.png'>";
									}
									PreLoadMediaItem('audio',sentAudioFileNameRoot);
							}
					}
			}
}


function PreLoadMediaItem(imageOrAudio,sentFileName){
	//window.status = window.status + '-1384'
	 if ((sentFileName != '')&&(sentFileName != null)){
				//------ we do the incrementing (+1) here.  We preload what should be the NEXT image or audio -----
				// -- Note: Audio doesn't come with an extension ---
				var fileExt = sentFileName.substr((sentFileName.length-4));
			 if ((fileExt == '.swf')||(fileExt == '.png')||(fileExt == '.jpg')){
					  nextFileName = sentFileName.substr(0,sentFileName.length-4);
				}else{
				 	nextFileName = sentFileName;
						fileExt = '';
				}
				nextFileNameRoot = nextFileName.substr(0,nextFileName.length-4);
				cNextFileNameFrame = nextFileName.substr(nextFileName.length-4);
    nNextFileNameFrame = parseInt(cNextFileNameFrame);
				nNextFileNameFrame = nNextFileNameFrame + 1;
				cNextFileNameFrame = PadLeftZeros(nNextFileNameFrame, 4);
				nextFileName = nextFileNameRoot + cNextFileNameFrame + fileExt;

				switch (imageOrAudio){
						case 'image':
									var fileExt = nextFileName.substr((nextFileName.length-3));
								
									switch (fileExt){
											case 'swf':
													var pngImageFileName = nextFileName.replace('.swf','.png'); 
													 document.getElementById('imagepreloaddiv').innerHTML = ''; //"<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'    width='0' height='0'><param name='movie' value='" + nextFileName + "'/><object type='application/x-shockwave-flash' data='" + nextFileName + "' width='0' height='0'><img src='" + pngImageFileName + "' width='0' height='0'/></object></object>";																
																	
													break;			
										case 'png':
												document.getElementById('imagepreloaddiv').innerHTML = ''; //"<img src='" + nextFileName + "' width='0' height='0'/>";
												break;
										case 'jpg':
												document.getElementById('imagepreloaddiv').innerHTML = ''; //"<img src='" + nextFileName + "' width='0' height='0'/>";
												break;		
								}						
								break;
								
						case 'audio':
						//  alert(nextFileName)
					   if(globalAudioState == 'on'){	
										if(audioTagSupport == true){											
													var audioPlayerCode = "<audio id='audioplayerpreload' autobuffer preload controls><source src='"+nextFileName+".ogg"+"'/><source src='"+nextFileName+".mp3"+"'/></audio>";
										}else{									  													
													var audioPlayerCode = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0'width='165' height='37' id='niftyPlayer1preload' align=''><param name=movie value='niftyplayer.swf?file="+nextFileName+".mp3"+"><param name=quality value=high><param name=bgcolor value=#FFFFFF><embed src='niftyplayer.swf?file="+nextFileName+".mp3"+" quality=high bgcolor=#FFFFFF width='165' height='37' name='niftyPlayer1preload' align=''type='application/x-shockwave-flash' swLiveConnect='true' pluginspage='http://www.macromedia.com/go/getflashplayer'></embed></object></audio><audio autobuffer preload><source src='"+nextFileName+".ogg"+"'/><source src='"+nextFileName+".mp3"+"'/><object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0' width='0'height='0' id='niftyPlayer2preload' align=''><param name=movie value='niftyplayer.swf?file="+nextFileName+".mp3"+"&as=0'><param name=quality value=high><param name=bgcolor value=#FFFFFF><embed src='niftyplayer.swf?file="+nextFileName+".mp3"+"&as=0' quality=high bgcolor=#FFFFFF width='165' height='37' name='niftyPlayer2preload' align='' type=    'application/x-shockwave-flash' swLiveConnect='true' pluginspage='http://www.macromedia.com/go/getflashplayer'></embed></object>";
										}
										document.getElementById('audiopreloaddiv').innerHTML = ''; //audioPlayerCode;	
								}
								break;
				}
		}
}

function PadLeftZeros(number, length) {   
//window.status = window.status + '-1437'
    var str = '' + number;
    while (str.length < length) {
        str = '0' + str;
    }   
    return str;
}


function PlayHTMLOrFlashAudio(){
	//window.status = window.status + '-1447'
	  if (audioTagSupport == true){
				 //-- play html audio --				
	    var audioPlayer = document.getElementById('audioplayer');
			  audioPlayer.play();
			}else{				 
				  //-- play flash audio ---
						javascript:niftyplayer('niftyPlayer1').play();
			}
			PreLoadMediaItem();
}

function PauseHTMLOrFlashAudio(){
	//window.status = window.status + '-1460'
	  if (audioTagSupport == true){
				 //-- play html audio --
	    var audioPlayer = document.getElementById('audioplayer');
		   audioPlayer.pause();
				//audioPlayer.stop();
			}else{
				  //-- play flash audio ---
						javascript:niftyplayer('niftyPlayer1').pause();
			}			
}

function DeleteOrStopAudioObject(){
	//window.status = window.status + '-1473'
  if(audioTagSupport == true){
			  var audioPlayer = document.getElementById('audioplayer');
			  delete audioPlayer;
					document.getElementById('audioplayerdiv').innerHTML = ''; 
		}else{
			  //-- this isn't a problem for the flash audio! --
			  javascript:niftyplayer('niftyPlayer1').stop();
		}
}

function SWFImage(sentFileName, sentHeight, sentWidth){
	//window.status = window.status + '-1485'
	 //alert('entering swfimage')
	 //-- blank means remove ---		
		var fileExt = sentFileName.substr((sentFileName.length-3));
		switch (fileExt){
				case 'swf':
				  // -- a swf was sent ---
				  var pngImageFileName = sentFileName.replace('.swf','.png'); //in case flash isn't working (we presume the png exists) --
						//document.getElementById('mainimagediv').innerHTML = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' name='wmode' value='opaque' height='" + sentHeight + "'><param name='movie' value='" + sentFileName + "' name='wmode' value='opaque'/><object type='application/x-shockwave-flash' data='" + sentFileName + "' width='" + sentWidth + "' height='" + sentHeight + "'><img src='" + pngImageFileName + "' width='" + sentWidth + "' height='" + sentHeight + "'/></object></object>";
					document.getElementById('mainimagediv').innerHTML = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' name='wmode' value='opaque' width='" + sentWidth + "' height='" + sentHeight + "'><param name='movie' value='" + sentFileName + "' name='wmode' value='opaque'/><object type='application/x-shockwave-flash' data='" + sentFileName + "' width='" + sentWidth + "' height='" + sentHeight + "'><img src='" + pngImageFileName + "' width='" + sentWidth + "' height='" + sentHeight + "'/></object></object>";						
      break;			
		  case 'png':
			   //-- this is a png (the swf must not have been available )------
				  document.getElementById('mainimagediv').innerHTML = "<img src='" + sentFileName + "' width='" + sentWidth + "' height='" + sentHeight + "'/>";
						break;
		  case 'jpg':
			   //-- this is a jpg (using a possible sketch as a last resort)------
				  document.getElementById('mainimagediv').innerHTML = "<img src='" + sentFileName + "' width='" + sentWidth + "' height='" + sentHeight + "'/>";
						break;
				default:
				  //-- no kind of image jack --
						document.getElementById('mainimagediv').innerHTML = '';					
		}
		PreLoadMediaItem('image',sentFileName);
}


			
function StartAutoAdvanceTimerAfterNewAudioStarts(){
	//window.status = window.status + '-1514'
		 if(globalAutoNext == true){
				if(document.getElementById('audioplayerdiv').innerHTML != ''){
							if(audioTagSupport == true){
										var oAudioPlayer = document.getElementById('audioplayer');
										if (oAudioPlayer.currentTime > 0){
													//-- audio player has begun ---
													clearInterval(StartAutoAdvanceTimerTimerID);
													takeActionTimerID = setInterval("TakeActionWhenAudioEnds('advancenext')",200); //polls the player state
										}				
							}else{
										//----eg, audioTagSupport = false ----
										if(niftyplayer("niftyPlayer1").getState() == 'playing') {
												// -- nifty is playing ---
													clearInterval(StartAutoAdvanceTimerTimerID);
													takeActionTimerID = setInterval("TakeActionWhenAudioEnds('advancenext')",200); //polls the player state
										}
							}
				}  																			
		}else{			 
			 clearInterval(StartAutoAdvanceTimerTimerID);
		}
}

function FailSafeTimeOut(){
	//window.status = window.status + '-1539'
			try{
					clearInterval(failSafeTimerID);
			}
			catch(e){
						var x = 8; //for ie				
			}	
}

function ClickedPrevious(){
	//window.status = window.status + '-1549'
	 if(globalPreviousNextTimerOperating == false){
			 globalPreviousNextTimerOperating = true; 
	   DeleteOrStopAudioObject(); 
		  timedPreviousTimerID = setInterval("TimeOutPrevious()",500);
				failSafeTimerID = setInterval("FailSafeTimeOut()",1500);
		}
}
function ClickedNext(){
	//window.status = window.status + '-1558'
	 if(globalPreviousNextTimerOperating == false){ 
		  globalPreviousNextTimerOperating = true;
	   DeleteOrStopAudioObject();
		  timedNextTimerID = setInterval("TimeOutNext()",500);
		}else{
			  //alert('timer on jack')
		}
}

function TimeOutNext(){
	//window.status = window.status + '-1569'
	  //-- this is so the Next doesn't start immediately when clicked (or by AutoNext) ---
			// -- Doing so can load a bunch of audioPlayers on top of each other causing pandemonium! --			
			try{
					clearInterval(timedNextTimerID);
			}
			catch(e){
						var x = 8; //for ie				
			}					
		//	if(globalPreviousNextTimerOperating == false){		
					UpdateMainPage('next','','',0,0,0);					
					// globalPreviousNextTimerOperating = false //in update now 
		//}
}

function TimeOutPrevious(){
	//window.status = window.status + '-1585'
	  //-- this is so the Next doesn't start immediately when clicked (or by AutoNext) ---
			// -- Doing so can load a bunch of audioPlayers on top of each other causing pandemonium! --
			try{
					clearInterval(timedPreviousTimerID);
			}
			catch(e){
						var x = 8; //for ie				
			}									
		//	if(globalPreviousNextTimerOperating == false){					
					UpdateMainPage('previous','','',0,0,0);				
					// globalPreviousNextTimerOperating = false //in update now;
		//	}
}

function MakeLanguageFlagCode(englishOrSpanish){
	//----- temp until you make spanish for all the special commands (just a few) and go through the text --
	//window.status = window.status + '-1602'
	return "<img id='flagimage' src='images/emptyColorBar.png'/>"; 
	 switch (englishOrSpanish){
			  case 'english':
	      return "<img id='flagimage' src='images/americanColorBar.png'/>";
       break;
			  case 'spanish':
	      return "<img id='flagimage' src='images/mexicanColorBar.png'/>";
       break;				
		}
}

function ChangeLanguages(){
	return; /// THIS WORKS FINE --BUT IT'LL MUCK THINGS UP IF A FILE ISN'T FOUND--SO KEEP IT ALL ENGLISH UNTIL YOU HAVE TIME
	//window.status = window.status + '-1616'
	//---  ALSO SEE MAKELANGUAGEFLAGCODE FUNCTION (ABOVE) WHICH HAS BEEN TEMPORARILY ANNULED --
  if(globalLanguage == 'english'){
			  globalLanguage = 'spanish';
					document.getElementById('languagebuttondiv').innerHTML = MakeLanguageFlagCode('english');					
		}else{
			  // -- it must be spanish --
					globalLanguage = 'english';
					document.getElementById('languagebuttondiv').innerHTML = MakeLanguageFlagCode('spanish');						
		}
		
		if (globalTextState == 'on'){ 
		  if(globalLanguage == 'english'){
		    document.getElementById('maintextdiv').innerHTML = globalMainTextHTML;			
				}else{
					 document.getElementById('maintextdiv').innerHTML = globalMainSpanTextHTML;		
				}
				SizeImageAndCenterMainDiv();
		}
		if (globalAudioState == 'on'){ 
		  ReloadAudio(globalLastAudioFileRoot);
		}

}

function ReloadAudio(sentFileName){
	//window.status = window.status + '-1642'
	 if(globalPreviousNextTimerOperating == false){ 
				try{
						clearInterval(takeActionTimerID);
				}
				catch(e){
							var x = 8; //for ie				
				}	
				if(globalAutoNext == true){
						globalAutoNext = false;
						SetAutoNextStyle();											
				}		
		  globalPreviousNextTimerOperating = true;
	   DeleteOrStopAudioObject();
		  timedReloadAudioTimerID = setInterval("TimeOutReloadAudio('"+sentFileName+"')",500);

		}
}

function TimeOutReloadAudio(sentFileName){
	//window.status = window.status + '-1662'
	  //-- this is so reload audio (ie, as used now, when changing languages) doesn't start immediately when clicked (or by AutoNext)
			// -- Doing so can load a bunch of audioPlayers on top of each other causing pandemonium! --			
			try{
					clearInterval(timedReloadAudioTimerID);
			}
			catch(e){
						var x = 8; //for ie				
			}					
		//	if(globalPreviousNextTimerOperating == false){
	
					AudioPlayer(sentFileName);
					globalPreviousNextTimerOperating = false; //this never goes through Update
		//}
}


function SetAutoNextStyle(){
	//window.status = window.status + '-1680'
	  oStartStopLabel = document.getElementById('startstopautolabel');
			oStartStopLabel.innerHTML = "Auto-Next";
			 if(globalAutoNext == true){
					  oStartStopLabel.style.color = 'white';
							oStartStopLabel.style.backgroundColor = 'red';
						//	document.getElementById('nextbutton').disabled = true;
							//	oStartStopLabel.style.textDecoration = 'blink';
				}else{
						oStartStopLabel.style.color = 'inherit';
						oStartStopLabel.style.backgroundColor = 'transparent';							
					// document.getElementById('nextbutton').disabled = false;
						//oStartStopLabel.style.textDecoration = 'none';
				}			
}

function StartStopAutoAdvance(){	  
//window.status = window.status + '-1697'
	  if(globalAutoNext == false){
				  // -- start auto advance --
					//	PlayHTMLOrFlashAudio();
				  globalAutoNext = true;
						takeActionTimerID = setInterval("TakeActionWhenAudioEnds('advancenext')",300);												
			}else{
				  // -- stop auto advance --
				  globalAutoNext = false;
						try{
								clearInterval(takeActionTimerID);
						}
						catch(e){
									var x = 8; //for ie				
						}							
						//PauseHTMLOrFlashAudio();
			}	
			SetAutoNextStyle();
}
     

function wtp(sentAssNum){	
//window.status = window.status + '-1719'
  //-- Practice Problems ----
		//-- EXCEPT FOR THE NOTICE OF NOT SIGNING IN, THIS IS IDENTICAL TO WTI (Working Teacher InteractivE) BELOW --
		//alert('wti=' + document.getElementById('i').value)
		globalVideoName = '';
			if(document.getElementById('i').value == ''){
				  // -- the user has to first be logged in to start a new help session ---
						UpdateMainPage('newpracprobsnotsignedin', '', '', sentAssNum,0,0);	
			}else{
     UpdateMainPage('newhelp', '', '', sentAssNum,0,0);
			}
}

function wti(sentAssNum){	
//window.status = window.status + '-1733'
  //-- Working Teacher Interactive --
		//alert('wti=' + document.getElementById('i').value)
		globalVideoName = '';
			if(document.getElementById('i').value == ''){
				  // -- the user has to first be logged in to start a new help session ---
						UpdateMainPage('newhelpnotsignedin', '', '', sentAssNum,0,0);	
			}else{
     UpdateMainPage('newhelp', '', '', sentAssNum,0,0);
			}
}
			
/*
	if($loadOK == true){
			// -- all this ajax is to see if the student is currently working on something (eg, frame > 0) ---
			var mygetrequest=new ajaxRequest();
			mygetrequest.onreadystatechange=function(){
				if (mygetrequest.readyState==4){
					if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
							//--- Here is where all the info comes back at -------
							var currentFrame = mygetrequest.responseText;
							if(currentFrame > 1){
									//-- the student is on frame 2 or higher ---
								//	var answer = confirm ("You are currently working in a help session.  Starting a new one will erase the one you are working on now.  Do you want to start a new help session?") 
							//		if (answer){
											// -- stu OK'd so go ahead ---
											UpdateMainPage('newhelp', '', '', sentAssNum,0,0);	
								//	}
							}else{
									// -- the student is on frame 0 or 1 ---
									UpdateMainPage('newhelp', '', '', sentAssNum,0,0);	
							}
								//----- above is where all the info came back at ---
					}//if (mygetrequest.status==200
				}//if (mygetrequest.readyState==4){
			}//mygetrequest.onreadystatechange=function()
			var stuID = document.getElementById('i').value;
			mygetrequest.open("GET", "GetStudentsFrame.php?i="+stuID, true);
			mygetrequest.send(null);									
		}	
		*/



function wtv(sentVideoName){
	//window.status = window.status + '-1788'
	 //-- replaces whatever is being shown with the video ----		
		//-- Note: video names are text names (usually with underscores for spaces) that are custom made, not derived from assname or assid --
	//	sentVideoName = "video/big_buck_bunny";
 //--- add the video directory name ----
	sentVideoName = 'video/' + sentVideoName;
	// -- strip off an FLV extension if it's on there --
	 sentVideoName = sentVideoName.replace('.flv','');
		sentVideoName = sentVideoName.replace('.FLV','');
		// -- strip off an MP4 extension if it's on there --
	 sentVideoName = sentVideoName.replace('.mp4','');
		sentVideoName = sentVideoName.replace('.MP4','');		
		// -- strip off an avi extension if it's on there --
	 sentVideoName = sentVideoName.replace('.avi','');
		sentVideoName = sentVideoName.replace('.AVI','');				
				
		globalVideoName = sentVideoName;
		
  var displayedVideoName = sentVideoName.replace('video/',''); //the video directory name
	//	var displayedVideoName = displayedVideoName.replace(/_/g,' '); // the g is for 'global" in a regular expression
  var topPart ="<div id='sep_specialtop'></div>	<div id='sep_topalert'></div>	<div id='mainalertdivwrapper'><div id='mainalertdiv'></div></div><div id='sep_alerttext'></div><div id='maintextdivwrapper'><div id='maintextdiv'>" + displayedVideoName + "</div></div><div id='sep_textimage'></div>		<div id='mainimagediv'>";

		if(videoTagSupport == true){		
		  //-- html 5 video supported ---
		  var middlePart = "<video id='mainvideo' width='640' height='480' controls preload='none'><source src='"+sentVideoName+".MP4' type='video/mp4' /><source src='"+sentVideoName+".OGV' type='video/ogg' /></video></div>";
		}else{
			  // -- no html 5 video so use flash ------			
				var middlePart ="<div id='flashvideodiv'><object id='player' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' name='player' width='100%' height='100%'><param name='movie' value='player.swf' /><param name='allowfullscreen' value='true' /><param name='allowscriptaccess' value='always' /><param name='flashvars' value='file="+sentVideoName+".flv&image=workingTeacherVideo.png' /><embed type='application/x-shockwave-flash' id='player2' name='player2' src='player.swf' width='100%' height='100%' allowscriptaccess='always'  allowfullscreen='true' flashvars='file="+sentVideoName+".flv&image=workingTeacherVideo.png' /></object></div></div>";
		}		
		var bottomPart = "<div id='sep_imageaudio'></div>		<div id='audiodiv'><div id='clickproblemdiv'></div><div id='audioplayerdiv'></div>	<div id='responsetextdiv'></div></div>		<div id='sep_responsebutton'></div>		<div id='mainbuttondiv'></div>  <div id='sep_specialbottom'></div>";
						
		document.getElementById('mainrightdiv2').innerHTML = topPart + middlePart + bottomPart;
		
		document.getElementById('mainimagediv').style.visibility = 'visible';

	 SizeImageAndCenterMainDiv();
}


function DeleteHelp(){	  
//window.status = window.status + '-1818'
	// 	var answer = confirm ("This will delete your current help session.  If you were planning on coming back and working on it later, you should click 'Sign-Out.'  Do you want to delete your current help session?") ;
	//	if (answer){
				// -- stu OK'd so go ahead ---
			if(globalDocsForBrowseHelp == true){
			  globalDocsForBrowseHelp = false;
					LoadBrowseHelpContents(-1,'student')
			}
			UpdateMainPage('deletehelp','','',0,0,0);	
	//	}	  	
}



function LoadBrowseHelpContents(sentBrowseType,studentOrTeacher){	
//window.status = window.status + '-1833'
  // -- this calls the PHP/msql page that returns an array of all the help in all available courses ---
  //--- 2 kinds of help are available: 1) Google searches for youtube videos, 2) Higgins help (interactive and pure comic book)
  //--- If the array has already been filled by a previous call, all we have to do is repopulate the help list from the array,
  //--- If not, then we do call the PHP page first and when it's returned, then populate the help list.  
	//	alert(sentBrowseType + '    ' + studentOrTeacher)
	 globalDocsForBrowseHelp = false;
		if (studentOrTeacher == 'u'){
			  //--- this part remains unchanged (eg, a click on one of the assignments under a course) --
		}else{
				if (studentOrTeacher == 'teacher'){
						document.getElementById('helpselectordiv').innerHTML = "<a onClick='LoadRosterContents()'><b>Available Help</b></a>";	 
				}else{
						document.getElementById('helpselectordiv').innerHTML = "<a onClick='LoadBrowseHelpContents(-1)'><b>Available Help</b></a>";
				}
		}

		if(globalBrowseArray.length == 0){
			 globalWaitingForBrowseHelpToLoad = true;
				var mygetrequest=new ajaxRequest();
				mygetrequest.onreadystatechange=function(){
				if (mygetrequest.readyState==4){
				if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
								//--- Here is where all the info comes back at -------
							
								var htmlContents = "<ul id='browsehelplist'>";					
								var fullString = mygetrequest.responseText;				
								globalBrowseArray = fullString.split('@@@@');
								for(var i=0; i< globalBrowseArray.length; i++){
										if(globalBrowseArray[i].indexOf("course=-1") > -1){
												htmlContents = htmlContents + globalBrowseArray[i];
										}
								}
							//	if (studentOrTeacher == 'teacher'){
									  //// -- TEMP while student help isn't available ---
								  htmlContents = htmlContents + "<ul id='browsehelplist'>";
								  document.getElementById('browseproblemdiv').innerHTML = htmlContents;					
										document.getElementById('browseproblemdiv').style.overflow = 'auto';
							//	}
						 	var empiricalFuckFudge = 20; //because I don't have time to fuck wit it
								globalBrowseHelpDivWidth = document.getElementById('browseproblemdiv').offsetWidth - empiricalFuckFudge;

								globalWaitingForBrowseHelpToLoad = false;
							}//if (mygetrequest.status==200
					}//if (mygetrequest.readyState==4){
			}//mygetrequest.onreadystatechange=function()		
			mygetrequest.open("GET", "GetBrowseHelpContents.php"+"?&qwert="+new Date().getTime(), true);
			mygetrequest.send(null);		
		 }else{ 
			// alert('else ' + globalBrowseArray.length + '   ' + sentBrowseType + '  ' + globalLastBrowseType)
			  // -- the browse array has already been initialized (eg, GetBrowseHelpContents.php has been called ---
					//-- so we can just use the javascript array previously made ----------------																																																					
					globalWaitingForBrowseHelpToLoad = true;
					var htmlContents = "<ul id='browsehelplist'>";	
					
					if (sentBrowseType == -1){	// -1 is code for a course title			
							for(var i=0; i< globalBrowseArray.length; i++){
									if(globalBrowseArray[i].indexOf("course=-1") > -1) {
											htmlContents = htmlContents + globalBrowseArray[i];
									}
							}
					}else{
						
								if(sentBrowseType == globalLastBrowseType){
									 //--- clicked on the last clicked course: show the full contents (same as above) ------
          globalLastBrowseType = -99;
						  //-- it must be a request for one of the courses ---		
										for(var i=0; i< globalBrowseArray.length; i++){
												if(globalBrowseArray[i].indexOf("course=-1") > -1) {
														htmlContents = htmlContents + globalBrowseArray[i];
												}
										}
								}else{
									 //-- clicked on a new or differnet course ---------
										globalLastBrowseType = sentBrowseType;
										var searchPhrase1 = "course=" + PadLeft(sentBrowseType,'0',4);
										var searchPhrase2 = "thiscourse=" + PadLeft(sentBrowseType,'0',4);				
										for(var i=0; i< globalBrowseArray.length; i++){									
												if((globalBrowseArray[i].indexOf(searchPhrase1) > -1)||(globalBrowseArray[i].indexOf(searchPhrase2) > -1)){
														htmlContents = htmlContents + globalBrowseArray[i];
												}
									}										
								}
					}
					htmlContents = htmlContents + "<ul id='browsehelplist'>";
					//if (studentOrTeacher == 'teacher'){
							//// -- TEMP while student help isn't available ---					
					  document.getElementById('browseproblemdiv').innerHTML = htmlContents;
							document.getElementById('browseproblemdiv').style.overflow = 'auto';
				//	}				
					//globalBrowseHelpDivWidth = document.getElementById('browseproblemdiv').offsetWidth;			

					globalWaitingForBrowseHelpToLoad = false;					
			}
   
			newMainDivHeight = document.getElementById('maindiv').offsetHeight;
   var oHelpSelectorDiv = document.getElementById('helpselectordiv');
					 
		 var newHelpHeight = newMainDivHeight - oHelpSelectorDiv.offsetHeight;			
			try{ //for IE8
     var oBrowseProblemDiv = document.getElementById('browseproblemdiv');
					oBrowseProblemDiv.style.height = newHelpHeight + 'px';
			}
			catch(e){
					var x=9; //for ie					
			}
			
		  
}//sentBrowseType

function PadLeft(val, ch, num) {
	//window.status = window.status + '-1943'
	  // val is the expression, ch is the padding character, and num is the resultant size --
				var re = new RegExp(".{" + num + "}$");
				var pad = "";
				if (!ch) ch = " ";
				do  {
								pad += ch;
				}while(pad.length < num);
				return re.exec(pad + val)[0];
}

function ReplaceSpacesWithNonBreakingSpaces(sentString){
	 var returnString = sentString.replace(' ','&nbsp;'); 
		return returnString;
}

function ClickedRosterRadio(teacherID,sentClassName,selectedButton,studentID,scope){
	//window.status = window.status + '-1955'
	 //-- Reload the roster based on the radio button selected. 0 means all ---
		var classNum = GetRosterRadioNumber();
		if(sentClassName == 'all'){
			 //-- an aesthetic tweak --
				sentClassName = "All classes";
		}
  globalRosterClassName = ReplaceSpacesWithNonBreakingSpaces(sentClassName);
  LoadRosterClassName(); //uses globalRosterClassName			
		// -- This is a nested ajax request for redoing the roster --						
//		alert(teacherID + '  ' + sentClassName + '   ' + classNum)
		var mygetrequest2=new ajaxRequest();
			mygetrequest2.onreadystatechange=function(){
			if (mygetrequest2.readyState==4){
					if (mygetrequest2.status==200 || window.location.href.indexOf("http")==-1){
							//--- Here is where all the info comes back which ain't nothing in this case-------	
					// alert (mygetrequest2.responseText); 
								var globalRosterContents = mygetrequest2.responseText;																	
								LoadRosterContents(globalRosterContents);
								SizeImageAndCenterMainDivDetail();
								
								if(studentID > 0){
										//-- this was called by ClickRosterNameFromOutsideList which wants the student's name to now be selected in the roster list --
										//--- find and select the option that contains this stuid ------
										//ClickRosterNameFromOutsideList(429,-23,'')
										//alert('tid = ' + teacherID  + ' stuid = ' + studentID)
										var oRosterSelect = document.getElementById('rosterselect');
										for (var i=0; i<oRosterSelect.length; i++){
												var optionStuID = oRosterSelect.options[i].getAttribute('stuid');
												if(optionStuID == studentID){		
															oRosterSelect.options[i].selected = true;
															break;
												}
										}
										ClickRosterNameOrContract(studentID,'roster',teacherID,scope);
										SetFocusToCurrentRosterName();								
								}								
					}//if (mygetrequest2.status==200
			}//if (mygetrequest2.readyState==4){
		}//mygetrequest2.onreadystatechange=function()		

		mygetrequest2.open("GET", "GetRosterContents.php"+"?i="+teacherID+"&gs="+globalSessionID+'&cn='+classNum+"&qwert="+new Date().getTime(), true);
		mygetrequest2.send(null);									
}


function ClickedNewStuRadio(teacherID,sentClassName){
	//window.status = window.status + '- into '
	 //-- just replaces the visible name of the class ----
		document.getElementById('newstuclassname').innerHTML = sentClassName; 
		var classNum = GetTodayRadioNumber();									
}

function ClickedTodayRadio(teacherID,sentClassName){
	//window.status = window.status + '-1990'
	 //-- Reload the roster based on the radio button selected. 0 means all ---
		var classNum = GetTodayRadioNumber();		
		// -- This is a nested ajax request for redoing the roster --						
		var mygetrequest2=new ajaxRequest();
			mygetrequest2.onreadystatechange=function(){
			if (mygetrequest2.readyState==4){
					if (mygetrequest2.status==200 || window.location.href.indexOf("http")==-1){
							//--- Here is where all the info comes back which ain't nothing in this case-------	
							//alert (mygetrequest.responseText);
							var signInListHTML = mygetrequest2.responseText;				
							globalTopBlurb = '';
							document.getElementById('mainalertdiv').innerHTML = globalTopBlurb;							
							document.getElementById('fullpagedatadiv').style.visibility = 'hidden';	
							document.getElementById('fullpagedatadiv').style.top = '-1000px';
       document.getElementById('fullpagedatadiv').innerHTML = signInListHTML;							
	      SizeImageAndCenterMainDivDetail();																
					}//if (mygetrequest2.status==200
			}//if (mygetrequest2.readyState==4){
		}//mygetrequest2.onreadystatechange=function()		
		var urlString = "GetTodaysAttendees.php?i="+teacherID+"&gs="+globalSessionID+'&cn='+classNum+"&qwert="+new Date().getTime();
//		alert(urlString)
		mygetrequest2.open("GET", urlString , true);
		mygetrequest2.send(null);									
}

function ClickedTodaysAttendance(teacherID){
	//window.status = window.status + '-2017'
	  globalDocsForBrowseHelp = false;
 	//--- fills in teacher data with a list of students who signed in today  ---
	//	if(globalLoadingMenuItem == false){
			 HighlightMenuText('today');
			 globalLoadingMenuItem = true;
				var mygetrequest=new ajaxRequest();
				mygetrequest.onreadystatechange=function(){
				if (mygetrequest.readyState==4){
						if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
								//--- Here is where all the info comes back which ain't nothing in this case-------	
									//alert (mygetrequest.responseText); 
									//window.status = "ClickedTodaysAttendance loaded  ";
									var signInListHTML = mygetrequest.responseText;				
									globalTopBlurb = '';
									document.getElementById('mainalertdiv').innerHTML = globalTopBlurb;							
									document.getElementById('fullpagedatadiv').style.visibility = 'hidden';	
									document.getElementById('fullpagedatadiv').style.top = '-1000px';
									document.getElementById('fullpagedatadiv').innerHTML = signInListHTML;			
									document.getElementById('verticalmenudiv').innerHTML = '';
									SizeImageAndCenterMainDivDetail();				
									globalLoadingMenuItem = false;
						}//if (mygetrequest.status==200
				}//if (mygetrequest.readyState==4){
			}//mygetrequest.onreadystatechange=function()		
			mygetrequest.open("GET", "GetTodaysAttendees.php?i="+teacherID+"&gs="+globalSessionID+"&cn=0"+"&qwert="+new Date().getTime(), true);
			mygetrequest.send(null);	
	// }
}

function GetTodayRadioNumber(){	 
//window.status = window.status + '-2047'
		objectArray = document.getElementsByName('todayRadioGroup');
		var radioValue = 0;  //default 'all'classes --may be changed below
  for (var i = 0; i <objectArray.length; i++) {
			 if(objectArray[i]){
						if (objectArray[i].checked == true){
         radioValue = objectArray[i].value;
									break;
							}//if					
				}
   }//for  	
			return radioValue;				
}

function GetWeekRadioNumber(){	
//window.status = window.status + '-2047'
		objectArray = document.getElementsByName('weekRadioGroup');
		var radioValue = 0;  //default 'all'classes --may be changed below
  for (var i = 0; i <objectArray.length; i++) {
			 if(objectArray[i]){
						if (objectArray[i].checked == true){
         radioValue = objectArray[i].value;
									break;
							}//if					
				}
   }//for  	
			return radioValue;				
}

function GetRosterRadioNumber(){	 
//window.status = window.status + '-2077'
		objectArray = document.getElementsByName('rosterRadioGroup');
		var radioValue = 70;  //default 'all' --may be changed below
  for (var i = 0; i <objectArray.length; i++) {
			 if(objectArray[i]){
						if (objectArray[i].checked == true){
         radioValue = objectArray[i].value;
									break;
							}//if					
				}
   }//for  	
			return radioValue;				
}

function ShowBrowseHelpContents(){
	//window.status = window.status + '-2092'
 //--- 2 kinds of help are available: 1) Google searches for youtube videos, 2) Higgins help (interactive and pure comic book) --
							alert('showBrowse...');
  globalWaitingForBrowseHelpToLoad = false; //legacy?
		radioValue = GetRadioValue('youtubehigginsradio',2);
		switch(radioValue){
    case 'higgins':				  
				  document.getElementById('browseproblemdiv').innerHTML = document.getElementById('browsehelphiggins').innerHTML;
						document.getElementById('browseproblemdiv').style.overflow = 'auto';
						globalLastHigginsYouTubeRadioValue = 'higgins';
			   break;	
				case 'youtube':				 
			 	document.getElementById('browseproblemdiv').innerHTML = document.getElementById('browsehelpyoutube').innerHTML;
					document.getElementById('browseproblemdiv').style.overflow = 'auto';
					globalLastHigginsYouTubeRadioValue = 'youtube';
     break;
		}
}



function testme(){
	//window.status = window.status + '-2112'
  StartStopAutoAdvance();
}
function testme1(){;
//window.status = window.status + '-2116'
	 globalAutoNext = false;
}

function ShowBrowseHelpBar(openCloseOrNone){
	 return; ///////////////////////////
		//window.status = window.status + '-2122'
	 switch(openCloseOrNone){
	    case 'open':
					  // -- browse help not seen.  Open browse help bar placed on the left ---
					  document.getElementById('openhelpbar').innerHTML = "<img src='/images/rightBarArrow.png'/>";
		     document.getElementById('closehelpbar').innerHTML = '';						
							break;
	    case 'close':
					  //-- browse help seen with a close bar on the right ---
					  document.getElementById('closehelpbar').innerHTML = "<img src='/images/leftBarArrow.png'/>";
		     document.getElementById('openhelpbar').innerHTML = '';		
							//-- shrink the browse help (since it now has a bar) to keep the whole main div the same width ---
							var reducedBrowseHelpDivWidth = globalBrowseHelpDivWidth - document.getElementById('openhelpbar').offsetWidth;
							document.getElementById('browsehelpdiv').width = reducedBrowseHelpDivWidth + 'px';							
							break;							
	    case 'none':
					  // -- no bars on eithe side.  Just the full browse help  -----
					  document.getElementById('browsehelpdiv').width = globalBrowseHelpDivWidth + 'px';
					  document.getElementById('closehelpbar').innerHTML = '';
		     document.getElementById('openhelpbar').innerHTML = '';		
							document.getElementById('browsehelpdiv').width = globalBrowseHelpDivWidth + 'px';	//in case it wasn't 
							break;												
	 }
}

function OpenBrowseHelp(closeBarStatus){
	  return; //////////////////////////////
			//window.status = window.status + '-2149'
	 switch(closeBarStatus){
			  case 'showclosebar':					
       ShowBrowseHelpBar('close');		
							break;
					case 'noclosebar':
					  ShowBrowseHelpBar('none');	
							break;
		}
		//workinghere --making the actual help section take up the whole space doesn't practically make the image
		//- any larger because it is limited by height.  So maybe you should reposition everything --but still
		//-- that doesn't give that much of an increase.  Maybe just leave it as it is and forget this idea.
}

function CloseBrowseHelp(){ 
  return; //////////////////////////////
		//window.status = window.status + '-2165'
		//--- empty out the browse help contents -----
		document.getElementById('browseproblemdiv').innerHTML = '';
		document.getElementById('browseproblemdiv').style.width = '0px'; //the div won't snap to 0 on its own even though css width:auto  
		document.getElementById('helpselectordiv').innerHTML = '';
		//-- Show the Open help bar on the far left ---	
		ShowBrowseHelpBar('open');					
		//-- fill up the whole space with the right side ----
			var mainDivW = document.getElementById('shadowmaindiv').offsetWidth;
			var openHelpBarW = document.getElementById('openhelpbar').offsetWidth;
			var availW = mainDivW - openHelpBarW;
			//-- have to set quite a few objects --
			document.getElementById('mainrightdiv').style.width = availW + 'px';
			document.getElementById('mainalertdiv').style.width = availW + 'px';
			document.getElementById('maintextdiv').style.width = availW + 'px';
}



function FireSizeAndCenter(whichOnes){
//window.status = window.status + '-2185'
	//	clearInterval(sizeAndPositionTimerID); //////////////////
		SizeImageAndCenterMainDivDetail(); ///////////////
	/*
	 switch(whichOnes){
			  case 'imageandhelp':
							try{
         var bogus = document.getElementById('mainimage').offsetHeight;
									//-- If you made it here, the image object has loaded ---
					    if (globalWaitingForBrowseHelpToLoad == false){
										 //-- And the help has also loaded ---
								   clearInterval(sizeAndPositionTimerID);
							    SizeImageAndCenterMainDivDetail();
							  }
							}
							catch(e){
								 //-- The image object has not loaded yet --									
									bogus = document.getElementById('i');//-- IE requires some meat in here ---								
							}						  
					  break;
			  case 'image':
							try{
         var actualNewImageH = document.getElementById('mainimage').offsetHeight;
									if(globalNewImageHeight == actualNewImageH){
									  clearInterval(sizeAndPositionTimerID);
									  SizeImageAndCenterMainDivDetail();
											globalOldImageHeight = globalNewImageHeight;
									}
							}
							catch(e){
								 //-- The image object has not loaded yet --									
									bogus = document.getElementById('i');//-- IE requires some meat in here ---								
							}											
					  break;			
			  case 'help':
					  if (globalWaitingForBrowseHelpToLoad == false){
								 clearInterval(sizeAndPositionTimerID);
							  SizeImageAndCenterMainDivDetail();
							}
					  break;							
		}
		*/
}

//<div id='sep_specialtop'></div>	<div id='sep_topalert'></div>	<div id='mainalertdivwrapper'><div id='mainalertdiv'></div></div><div id='sep_alerttext'></div>		<div id='maintextdivwrapper'><div id='maintextdiv'></div></div><div id='sep_textimage'></div>
//</div><div id='sep_imageaudio'><div id='audiodiv'><div id='audioplayerdiv'></div>	<div id='responsetextdiv'></div></div>		</div><div id='sep_responsebutton'></div><div id='mainbuttondiv'></div>  <div id='sep_specialbottom'></div>	 





function vidtest(){
	 //-- it will naturallly scale so just change one dimension-----
 // document.getElementById('maintextdiv').style.height = '0px';
//	document.getElementById('maintextdivwrapper').style.height = '0px';
  // myVideo.height = (myVideo.videoHeight / 2 ) ;
		//	myVideo.width = (myVideo.videoWidth / 2 ) ;
		//	myVideo.width = '100%'; //(myVideo.videoWidth / 2 ) ;
	
}

function vidtest1(){
	    //-- this works for pausing or playing (resuming) html 5 video ---
//window.status = window.status + '-2248'
        var myVideo = document.getElementsByTagName('video')[0];

         if (myVideo.paused){

            myVideo.play();

									}else{

            myVideo.pause();

       }
}

function ws(sentAssID){
	  //--links to a ws page --
	
}

function StartUpRightSideCode(){
//window.status = window.status + '-2268'
			document.getElementById('mainrightdiv1').innerHTML = '';
			document.getElementById('mainrightdiv2').innerHTML = "<div id='sep_specialtop'></div>	<div id='sep_topalert'></div><div id='mainalertdiv'></div><div id='sep_alerttext'></div><div id='maintextdivwrapper'><div id='maintextdiv'></div></div>		<div id='sep_textimage'></div>		<div id='mainimagediv'></div><div id='sep_imageaudio'></div>		<div id='audiodiv'><div id='clickproblemdiv'></div><div id='audioplayerdiv'></div>	<div id='responsetextdiv'></div></div><div id='sep_responsebutton'></div>		<div id='mainbuttondiv'></div>  <div id='sep_specialbottom'></div>";	 
}




function ClickedSeekProblem(sentAssignment, sentFrame){
	//window.status = window.status + '-2277'
	 if(globalPreviousNextTimerOperating == false){ 
		  globalPreviousNextTimerOperating = true;
	   DeleteOrStopAudioObject();
		  timedSeekProblemTimerID = setInterval("TimeOutSeekProblem("+ sentAssignment +","+ sentFrame +")",500);
				if(globalAutoNext == true){
						globalAutoNext = false;
						SetAutoNextStyle();											
				}						
		}
}

function TimeOutSeekProblem(sentAssignment, sentFrame){
	//window.status = window.status + '-2290'
	  //-- this is so the Next doesn't start immediately when clicked (or by AutoNext) ---
			// -- Doing so can load a bunch of audioPlayers on top of each other causing pandemonium! --			
			try{
					clearInterval(timedSeekProblemTimerID);
			}
			catch(e){
						var x = 8; //for ie				
			}					
		//	if(globalPreviousNextTimerOperating == false){	
		   UpdateMainPage('seekproblem','','',sentAssignment,sentFrame,0);
				//	globalPreviousNextTimerOperating = false; //do this in UPDATE! after the page comes back
		//}
}

function FlashResponseTextDiv(){
	//window.status = window.status + '-2036'
	 oDiv = document.getElementById('responsetext');
		if(oDiv.style.backgroundColor == 'white'){
		  oDiv.style.backgroundColor = 'rgb(255,255,150)'; //must match track.css
  }else{
		  oDiv.style.backgroundColor = 'white';
		}	
}



function TakeActionWhenAudioEnds(actionType){			 
		//-- a timer (takeActionTimerID)calls this function every 1/2 second or so.  As soon as a not-playing state is discovered, --
		//-- the Next button is automatically clicked for the user -----------------
		//window.status = window.status + '-2320'
		if(globalAudioState == 'on'){
				if((document.getElementById('audioplayerdiv').innerHTML != '')||(globalAudioState == 'off')){
							if(audioTagSupport == true){
										var oAudioPlayer = document.getElementById('audioplayer');
										if(oAudioPlayer.currentTime >= oAudioPlayer.duration){
													//-- audio player is at end of file ---
													clearInterval(takeActionTimerID);
													TakeActionWhenAudioEndsDetail(actionType);
										}else{
													//-- audio player is playing --
										}				
							}else{
										//----eg, audioTagSupport = false ----
										if(niftyplayer("niftyPlayer1").getState() == 'playing') {
												// -- nifty is playing ---											
										}else{
												//-- nifty is not playing ---
												clearInterval(takeActionTimerID);
												TakeActionWhenAudioEndsDetail(actionType);	
										}
							}
				}else{
					// -- no audio loaded or audio is turned off --
				}  		
		}
}

function TakeActionWhenAudioEndsDetail(actionType){
	//window.status = window.status + '-2349'
	  switch (actionType){
				  case 'advancenext':
						  if(globalAutoNext == true){
						    ClickedNext();
								}else{
									 clearInterval(takeActionTimerID);
								}
						  break;								
						case 'playmainaudio':		
						  // -- fires when there is prefix audio only ----
								AudioPlayer(globalAudioFileNameRoot);
								break;
						case 'playmainaudiosizeandcentermaindivstartprefix':		
	       //--- fires when there is suffix audio, main audio, and prefix audio --
					  	SizeImageAndCenterMainDiv();
								AudioPlayer(globalPrefixFileRoot);
								takeActionTimerID = setInterval("TakeActionWhenAudioEnds('playmainaudio')",200); //polls the player state
								break;
						case 'sizeandcentermaindivstartprefix':		
	       //--- fires when there is suffix audio, main audio, and prefix audio --
					  	SizeImageAndCenterMainDiv();
								AudioPlayer(globalPrefixFileRoot);
								break;							
						case 'sizeandcentermaindiv':		
	       //--- fires when there is suffix audio only --								
								//globalSuffixText
								if(globalSuffixFileRoot.indexOf('logout') > -1){
									 //--- In the case of signing off, we also clear out the audio player ----
									 AudioPlayer('');
								}
					  	SizeImageAndCenterMainDiv();
								break;								
						case 'playmainaudiosizeandcentermaindiv':		
	       //--- fires when there is suffix and main audio only --
								AudioPlayer(globalAudioFileNameRoot);
					  	SizeImageAndCenterMainDiv();
								break;										
			}	
			
									
}



function LoadMainElements(){
	//window.status = window.status + '-2395'
		document.getElementById('mainalertdiv').innerHTML = globalTopBlurb;
		document.getElementById('mainbuttondiv').innerHTML = globalButtonHTML;
		document.getElementById('mainrightdiv1').innerHTML = globalTopLinkHTML;
		document.getElementById('responsetextdiv').innerHTML = globalResponseTextHTML;
		document.getElementById('clickproblemdiv').innerHTML = globalProblemSelectHTML;
		
		if ((globalTextState == 'on') ||(globalForceShowText == 1)){ 
		  if(globalLanguage == 'english'){
		    document.getElementById('maintextdiv').innerHTML = globalMainTextHTML;			
				}else{
					 document.getElementById('maintextdiv').innerHTML = globalMainSpanTextHTML;		
				}
				
		}else{
		  document.getElementById('maintextdiv').innerHTML = '';
  }
}

function SetStudentUIPreferences(languagePref, textPref, maxPref){
	//window.status = window.status + '-2415'
	 if((languagePref != globalLanguage)&&(languagePref != '')){
			  ChangeLanguages();
		}
	 if((textPref != globalTextState)&&(textPref != '')){
			 ToggleTextState('noresize');
		}		
	 if((maxPref != globalMaxState)&&(maxPref != '')){
			 ToggleMaxState('noresize');
		}				
}

function RestoreDefaultLoginState(){	 	
  //window.status = window.status + '-2428'
  document.getElementById('user').value = '';
		document.getElementById('pass').value = '';
	 document.title	= document.getElementById('defaultpagetitle').innerHTML;
			
	/*	document.getElementById('mainleftdiv').innerHTML = document.getElementById('defaultmainleftdiv').innerHTML;
		document.getElementById('mainrightdiv1').innerHTML = document.getElementById('defaulttoplinks').innerHTML;
		document.getElementById('mainalertdiv').innerHTML = document.getElementById('defaultalert').innerHTML;
		document.getElementById('maintextdiv').innerHTML = document.getElementById('defaulttext').innerHTML;
		document.getElementById('responsetextdiv').innerHTML = document.getElementById('defaultresponsetext').innerHTML ;
		document.getElementById('mainbuttondiv').innerHTML = document.getElementById('defaultbuttons').innerHTML; 
	*/
 
		document.getElementById('maindiv').innerHTML = document.getElementById('defaultmainlogindiv').innerHTML;
	
		oFullPageDataDiv = document.getElementById('fullpagedatadiv');
		if(oFullPageDataDiv != null){
			  oFullPageDataDiv.innerHTML = '';
					oFullPageDataDiv.style.height = '0px';
					oFullPageDataDiv.style.width = '0px';
					oFullPageDataDiv.style.top = '0px';					
		}
	 		
  globalTextToggleEnabled = false;
		globalForceShowText = 1;

	 globalTextState = 'off'; 
		SetTextIcon('off');		
		
		globalMaxState = 'normal';	 
		SetMaxIcon('normal');

		globalAudioState = 'on';
		SetAudioIcon('on');		
		LoadBrowseHelpContents(-1,'student')  
		
		//-- give the username the focus --
		StartUserFocus();
  
}

function PassHasFocus(){
	  //window.status = window.status + '-2470'
	 globalPassHasFocus = true;
}
function PassLostFocus(){
	  //window.status = window.status + '-2474'
  globalPassHasFocus = false;	
}
function StartUserFocus(){
	  //window.status = window.status + '-2478'
		try{
				clearInterval(setUserFocusTimerID);
		}
		catch(e){
					var x = 8; //for ie
		}
	  document.getElementById('user').focus();
	  setUserFocusTimerID = setInterval("SetUserFocus()",1000); 
}
function SetUserFocus(){
	  //window.status = window.status + '-.'
	  //triggered by timer setUserFocusTimerID --
			//-- We don't set the focus to username if the password input currently has the focus --
			if(globalPassHasFocus == false){
				  document.getElementById('user').focus();
			}			
}

function RestoreDefaultSetFocusAfterASecond(){
	  //-- I don't know why it won't do it right away --
			//window.status = window.status + '-2499'
		clearInterval(setUserFocusTimerID);
	 oUserText = document.getElementById('user');
	 oUserText.focus(); 					
			
}

function ClearAllTimers(){
	//window.status = window.status + '-2507'
		try{
				clearInterval(setUserFocusTimerID);
		}
		catch(e){
					var x = 8; //for ie
		}	
		try{
				clearInterval(autoLogoutTimerID);
		}
		catch(e){
					var x = 8; //for ie
		}	
		try{
				clearInterval(longAutoLogoutTimerID);
		}
		catch(e){
					var x = 8; //for ie
		}	
		try{
				clearInterval(oneMinuteTimerTimerID); 
		}
		catch(e){
					var x = 8; //for ie
		}	
		try{
				clearInterval(StartAutoAdvanceTimerTimerID); 
		}
		catch(e){
					var x = 8; //for ie
		}	
		try{
				clearInterval(takeActionTimerID); 
		}
		catch(e){
					var x = 8; //for ie
		}	
		try{
				clearInterval(failSafeTimerID); 
		}
		catch(e){
					var x = 8; //for ie
		}	
		try{
				clearInterval(timedNextTimerID); 
		}
		catch(e){
					var x = 8; //for ie
		}	
		try{
				clearInterval(timedPreviousTimerID); 
		}
		catch(e){
					var x = 8; //for ie
		}	
		try{
				clearInterval(timedReloadAudioTimerID); 
		}
		catch(e){
					var x = 8; //for ie
		}	
		try{
				clearInterval(timedSeekProblemTimerID); 
		}
		catch(e){
					var x = 8; //for ie
		}			
}



function LoadBlankHelpSelectorDiv(){
	//window.status = window.status + '-2579'
		//document.getElementById('helpselectordiv').innerHTML = "<div><a onClick=\"LoadBrowseHelpContents(-1,'teacher')\"><div id='rosterclassname'></div></a></div><div id='rosterclassbuttons'></div>";
				document.getElementById('helpselectordiv').innerHTML = "<div><a><div id='rosterclassname'></div></a></div><div id='rosterclassbuttons'></div>";
}

function LoadRosterClassName(){
	//window.status = window.status + '-2585'
	 //-- modifies the title of the roster to show the name --
		document.getElementById('rosterclassname').innerHTML = "<b>Roster&nbsp;(" + globalRosterClassName +")</b>";		
}

function LoadRosterRadioButtons(){
	//window.status = window.status + '-2591'
	 document.getElementById('rosterclassbuttons').innerHTML = globalRosterClassRadioHTML;	
}

function LoadRosterContents(globalRosterContents){	
//window.status = window.status + '-2596'
		var htmlContents = "<ul id='browsehelplist'>" + globalRosterContents + "</ul>";	
		$("#browseproblemdiv").html(htmlContents);
		document.getElementById('browseproblemdiv').style.overflow = 'visible';
		globalBrowseHelpDivWidth = document.getElementById('browseproblemdiv').offsetWidth;				
			newMainDivHeight = document.getElementById('maindiv').offsetHeight;
   var oHelpSelectorDiv = document.getElementById('helpselectordiv');
		 var oBrowseProblemDiv = document.getElementById('browseproblemdiv');
		 var newHelpHeight = newMainDivHeight - oHelpSelectorDiv.offsetHeight;
		 oBrowseProblemDiv.style.height = newHelpHeight + 'px'; 		
}


function GetCookie(name){
	//window.status = window.status + '-2623'
  var cookies = document.cookie;
	 if (cookies.indexOf(name) != -1){
			 var startpos = cookies.indexOf(name)+name.length+1;
		  var endpos = cookies.indexOf(";",startpos)-1;
    if (endpos == -2){
					 endpos = cookies.length;
				}
		  return unescape(cookies.substring(startpos,endpos));
	 }else{
		    return false; // the cookie couldn't be found!     
	 }		
}

function SetCookie(cookieName,sentValue){
	//window.status = window.status + '-2638'
  var exdate=new Date();
		exdays = 9000;
  exdate.setDate(exdate.getDate() + exdays);
  var cookieStringValue = escape(sentValue) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
  document.cookie= cookieName+"="+escape(sentValue)+";expires="+exdate.toUTCString()+ ";path=/;"; 		//accessible to all since it's in the root path
}   
			

function ClickedClassCompCheck(cookieName,teacherID){
	//window.status = window.status + '-2648'
	 //-- Note: this now includes the 3 other computer related cookies that can be set by teacherHome --
 	//--- sends info from teachertable and nothing comes back ---
		if (AreCookiesEnabled() == false){
     alert('The browser does not have cookies enabled so this change cannot be made');
		}else{
		 	
				switch(cookieName){
						case 'cc':
								var checkVal = document.tchrrecform.classcompcheck.checked;
								break;
						case 'tc':
								var checkVal = document.tchrrecform.testcompcheck.checked;
								break;				
						case 'rc':
								var checkVal = document.tchrrecform.tchrcompcheck.checked;
								break;														
				}
				if(checkVal == 1){
							//--- get the encrypted value first -----------
							var mygetrequest=new ajaxRequest();
							mygetrequest.onreadystatechange=function(){
							if (mygetrequest.readyState==4){
									if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){												
											var encryptedCookieValue = mygetrequest.responseText;	
											//window.status = "ClickedClassCompCheck loaded  ";
										SetCookie(cookieName,encryptedCookieValue);
									}//if (mygetrequest.status==200
							}//if (mygetrequest.readyState==4){
						}//mygetrequest.onreadystatechange=function()		
						mygetrequest.open("GET", "GetCookie.php?i="+teacherID+"&c="+cookieName+"&gs="+globalSessionID+"&qwert="+new Date().getTime(), true);	
						mygetrequest.send(null);							
							
				}else{
							// --clear cookie --
						 	SetCookie(cookieName,''); 
				}

		}
}

function TestCookiesEnabled(){
	//window.status = window.status + '-2690'
			if(navigator.cookieEnabled){
				 	return 1;
			}else{
					return 0;
			}
}

function GetTeacherHomeTab(teacherID){
	//window.status = window.status + '-2699'
 	//--- fills in teacher data with general purpose teacher items ---
		//-- uses globalTeacherAudioAlerts --
		var classComp = GetCookie('cc');
		var cookiesEnabled = TestCookiesEnabled();
		var mygetrequest=new ajaxRequest();
		mygetrequest.onreadystatechange=function(){
		if (mygetrequest.readyState==4){
				if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
						//--- Here is where all the info comes back which ain't nothing in this case-------	
					 	//alert (mygetrequest.responseText); 
							//window.status = "GetTeacherHomeTab loaded  ";
							var tabContentHTML = mygetrequest.responseText;
		   //  try{ //for IE8
         document.getElementById('tabcontent').innerHTML = tabContentHTML;
		   //  }
		   //  catch(e){
				  //  	var x = 8; //for ie
		   //  }										       		   
	      SizeImageAndCenterMainDivDetail();											
				}//if (mygetrequest.status==200
		}//if (mygetrequest.readyState==4){
	}//mygetrequest.onreadystatechange=function()		
	mygetrequest.open("GET", "GetTeacherHome.php?i="+teacherID+"&gs="+globalSessionID+"&aud="+globalTeacherAudioAlerts+"&cc="+classComp+"&cooks="+cookiesEnabled+"&qwert="+new Date().getTime(), true);
	mygetrequest.send(null);	
}


//pause +"&qwert="+new Date().getTime()



function ClickedGetCasasLeaders(teacherID){
	//window.status = window.status + '-2732'
 	//--- fills in teacher data with a list of students who signed in today  ---
		 globalDocsForBrowseHelp = false;
	//	if(globalLoadingMenuItem == false){
			  HighlightMenuText('hours');
			  globalLoadingMenuItem = true;
				var mygetrequest=new ajaxRequest();
				mygetrequest.onreadystatechange=function(){
				if (mygetrequest.readyState==4){
						if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
								//--- Here is where all the info comes back which ain't nothing in this case-------	
									//alert (mygetrequest.responseText); 
									//window.status = "ClickedGetCasasLeaders loaded  ";
									document.getElementById('mainbuttondiv').innerHTML = '';
									document.getElementById('mainalertdiv').innerHTML = '';
									globalTopBlurb = '';
									var casasLeadersHTML = mygetrequest.responseText;							
									document.getElementById('fullpagedatadiv').style.visibility = 'hidden';	
									document.getElementById('fullpagedatadiv').style.top = '-1000px';
									document.getElementById('fullpagedatadiv').innerHTML = casasLeadersHTML;		
									document.getElementById('verticalmenudiv').innerHTML = '';
									
									SizeImageAndCenterMainDivDetail();				
									globalLoadingMenuItem = false;
						}//if (mygetrequest.status==200
				}//if (mygetrequest.readyState==4){
			}//mygetrequest.onreadystatechange=function()		
			mygetrequest.open("GET", "GetCasasLeaders.php?i="+teacherID+"&gs="+globalSessionID+"&qwert="+new Date().getTime(), true);  
			mygetrequest.send(null);	
	//			}
}

function ClearMainAlertAndButtonHTML(){
	
}

function ClickSelectControlRosterName(oSentSelect,scope){
	//window.status = window.status + '-2768'
  //-- this screwy business is to accomodate Internet Explorer ---
		var stuIDTeacherIDPair = oSentSelect.options[oSentSelect.selectedIndex].value;
		var commaPos = stuIDTeacherIDPair.indexOf(',');
		var studentID = stuIDTeacherIDPair.substr(0,commaPos);
		var teacherID = stuIDTeacherIDPair.substr(commaPos+1)
		ClickRosterName(studentID,teacherID,scope);
}

function SetFocusToCurrentRosterName(){
//	 var selIndex =  document.getElementById('rosterselect').selectedIndex;
	//	alert(selIndex)
  document.getElementById('rosterselect').focus();
	//document.getElementById('rosterselect').options[selIndex].selected;
	//	document.getElementById('rosterselect').options[selIndex].selected=true;
	//	document.getElementById('rosterselect').options[selIndex].focus();
}

function OnKeyPressRosterSelect(e,teacherID){
	 //-- hot keys that apply when the roster list has the focus --
		// M -> main,   N or C -> contract,   B -> current
		if(window.event){ //IE
			var keynum = e.keyCode;
		}else if(e.which){ // Netscape/Firefox/Opera
				var keynum = e.which;
		}
		var keychar = String.fromCharCode(keynum);
		var selIndex =  document.getElementById('rosterselect').selectedIndex;
  var studentID = document.getElementById('rosterselect').options[selIndex].getAttribute('stuid');
		
		switch(keychar){
			  case 'm':
					case 'M':
					  ClickRosterFromVertMenu(studentID,teacherID);
				   break;
			  case 'n':
					case 'N':
			  case 'c':
					case 'C':					
					  ClickContract(studentID,teacherID);
				   break;	
			  case 'b':
					case 'B':
					  ClickedCurrentStudentWorkForTeacher(studentID,teacherID);
				   break;									
		}
		////window.status = 'keychar='+keychar+' ' + teacherID + ' ' + studentID;
}



function OnChangeRosterSelectTimer(){
	  //-- this starts the timer that calls teh real function ---
		try{
				clearInterval(onChangeRosterSelectTimerID);
		}
		catch(e){
					var x = 8; //for ie
		}						
		onChangeRosterSelectTimerID = setInterval("OnChangeRosterSelect()",200); 
}

function OnChangeRosterSelect(){
		try{
				clearInterval(onChangeRosterSelectTimerID);
		}
		catch(e){
					var x = 8; //for ie
		}		
	 var selIndex =  document.getElementById('rosterselect').selectedIndex;
  var studentID = document.getElementById('rosterselect').options[selIndex].getAttribute('stuid');
		var teacherID = document.getElementById('rosterselect').options[selIndex].getAttribute('tchrid');
		var scope = document.getElementById('rosterselect').options[selIndex].getAttribute('scope');
	 ClickRosterName(studentID,teacherID,scope);
}

function ClickRosterNameFromOutsideList(studentID,teacherID,scope){
	 //window.status = window.status + '-2778a'				
	 document.getElementById('lastvertmenu').value = 'main';
	 document.getElementById('stuidforscanner').value = studentID;
		//-- Open the 'all' periods list and navigates to the student's name on the roster list  
	 SetRosterRadioGroupValue(0); //this takes the place of actually clicking on it
	//alert(studentID+ '  ' + teacherID + '  ' + scope)
		ClickedRosterRadio(teacherID,'all',0,studentID,scope); //need the full list to: 1) find the stu, and 2) be sure the name is present
				
}

function SetRosterRadioGroupValue(sentValue){
		var oRosterRadioGroup = document.getElementsByName("rosterRadioGroup");
		var radioLength = oRosterRadioGroup.length;
		for(var i = 0; i < radioLength; i++){
			 oRosterRadioGroup[i].checked = false;
			 if(oRosterRadioGroup[i].value == sentValue.toString()){
				  oRosterRadioGroup[i].checked = true;
		 	}
		}
}

function ClickRosterName(studentID,teacherID,scope){
	//window.status = window.status + '-2778b'
	//alert('click roster name')
	 document.getElementById('stuidforscanner').value = studentID;
	 ClickRosterNameOrContract(studentID,'roster',teacherID,scope);		
}

function ClickRosterFromVertMenu(studentID,teacherID,scope){
	//window.status = window.status + '-2778c'
	 document.getElementById('lastvertmenu').value = 'main';
	 document.getElementById('stuidforscanner').value = studentID;
	 ClickRosterNameOrContract(studentID,'roster',teacherID,scope);		
		SetFocusToCurrentRosterName();
}

function ChAtt(boxID, stuID, addOrRemove, dateUnix){
	//window.status = window.status + '-2785'
	//  alert(stuID + ' ' + addOrRemove + ' ' + dateUnix)
	//-- YOIU DON'T EVEN NEEDD THE SENT addorremove INFO! (SEE innerHTML test below) --
 	//--- adds or removes a particular coded date entry in the student's attendance record (eg, student.attendance) ---
		var teacherID = document.tchrrecform.teacherid.value; 
		var oBox = document.getElementById(boxID);
		if(oBox.innerHTML == 'X'){ //must match what's in GetWeekAttendance.php
					var addOrRemove = 'remove';
					document.getElementById(boxID).innerHTML = ''; 
		}else{
					var addOrRemove = 'add';
					document.getElementById(boxID).innerHTML = 'X'; //must match what's in GetWeekAttendance.php
		}		
		var mygetrequest=new ajaxRequest();
		mygetrequest.onreadystatechange=function(){
		if (mygetrequest.readyState==4){
				if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
						// -- This php call only changes the mysql table.  ClickedWeekAttendance.php is recalled to refresh the screen --
						//-- Do all the visible changes with javascript ---
					//alert (mygetrequest.responseText);
					//window.status = "ChAtt loaded  ";

				}//if (mygetrequest.status==200
		}//if (mygetrequest.readyState==4){
	}//mygetrequest.onreadystatechange=function()		
	mygetrequest.open("GET", "AddOrRemoveAttendDay.php?i="+stuID+"&addorremove="+addOrRemove+"&dateunix="+dateUnix+"&gs="+globalSessionID+"&qwert="+new Date().getTime(), true);
	mygetrequest.send(null);				
}

function ClickedMaterials(teacherID,inventoryOrCheckout){
	//window.status = window.status + '-2815'
	globalDocsForBrowseHelp = false;
	 switch(inventoryOrCheckout){
			  case 'inventory':
					  GetMaterialsInventory(teacherID);
							break;
			  case 'checkout':
					  GetMaterialsCheckout(teacherID);
							break;							
					default: //eg 'uncertain'
					  // --see what's most appropriate ---
							var mygetrequest=new ajaxRequest();
							mygetrequest.onreadystatechange=function(){
							if (mygetrequest.readyState==4){
									if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
											//--- Here is where all the info comes back which ain't nothing in this case-------	
											//alert (mygetrequest.responseText); 
											document.getElementById('verticalmenudiv').innerHTML = '';
											//window.status = "ClickedMaterials loaded  ";
											var inventoryOrCheckout = mygetrequest.responseText;				
											//inventoryOrCheckout = 'inventory'
											if(inventoryOrCheckout == 'inventory'){
														GetMaterialsInventory(teacherID);
											}else{
														GetMaterialsCheckout(teacherID);
											}			
									}//if (mygetrequest.status==200
							}//if (mygetrequest.readyState==4){
						}//mygetrequest.onreadystatechange=function()		
						var urlString = "SelectInventoryOrCheckout.php?i="+teacherID+"&gs="+globalSessionID+"&qwert="+new Date().getTime();
						mygetrequest.open("GET",urlString , true);
						mygetrequest.send(null);	
											
		}//end of main switch
}

function GetMaterialsInventory(teacherID){
 	//--- fills in teacher data with a list of materials followed by 10 blank spots ---
//		if(globalLoadingMenuItem == false){
	//window.status = window.status + '-2853'
			 HighlightMenuText('materials'); 
			 globalLoadingMenuItem = true;
				var mygetrequest=new ajaxRequest();
				mygetrequest.onreadystatechange=function(){
				if (mygetrequest.readyState==4){
						if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
								//--- Here is where all the info comes back which ain't nothing in this case-------	
					//	alert (mygetrequest.responseText); 
					//window.status = "GetMaterialsInventory loaded  ";
									var weekAttendanceHTML = mygetrequest.responseText;				
									globalTopBlurb = '';
									document.getElementById('mainalertdiv').innerHTML = globalTopBlurb;							
								//	document.getElementById('fullpagedatadiv').style.visibility = 'hidden';	
								//	document.getElementById('fullpagedatadiv').style.top = '-1000px';
									document.getElementById('fullpagedatadiv').innerHTML = weekAttendanceHTML;							
									SizeImageAndCenterMainDivDetail();			
									globalLoadingMenuItem = false;
						}//if (mygetrequest.status==200
				}//if (mygetrequest.readyState==4){
			}//mygetrequest.onreadystatechange=function()		
			var urlString = "GetMaterialsInventory.php?i="+teacherID+"&gs="+globalSessionID+"&qwert="+new Date().getTime();
			mygetrequest.open("GET",urlString , true);
			mygetrequest.send(null);	
	//	}
}

function GetMaterialsCheckout(teacherID){
 	//--- fills in teacher data with a list of materials followed by 10 blank spots ---
		//if(globalLoadingMenuItem == false){
			//window.status = window.status + '-2883'
			 HighlightMenuText('materials'); 
			 globalLoadingMenuItem = true;
				var mygetrequest=new ajaxRequest();
				mygetrequest.onreadystatechange=function(){
				if (mygetrequest.readyState==4){
						if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
								//--- Here is where all the info comes back which ain't nothing in this case-------	
					  //alert (mygetrequest.responseText); 
							//window.status = "etMaterialsCheckout loaded  ";
									var weekAttendanceHTML = mygetrequest.responseText;				
									globalTopBlurb = '';
									document.getElementById('mainalertdiv').innerHTML = globalTopBlurb;							
								//	document.getElementById('fullpagedatadiv').style.visibility = 'hidden';	
								//	document.getElementById('fullpagedatadiv').style.top = '-1000px';
									document.getElementById('fullpagedatadiv').innerHTML = weekAttendanceHTML;			
									SizeImageAndCenterMainDivDetail();			
									globalLoadingMenuItem = false;
						}//if (mygetrequest.status==200
				}//if (mygetrequest.readyState==4){
			}//mygetrequest.onreadystatechange=function()		
			var urlString = "GetMaterialsCheckout.php?i="+teacherID+"&gs="+globalSessionID+"&qwert="+new Date().getTime();
			mygetrequest.open("GET",urlString , true);
			mygetrequest.send(null);	
	//	}
}


function ClickedWeekAttendance(teacherID,weekOffset,allOrShow){
 	//--- fills in teacher data with a list of students who signed in today  ---
		//window.status = window.status + '-2913'
		globalDocsForBrowseHelp = false;
		//alert(teacherID)
	//	if(globalLoadingMenuItem == false){
			 globalLoadingMenuItem = true;
				HighlightMenuText('week');
				var classNum = GetWeekRadioNumber();
				if(allOrShow == ''){
						//-- get the value from what it currently is --
						try{
										//-- the all or show checkbox isn't shown when there are no listed students ----
									if(document.tchrrecform.allorshowcheckbox.checked == true){
											var allOrShow = 'all';
									}else{
											var allOrShow = 'show';
									}		
							}
							catch(e){
											var allOrShow = 'show';
							}	  
				}else{
						//-- use the sent value --				
				}
				//alert(teacherID + '  ' + weekOffset + '   ' + allOrShow + '   ' + classNum);
				var mygetrequest=new ajaxRequest();
				mygetrequest.onreadystatechange=function(){
				if (mygetrequest.readyState==4){
						if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
								//--- Here is where all the info comes back which ain't nothing in this case-------	
							//alert (mygetrequest.responseText); 
							//window.status = "ClickedWeekAttendance loaded  ";
									var weekAttendanceHTML = mygetrequest.responseText;				
									globalTopBlurb = '';
									document.getElementById('mainalertdiv').innerHTML = globalTopBlurb;							
									document.getElementById('fullpagedatadiv').style.visibility = 'hidden';	
									document.getElementById('fullpagedatadiv').style.top = '-1000px';
									document.getElementById('fullpagedatadiv').innerHTML = weekAttendanceHTML;					
									document.getElementById('verticalmenudiv').innerHTML = '';
									SizeImageAndCenterMainDivDetail();
									globalLoadingMenuItem = false;
						}//if (mygetrequest.status==200
				}//if (mygetrequest.readyState==4){
			}//mygetrequest.onreadystatechange=function()		
			var urlString = "GetWeekAttendance.php?i="+teacherID+"&allorshow="+allOrShow+"&weekoffset="+weekOffset+"&gs="+globalSessionID+"&cn="+classNum+"&qwert="+new Date().getTime();
			mygetrequest.open("GET",urlString , true);
			mygetrequest.send(null);	
	//	}
}




function ClickedTeacherHelp(teacherID){
	//window.status = window.status + '-2965'
	globalDocsForBrowseHelp = false;
 	//--- fills in teacher data with general purpose teacher items ---
	//	if(globalLoadingMenuItem == false){
			 HighlightMenuText('help');
			 globalLoadingMenuItem = true;
				var mygetrequest=new ajaxRequest();
				mygetrequest.onreadystatechange=function(){
				if (mygetrequest.readyState==4){
						if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
								//--- Here is where all the info comes back which ain't nothing in this case-------	
									//alert (mygetrequest.responseText); 
									//window.status = "ClickedTeacherHelp loaded  ";
									teacherTableHTML = mygetrequest.responseText;
									document.getElementById('mainalertdiv').innerHTML = ''; //doesn't play nice with tchrdatacontent way of doing things -- put it ALL in tchrdatacontent
									document.getElementById('fullpagedatadiv').style.visibility = 'hidden';
									document.getElementById('fullpagedatadiv').style.top = '-1000px';
									document.getElementById('fullpagedatadiv').innerHTML = teacherTableHTML;			
									document.getElementById('verticalmenudiv').innerHTML = '';
									SizeImageAndCenterMainDivDetail();		
									globalLoadingMenuItem = false;
						}//if (mygetrequest.status==200
				}//if (mygetrequest.readyState==4){
			}//mygetrequest.onreadystatechange=function()		
			mygetrequest.open("GET", "GetTeacherHelpPage.php?i="+teacherID+"&gs="+globalSessionID+"&qwert="+new Date().getTime(), true);
			mygetrequest.send(null);			
		//		}
}



function ClickedHome(sentParam){ //see workinghere for small trouble in positioning
//window.status = window.status + '-2994'
 	//--- fills in teacher data with general purpose teacher items ---
		globalDocsForBrowseHelp = false;
	//	if(globalLoadingMenuItem == false){
			 HighlightMenuText('preferences'); 
			 globalLoadingMenuItem = true;
				globalActiveTab = 'scheduletab';
				var mygetrequest=new ajaxRequest();
				mygetrequest.onreadystatechange=function(){
				if (mygetrequest.readyState==4){
						if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
								//--- Here is where all the info comes back -------	
									//alert (mygetrequest.responseText); 
									//window.status = "ClickedPreferences loaded  ";
									globalTopBlurb = '';
									document.getElementById('mainalertdiv').innerHTML = '';
									var preferencesHTML = mygetrequest.responseText;
									oFullPageDataDiv = document.getElementById('fullpagedatadiv');
									oFullPageDataDiv.style.visibility = 'hidden';
									oFullPageDataDiv.style.top = '-1000px';
									oFullPageDataDiv.innerHTML = preferencesHTML;
									document.getElementById('verticalmenudiv').innerHTML = '';			
									SizeImageAndCenterMainDivDetail();			
									globalLoadingMenuItem = false;
						}//if (mygetrequest.status==200
				}//if (mygetrequest.readyState==4){
			}//mygetrequest.onreadystatechange=function()		
			mygetrequest.open("GET", "GetHomeHTML.php?s="+sentParam+"&qwert="+new Date().getTime(), true);
			mygetrequest.send(null);	
		//		}
}

function ClickedPreferences(teacherID){ //see workinghere for small trouble in positioning
//window.status = window.status + '-2994'
 	//--- fills in teacher data with general purpose teacher items ---
		globalDocsForBrowseHelp = false;
	//	if(globalLoadingMenuItem == false){
			 HighlightMenuText('preferences'); 
			 globalLoadingMenuItem = true;
				globalActiveTab = 'scheduletab';
				var mygetrequest=new ajaxRequest();
				mygetrequest.onreadystatechange=function(){
				if (mygetrequest.readyState==4){
						if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
								//--- Here is where all the info comes back -------	
									//alert (mygetrequest.responseText); 
									//window.status = "ClickedPreferences loaded  ";
									globalTopBlurb = '';
									document.getElementById('mainalertdiv').innerHTML = '';
									var preferencesHTML = mygetrequest.responseText;
									oFullPageDataDiv = document.getElementById('fullpagedatadiv');
									oFullPageDataDiv.style.visibility = 'hidden';
									oFullPageDataDiv.style.top = '-1000px';
									oFullPageDataDiv.innerHTML = preferencesHTML;
									document.getElementById('verticalmenudiv').innerHTML = '';			
									//--- set the overall tabbox width (it'll stretch to tabsandcontentdiv) ---------
									//-- You have to pick something man.
									var newTabBoxWidth = 500; 							
									document.getElementById('tabsandcontentdiv').style.width = newTabBoxWidth + 'px'; 
									//--- init the tabs --
									SetTabWidths(newTabBoxWidth);
									ClickTab(globalActiveTab,teacherID);		//initial tab to show						
									
									SizeImageAndCenterMainDivDetail();			
									globalLoadingMenuItem = false;
						}//if (mygetrequest.status==200
				}//if (mygetrequest.readyState==4){
			}//mygetrequest.onreadystatechange=function()		
			mygetrequest.open("GET", "GetPreferences.php?i="+teacherID+"&gs="+globalSessionID+"&qwert="+new Date().getTime(), true);
			mygetrequest.send(null);	
		//		}
}



function SetTabWidths(howWide){
	//window.status = window.status + '-3035'
		//-- make each of the tabs the same width ---
		var availWidth = howWide; //document.getElementById('fullpagedatadiv').offsetWidth;
		var tabWidth = (availWidth/4) -3; //for the borders
		document.getElementById('scheduletab').style.width = tabWidth+ 'px';
		document.getElementById('coursetab').style.width = tabWidth + 'px';
		document.getElementById('casastab').style.width = tabWidth + 'px';
		document.getElementById('misctab').style.width = tabWidth + 'px';
}

function Trim(stringToTrim) {
	  //-- Trims off white space ---
  return stringToTrim.replace(/^\s+|\s+$/g,"");
}


function MatChange(matID){
	 //-- a change was made to an existing material name or copies-string ---
		var liveOnesValue = document.tchrrecform.liveones.value;
		if(liveOnesValue.indexOf(matID) > -1){
			  //-- this material id is already in live ones --
		}else{
			 document.tchrrecform.liveones.value = matID + "*" + liveOnesValue;
		}
}

function SaveMaterialsInventory(teacherID){
		var XMLHttpRequestObject = new ajaxRequest();
		var pageURL = 'SaveMaterialsInventory.php';

		oddDelimiter = String.fromCharCode(197,201);
		oddDelimiterLength = 2;
		
		var oInputsArray = document.tchrrecform.getElementsByTagName('input');
		var matIDArray = new Array;	
		var matNameArray = new Array;	 
		var matCopiesArray = new Array;	 
		var newMatNameArray = new Array;	 
		var newMatCopiesArray = new Array;	  		
		var liveOnesString = document.tchrrecform.liveones.value;
		liveOnesString = liveOnesString.substr(0,liveOnesString.length -1);//--take off the last asterisk
		if(liveOnesString != ''){
				var liveOnesArray = liveOnesString.split('*');
				var matNameString = '';  
				var matCopiesString = '';  
				var newMatNameString = '';  
				var newMatCopiesString = '';
				for(var i=0;i<liveOnesArray.length;i++){
						if(liveOnesArray[i] > 0){
								// -- its an existing one --
								var oMatName = 'matname' + liveOnesArray[i];					
								var nameValue = document.getElementById(oMatName).value;
								
								//nameValue = nameValue.replace(' ','');
								if(nameValue != ''){
								  oMatCopies = 'matcopy' + liveOnesArray[i];	
								  var copiesValue = document.getElementById(oMatCopies).value;
								  matNameString = matNameString + nameValue + oddDelimiter;		
								  matCopiesString = matCopiesString + copiesValue + oddDelimiter;
								}
						}else{
								// -- its a new one ---
								var oMatName = 'matnewn' + liveOnesArray[i];			
								var nameValue = document.getElementById(oMatName).value;
								
								//nameValue = nameValue.replace(' ','');
								if(nameValue != ''){
								  oMatCopies = 'matnewc' + liveOnesArray[i];	
								  var copiesValue = document.getElementById(oMatCopies).value;
								  newMatNameString = newMatNameString + nameValue + oddDelimiter;		
								  newMatCopiesString = newMatCopiesString + copiesValue + oddDelimiter;					
								}
						}
				}				
				
				//-- remove the final delimiter char ---
				matNameString = matNameString.substr(0,matNameString.length - oddDelimiterLength);  
				matCopiesString = matCopiesString.substr(0,matCopiesString.length - oddDelimiterLength); 
				newMatNameString = newMatNameString.substr(0,newMatNameString.length - oddDelimiterLength);  
				newMatCopiesString = newMatCopiesString.substr(0,newMatCopiesString.length - oddDelimiterLength);	
				urlVarString = "odd="+oddDelimiter+"&i="+teacherID+'&matn='+matNameString+'&matc='+matCopiesString+'&newmatn='+newMatNameString+'&newmatc='+newMatCopiesString+'&live='+liveOnesString;
						
				XMLHttpRequestObject.open("POST", pageURL);
				XMLHttpRequestObject.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
				XMLHttpRequestObject.onreadystatechange = function(){
				if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) {					
		
								var fullString = XMLHttpRequestObject.responseText;
							//	alert(fullString);
								document.tchrrecform.liveones.value = '';
								ClickedMaterials(teacherID,'inventory'); //refresh with the saved values, and any new blank spots						
		
						}//if
				}//function 
				XMLHttpRequestObject.send(urlVarString);
		} //if livesonesstring != ''
}


function SaveSchedule(teacherID){
  var oInputsArray = document.tchrrecform.getElementsByTagName('input');
		var nameArrayString = '';
		var durationArrayString = '';  
		for(var i=0;i<oInputsArray.length;i++){
    if(oInputsArray[i].type=="text"){
				  var nameValue = Trim(oInputsArray[i].value);
						nameArrayString = nameArrayString + nameValue + '@@@@';
						i++;
				  var durationValue = Trim(oInputsArray[i].value);
						durationArrayString = durationArrayString + durationValue + '@@@@';						
		  }
		}		
		
		var mygetrequest=new ajaxRequest();
		mygetrequest.onreadystatechange=function(){
		if (mygetrequest.readyState==4){
				if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
						//--- Here is where all the info comes back which ain't nothing in this case-------	
					 //	alert (mygetrequest.responseText); 		
						//window.status = " loaded  ";
				}//if (mygetrequest.status==200   
		}//if (mygetrequest.readyState==4){
	}//mygetrequest.onreadystatechange=function()		

	var urlString = "SaveData.php?type=schedule&i="+teacherID+"&gs="+globalSessionID+'&nas='+nameArrayString+'&das='+durationArrayString+"&qwert="+new Date().getTime();
	mygetrequest.open("GET" ,urlString, true);
	mygetrequest.send(null);				
}

function SaveCasasTests(teacherID){
	//window.status = window.status + '-3165'
  var oInputsArray = document.tchrrecform.getElementsByTagName('input');
		var textArrayString = '';
		//-- we have to do it in 2 groups to preserve the order (due to the fact that number 11 comes before number 2, for ex, in the 2-column table) --
		for(var i=0;i<oInputsArray.length;i++){
    if(oInputsArray[i].type=="text"){
				  var textValue = Trim(oInputsArray[i].value);
      if(textValue != ''){
							 if(oInputsArray[i].name == 'col1'){
							   textArrayString = textArrayString + textValue + '@@@@';
								}
						}
		  }
		}
		for(var i=0;i<oInputsArray.length;i++){
    if(oInputsArray[i].type=="text"){
				  var textValue = Trim(oInputsArray[i].value);
      if(textValue != ''){
							 if(oInputsArray[i].name == 'col2'){									  
							   textArrayString = textArrayString + textValue + '@@@@';
								}
						}
		  }
		}		
		var mygetrequest=new ajaxRequest();
		mygetrequest.onreadystatechange=function(){
		if (mygetrequest.readyState==4){
				if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
						//--- Here is where all the info comes back which ain't nothing in this case-------	
					 //alert (mygetrequest.responseText); 	
						//window.status = "SaveCasasTests loaded  ";
				}//if (mygetrequest.status==200
		}//if (mygetrequest.readyState==4){
	}//mygetrequest.onreadystatechange=function()		
	mygetrequest.open("GET", "SaveData.php?type=casastests&i="+teacherID+"&gs="+globalSessionID+'&tas='+textArrayString+"&qwert="+new Date().getTime(), true);
	mygetrequest.send(null);				
}


function DropDownTextToBox(objDropdown, strTextboxId) {
	//window.status = window.status + '-3205'
			//---- code I got for making comboboxes 1 of 2-----------
				document.getElementById(strTextboxId).value = objDropdown.options[objDropdown.selectedIndex].value;
				DropDownIndexClear(objDropdown.id);
				document.getElementById(strTextboxId).focus();
}
function DropDownIndexClear(strDropdownId) {
	//window.status = window.status + '-3212'
	//---- code I got for making comboboxes 2 of 2 -----------
				if (document.getElementById(strDropdownId) != null) {
								document.getElementById(strDropdownId).selectedIndex = -1;
				}
}

function SaveCasasIntervals(teacherID){
	//window.status = window.status + '-3220'
	 var newCasasIntervalValue = document.tchrrecform.casasinterval.value;
		var newCasas2IntervalValue = document.tchrrecform.casas2interval.value;
		var newCasasMonthsValue = document.tchrrecform.casasmonths.value;
		var newWaitingPeriodValue = document.tchrrecform.casaswaitingperiodselect.options[document.tchrrecform.casaswaitingperiodselect.selectedIndex].value;
		var mygetrequest=new ajaxRequest();
		mygetrequest.onreadystatechange=function(){
		if (mygetrequest.readyState==4){
				if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
						//--- Here is where all the info comes back which ain't nothing in this case-------	
					 	//alert (mygetrequest.responseText); 		
							//window.status = "SaveCasasIntervals loaded  ";
				}//if (mygetrequest.status==200
		}//if (mygetrequest.readyState==4){
	}//mygetrequest.onreadystatechange=function()		
	mygetrequest.open("GET", "SaveData.php?type=casasintervals&i="+teacherID+"&gs="+globalSessionID+'&ci='+newCasasIntervalValue+'&wp='+newWaitingPeriodValue+'&c2i='+newCasas2IntervalValue+'&cm='+newCasasMonthsValue+"&qwert="+new Date().getTime(), true);
	mygetrequest.send(null);				
}


function GetScheduleTab(teacherID){
	  //-- in effect, this is a nested ajax -- going into ClickePreferences() --
			//window.status = window.status + '-3241'
		var mygetrequest=new ajaxRequest();
		mygetrequest.onreadystatechange=function(){
		if (mygetrequest.readyState==4){
				if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
						//--- Here is where all the info comes back -------	
						//window.status = "GetScheduleTab loaded  ";
						 var tabContentHTML = mygetrequest.responseText;
		     try{ //for IE8
         document.getElementById('tabcontent').innerHTML = tabContentHTML;
		     }
		     catch(e){
				    	var x = 8; //for ie
		     }																
	      SizeImageAndCenterMainDivDetail();												
				}//if (mygetrequest.status==200
		}//if (mygetrequest.readyState==4){
	}//mygetrequest.onreadystatechange=function()		
	mygetrequest.open("GET", "GetScheduleTab.php?i="+teacherID+"&gs="+globalSessionID+"&qwert="+new Date().getTime(), true);
	mygetrequest.send(null);					
}

function GetCasasTestsTab(teacherID){
	//window.status = window.status + '-3265'
	  //-- in effect, this is a nested ajax -- going into ClickePreferences() --
		var mygetrequest=new ajaxRequest();
		mygetrequest.onreadystatechange=function(){
		if (mygetrequest.readyState==4){
				if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
						//--- Here is where all the info comes back -------	
						//window.status = "GetCasasTestsTab loaded  ";
							var tabContentHTML = mygetrequest.responseText;
		     try{ //for IE8
         document.getElementById('tabcontent').innerHTML = tabContentHTML;
		     }
		     catch(e){
				    	var x = 8; //for ie
		     }									       		   
	      SizeImageAndCenterMainDivDetail();												
				}//if (mygetrequest.status==200
		}//if (mygetrequest.readyState==4){
	}//mygetrequest.onreadystatechange=function()		
	mygetrequest.open("GET", "GetCasasTestsTab.php?i="+teacherID+"&gs="+globalSessionID+"&qwert="+new Date().getTime(), true);
	mygetrequest.send(null);					
}

function GetCasasIntervalsTab(teacherID){
	//window.status = window.status + '-3289'
	  //-- in effect, this is a nested ajax -- going3289ClickePreferences() --
		var mygetrequest=new ajaxRequest();
		mygetrequest.onreadystatechange=function(){
		if (mygetrequest.readyState==4){
				if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
						//--- Here is where all the info comes back -------	
						//window.status = "GetCasasIntervalsTab loaded  ";
							var tabContentHTML = mygetrequest.responseText;
       document.getElementById('tabcontent').innerHTML = tabContentHTML;		   
	      SizeImageAndCenterMainDivDetail();												
				}//if (mygetrequest.status==200
		}//if (mygetrequest.readyState==4){
	}//mygetrequest.onreadystatechange=function()		
	mygetrequest.open("GET", "GetCasasIntervalsTab.php?i="+teacherID+"&gs="+globalSessionID+"&qwert="+new Date().getTime(), true);
	mygetrequest.send(null);					
}

function GetAboutTab(teacherID){
	//window.status = window.status + '-3308'
	  //-- in effect, this is a nested ajax -- going3308ClickePreferences() --
		var mygetrequest=new ajaxRequest();
		mygetrequest.onreadystatechange=function(){
		if (mygetrequest.readyState==4){
				if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
						//--- Here is where all the info comes back -------	
							var tabContentHTML = mygetrequest.responseText;
							//window.status = "GetAboutTab loaded  ";
       document.getElementById('tabcontent').innerHTML = tabContentHTML;		   
	      SizeImageAndCenterMainDivDetail();												
				}//if (mygetrequest.status==200
		}//if (mygetrequest.readyState==4){
	}//mygetrequest.onreadystatechange=function()		
	mygetrequest.open("GET", "GetAboutTab.php?i="+teacherID+"&gs="+globalSessionID+"&qwert="+new Date().getTime(), true);
	mygetrequest.send(null);					
}

function ClickTab(sentTabName,teacherID){	 
//window.status = window.status + '-3237'
		globalActiveTab = sentTabName;
		HighlightTab('over',sentTabName);
		switch(sentTabName){
				case 'scheduletab':
						GetScheduleTab(teacherID);
						break;
				case 'coursetab':
						GetCasasTestsTab(teacherID);
						break;
				case 'casastab':
      GetCasasIntervalsTab(teacherID);
						break;
				case 'misctab':
      GetTeacherHomeTab(teacherID);
						break;																				
		}
		document.getElementById('tabcontent').scrollTop = 0;
}



function HighlightTab(overOrOut,sentTabName){
	//window.status = window.status + '-3350'
		//-- put lines under non-used tabs --
		var onColor = 'rgb(254,255,151)'; //same as css #tabcontent,.tabdiv, .tabdoublediv
		var offColor = 'black';
		//--- turn them all off --	
		document.getElementById('scheduletab').style.borderBottomColor = offColor;	
		document.getElementById('coursetab').style.borderBottomColor = offColor;	
		document.getElementById('casastab').style.borderBottomColor = offColor;	
		document.getElementById('misctab').style.borderBottomColor = offColor;	
		//--- turn the sent tab on or off depending on whether its a mouseout or mouseover operation --
		if(overOrOut == 'over'){
				document.getElementById(sentTabName).style.borderBottomColor = onColor;
		}else{
				//-- mouseout ---
				document.getElementById(sentTabName).style.borderBottomColor = offColor;
		}					
		//-- turn on the global tab----
		document.getElementById(globalActiveTab).style.borderBottomColor = onColor;
			
}
		
		
  

function GetExpDate(days, hours, minutes) {
	//window.status = window.status + '-3375'
    var expDate = new Date( );
    if (typeof days == "number" && typeof hours == "number" && typeof hours == "number") {
        expDate.setDate(expDate.getDate( ) + parseInt(days));
        expDate.setHours(expDate.getHours( ) + parseInt(hours));
        expDate.setMinutes(expDate.getMinutes( ) + parseInt(minutes));
        return expDate.toGMTString( );								
    }				
}





function SaveTeacherHome(teacherID){
	//window.status = window.status + '-3390'
 	//--- sends info from teachertable and nothing comes back ---
		var user = document.tchrrecform.tchrusername.value;//
		var pass = document.tchrrecform.tchrpass.value;//
		var first = document.tchrrecform.tchrfirst.value; //
		var last = document.tchrrecform.tchrlast.value;//
		var sal = document.tchrrecform.tchrsal.value;//
		var classroomComputer = '0';
  if(document.tchrrecform.audioalertcheck.checked == true){
			  var audioAlert = 1;
		}else{
			  var audioAlert = 0;
		}
		var mygetrequest=new ajaxRequest();
		mygetrequest.onreadystatechange=function(){
		if (mygetrequest.readyState==4){
				if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
						//--- Here is where all the info comes back which ain't nothing in this case-------	
					 	//alert (mygetrequest.responseText); 
							//window.status = "SaveTeacherHome loaded  ";
				}//if (mygetrequest.status==200
		}//if (mygetrequest.readyState==4){
	}//mygetrequest.onreadystatechange=function()		
	mygetrequest.open("GET", "SaveTeacherHome.php?i="+teacherID+"&user="+user+"&first="+first+"&last="+last+"&sal="+sal+"&pass="+pass+"&aud="+audioAlert+"&gs="+globalSessionID+"&qwert="+new Date().getTime(), true);	
	mygetrequest.send(null);	
}

function OneMinuteAutoLogout(){
	//window.status = window.status + '-3418'
	 if(disableAutoLogOut == true){
			  return
		}	
		try{
				clearInterval(oneMinuteLogoutTimerID);
		}
		catch(e){
					var x = 8; //for ie
		}	
		UpdateMainPage('logout','','',0,0,0);
}

function AutoLogout(){
	//window.status = window.status + '-3432'
	 if(disableAutoLogOut == true){
			  return
		}
		try{
				clearInterval(autoLogoutTimerID);
		}
		catch(e){
					var x = 8; //for ie
		}	
		try{
				clearInterval(longAutoLogoutTimerID);
		}
		catch(e){
					var x = 8; //for ie
		}			
	 UpdateMainPage('logout','','',0,0,0);
}

function LongAutoLogout(){
	//window.status = window.status + '-3452'
	 if(disableAutoLogOut == true){
			  return
		}	
		try{
				clearInterval(longAutoLogoutTimerID);
		}
		catch(e){
					var x = 8; //for ie
		}	
	 UpdateMainPage('logout','','',0,0,0);
}



function UpdateMainPage(sentAction, sentUsername, sentPassword, sentAssNum, sentFrame, sentStuID){
	//window.status = window.status + '-3468'
	// --- Note: the data SENT to GetPageInf.php is at the BOTTOM of this function --- 

//alert('in update: ' + sentAction + ' ' + sentAssNum + ' ' + sentFrame + ' ' + sentUsername + ' ' + sentPassword);  
  globalDocsForBrowseHelp = false;
  globalTextToggleEnabled = true;
		globalStudentRecordActive = false;
		SetAssignmentNamePointer('off');
		globalUsernameValue = '';

		var cc = GetCookie('cc');
		var tc = GetCookie('tc');
		var rc = GetCookie('rc');		
		
	 try{
				clearInterval(setUserFocusTimerID);
		}
		catch(e){
					var x = 8; //for ie
		}						
		try{
				clearInterval(autoLogoutTimerID);//
		}
		catch(e){
					var x = 8; //for ie
		}		
		try{
				clearInterval(longAutoLogoutTimerID);
		}
		catch(e){
					var x = 8; //for ie
		}	
//		globalTextState = 'on'; //seekproblem
	 var mygetrequest=new ajaxRequest();
	 mygetrequest.onreadystatechange=function(){
	 if (mygetrequest.readyState==4){
	  if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
	    //--- Here is where all the info comes back at -------
				//window.status = "UpdateMainPage loaded  ";
					var partsArray = mygetrequest.responseText.split('@@@@');
//  alert(sentAction + '  ' + mygetrequest.responseText)				//phperror see it here!
					globalTopBlurb = partsArray[0];
					var stuName = partsArray[1];					
					var text = partsArray[2];					
					var imageFileName = partsArray[3];
					var imageHeight = partsArray[4]; //-- the native width returned from php
					var imageWidth = partsArray[5]; //-- the native height returned from php
					var returnedStuID = partsArray[6];
					var showControls = partsArray[7];  //0=no,  1=yes
					var loginStatus = partsArray[8]; //studentok, teacherok or fail
					globalAudioFileNameRoot = partsArray[9]; //'' means no file is available -- the mp3 and ogg extensions are added in the player					
					var showPrint = partsArray[10]; //0 or 1
					var question = partsArray[11];
					var answer = partsArray[12];
					if(answer == ''){//0 or 1 (is a problem whose answer is not "noanswer' or '', eg, a real answer is required)
					  var hasAnswer = 0;
					}else{
						var hasAnswer = 1;
					}
					var globalFrame = partsArray[13]; // frame=0 means the student isn't working on anything so we'll later show text.  Otherwise
					 // we hide the text since the .wav voice is reading it.  
					//alert('loginstatus = ' + 	loginStatus)																									
					globalProblemSelectHTML = partsArray[14];				
					globalAudioBlurbFileNameRoot = partsArray[15];					
					globalResponseTextHTML = partsArray[16];				
					globalTopLinkHTML = partsArray[17];				
					globalButtonHTML = partsArray[18];	
					globalMainTextHTML = partsArray[19];	
					globalSuffixFileRoot = partsArray[20];	
					globalSuffixText = partsArray[21];
					globalSuffixSpanText = partsArray[22];
					globalPrefixFileRoot = partsArray[23];	
					globalPrefixText = partsArray[24];
					globalPrefixSpanText = partsArray[25];			
					globalMainSpanTextHTML = partsArray[26];	
					studentLanguagePref = partsArray[27];
					studentTextPref = partsArray[28];
					studentMaxPref = partsArray[29];
					globalForceShowText = partsArray[30];
					globalSessionID = partsArray[31]; 
					globalRosterContents = partsArray[32];
					autoLogOut = partsArray[33];
					longAutoLogOut = partsArray[34];
					fullPageData = partsArray[35];
					globalTeacherID = partsArray[36]; //used only for logging out --and try to keep it that way
					var teacherID = partsArray[36];
					globalRosterClassRadioHTML = partsArray[37];
					globalRosterClassName = ReplaceSpacesWithNonBreakingSpaces(partsArray[38]);
					generalInfo = partsArray[39];
					globalTeacherAudioAlerts = partsArray[40]; // 1 or 0
					var studentLogInAlert = partsArray[41]; // 1 or 0 --indicates to audio notify the teacher
					var studentCourseID = partsArray[42]; 
					var perpetualTextInput = partsArray[43];
					var rosterMetric1Name = partsArray[44];
					var rosterMetric5Names = partsArray[45];
					var teacherSalutation = partsArray[46];
//alert('tid = ' + teacherID)
											//	var firstTen = rosterContents.substr(400,20);
										//		document.title  = document.title + ' a:'+firstTen;		
					//--- taking out prefix and suffix timer audio until I can get it to work reliably 
					globalSuffixFileRoot = '';
					globalSuffixText = '';
					globalSuffixSpanText = '';
					globalPrefixFileRoot = '';
					globalPrefixText = '';
					globalPrefixSpanText = '';		
 
     if(generalInfo == 'startflashing'){
						  FlashingBackground('on');
					}else{
						  FlashingBackground('off');
					}
    
				 if(studentLogInAlert == 1){
						  WriteFileNotice(teacherID); //so the teacher can be audio alerted
					}

     if(globalTeacherAudioAlerts == 1){						  
       ChangeAudioAlerts(1,teacherID); //turn it on
					}else{
					  ChangeAudioAlerts(0,0); //turn it off
					}
 
					//--- used now only for returning initial fullpage data for the student (eg, contract list and next action button) --toplink
					document.getElementById('fullpagedatadiv').innerHTML = fullPageData;

					//--- this and that clean up ---
					if(((sentAction == 'login')||(sentAction == 'prismlogin'))&&(loginStatus != 'fail')){						
					  //------ normal - audio on and text off ---
						 SetStudentUIPreferences(studentLanguagePref, studentTextPref, studentMaxPref);
							if(loginStatus == 'studentok'){								 
								  if(longAutoLogOut > 0){
											 //alert('in da long groove')
												if(longAutoLogOut == 1){
													 //-- medium time : enough to click a menu item if desired --
								      longAutoLogoutTimerID = setInterval("LongAutoLogout()",5000); //5 seconds--fires even if auto log out wasn't enabled (for students who have a message but just leave it on the screen and don't log out manually after reading it)
												}
												if(longAutoLogOut == 2){
													 //-- long time : to read a message that has been sent (casas or teacher) --
								      longAutoLogoutTimerID = setInterval("LongAutoLogout()",60000); //60 seconds--fires even if auto log out wasn't enabled (for students who have a message but just leave it on the screen and don't log out manually after reading it)
												}												
										}									
										if(autoLogOut == 1){
							     autoLogoutTimerID = setInterval("AutoLogout()",2000); //2 seconds seems good
										}
							}
					}
					if(loginStatus == 'fail'){						
					  //-- show what the problem was ---
						 document.getElementById('mainalertdiv').innerHTML = globalTopBlurb;
       document.getElementById('user').value = '';
							document.getElementById('pass').value = '';
							StartUserFocus();
					}					

					switch (loginStatus){

								case 'gedtesterok':
								  ClearAllTimers();										
										if(sentAction == 'gedtesterlogout'){
											 SetBackground('student');
											 RestoreDefaultLoginState();
												SizeImageAndCenterMainDivDetail();	//Detail is ok since this is a one-shot deal
										}else{											
											// SetBackground('teachervisitor');
											 document.getElementById('maindiv').innerHTML = "<div id='fullmaindiv'></div>";
												document.getElementById('fullmaindiv').innerHTML = fullPageData;
												SizeImageAndCenterMainDivDetail();
										}
								  break;

								case 'visitorok':								  
								  ClearAllTimers();							
									//document.title = "Working Teacher Visitor of "+ teacherSalutation;	
									document.title  = document.title + ' visok ';
										if(sentAction == 'vislogout'){
											 SetBackground('student');
											 RestoreDefaultLoginState();
												SizeImageAndCenterMainDivDetail();	//Detail is ok since this is a one-shot deal
										}else{
											 SetBackground('teachervisitor');

											 document.getElementById('responsetextdiv').innerHTML = ''; //August
										//		var firstTen = rosterContents.substr(400,20);
										//		document.title  = document.title + ' b:'+firstTen;			
												LoadRosterContents(globalRosterContents); 
            LoadBlankHelpSelectorDiv();
            LoadRosterClassName(); //uses globalRosterClassName
            LoadRosterRadioButtons();	// uses globalRosterClassRadioHTML												
												//--- need to load toplinks, teacherData, mainAlert, and buttons ---
												LoadMainElements();								
												//-- these are used for restoring basic teacher controls after deleting a student --
												document.getElementById('rostermetric1name').innerHTML = rosterMetric1Name;
												document.getElementById('rostermetric5names').innerHTML = rosterMetric5Names;
												globalBasicTeacherTopLinkHTML = globalTopLinkHTML;	
												globalBasicTeacherButtonHTML = globalButtonHTML;			
												globalBasicTeacherTopBlurb = globalTopBlurb;
												SizeImageAndCenterMainDivDetail();
										}
								  break;

								case 'teacherok':								  
								  ClearAllTimers();										
										if(sentAction == 'tchrlogout'){
											 SetBackground('student');
											 RestoreDefaultLoginState();
												SizeImageAndCenterMainDivDetail();	//Detail is ok since this is a one-shot deal
										}else{									
										  SetBackground('teachervisitor');
										  document.getElementById('responsetextdiv').innerHTML = ''; //August
												document.getElementById('perpet').innerHTML = perpetualTextInput;
												document.getElementById('perpetualtext').focus();
												LoadRosterContents(globalRosterContents); 
            LoadBlankHelpSelectorDiv();
            LoadRosterClassName(); //uses globalRosterClassName
            LoadRosterRadioButtons();	// uses globalRosterClassRadioHTML			
												//--- need to load toplinks, teacherData, mainAlert, and buttons ---
												LoadMainElements();
												//-- these are used for restoring basic teacher controls after deleting a student --
												document.getElementById('rostermetric1name').innerHTML = rosterMetric1Name;
												document.getElementById('rostermetric5names').innerHTML = rosterMetric5Names;
												globalBasicTeacherTopLinkHTML = globalTopLinkHTML;	
												globalBasicTeacherButtonHTML = globalButtonHTML;			
												globalBasicTeacherTopBlurb = globalTopBlurb;
												SizeImageAndCenterMainDivDetail();
										}
								  break;
										
								case 'studentok':								
								  SetBackground('student');
						    document.title = stuName + "'s WorkingTeacher";					
										
										switch (sentAction){															
													case 'logout':							
															ClearAllTimers();
												 		RestoreDefaultLoginState();
											  	//	LoadMainElements('');
																
															AudioPlayer('');
															globalImageName = '';
               StartUp('keepBrowseHelp'); //puts everything back real nice
										  			SizeImageAndCenterMainDivDetail();	//Detail is ok since this is a one-shot deal
															document.getElementById('i').value = '';
															break;
												
												case 'login':
												case 'prismlogin':
												 // alert('hello')
													
												  document.getElementById('responsetextdiv').innerHTML = 'hey whats going on here anyway'; //August
												  LoadMainElements();		
														if ($("#fastlogout").length > 0){//using jquery to check for existence of a particular object
														  document.getElementById('fastlogout').focus();
														}
												  break;
											/*				
													case ((globalSuffixFileRoot== '')&&(globalPrefixFileRoot == '')):					
													  document.getElementById('i').value = returnedStuID ;	
															//-- normal: no prefix or suffix ---							
															if(studentCourseID > 0){
																  // -- load the student's current work --
																		ClickedGetStudentCurrentWork(returnedStuID);
																
															}else{
																	//--- Do the traditional thing -------------											
																	LoadMainElements();		
																	//--- Fill up the more complex elements --------
																		AudioPlayer(globalAudioFileNameRoot); 					
																	//--- update javascript vars ----------																								
																	//------ update the global javascript vars ---------
																	globalImageName = imageFileName;
																	if((globalAudioFileNameRoot == '')&&(globalImageName == '')){
																				//--super simple situation, no need for sizing delay (which causes a jump) --
																				SizeImageAndCenterMainDivDetail();
																	}else{
																			SizeImageAndCenterMainDiv();
																	}
															}
															break;
															
													case ((globalSuffixFileRoot!= '')&&(globalPrefixFileRoot == '')):
															//-- just a suffix ---
															//alert('spot3')
															//--- Fill Em Up -------------
																LoadMainElements();		
															//--- Fill up the more complex elements --------
																	AudioPlayer(globalSuffixFileRoot); 					
															//--- update javascript vars ----------
																document.getElementById('i').value = returnedStuID ;										
															//------ update the global javascript vars ---------
																globalImageName = imageFileName;
																if(globalAudioFileNameRoot != ''){
																		takeActionTimerID = setInterval("TakeActionWhenAudioEnds('playmainaudiosizeandcentermaindiv')",200); //polls the player state
																}else{
																	takeActionTimerID = setInterval("TakeActionWhenAudioEnds('sizeandcentermaindiv')",200); //polls the player state		
																}											
																
															break;										
															
													case ((globalSuffixFileRoot== '')&&(globalPrefixFileRoot != '')):
												   //alert('spot4 ' + globalPrefixFileRoot)
															//-- just a prefix ---
														//	alert('just prefix')
															//--- Fill Em Up -------------
															LoadMainElements();					
															//--- Fill up the more complex elements --------
																AudioPlayer(globalPrefixFileRoot); 					
															//--- update javascript vars ----------
															document.getElementById('i').value = returnedStuID;										
															//------ update the global javascript vars ---------
															globalImageName = imageFileName;
															SizeImageAndCenterMainDiv();
															//------ play main audio when prefix audio ends -----
															if(globalAudioFileNameRoot != ''){
																// alert('if')
																	takeActionTimerID = setInterval("TakeActionWhenAudioEnds('playmainaudio')",200); //polls the player state
															}else{
																	//alert(' else ')			
															}
															break;			
													case ((globalSuffixFileRoot!= '')&&(globalPrefixFileRoot != '')):
													  //alert('spot5')
															//-- both a suffix and a prefix ---
															//	alert('suffix and prefix')
															if(globalAudioFileNameRoot != ''){
																	// -- there is some main audio ---
																	takeActionTimerID = setInterval("TakeActionWhenAudioEnds('playmainaudiosizeandcentermaindivstartprefix')",200); //polls the player state
															}else{
																		// --- there is not any main audio --------
																	takeActionTimerID = setInterval("TakeActionWhenAudioEnds('sizeandcentermaindivstartprefix')",200); //polls the player state													
															}
															//--- Fill Em Up -------------
															LoadMainElements();				
															//--- Fill up the more complex elements --------
																AudioPlayer(globalSuffixFileRoot); 					
															//--- update javascript vars ----------
															document.getElementById('i').value = returnedStuID ;										
															//------ update the global javascript vars ---------
															globalImageName = imageFileName;
															SizeImageAndCenterMainDiv();
															break;				
													*/
													
										} // end of switch 
										
										//-- THE FOLLOWING CLEAN-UP STUFF APPLIES NO MATTER IF A PREFIX OR SUFFIX IS RETURNED --
			
										//-- turn off the possibly flashing responseText background (may be turned on below)-----
										try{
												clearInterval(flashResponseTextDivTimerID);
										}
										catch(e){
													var x = 8; //for ie
										}
										//-- if the response text box is present, give it the focus ---
										try{
											oResponseText = document.getElementById('responsetext');
											oResponseText.focus();
										}
										catch(e){
													var x = 8; //for ie
												//-- if it doesn't run no problem --
										}													
										globalPreviousNextTimerOperating = false; 
										
								default:
								  SetBackground('student');
								  if(sentAction == 'logout'){
											  RestoreDefaultLoginState();
										}
					} //switch loginstatus
					
					
					//if(sentAction == 'tchrlogout'){  //logout
					 //	document.getElementById('fullpagedatadiv').innerHTML = ''; 
						// LoadBrowseHelpContents(-1,'student');
						// document.getElementById('i').value = '';
			//	}
	  }//if (mygetrequest.status==200
	 }//if (mygetrequest.readyState==4){
	}//mygetrequest.onreadystatechange=function()  tchrid teacherid
    // -- we send what we have and let GetPageInf sort it all out ----------imageaudioPlayer
				
	 stuID = document.getElementById('i').value;
		cResponse = '';
		try{
				cResponse = document.getElementById('responsetext').value;
			//alert('whoa' + cResponse)
		}
		catch(e){
					var x = 8; //for ie //teacherdata
		}		

//sentAction
//alert('before myrequest:' + debug);  loginstatus  fullpagedata  visitor

	mygetrequest.open("GET", "GetPageInfo.php?p="+sentPassword+"&u="+sentUsername+"&f="+sentFrame+"&c="+sentAction+"&i="+stuID+"&r="+cResponse+"&a="+sentAssNum+"&lp="+globalLanguage+"&tp="+globalTextState+"&mp="+globalMaxState+"&gs="+globalSessionID+"&cc="+cc+"&tc="+tc+"&rc="+rc+"&qwert="+new Date().getTime(), true);
	mygetrequest.send(null);
} //function UpdateMainPage  responsetextdiv  teacherid did not enter  loadbrowse


function SetBackground(sentUserType){
	 switch(sentUserType){
			 case 'student':
				
				  break;
				case 'teacher':
				
				  break;
		}
}

function ChangeAudioAlertsButtonClick(tchrID,sentObj){
	//window.status = window.status + '-3837'
	//-- note: this doesn't change it permanently but just for the current session --
	if(sentObj.checked == true){
		  ChangeAudioAlerts(1,tchrID); //turn it on
	}else{
		  ChangeAudioAlerts(0,tchrID); //turn it off
	}
}

function ChangeAudioAlerts(onOrOff,tchrID){
	return;  //taken out September 14 -- for debugging general errors
	//window.status = window.status + '-3847'
	 if(onOrOff == 1){
			 //-- turn it on --
				globalTeacherAudioAlerts = 'on';
	   globalLastTeacherAudioAlertTime = Math.round(new Date().getTime() / 1000);  
		  checkForTeacherAlertTimerID = setInterval("CheckForTeacherAlert("+tchrID+")",2000);	
		}else{
			  globalTeacherAudioAlerts = 'off';
    try{
     clearInterval(checkForTeacherAlertTimerID);
    }
    catch(e){
     //suppress error
    }			
			 
		}
}

function WriteFileNotice(tchrID){
	//window.status = window.status + '-3866'
	 //-- so the teacher can be notified of an event --
	 var mygetrequest=new ajaxRequest();
		mygetrequest.onreadystatechange=function(){
		if (mygetrequest.readyState==4){
				if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
						//--- Here is where all the info comes back which ain't nothing in this case-------	
						// alert(mygetrequest.responseText);
						//window.status = "WriteFileNotice loaded  ";
				}//if (mygetrequest.status==200
		}//if (mygetrequest.readyState==4){
	}//mygetrequest.onreadystatechange=function()		
	mygetrequest.open("GET", "WriteFileNotice.php?i="+tchrID+"&qwert="+new Date().getTime(), true);
	mygetrequest.send(null);						
}

function PlayAudioAlertAndCancelAlert(tchrID){		 
//window.status = window.status + '-1'
		if ($("#iamteachermatcheck").length > 0){//using jquery to check for existence of a particular object
		  //--- if the teacher's material checkout screen is open, refresh it ---
    GetMaterialsCheckout(tchrID);
		}  
		if ($("#iamtodaysattendees").length > 0){//using jquery to check for existence of a particular object
		  //--- if the teacher's material checkout screen is open, refresh it ---
    ClickedTodayRadio(tchrID,'');
		}  		
		PlayAudioAlert();		
	 var mygetrequest=new ajaxRequest();
		mygetrequest.onreadystatechange=function(){
		if (mygetrequest.readyState==4){
				if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
						//--- Here is where all the info comes back which ain't nothing in this case-------	
						// alert(mygetrequest.responseText);
						//window.status = "PlayAudioAlertAndCancelAlert loaded  ";
				}//if (mygetrequest.status==200
		}//if (mygetrequest.readyState==4){
	}//mygetrequest.onreadystatechange=function()		
	mygetrequest.open("GET", "ClearFileNotice.php?i="+tchrID+"&qwert="+new Date().getTime(), true);
	mygetrequest.send(null);				
}

function PlayAudioAlert() {
	 return;
		//window.status = window.status + '-2'
	 soundobj = 'storechimesound'; //this is an object in the index that indicates the actual wave file to be played (storechime.wav)
  var thissound= eval("document."+soundobj);
  thissound.Play();
}

function CheckForTeacherAlert(tchrID){
	//window.status = window.status + '-3'
	 var mygetrequest=new ajaxRequest();
		mygetrequest.onreadystatechange=function(){
		if (mygetrequest.readyState==4){
				if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
						//--- Here is where all the info comes back which ain't nothing in this case-------	
						// alert(mygetrequest.responseText);
						//window.status = "CheckForTeacherAlert loaded  ";
					 var teacherAlertStatus = mygetrequest.responseText; 
						if(teacherAlertStatus == 1){
							// PlayAudioAlertAndCancelAlert(tchrID);  September 14 removed
						}
				}//if (mygetrequest.status==200
		}//if (mygetrequest.readyState==4){
	}//mygetrequest.onreadystatechange=function()		
	mygetrequest.open("GET", "CheckTeacherAlertStatus.php?i="+tchrID+"&qwert="+new Date().getTime(), true);
	mygetrequest.send(null);	
}

function FlashingBackground(onOrOff){
	//window.status = window.status + '-4'
	 if(onOrOff == 'on'){
			 //-- make sure we don't have more than one of them going at the same time due to some programming carelessness ---
				try{
						clearInterval(flashingBackgroundTimerID);
				}
				catch(e){
						x = 8; //for IE						
				}			
			 globalFlashingStatus = 'off';
			 SetFlashingBackgroundColor(globalFlashingStatus); 
			 flashingBackgroundTimerID = setInterval("FlashingBackgroundTimer()",700);	
		}else{
				try{
						clearInterval(flashingBackgroundTimerID);
				}
				catch(e){
						x = 8; //for IE						
				}
				SetFlashingBackgroundColor('off');
		}
}

function FlashingBackgroundTimer(){	  
//window.status = window.status + '-5'
	 if(globalFlashingStatus == 'off'){
			 globalFlashingStatus = 'on';
		}else{
			 globalFlashingStatus = 'off';
		}
		SetFlashingBackgroundColor(globalFlashingStatus);
}

function SetFlashingBackgroundColor(onOrOff){
	//window.status = window.status + '-6'
  if(onOrOff == 'on'){
			  var backgroundColor = 'red';
					var textColor = 'white';
					var mainAlertColor = 'white';
		}else{
			  var backgroundColor = 'white';
					var textColor = 'black';
					var mainAlertColor = '#333333';
		}
		document.getElementById('shadowmaindiv').style.backgroundColor = backgroundColor;
		document.getElementById('maindiv').style.color = textColor;
		document.getElementById('mainalertdiv').style.color = mainAlertColor;		
}



function SizeAndCenterWorksheetPage(){
	//window.status = window.status + '-7'
	 var topOrBottomMargin = 15; //minimum gap at top and bottom outside main div and viewport
		var oMainDiv = document.getElementById('maindiv');
		var oShadowDiv = document.getElementById('shadowmaindiv');
		var oSitOnTop = document.getElementById('sitontop');
		oMainDiv.style.visibility = 'visible';		
		oShadowDiv.style.visibility = 'visible';	
 //	var viewportH = GetViewportHeightIncludingScrollBar();			
// 	var viewportW = GetViewportWidthIncludingScrollBar();	
		if (viewportH <= 400){
			 mainDivH = 400; // minimum height
				var topMargin = oSitOnTop.offsetHeight;
				var bottomMargin = 0;
		}else{
			 var topMargin = 30;
				var bottomMargin = 20;
		  var mainDivH = viewportH - topMargin - bottomMargin;
		}  
		if (globalViewportW <= 700){
				var leftMargin = 0;
				var rightMargin = 0;
				var mainDivW = 700; // minimum width
		}else{
				var leftMargin = 10;
				var rightMargin = 10;
				var mainDivW = globalViewportW - leftMargin - rightMargin;
		}				
		oMainDiv.style.height = mainDivH + 'px';
		oShadowDiv.style.height =  mainDivH + 'px';	
		oMainDiv.style.top =  topMargin + 'px';
		oShadowDiv.style.top =  topMargin + 'px';
		oMainDiv.style.width = mainDivW + 'px';
		oShadowDiv.style.width =  mainDivW + 'px';			
		var sitOnTopTop = topMargin - oSitOnTop.offsetHeight;
		oSitOnTop.style.top = sitOnTopTop + 'px';
		oMainDiv.style.left = leftMargin + 'px';
		oShadowDiv.style.left = leftMargin + 'px';	
		oShadowDiv.style.left = leftMargin + 'px';		
}


function InternetExplorerFontChangeDetector(){
	//window.status = window.status + '-8'
	 //-- Mozilla and others will zoom a page which causes the page resize event to fire --
		//-- Internet Explorer does not, but onResize code in the emObject WILL fire and so we'll catch zoom (er front change) that way
	 SizeImageAndCenterMainDiv();
}
  


function ChangedContractRecForm(){
	//window.status = window.status + '-9'
	  var courseID = document.sturecform.stucontract.value;			
			//UpdateHighestContractPassed(courseID,0);
			//UpdateContractAssignmentAndFrame(courseID,'firstassignment',1); //11-7-10 taken out since we use the whole page contract form now
			//--- this can cause the table to grow too wide to fit in the data area --
		//	SizeImageAndCenterMainDivDetail(); //11-7-10 taken out since not needed 
}

function ChangedContractConForm(){
	//window.status = window.status + '-10'
	  var courseID = document.sturecform.stucontract.value;			
		//	UpdateHighestContractPassed(courseID,0);
	//		UpdateContractAssignmentAndFrame(courseID,'firstassignment',1)
			//--- this can cause the table to grow too wide to fit in the data area --
			SizeImageAndCenterMainDivDetail();
}

function ChangedConAssignment(){
	//window.status = window.status + '-11'
		var numberOfFrames = document.sturecform.stuassignment.value;
		var assID = document.sturecform.stuassignment.assid;
		document.sturecform.hiddenstuconass.value = assID;
		UpdateContractFrame(numberOfFrames,1);		
}

function ChangedHelpStatus(){	 
//window.status = window.status + '-12'
  //ClearCasualHelpAssignmentAndFrame();
  if((document.sturecform.stucasualhelpcheck.checked == true)&&(document.sturecform.hiddenstuass.value==0)){	
		  //-- the user clicked to make help active but there is not help assignment in there ---
				document.sturecform.stucasualhelpcheck.checked = false;
				//-- This alert STAYS! ---------
				alert("Activate help by clicking on an assignment from the help list.");
		}
}



function DeleteStudentRecord(nagOrNot,studentID, teacherID,scope){
	//window.status = window.status + '-13'
	 if(nagOrNot == 'nag'){
		  var reply = confirm("are you sure?");
		}else{
			 reply = true;
		}
		if (reply == true){	
		  var studentID = document.sturecform.hiddenstuid.value;
				var mygetrequest=new ajaxRequest();
				mygetrequest.onreadystatechange=function(){
				if (mygetrequest.readyState==4){
						if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
								//--- Here is where all the info comes back which ain't nothing in this case-------		
							teacherTableHTML = mygetrequest.responseText;
					  globalTopLinkHTML = globalBasicTeacherTopLinkHTML;
					  globalButtonHTML = globalBasicTeacherButtonHTML;
							globalTopBlurb = globalBasicTeacherTopBlurb;							
       //--- need to load toplinks, teacherData, mainAlert, and buttons ---
							document.getElementById('fullpagedatadiv').innerHTML = teacherTableHTML;
							document.getElementById('verticalmenudiv').innerHTML = '';
							document.sturecform.hiddenstuid.value = 0;
							document.getElementById('stuidforscanner').value = 0;
							LoadMainElements(); //all this should be the same from the last teacher login
								// -- This is a nested ajax request for redoing the roster --						
								var mygetrequest2=new ajaxRequest();
								mygetrequest2.onreadystatechange=function(){
								if (mygetrequest2.readyState==4){
										if (mygetrequest2.status==200 || window.location.href.indexOf("http")==-1){
												//--- Here is where all the info comes back which ain't nothing in this case-------	
											// alert (mygetrequest2.responseText); 
											 //-- Get the index of the name being deleted so it's adjacent one can be selected after deletion from the roster list--
												/*
												var oRosterSelect = document.getElementById('rosterselect');
												var rosterSelectIndex = 0;
												for (var i=0; i<oRosterSelect.length; i++){
														var optionStuID = oRosterSelect.options[i].getAttribute('stuid');
														if(optionStuID == studentID){		
														  rosterSelectIndex = i;
																break;
														}
												}	*/																						
													var globalRosterContents = mygetrequest2.responseText;																	
													LoadRosterContents(globalRosterContents);
													/*
													var nextIndex = rosterSelectIndex + 1;
													if(oRosterSelect.options[nextIndex] == null){
														 var nextIndex = rosterSelectIndex - 1;
													}
													if(oRosterSelect.options[nextIndex] != null){
													  oRosterSelect.options[nextIndex].selected = true;
										     ClickRosterNameOrContract(studentID,'roster',teacherID,scope);
										     SetFocusToCurrentRosterName();																
													}
													*/
													SizeImageAndCenterMainDivDetail();
										
										}//if (mygetrequest2.status==200
								}//if (mygetrequest2.readyState==4){
							}//mygetrequest2.onreadystatechange=function()		
							var classNum = GetRosterRadioNumber();
							mygetrequest2.open("GET", "GetRosterContents.php?i="+teacherID+"&gs="+globalSessionID+'&cn='+classNum+"&qwert="+new Date().getTime(), true);
							mygetrequest2.send(null);									
							//--- end of nested ajax ---							
							
						}//if (mygetrequest.status==200
				}//if (mygetrequest.readyState==4){
			}//mygetrequest.onreadystatechange=function()		
			mygetrequest.open("GET", "DeleteStudentRecord.php?i="+studentID+"&gs="+globalSessionID+"&qwert="+new Date().getTime(), true);
			mygetrequest.send(null);		
	 }
}


function ClickedTeacherLogOut(teacherID){
	//window.status = window.status + '-14'
	 globalDocsForBrowseHelp = false;
	// alert('not finished 2-18-11');
}

function ChangedClassName(){
	//window.status = window.status + '-15'
	  //-- this updates the student class dur value when the class name is changed --
			var classNum = document.sturecform.stuclassnameselect.value;
			var idName = 'classnum' + classNum;
			var oHidden = document.getElementById(idName);
			if(oHidden != null){
				 document.sturecform.stuclassdur.value = oHidden.value;
			}
}


function SaveStudentRecord(newStuOrNot,studentID,teacherID,scope){
	//window.status = window.status + '-16'
  // --- takes what's on the form and saves it to the mysql table --
		var studentUsername = document.sturecform.stuuser.value;//
		var studentPassword = document.sturecform.stupass.value;//
		var studentFirstname = document.sturecform.stufirst.value; //
		var studentLastname = document.sturecform.stulast.value;//
		//var studentID = document.sturecform.hiddenstuid.value;
		//var highestPassedContractTest = document.sturecform.stucontracttested.value;
		var casasTestVersion = document.sturecform.stucasas.value;	
		var tookCasas = document.sturecform.stutookcasas.value;	
		var classDuration = document.sturecform.stuclassdur.value;	
		var classNum = document.sturecform.stuclassnameselect.value;
		var casasHrs = document.sturecform.stucasashrs.value;
  var noteToStudent = document.notetostuform.notetostutextarea.value;
		var noteAboutStudent = document.noteaboutstuform.noteaboutstutextarea.value;
		var rfid = document.getElementById('rfidtext').value;

		switch (scope){
					case 'full':
							var languagePref = document.sturecform.stulanguagepref.value;
				                                       			
							var textPref = document.sturecform.stutextpref.value;
							var maxPref = document.sturecform.stumaxpref.value;			 		
							//not installed on form yet? var stuConAssFrameArray = document.sturecform.stuassignment.value.split('@');
							var studentConAssignment = 0; //var studentConAssignment = stuConAssFrameArray[0]; 
							var studentConFrame = 0; //not on form yet? var studentConFrame = document.sturecform.stucontractframe.value;			
							var studentCourseID = document.sturecform.stucontract.value;
							var studentPretestID = document.sturecform.stupretest.value;
							var studentAssignment = 0; //not installed on form yet? var studentAssignment = document.sturecform.hiddenstuass.value;
							var studentFrame = document.sturecform.stucasualhelpframe.value;
							if(document.sturecform.stucasualhelpcheck.checked == true){				
									var studentHelpStatus = 'help';
							}else{
									var studentHelpStatus = '';
							}				
			    break;
			default:				
			  // -- eg, a student whose teacher is using wt just for casas ---
				var languagePref = 'na'; 
				var textPref = 'na';
				var maxPref = 'na';
				//var globalOGCourseID = 0; 
				var globalOriginalPretestID = 0;
				var studentConAssignment = 0;  
				var studentConFrame = 0; 
		  var studentCourseID = 0;
				var studentPretestID = 0;
		  var studentAssignment = 0;
	  	var studentFrame = 0;
				var studentHelpStatus = 'na';				
				break;
		}

		if(document.sturecform.concurrentcheckbox.checked == true){
			 var concurrent = 1;				
		}else{
			 var concurrent = 0;
		}
	
		var mygetrequest=new ajaxRequest();
		mygetrequest.onreadystatechange=function(){
		if (mygetrequest.readyState==4){
				if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
						    //--- Here is where all the info comes back which ain't nothing in this case-------	
								//	alert(mygetrequest.responseText);
								//window.status = "SaveStudentRecord loaded  ";
								 	var partsArray = mygetrequest.responseText.split('@@@@');
								 	var usernameStatus = partsArray[0];						
									 var passwordStatus = partsArray[1];	
									//	alert(usernameStatus + '  ' + passwordStatus)
										
										switch(true){
											  case ((usernameStatus == 'inuse')&&(passwordStatus == 'inuse')):
												    ShowFloatingHelp('passwordandusernametaken','small');
										      break;
											  case (usernameStatus == 'inuse'):
												   ShowFloatingHelp('usernametaken','small');
										      break;
											  case (passwordStatus == 'inuse'):
													   ShowFloatingHelp('passwordtaken','small');
										      break;						
										}
										// -- This is a nested ajax request for redoing the roster --						
										var mygetrequest2=new ajaxRequest();
										mygetrequest2.onreadystatechange=function(){
										if (mygetrequest2.readyState==4){
												if (mygetrequest2.status==200 || window.location.href.indexOf("http")==-1){
														//--- Here is where all the info comes back which ain't nothing in this case-------	
													// alert ('two-- ' + mygetrequest2.responseText); 
															var globalRosterContents = mygetrequest2.responseText;																	
															LoadRosterContents(globalRosterContents);																			
												}//if (mygetrequest2.status==200
										}//if (mygetrequest2.readyState==4){
									}//mygetrequest2.onreadystatechange=function()		
									var classNum = GetRosterRadioNumber();
								//	alert('tid=' + teacherID)
									mygetrequest2.open("GET", "GetRosterContents.php?i="+teacherID+"&gs="+globalSessionID+'&cn='+classNum+"&qwert="+new Date().getTime(), true);
									mygetrequest2.send(null);									
									//--- end of nested ajax ---				

							
							//-- reload to get possible new elements --
							ClickRosterName(studentID,teacherID); 
												
				}//if (mygetrequest.status==200
		}//if (mygetrequest.readyState==4){
	}//mygetrequest.onreadystatechange=function()		
//	alert('OGC for url:' + globalOGCourseID)
	 var urlVarString = "pass="+studentPassword+"&user="+studentUsername+"&first="+studentFirstname+"&last="+studentLastname+"&i="+studentID+"&c="+studentCourseID+"&pre="+studentPretestID+"&oc="+globalOGCourseID+"&opre="+globalOGPretestID+"&ass="+studentAssignment+"&frame="+studentFrame+"&help="+studentHelpStatus+"&lang="+languagePref+"&text="+textPref+"&max="+maxPref+"&classdur="+classDuration+"&class="+classNum+"&casas="+casasTestVersion+"&casashrs="+casasHrs+"&tookcasas="+tookCasas+"&conc="+concurrent+"&notetostu="+noteToStudent+"&noteaboutstu="+noteAboutStudent+"&rfid="+rfid+"&gs="+globalSessionID;
		//alert(urlVarString)
	mygetrequest.open("GET", "SaveStudentRecord.php?"+urlVarString+"&qwert="+new Date().getTime(), true);
	mygetrequest.send(null);	
}
//contract

function AlertCasasDefaults(){
	//window.status = window.status + '-17'
	 // ---- superceeded by ShowCasasDefaults --------
		alertcode = '------------------------CASAS Test Defaults-----------------------\n\nBasic Math-Beginning(53-03-71)..........33M | 34M (bef.2-H)\n\nBasic Math-Intermediate(53-03-72).....33M | 34M (bef.2)\n\nBasic Math-Advanced(53-03-73).........35M | 36M (bef.4)\n\nIntegrated Math(31-01-61/2/3/4).......37M | 38M (bef.5)\n\nAlgebra 1AB(31-02-71/2)...............505M | 506M (bef.4)\n\nGeometry 1AB(31-03-71/2)............505M | 506M (bef.4)\n\nCAHSEE Prep-Math(31-01-65)........37M | 38M (bef.test)\n\nGED Prep-Math(30-50-71).............37M | 38M (bef.test)\n\n';
		alert(alertcode);
}


function ShowCasasDefaults(teacherID){
	//window.status = window.status + '-18'
	  //-- in the future, tie this to just the courses the teacher is interested in --
			globalDocsForBrowseHelp = false;
 	 ShowFloatingHelp('casasdefaults','normal');		
}

function ClickedManuallyClearCheckOut(studentID){
	//window.status = window.status + '-19'
			var mygetrequest=new ajaxRequest();
			mygetrequest.onreadystatechange=function(){
			if (mygetrequest.readyState==4){
					if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
							//--- Here is where all the info comes back which ain't nothing in this case-------				
						//alert(mygetrequest.responseText)			
	    	oCheckedOutItemSlot = document.getElementById('sturecordcheckedoutitemdiv');	
		    if(oCheckedOutItemSlot != null){			
						  //-- clear out the name of the item on the student record that WAS checked out --
						  oCheckedOutItemSlot.innerHTML = '';
						}
					}//if (mygetrequest.status==200
			}//if (mygetrequest.readyState==4){
		}//mygetrequest.onreadystatechange=function()		
		mygetrequest.open("GET", "ManuallyClearCheckOut.php?i="+studentID+"&gs="+globalSessionID+"&qwert="+new Date().getTime(), true);  
		mygetrequest.send(null);	

}

function ClickedOpenBarCodeScanner(teacherID){
	//window.status = window.status + '-20'
		RefreshBarCodeScanner('');
}

function RefreshBarCodeScanner(textValue){
	//window.status = window.status + '-21'
 	//alert('here go')
	 globalDocsForBrowseHelp = false;
		var stuIDForScanner = document.getElementById('stuidforscanner').value;	
	//	alert('coming in: ' + stuIDForScanner)
	//	if(globalLoadingMenuItem == false){
			  HighlightMenuText('hours');
			  globalLoadingMenuItem = true;
				var mygetrequest=new ajaxRequest();
				mygetrequest.onreadystatechange=function(){
				if (mygetrequest.readyState==4){
						if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
								//--- Here is where all the info comes back which ain't nothing in this case-------				
								//alert(mygetrequest.responseText)
						   var partsArray = mygetrequest.responseText.split('@@@@');
									var hitALiveOne =  partsArray[0];
								 var scannedStudentID = partsArray[1]; 	
									var barCodeScannerHTML = partsArray[2]; 
									var verticalMenuHTML = partsArray[3];
							//		var debug = verticalMenuHTML; //partsArray[4];
									
									  document.getElementById('verticalmenudiv').innerHTML = verticalMenuHTML;
											document.getElementById('mainbuttondiv').innerHTML = '';
											document.getElementById('mainalertdiv').innerHTML = '';
											globalTopBlurb = '';				
											document.getElementById('fullpagedatadiv').style.visibility = 'hidden';	
											document.getElementById('fullpagedatadiv').style.top = '-1000px';
											document.getElementById('fullpagedatadiv').innerHTML = barCodeScannerHTML;											
											SizeImageAndCenterMainDivDetail();				
											globalLoadingMenuItem = false;
											document.getElementById('barcodeinputtext').value = '';
											document.getElementById('barcodeinputtext').focus();
											if((scannedStudentID != '')&&(scannedStudentID != '0')){

													//-- a student scanned in with his RFID card --
													document.getElementById('stuidforscanner').value = scannedStudentID;
											}						
						}//if (mygetrequest.status==200
				}//if (mygetrequest.readyState==4){
			}//mygetrequest.onreadystatechange=function()		
			mygetrequest.open("GET", "GetBarCodeScanner.php?s="+stuIDForScanner+"&tv="+textValue+"&gs="+globalSessionID+"&qwert="+new Date().getTime(), true);  
			mygetrequest.send(null);	
//		}
}

function KeyPressHiddenBarCodeText(e){
	//window.status = window.status + '-22'
		var key;
			if(window.event)
								key = window.event.keyCode; //IE
			else
								key = e.which;     //firefox    
		if (key == 13){
				//-- the enter key was 'pressed' --
				var textValue = document.getElementById('barcodeinputtext').value;	
				if(textValue.length >= 9){
						//-- if it's 9 or longer, check it out --		

						document.getElementById('barcodeinputtext').value = ''; //clear it for the next entry
						RefreshBarCodeScanner(textValue);
				}
		}	

}



function ClickedAddNewStudentButtons(teacherID){
	//window.status = window.status + '-23'
 	//--- fills in teacher data with 2 buttons (single or 10) to choose how many you want to add  ---
		
	//	if(globalLoadingMenuItem == false){
		
			 HighlightMenuText('newstudent');
			 globalLoadingMenuItem = true;
				var mygetrequest=new ajaxRequest();
				mygetrequest.onreadystatechange=function(){
				if (mygetrequest.readyState==4){
						if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
								//--- Here is where all the info comes back which ain't nothing in this case-------	
							// alert (mygetrequest.responseText); 
							//window.status = "ClickedAddNewStudentButtons loaded  ";
							  var buttonHTML = mygetrequest.responseText;
									document.getElementById('mainalertdiv').innerHTML = '';							
									document.getElementById('fullpagedatadiv').style.visibility = 'hidden';	
									document.getElementById('fullpagedatadiv').style.top = '-1000px';
									document.getElementById('fullpagedatadiv').innerHTML = buttonHTML;			
									document.getElementById('verticalmenudiv').innerHTML = '';
									SizeImageAndCenterMainDivDetail();				
									globalLoadingMenuItem  = false;
						}//if (mygetrequest.status==200
				}//if (mygetrequest.readyState==4){
			}//mygetrequest.onreadystatechange=function()		
			mygetrequest.open("GET", "GetAddNewStudentButtons.php?i="+teacherID+"&gs="+globalSessionID+"&qwert="+new Date().getTime(), true);
			mygetrequest.send(null);	
		//		}
}




function GetAddMultipleStudentForm(teacherID){ 	
		// -- Get the class num radio val -----
		//window.status = window.status + '-24'
		objectArray = document.getElementsByName('newstuRadioGroup');
		for (var i = 0; i <objectArray.length; i++) {
				if(objectArray[i]){
						if (objectArray[i].checked == true){
									radioValue = objectArray[i].value;
									break;
							}//if					
				}
			}//for  					
			var classNumber = radioValue;		
		
		var mygetrequest=new ajaxRequest();
		mygetrequest.onreadystatechange=function(){
		if (mygetrequest.readyState==4){
				if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
						//--- Here is where all the info comes back which ain't nothing in this case-------	
					// alert (mygetrequest.responseText); 
					//window.status = "GetAddMultipleStudentForm loaded  ";
							var AddMultipleStudentFormHTML = mygetrequest.responseText;				
							globalTopBlurb = '';
							document.getElementById('mainalertdiv').innerHTML = globalTopBlurb;							
							document.getElementById('fullpagedatadiv').style.visibility = 'hidden';	
							document.getElementById('fullpagedatadiv').style.top = '-1000px';
       document.getElementById('fullpagedatadiv').innerHTML = AddMultipleStudentFormHTML;							
	      SizeImageAndCenterMainDivDetail();												
				}//if (mygetrequest.status==200
		}//if (mygetrequest.readyState==4){
	}//mygetrequest.onreadystatechange=function()		
	mygetrequest.open("GET", "GetAddMultipleStudentsForm.php?i="+teacherID+"&gs="+globalSessionID+"&cn="+classNumber+"&qwert="+new Date().getTime(), true);
	mygetrequest.send(null);	
}


function SetRosterRadioButtons(sentValue){
	//window.status = window.status + '-25'
		objectArray = document.getElementsByName('rosterRadioGroup');
  for (var i = 0; i <objectArray.length; i++) {
			 if(objectArray[i]){
					  if (objectArray[i].value == sentValue){
					    objectArray[i].checked = true;
									break;
							}				
				}
   }
}


function AddMultipleStudents(teacherID){
	//window.status = window.status + '-26'
	 var classNumber = document.multiplenewstuform.classnumber.value;
	// -- build strings for the first and last names ---
		var firstNameArrayString = '';
		var lastNameArrayString = '';
		var firstname= '';
		var lastname = '';
		var goofyChar = '^'; //must match what's in SaveMultipleNewStudents.php
			var elem = document.getElementById('multiplenewstuform').elements;
			for(var i=0; i<elem.length; i++){
					if(elem[i].type == 'text'){					
							if (elem[i].name.substr(0,8) == 'newfirst'){
									firstname = elem[i].value;
									firstname = firstname.replace(goofyChar,''); //for the rare chance that someone uses it
									firstNameArrayString = firstNameArrayString + firstname + goofyChar;
							}
							if (elem[i].name.substr(0,7) == 'newlast'){
									lastname = elem[i].value;
									lastname = lastname.replace(goofyChar,''); //for the rare chance that someone uses it
									lastNameArrayString = lastNameArrayString + lastname + goofyChar;
							}						
					}
			} 
		// -- get down to business ---	
		var mygetrequest=new ajaxRequest();
		mygetrequest.onreadystatechange=function(){
		if (mygetrequest.readyState==4){
				if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
						//--- Here is where all the info comes back which ain't nothing in this case-------	
					// alert (mygetrequest.responseText);
					//window.status = "AddMultipleStudents loaded  ";
							var AddMultipleStudentFormHTML = mygetrequest.responseText;				
							globalTopBlurb = '';
							document.getElementById('mainalertdiv').innerHTML = '';							
							document.getElementById('fullpagedatadiv').style.visibility = 'hidden';	
							document.getElementById('fullpagedatadiv').style.top = '-1000px';
       document.getElementById('fullpagedatadiv').innerHTML = AddMultipleStudentFormHTML;			
							// -- This is a nested ajax request for redoing the roster --						
							var mygetrequest2=new ajaxRequest();
							mygetrequest2.onreadystatechange=function(){
							if (mygetrequest2.readyState==4){
									if (mygetrequest2.status==200 || window.location.href.indexOf("http")==-1){
											//--- Here is where all the info comes back which ain't nothing in this case-------	
										  var partsArray = mygetrequest2.responseText.split('@@@@');
										  SetRosterRadioButtons(classNumber);
												var globalRosterContents = partsArray[0];
												var className = partsArray[1];
												document.getElementById('rosterclassname').innerHTML = className;
												LoadRosterContents(globalRosterContents); 
												SizeImageAndCenterMainDivDetail();
									}//if (mygetrequest2.status==200
							}//if (mygetrequest2.readyState==4){
						}//mygetrequest2.onreadystatechange=function()		
						mygetrequest2.open("GET", "GetRosterContentsAndClassName.php?i="+teacherID+"&gs="+globalSessionID+'&cn='+classNumber+"&qwert="+new Date().getTime(), true);
						mygetrequest2.send(null);									
						//--- end of nested ajax ---
													
	     SizeImageAndCenterMainDivDetail();												
				}//if (mygetrequest.status==200
		}//if (mygetrequest.readyState==4){
	}//mygetrequest.onreadystatechange=function()		
	mygetrequest.open("GET", "SaveMultipleNewStudents.php?i="+teacherID+"&first="+firstNameArrayString+"&last="+lastNameArrayString+"&gs="+globalSessionID+'&cn='+classNumber+"&qwert="+new Date().getTime(), true);
	mygetrequest.send(null);				
			
}
	


function ClearMultipleStudentsForm(teacherID){
	//window.status = window.status + '-27'
		var elem = document.getElementById('multiplenewstuform').elements;
		for(var i=0; i<elem.length; i++){
				if(elem[i].type == 'text'){					
						if (elem[i].name.substr(0,8) == 'newfirst'){
								elem[i].value = '';
						}
						if (elem[i].name.substr(0,7) == 'newlast'){
								elem[i].value = '';
						}						
				}
		} 	
}

function AddNewStudent(teacherID,scope){
	//window.status = window.status + '-28'
		//--- This calls the basic teacher data page (for structure), adds the next student record (uses increment for id), and saves the id to the hidden var --
		//	globalWaitingForStuRecToLoad = true;
			var classComp = GetCookie('cc');				
			
			// -- Get the class num radio val -----
			objectArray = document.getElementsByName('newstuRadioGroup');
			for (var i = 0; i <objectArray.length; i++) {
					if(objectArray[i]){
							if (objectArray[i].checked == true){
										radioValue = objectArray[i].value;
										break;
								}//if					
					}
				}//for  					
				var classNumber = radioValue;
					
				var mygetrequest=new ajaxRequest()
				mygetrequest.onreadystatechange=function(){

				if (mygetrequest.readyState==4){
				  if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
						  //--- Here is where all the info comes back -------				
						//alert (mygetrequest.responseText); 
						//window.status = "AddNewStudent loaded  ";
						  var partsArray = mygetrequest.responseText.split('@@@@');
								var studentRecordString = partsArray[0]; 
								var studentRecordArray = studentRecordString.split('%%%%');
								var studentID = studentRecordArray[0];
			     var stuFirst = studentRecordArray[11];
			     var stuLast = studentRecordArray[12];											
								globalTopBlurb = ''; //partsArray[1];	
					   //globalTopLinkHTML = partsArray[2];	
					   globalButtonHTML = partsArray[3];		
						  teacherTableHTML = partsArray[4];							
								var noteToStudentHTML = partsArray[5];
								var noteAboutStudentHTML = partsArray[6];			
								var verticalMenuHTML = partsArray[7];
								var newStudentID = partsArray[8];
								
								document.getElementById('mainalertdiv').innerHTML = globalTopBlurb;
								document.getElementById('mainrightdiv1').innerHTML = globalTopLinkHTML;
								document.getElementById('fullpagedatadiv').style.visibility = 'hidden';
								document.getElementById('fullpagedatadiv').style.top = '-1000px';
						  document.getElementById('fullpagedatadiv').innerHTML = teacherTableHTML;		
		      document.getElementById('mainbuttondiv').innerHTML = globalButtonHTML;					
								document.getElementById('notetostudentdiv').innerHTML = noteToStudentHTML;
								document.getElementById('noteaboutstudentdiv').innerHTML = noteAboutStudentHTML;		
								document.getElementById('verticalmenudiv').innerHTML = verticalMenuHTML;
								//--- Load many of the components of the data div (current course, current casual assignment name, etc) from
								//-- a combination of info retured from student record and the Help Available array (which has all the course
        //-- and assignment names already here in javascript. -----------------		
															
								//var fullName = stuFirst + ' ' + stuLast;
								globalStudentRecordActive = true;
								SetAssignmentNamePointer('on');
								FillOutStudentRecord(studentRecordArray,scope);
							//	document.getElementById('mainalertdiv').innerHTML = '<b>' + fullName + '</b>';

								
						//	 var newArrayElementLine = "<li onclick=\"ClickRosterName('"+studentID+"')\" class='coursetitleli' style='padding-top:0em;'><div class='clickcourse'>"+fullName+"</div></li>"; //this mirrors the structure in GetRosterContents() function in GetPageInf.php 
						//		var newElementNum = globalRosterArray.length;
							//	globalRosterArray[newElementNum] = newArrayElementLine;				
						//  LoadRosterContents(); //uses globalRosterArray							
						// globalWaitingForStuRecToLoad = false;
								SizeImageAndCenterMainDivDetail();
								document.sturecform.stufirst.	focus();
				 	}//if (mygetrequest.status==200
				}//if (mygetrequest.readyState==4){
			}//mygetrequest.onreadystatechange=function()		
			mygetrequest.open("GET", "GetStudentRecord.php?s=new&req=roster&t="+teacherID+"&cc="+classComp+"&gs="+globalSessionID+"&cn="+classNumber+"&qwert="+new Date().getTime(), true);
			mygetrequest.send(null);							
}


function LeftStuNameMult(sentID){
	//window.status = window.status + '-29'
		if(document.multiplenewstuform.capitalizecheckbox.checked == true){
		  //-- capitalize ----
				oName = document.getElementById(sentID);
				var basename = oName.value;
				var capName = basename.substr(0,1).toUpperCase() + basename.substr(1);
				oName.value = capName;		
		}

}




function LeftStuFirst(){
	//window.status = window.status + '-q'
	 //-- left the firstname text field: use it to populate username if username is blank --
		//-- if it's a new student we autocapitalize --
		if(document.sturecform.hiddennewstu.value == '1'){
		  //-- capitalize ----
				var basename = document.sturecform.stufirst.value;
				var capName = basename.substr(0,1).toUpperCase() + basename.substr(1);
				document.sturecform.stufirst.value = capName;		
				UpdateFullNameDiv(); //to show the effect
  }

}


function LeftStuLast(){	
//window.status = window.status + '-w'
			if(document.sturecform.hiddennewstu.value == '1'){
							//-- capitalize ----
							var basename = document.sturecform.stulast.value;
							var capName = basename.substr(0,1).toUpperCase() + basename.substr(1);
							document.sturecform.stulast.value = capName;
							UpdateFullNameDiv(); //to show the effect
   }

}
function StuAutoPassGen(){
	//window.status = window.status + '-e'
	//-- finds a unique password for the student and fills in the password textbox (but doesn't save it to table) --			
	   var studentID = document.sturecform.hiddenstuid.value;
				var mygetrequest=new ajaxRequest();
				mygetrequest.onreadystatechange=function(){
				if (mygetrequest.readyState==4){
				  if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
						  //--- Here is where all the info comes back -------				
								//window.status = "StuAutoPassGen loaded  ";
							 var uniquePassword = (mygetrequest.responseText); 
        document.sturecform.stupass.value = uniquePassword;
				 	}//if (mygetrequest.status==200
				}//if (mygetrequest.readyState==4){
			}//mygetrequest.onreadystatechange=function()		
			mygetrequest.open("GET", "GetUniquePassword.php?i="+studentID+"&qwert="+new Date().getTime(), true);
			mygetrequest.send(null);						
}


function UpdateFullNameDiv(){
	//window.status = window.status + '-r'
 	//-- takes what's in stufirst and stulast and updates the student's full name in main alert at the top of the page --
		var firstname = document.sturecform.stufirst.value;
		var lastname = document.sturecform.stulast.value;
		try{
			 // -- if this isn't a new student just added, this check won't be there ---
				if(document.sturecform.stunamepropercheck.checked == true){
							//-- capitalize ----
							firstname = firstname.substr(0,1).toUpperCase() + firstname.substr(1);
				}
		}
		catch(e){
    x = 8; //for IE						
		}		
		try{
			 // -- if this isn't a new student just added, this check won't be there ---
				if(document.sturecform.stunamepropercheck.checked == true){
							//-- capitalize ----
							lastname = lastname.substr(0,1).toUpperCase() + lastname.substr(1);
				}
		}
		catch(e){
    x = 8; //for IE						
		}			
		
 	var blurb = "<b>" + firstname + " "  + lastname + "</b>";
	 document.getElementById('fullnamediv').innerHTML = blurb; 
}



function StuAutoUserGen(){
	//window.status = window.status + '-t'
	//-- finds a unique password for the student and fills in the password textbox (but doesn't save it to table) --	
	// -- takes it from whatever is in the first name text field ---
	   var existingFirstName = document.sturecform.stufirst.value;
				var studentID = document.sturecform.hiddenstuid.value;
				var mygetrequest=new ajaxRequest();
				mygetrequest.onreadystatechange=function(){
				if (mygetrequest.readyState==4){
				  if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
						  //--- Here is where all the info comes back -------			
								//window.status = "StuAutoUserGen loaded  ";
							 var uniqueUsername = (mygetrequest.responseText); 
        document.sturecform.stuuser.value = uniqueUsername;
				 	}//if (mygetrequest.status==200
				}//if (mygetrequest.readyState==4){
			}//mygetrequest.onreadystatechange=function()		
			mygetrequest.open("GET", "GetUniqueUsername.php?f="+existingFirstName+"&i="+studentID+"&gs="+globalSessionID+"&qwert="+new Date().getTime(), true);
			mygetrequest.send(null);						
}



function UpdateContractCourse(recordOrContract,studentCourseID){
	//window.status = window.status + '-y'
	  switch(recordOrContract){
				  case 'record':
		     	var contractCode = "<select name='stucontract' onchange='ChangedContractRecForm()'>"	;
								break;
				  case 'contract':
		     	var contractCode = "<select name='stucontract' onchange='ChangedContractConForm()'>"	;
								break;					
			}
			var selectedCode = '';
		 courseTitleArray = GetCourseTitleArray();
			var line = '';
			var courseID = 0;
			var courseTitle = '';						
			nStudentCourseID = studentCourseID*1;
			//-- set the first line -- 'None' ---
			if(nStudentCourseID == 0){
				 selectedCode = " selected='selected' ";
			}else{
				selectedCode = '';
			}
			var line = "<option "+selectedCode+" value='0'>(None)</option>";
			contractCode = contractCode + line;
			for(var i=0; i< courseTitleArray.length; i++){
			  courseID = courseTitleArray[i][1];
					nCourseID = courseID*1;
			  courseTitle = courseTitleArray[i][0];				 	 
					if(nCourseID == nStudentCourseID){
						  selectedCode = " selected='selected' ";
					}else{
						 selectedCode = '';
					} 
					line = "<option "+selectedCode+" value='"+courseID +"'>"+courseTitle+"</option>";
					contractCode = contractCode + line;
		 }
			contractCode = contractCode + '</select>';
			document.getElementById('stucontractdiv').innerHTML = contractCode;	
}



function UpdateContractAssList(studentCourseID){
	//window.status = window.status + '-u'
	  //--- this is for the contract page ------
		 var contractCode = "<select name='stucontract' onchange='ChangedContractConForm()'>"	;
			var selectedCode = '';
		 courseTitleArray = GetCourseTitleArray();
			var line = '';
			var courseID = 0;
			var courseTitle = '';						
			nStudentCourseID = studentCourseID*1;
			//-- set the first line -- 'None' ---
			if(nStudentCourseID == 0){
				 selectedCode = " selected='selected' ";
			}else{
				selectedCode = '';
			}
			var line = "<option "+selectedCode+" value='0'>(None)</option>";
			contractCode = contractCode + line;
			for(var i=0; i< courseTitleArray.length; i++){
			  courseID = courseTitleArray[i][1];
					nCourseID = courseID*1;
			  courseTitle = courseTitleArray[i][0];				 	 
					if(nCourseID == nStudentCourseID){
						  selectedCode = " selected='selected' ";
					}else{
						 selectedCode = '';
					} 
					line = "<option "+selectedCode+" value='"+courseID +"'>"+courseTitle+"</option>";
					contractCode = contractCode + line;
		 }
			contractCode = contractCode + '</select>';
			document.getElementById('stucontractdiv').innerHTML = contractCode;	
}

function FillOutStudentRecord(studentRecordArray,scope){
} 

function ShowNoteToStudent(){
	//window.status = window.status + '-p'
	 // --- positions and shows the div containing the text field where the teacher can create, see, and modify student.notetostu ----
		var oNoteToStuDiv = document.getElementById('notetostudentdiv');	
		oNoteToStuDiv.style.visibility = 'visible';
		var oMainDiv = document.getElementById('maindiv');	
		var topDrop = (oMainDiv.offsetHeight - oNoteToStuDiv.offsetHeight)/2;
		if(topDrop < 0){
			 topDrop = 0;
		}
		var leftMargin = (oMainDiv.offsetWidth - oNoteToStuDiv.offsetWidth)/2;
		if(leftMargin < 0){
			 leftMargin = 0;
		}		
		var topPos = oMainDiv.offsetTop + topDrop;
		var leftPos = oMainDiv.offsetLeft + leftMargin;
		oNoteToStuDiv.style.top = topPos + 'px';
	 oNoteToStuDiv.style.left = leftPos + 'px';	
}

function ShowNoteAboutStudent(){
	//window.status = window.status + '-p'
	 // --- positions and shows the div containing the text field where the teacher can create, see, and modify student.notetostu ----
		var oNoteAboutStuDiv = document.getElementById('noteaboutstudentdiv');	
		oNoteAboutStuDiv.style.visibility = 'visible';
		var oMainDiv = document.getElementById('maindiv');	
		var topDrop = (oMainDiv.offsetHeight - oNoteAboutStuDiv.offsetHeight)/2;
		if(topDrop < 0){
			 topDrop = 0;
		}
		var leftMargin = (oMainDiv.offsetWidth - oNoteAboutStuDiv.offsetWidth)/2;
		if(leftMargin < 0){
			 leftMargin = 0;
		}		
		var topPos = oMainDiv.offsetTop + topDrop;
		var leftPos = oMainDiv.offsetLeft + leftMargin;
		oNoteAboutStuDiv.style.top = topPos + 'px';
	 oNoteAboutStuDiv.style.left = leftPos + 'px';	
}


function ShowFloatingHelp(helpContent,sentWidth){
	//window.status = window.status + '-a'
	 if(helpContent != 'weekeditdisabled'){ ///////////////////
	   return; /////////////
		} //////////////////////////////
		var mygetrequest=new ajaxRequest();
		mygetrequest.onreadystatechange=function(){
		if (mygetrequest.readyState==4){
				if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
						//--- Here is where all the info comes back -------	
						//window.status = "ShowFloatingHelp loaded  ";
							var contentHTML = mygetrequest.responseText;
							//alert(contentHTML)
							// --- positions and shows the div containing the text field where the teacher can create, see, and modify student.notetostu ----
							var oFloatHelp = document.getElementById('floatinghelpdiv');	
							var oMainDiv = document.getElementById('maindiv');	
							oFloatHelp.innerHTML = contentHTML;
							//-- size it relative to the main div ---
							switch(sentWidth){
								  case 'wide':
							     var helpWidth = 800;
												break;					
								  case 'normal':
							     var helpWidth = 600;
												break;												
								  case 'narrow':
							     var helpWidth = 400;
												break;		
								  case 'small':
							     var helpWidth = 250;
												break;					
								  case 'tiny':
							     var helpWidth = 100;
												break;														
							}
							
							if(helpWidth > oMainDiv.offsetWidth){
								 helpWidth = oMainDiv.offsetWidth;
							}
					 //-- set the width and let the content set the height ---
							oFloatHelp.style.width = helpWidth + 'px';

							if(sentWidth == 'wide'){
										//-- set to the viewport --
		       // var viewportH = GetViewportHeightIncludingScrollBar();				
		      //  var viewportW = GetViewportWidthIncludingScrollBar();											
										var topDrop = (viewportH - oFloatHelp.offsetHeight)/2;
										if(topDrop < 0){
												topDrop = 0;
										}
										var leftMargin = (globalViewportW - oFloatHelp.offsetWidth)/2;
										if(leftMargin < 0){
												leftMargin = 0;
										}		
										var topPos = topDrop;
										var leftPos = leftMargin;													
							}else{
										//-- set to the main div ---
										var topDrop = (oMainDiv.offsetHeight - oFloatHelp.offsetHeight)/2;
										if(topDrop < 0){
												topDrop = 0;
										}
										var leftMargin = (oMainDiv.offsetWidth - oFloatHelp.offsetWidth)/2;
										if(leftMargin < 0){
												leftMargin = 0;
										}		
										var topPos = oMainDiv.offsetTop + topDrop;
										var leftPos = oMainDiv.offsetLeft + leftMargin;																				
							}
							
							oFloatHelp.style.top = topPos + 'px';
							oFloatHelp.style.left = leftPos + 'px';	
							
							oFloatHelp.style.visibility = 'visible';
					

				}//if (mygetrequest.status==200
		}//if (mygetrequest.readyState==4){
	}//mygetrequest.onreadystatechange=function()		
	mygetrequest.open("GET", "GetHelpContent.php?h="+helpContent+"&qwert="+new Date().getTime(), true);
	mygetrequest.send(null);							
}

function HideFloatingHelp(){
	//window.status = window.status + '-s'
		var oFloatHelp = document.getElementById('floatinghelpdiv');		
		oFloatHelp.style.visibility = 'hidden';
}

function ClearNoteToStudent(){
	//window.status = window.status + '-d'
	  document.notetostuform.notetostutextarea.value = '';			
}
function HideNoteToStudent(){
	//window.status = window.status + '-f'
		var oNoteToStuDiv = document.getElementById('notetostudentdiv');	
		oNoteToStuDiv.style.visibility = 'hidden';
}
function ClearNoteAboutStudent(){
	//window.status = window.status + '-g'
	  document.noteaboutstuform.noteaboutstutextarea.value = '';			
}
function HideNoteAboutStudent(){
	//window.status = window.status + '-h'
		var oNoteAboutStuDiv = document.getElementById('noteaboutstudentdiv');	
		oNoteAboutStuDiv.style.visibility = 'hidden';
}

function UpdateHighestContractPassed(studentCourseID,highestPassedContractTest){
	//window.status = window.status + '-j'
		 assTitleArray = GetAssTitleArray(studentCourseID);
			var assCode = "<select name='stucontracttested'>";		
			var selectedCode = '';
			var line = '';
			var assID = 0;
			var assTitle = '';						
			nHighestPassedContractTest = highestPassedContractTest*1;
			for(var i=-1; i< assTitleArray.length; i++){
				 if(i == -1){
						 //-- the first list item means no tests have been passed -- 
							if(nHighestPassedContractTest == 0){
										selectedCode = " selected='selected' ";
							}else{
									selectedCode = '';
							} 
							line = "<option "+selectedCode+" value='0'>"+'(None)'+"</option>";						
					}else{
							assID = assTitleArray[i][1];
							nAssID = assID*1;
							assTitle = assTitleArray[i][0];				 	 
							if(nAssID == nHighestPassedContractTest){
										selectedCode = " selected='selected' ";
							}else{
									selectedCode = '';
							} 
							line = "<option "+selectedCode+" value='"+assID +"'>"+assTitle+"</option>";
					}
					assCode = assCode + line;
		 }
			assCode = assCode + '</select>';			
		 document.getElementById('stucontracttesteddiv').innerHTML = assCode;		
}


function UpdateContractAssignmentAndFrame(sentCourseID, currentConAssID, selectedFrame){
	//window.status = window.status + '-k'
	  if(sentCourseID == 0){
					assCode = "<select name='stuassignment' value='0@0@'></select>";	
					numberOfFrames = 0;
					selectedFrame = 0;
			}else{
					assTitleArray = GetAssTitleArray(sentCourseID);
					if(currentConAssID == 'firstassignment'){
							currentConAssID = assTitleArray[0][1];
							nCurrentConAssID = currentConAssID*1;	
					}
					var assCode = "<select name='stuassignment' onchange='ChangedConAssignment()'>";		
					var selectedCode = '';
					var line = '';
					var assID = 0;
					var assTitle = '';						
					nCurrentConAssID = currentConAssID*1;			
					var numberOfFrames = 0;
					for(var i=0; i< assTitleArray.length; i++){
							assID = assTitleArray[i][1];
							nAssID = assID*1;
							assTitle = assTitleArray[i][0];							
							if(nAssID == nCurrentConAssID){
										selectedCode = " selected='selected' ";
										numberOfFrames = assTitleArray[i][2];
							}else{
									selectedCode = '';
							} 
							line = "<option "+selectedCode+" value='"+assID+"@"+numberOfFrames+"@'>"+assTitle+"</option>";
							assCode = assCode + line;
					}
					assCode = assCode + '</select>';			
			}
			document.getElementById('stuassignmentdiv').innerHTML = assCode;
			UpdateContractFrame(numberOfFrames, selectedFrame);			
}

function UpdateContractFrame(numberOfFrames, selectedFrame){
	//window.status = window.status + '-l'
	 if(numberOfFrames == 0){
			 var frameCode = "<select name='stucontractframe' value='0'></select>";	
		}else{
				var frameCode = "<select name='stucontractframe' >";
				var selectedCode = '';
				var line = '';
				var frame = 0;		
				nSelectedFrame = selectedFrame*1;			
				for(var i=1; i<= numberOfFrames; i++){
						if(i == nSelectedFrame){
									selectedCode = " selected='selected' ";
						}else{
								selectedCode = '';
						} 
						line = "<option "+selectedCode+" value='"+i+"'>"+i+"</option>";
						frameCode = frameCode + line;
				}
				frameCode = frameCode + '</select>';			

		}
		document.getElementById('stucontractframediv').innerHTML = frameCode;				
}


function SetAssignmentNamePointer(onOrOff){
	//window.status = window.status + '-z'
	 // --NOT USING NOW ---
	 //-- this was intended to allow a pointer for teachers but not for students --look into the css (if it means huge loops, forget it) --
	 if (onOrOff = 'on'){
   
		}else{
			
		}
}


function clickass(assID){
	//window.status = window.status + '-c'
	  //-- click an assignment NAME from the assignment list --
			// --- if a student clicks, nothing will happen --
			if(globalStudentRecordActive == true){				 
			  document.sturecform.stucasualhelpcheck.checked = true;
					var assNameFrameArray = GetAssignmentNameAndFrames(assID);
					//-- update the text and assid for the text ---------
				 document.sturecform.stucasualhelpass.value = assNameFrameArray[0];				
					document.sturecform.stucasualhelpass.ass = assID;
					document.sturecform.hiddenstuass.value = assID;
					//--- list all the available frames and set the frame to 1 ---
					var numberOfFrames = assNameFrameArray[1];
					UpdateCasualHelpFrames(numberOfFrames, 1);
					
			}
			
}

function ClearCasualHelpAssignmentAndFrame(){
	//window.status = window.status + '-v'
	 document.getElementById('stucasualhelpassdiv').innerHTML = "<input type='text' size='25' name='stucasualhelpass' value='' assid='0' readonly='readonly'/>";
		document.sturecform.stucasualhelpass.value = '';				
		document.sturecform.stucasualhelpass.ass = 0;	
		document.sturecform.hiddenstuass.value = 0;
	 UpdateCasualHelpFrames(0,0);	
}

function EnableDisableCasualAssignmentAndFrameList(enableOrDisable){
	//window.status = window.status + '-b'
	  //--- NOT USED NOW ---
	  if(enableOrDisable == 'enable'){
				  document.sturecform.stucasualhelpass.disabled = false;
						document.sturecform.stucasualhelpframe.disabled = false;
			}else{
				  document.sturecform.stucasualhelpass.disabled = true;
						document.sturecform.stucasualhelpframe.disabled = true;
			}
}

function GetAssignmentNameAndFrames(assID){
	//window.status = window.status + '-n'
	  var searchExpression = "ass="+assID;
			var assNamePrefix = "<span class='mark'></span>"; //this is set in GetBrowseHelpContents.php
			var assNameSuffix = "</span></li>";//this is set in GetBrowseHelpContents.php			
			var numFramesPrefix = "numframes="; //this is set in GetBrowseHelpContents.php
			var numFramesSuffix = ' ';//this is set in GetBrowseHelpContents.php								
			var assName = '';
			assNameArray = new Array();
			//-- plow through the whole array until we hit it --
			for(var i=0; i< globalBrowseArray.length; i++){				  
					if(globalBrowseArray[i].indexOf(searchExpression) > -1) {
							startPos = globalBrowseArray[i].indexOf(assNamePrefix) + assNamePrefix.length; 
							endPos = globalBrowseArray[i].indexOf(assNameSuffix);
							assName = globalBrowseArray[i].substring(startPos,endPos);			
							assNameArray[0] = assName;
							//-- numFrames -----
							startPos = globalBrowseArray[i].indexOf(numFramesPrefix) + numFramesPrefix.length; 
							endPos = globalBrowseArray[i].indexOf(numFramesSuffix,startPos);
							numFrames = globalBrowseArray[i].substring(startPos,endPos);
							assNameArray[1] = numFrames;								
							break;
					}		
			}	
			return assNameArray;
}

function UpdateCasualHelpFrames(numberOfFrames, selectedFrame){
	//window.status = window.status + '-m'
	  if((numberOfFrames == 0)&&(selectedFrame == 0)){
				  var frameCode = "<select name='stucasualhelpframe'></select>"	;	
			}else{
					var frameCode = "<select name='stucasualhelpframe'>"	;	
					var selectedCode = '';
					var line = '';
					var frame = 0;		
					nSelectedFrame = selectedFrame*1;			
					for(var i=1; i<= numberOfFrames; i++){
							if(i == nSelectedFrame){
										selectedCode = " selected='selected' ";
							}else{
									selectedCode = '';
							} 
							line = "<option "+selectedCode+" value='"+i+"'>"+i+"</option>";
							frameCode = frameCode + line;
					}
					frameCode = frameCode + '</select>';			
			}
		 document.getElementById('stucasualhelpframediv').innerHTML = frameCode;		 		
}

function GetCourseTitleArray(){
	//window.status = window.status + '-qq'
			var StartPos = 0;
			var endPos = 0;

			var courseTitle = '';
			// -- cycle through all the course titles --		
			var courseTitleArray = new Array();
			var titlePrefix = "'clickcourse'>"; //this is set in GetBrowseHelpContents.php
			var titleSuffix = "</div></li>";//this is set in GetBrowseHelpContents.php	
			var courseIDPrefix = "courseid="; //this is set in GetBrowseHelpContents.php
			var courseIDSuffix = "onclick";//this is set in GetBrowseHelpContents.php				
			var inc=0;
			for(var i=0; i< globalBrowseArray.length; i++){
					if(globalBrowseArray[i].indexOf("course=-1") > -1) {
						 courseTitleArray[inc] = new Array();
							// -- the title ---
							startPos = globalBrowseArray[i].indexOf(titlePrefix) + titlePrefix.length; 
							endPos = globalBrowseArray[i].indexOf(titleSuffix);
							courseTitle = globalBrowseArray[i].substring(startPos,endPos);						
							courseTitleArray[inc][0] = courseTitle;
							//---- the course id -----
							startPos = globalBrowseArray[i].indexOf(courseIDPrefix) + courseIDPrefix.length; 
							endPos = globalBrowseArray[i].indexOf(courseIDSuffix,startPos);		
							courseID = globalBrowseArray[i].substring(startPos,endPos);
						 courseTitleArray[inc][1] = courseID;
							inc++;
					}		
			}	
			return courseTitleArray;
}

function GetAssTitleArray(sentCourseID){
	//window.status = window.status + '-qw'
			var StartPos = 0;
			var endPos = 0;	
			var assignmentTitle = '';
			var numFrames = 0;
			var assignmentID = 0;
			var assTitleArray = new Array();
			var sentCourseIDCode = "courseid="+sentCourseID;
			var assNamePrefix = "<span class='mark'></span>"; //this is set in GetBrowseHelpContents.php
			var assNameSuffix = "</span></li>";//this is set in GetBrowseHelpContents.php			
			var assIDPrefix = "ass="; //this is set in GetBrowseHelpContents.php
			var assIDSuffix = ' ';//this is set in GetBrowseHelpContents.php				
			var numFramesPrefix = "numframes="; //this is set in GetBrowseHelpContents.php
			var numFramesSuffix = ' ';//this is set in GetBrowseHelpContents.php							
			var inc=0;
			for(var i=0; i< globalBrowseArray.length; i++){				 
					if((globalBrowseArray[i].indexOf(sentCourseIDCode) > -1)&&(globalBrowseArray[i].indexOf("course=-1") == -1)){
						 assTitleArray[inc] = new Array();
						 //alert(globalBrowseArray[i]);
							startPos = globalBrowseArray[i].indexOf(assNamePrefix) + assNamePrefix.length; 
							endPos = globalBrowseArray[i].indexOf(assNameSuffix );
							assignmentTitle = globalBrowseArray[i].substring(startPos,endPos);
							assTitleArray[inc][0] = assignmentTitle;
							//-- ass id -----
							startPos = globalBrowseArray[i].indexOf(assIDPrefix) + assIDPrefix.length; 
							endPos = globalBrowseArray[i].indexOf(assIDSuffix,startPos);
							assignmentID = globalBrowseArray[i].substring(startPos,endPos);
							assTitleArray[inc][1] = assignmentID;					
							//-- numFrames -----
							startPos = globalBrowseArray[i].indexOf(numFramesPrefix) + numFramesPrefix.length; 
							endPos = globalBrowseArray[i].indexOf(numFramesSuffix,startPos);
							numFrames = globalBrowseArray[i].substring(startPos,endPos);
							assTitleArray[inc][2] = numFrames;											
							inc++;
					}		
			}			
   return assTitleArray;
}



function MsOverRos(oRosterName){
	//window.status = window.status + '.'
 // --roll over a roster name on the left main roster list --
	oRosterName.style.	textDecoration = 'underline';	
}
function MsOutRos(oRosterName){
	//window.status = window.status + ','
 // --roll over a roster name on the left main roster list --
	oRosterName.style.	textDecoration = 'none';
}

function ClearDefaultText(sentDefaultText, oText){
	//window.status = window.status + '-qt'
  if(oText.value == sentDefaultText){
			 oText.value = '';
		}
}



function GiveCasasNow(studentID,teacherID,scope){
	//window.status = window.status + '-qu'
	 //-- this just calls resets the casas hours to 0 and then reload the student's record without the message and button---
				var mygetrequest1=new ajaxRequest();
				mygetrequest1.onreadystatechange=function(){
				if (mygetrequest1.readyState==4){
				  if (mygetrequest1.status==200 || window.location.href.indexOf("http")==-1){
						  //--- Here is where all the info comes back -------				
							//alert ('small ' + mygetrequest1.responseText); 
							//window.status = "GiveCasasNow loaded  ";
							ClickRosterNameOrContract(studentID,'roster',teacherID,scope);								
				 	}//if (mygetrequest.status==200
				}//if (mygetrequest.readyState==4){
			}//mygetrequest.onreadystatechange=function()		
			mygetrequest1.open("GET", "GiveCasasNow.php?i="+studentID+"&gs="+globalSessionID+"&t="+teacherID+"&qwert="+new Date().getTime(), true);
			mygetrequest1.send(null);						
	
}




function TakeAssignmentTest(stuName, assName, userType,stuID,assID){
	//window.status = window.status + '-qi'
		var mygetrequest=new ajaxRequest();
		var probType = 't'; //corresponds to the track designation for test frames
		mygetrequest.onreadystatechange=function(){
		if (mygetrequest.readyState==4){
				if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
						//--- Here is where all the info comes back which ain't nothing in this case-------	
				  //alert (mygetrequest.responseText); 
						//window.status = "TakeAssignmentTest loaded  ";
					 var partsArray = mygetrequest.responseText.split('@@@@');		
						var statusInfo = partsArray[0];
				 	var problemMainBlurb = partsArray[1];
				 	var problemSetHTML = partsArray[2];				
						switch(statusInfo){
							 case 'norecs':
									 document.getElementById('mainalertdiv').innerHTML = problemMainBlurb;
										break;
								default:			
								  // -- All is good -----
					  	  document.getElementById('mainalertdiv').innerHTML = problemMainBlurb;							
				    		document.getElementById('fullpagedatadiv').innerHTML = problemSetHTML;			
										//--- clear out top links so the student doesn't think he can exit out ---
          document.getElementById('mainrightdiv1').innerHTML = '';									
						}
						SizeImageAndCenterMainDivDetail();												
				}//if (mygetrequest.status==200
		}//if (mygetrequest.readyState==4){
	}//mygetrequest.onreadystatechange=function()		
	mygetrequest.open("GET", "GetStudentProblemSet.php?i="+stuID+"&usertype="+userType+"&assid="+assID+"&probtype="+probType+"&stuname="+stuName+"&assname="+assName+"&gs="+globalSessionID+"&qwert="+new Date().getTime(), true);
	mygetrequest.send(null);	
}

function ExportWeekAttendance(sessionID, teacherID, allOrShow, weekOffset, classNum){
	 //-- THIS ISN'S USED NO MORE.  WE GO DIRECT TO THE WINDOW FROM THE HTML ---
	////window.status = window.status + '-qo'
//	alert('what')
	//return; ///	won't work on server but will work on local ???????????????
//	alert(allOrShow)
		var mygetrequest=new ajaxRequest();
		mygetrequest.onreadystatechange=function(){
		if (mygetrequest.readyState==4){
				if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
						//--- Here is where all the info comes back which ain't nothing in this case-------	
						//-- Nothing comes back.  The code I got will spit out a pdf that the browser then deals with --
					//	//window.status = "ExportWeekAttendance loaded  ";
						
		 // alert (mygetrequest.responseText); 
				}//if (mygetrequest.status==200
		}//if (mygetrequest.readyState==4){
	}//mygetrequest.onreadystatechange=function()		
	mygetrequest.open("GET", "MakeWeeklyAttendancePDF.php?i="+teacherID+"&allorshow="+allOrShow+"&weekoffset="+weekOffset+"&classnum="+classNum+"&qwert="+new Date().getTime(), true);
	mygetrequest.send(null);	
}

function TeacherExport(exportWhat,extra){
	//window.status = window.status + '-qp'
	  //-- makes a pdf that can be opened or downloaded --
			switch(exportWhat){
				  case 'casasleaders':
						  
						  break;
				  case 'teacherpreferences':
						  
						  break;							
				  case 'todaysattendees':
						  
						  break;			
				  case 'sturec':
						  var studentID = extra;
						  break;																
				  case 'weekattendance':
						  var extraArray = extra.split('@@@@');
								teacherID = extraArray[0];
								weekOffset = extraArray[1];

						  break;					
				  case 'roster':
								teacherID = extra;
        var classNum = GetRosterRadioNumber();

						  break;											
								
			}
}



function SizeImageAndCenterMainDiv(){
// alert(' in resize ' )
  //document.getElementById('mainalertdiv').innerHTML = 'Read this';
	//window.status = window.status + '-qa'
	 //-- we do this with a timer so that resize executes after a certain amount of time goes by and won't stack up
		// -- a whole bunch of times (which takes a long time to finish!)---------------
		try{
    clearInterval(sizeImageTimerID);
		}
		catch(e){
    x = 8; //for IE						
		}			
  globalViewportW = GetViewportWidthIncludingScrollBar();
  globalViewportH = GetViewportHeightIncludingScrollBar();		
	//	alert(' will reset status')
 //window.status = ' w=' + globalViewportW + ' ';
		sizeImageTimerID = setInterval("SizeImageAndCenterMainDivDetail()",700); 

	//return; ////////////
	  //-- we can't do anything until both the browse help contents (via php ajax) and the image (via www) have been loaded --
			//- Once they are, then we size and position everything ---
			//-- This now also sizes the main div itself ---
 /* if((globalWaitingForImageToLoad == false)&&(globalWaitingForBrowseHelpToLoad == false)){

  		SizeImageAndCenterMainDivDetail();
		}else{			 
			 switch(true){
						case ((globalWaitingForImageToLoad == true)&&(globalWaitingForBrowseHelpToLoad == true)):
						//  sizeAndPositionTimerID = setInterval("FireSizeAndCenter('imageandhelp')",10);	
								break;
						case (globalWaitingForImageToLoad == true):
						//  sizeAndPositionTimerID = setInterval("FireSizeAndCenter('image')",10);
								break;				
						case (globalWaitingForBrowseHelpToLoad = true):
						//  sizeAndPositionTimerID = setInterval("FireSizeAndCenter('help')",10);
								break;				
				}
		} */
}		

function ClickedNewTeacherRegistration(){
 globalDocsForBrowseHelp = false;
  alert("Sorry it's not quite there yet.  It will be ready very soon I promise!  Email workingTeacher@gmail.com If you'd like to get started right away.") //getmaterials
		return;
		//window.status = window.status + '-qs'
	  var firstname = document.newteacherregform.firstname.value;
			var lastname = document.newteacherregform.lastname.value;
			var email = document.newteacherregform.email.value;
			var securityQuestion = document.newteacherregform.secquestion.value;
			var securityAnswer = document.newteacherregform.secanswer.value;
			var missingInfo = 0;
			oLabel = document.getElementById('firstnamelabel');
			if(Trim(firstname) == ''){
			   missingInfo++;
						oLabel.style.color = 'red';
						oLabel.style.textDecoration = 'underline';
   }else{
						oLabel.style.color = '#333333'; //std for the page
						oLabel.style.textDecoration = 'none';				  
			}
			oLabel = document.getElementById('lastnamelabel');
			if(Trim(lastname) == ''){
			   missingInfo++;
						oLabel.style.color = 'red';
						oLabel.style.textDecoration = 'underline';
   }else{
						oLabel.style.color = 'red';
						oLabel.style.color = '#333333'; //std for the page			
			}
			oLabel1 = document.getElementById('emaillabel1');
			oLabel2 = document.getElementById('emaillabel2');
			if(Trim(email) == ''){
			   missingInfo++;
						oLabel1.style.color = 'red';
						oLabel1.style.textDecoration = 'underline';
						oLabel2.style.color = 'red';
						oLabel2.style.textDecoration = 'underline';						
   }else{
						oLabel1.style.color = 'red';
						oLabel1.style.color = '#333333'; //std for the page			
						oLabel2.style.color = 'red';
						oLabel2.style.color = '#333333'; //std for the page									
			}
			oNotice = document.getElementById('badregnotice');
			if(missingInfo > 0){
				 oNotice.style.color = 'red'; 
				 if(missingInfo == 1){
					  oNotice.innerHTML = 'The item highlighted below is not complete.'
					}else{
						oNotice.innerHTML = 'The items highlighted below are not complete.'
					}
			}else{
				 //--- proceed with registration --
					oNotice.style.color = 'blue';
					oNotice.innerHTML = "You have been sent an email with a link that will complete your registration.";
		var mygetrequest=new ajaxRequest();
		mygetrequest.onreadystatechange=function(){
		if (mygetrequest.readyState==4){
				if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
						//--- Here is where all the info comes back which ain't nothing in this case-------	
					// alert (mygetrequest.responseText); 								
					//window.status = "ClickedNewTeacherRegistration loaded  ";
				}//if (mygetrequest.status==200
		}//if (mygetrequest.readyState==4){
	}//mygetrequest.onreadystatechange=function()		
	mygetrequest.open("GET", "SendNewRegistrationEmail.php?f="+firstname+"&l="+lastname+"&e="+email+"&q="+securityQuestion+"&a="+securityAnswer+"&qwert="+new Date().getTime(), true);
	mygetrequest.send(null);						
					
			} //if else missingInfo
}

function HighlightMenuText(whichOne){
	//window.status = window.status + '-qd'
	oToday = document.getElementById('todaymenutext');
	oWeek = document.getElementById('weekmenutext');
	oNew= document.getElementById('newstudentmenutext');
	oHours = document.getElementById('hoursmenutext');
	oPrefs = document.getElementById('preferencesmenutext');
	oMaterials = document.getElementById('materialsmenutext');
	oHelp = document.getElementById('helpmenutext');
		//--- set all of them to normal ---

	oToday.style.textDecoration = '';
	oWeek.style.textDecoration = '';
	oNew.style.textDecoration = '';
	oHours.style.textDecoration = '';
	oPrefs.style.textDecoration = '';
	oMaterials.style.textDecoration = '';
	oHelp.style.textDecoration = '';
 // -- highlight the clicked one --
	switch(whichOne){ 
		 case 'today':
			  oToday.style.textDecoration = 'underline';
					break;
		 case 'week':
			  oWeek.style.textDecoration = 'underline';
					break;
		 case 'newstudent':
			  oNew.style.textDecoration = 'underline';
					break;
		 case 'hours':
			  oHours.style.textDecoration = 'underline';
					break;
		 case 'preferences':
			  oPrefs.style.textDecoration = 'underline';
					break;
		 case 'materials':
			  oMaterials.style.textDecoration = 'underline';
					break;
		 case 'help':
			  oHelp.style.textDecoration = 'underline';
					break;					
	}
}

function HighlightMenuTextOG(whichOne){ ////////////////////////////////////////
//window.status = window.status + '-qf'
	oToday = document.getElementById('todaymenutext');
	oWeek = document.getElementById('weekmenutext');
	oNew= document.getElementById('newstudentmenutext');
	oHours = document.getElementById('hoursmenutext');
	oPrefs = document.getElementById('preferencesmenutext');
	oMaterials = document.getElementById('materialsmenutext');
	oHelp = document.getElementById('helpmenutext');
		//--- set all of them to normal ---

	oToday.style.backgroundColor = '';
	oWeek.style.backgroundColor = '';
	oNew.style.backgroundColor = '';
	oHours.style.backgroundColor = '';
	oPrefs.style.backgroundColor = '';
	oMaterials.style.backgroundColor = '';
	oHelp.style.backgroundColor = '';
 // -- highlight the clicked one --
	switch(whichOne){ 
		 case 'today':
			  oToday.style.backgroundColor = 'rgb(254,255,151)';
					break;
		 case 'week':
			  oWeek.style.backgroundColor = 'rgb(254,255,151)';
					break;
		 case 'newstudent':
			  oNew.style.backgroundColor = 'rgb(254,255,151)';
					break;
		 case 'hours':
			  oHours.style.backgroundColor = 'rgb(254,255,151)';
					break;
		 case 'preferences':
			  oPrefs.style.backgroundColor = 'rgb(254,255,151)';
					break;
		 case 'materials':
			  oMaterials.style.backgroundColor = 'rgb(254,255,151)';
					break;
		 case 'help':
			  oHelp.style.backgroundColor = 'rgb(254,255,151)';
					break;					
	}
}

function SetCurvedCorners(trueOrFalse){
	//window.status = window.status + '-qg'
		var oMainDiv = document.getElementById('maindiv');	
		var oShadowDiv = document.getElementById('shadowmaindiv');	
	//	var oMainBody = document.getElementById('mainbody');	
	 if (trueOrFalse == true){
    oMainDiv.className = 'rounded';
    oShadowDiv.className = 'rounded'; 
		//		oMainBody.className = 'overallscrollbars';
		}else{
    oMainDiv.className = 'notrounded';
    oShadowDiv.className = 'notrounded'; 
			//	oMainBody.className = 'nooverallscrollbars';
		}
}

function ClickedCheckOutMaterials(studentID){
	//window.status = window.status + '-qh'
			if(globalDocsForBrowseHelp == true){
			  globalDocsForBrowseHelp = false;
					LoadBrowseHelpContents(-1,'student')
			}
				var mygetrequest=new ajaxRequest();
				mygetrequest.onreadystatechange=function(){
				if (mygetrequest.readyState==4){
						if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
								//--- Here is where all the info comes back which ain't nothing in this case-------	
				  //	alert (mygetrequest.responseText); 
						//window.status = "ClickedCheckOutMaterials loaded  ";
						  var partsArray = mygetrequest.responseText.split('@@@@');
								//globalTopLinkHTML= partsArray[0]; 				//leave it just the way it was								
							 globalMainTextHTML = partsArray[1];		
						 	globalButtonHTML = partsArray[2];		//the checkout selected materials button	
								globalTopBlurb = partsArray[3];								
								globalResponseTextHTML = '';
								globalProblemSelectHTML = '';

								LoadMainElements();
								SizeImageAndCenterMainDivDetail();		
						}//if (mygetrequest.status==200
				}//if (mygetrequest.readyState==4){
			}//mygetrequest.onreadystatechange=function()		
			//mygetrequest.open("GET", "GetStudentCheckoutMaterials.php?s="+studentID+"&gs="+globalSessionID+"&t="+teacherID+"&qwert="+new Date().getTime(), true);
			mygetrequest.open("GET", "GetStudentCheckoutMaterials.php?s="+studentID+"&gs="+globalSessionID+"&qwert="+new Date().getTime(), true);
			mygetrequest.send(null);			
}


//function ResetGlobalWaitingForStuRecToLoadVar(){
	  //-- for unknown reasons, sometimes a student record will load but the variable won't get reset.  What the fuck man? --
			//-- This here timer will, after 2 seconds, ASSUME that the record has loaded and will reset the variable -------
		//globalWaitingForStuRecToLoad = false;
			//clearInterval(globalWaitingForStuRecToLoadTimerID);
//}

function ClickRosterNameOrContract(studentID,rosterOrContract,teacherID,scope){
	 //window.status = window.status + '-qj'
	  //--- Loads the student's record, contract or current work into main viewport area --
		// alert(studentID + ' ' + rosterOrContract + '  ' + teacherID + '  ' + scope)
			var lastVerticalMenuView = document.getElementById('lastvertmenu').value;
			switch(lastVerticalMenuView){
				 case 'main':
					  ClickRosterNameOrContractDetail(studentID,rosterOrContract,teacherID,scope);
							break;
				 case 'contract':
					  ClickContract(studentID,teacherID);
							break;			
				 case 'current':
					  ClickedCurrentStudentWorkForTeacher(studentID,teacherID);
							break;									
			}
}

function ClickRosterNameOrContractDetail(studentID,rosterOrContract,teacherID,scope){
	//	globalWaitingForStuRecToLoadTimerID = setInterval("ResetGlobalWaitingForStuRecToLoadVar()",2000);
	//	if(globalWaitingForStuRecToLoad == false){		 
		//window.status = window.status + '-zx'
			 globalWaitingForStuRecToLoad = true;
				var classComp = GetCookie('cc');

				var mygetrequest=new ajaxRequest();
				mygetrequest.onreadystatechange=function(){
					
				if (mygetrequest.readyState==4){
				  if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
						  //--- Here is where all the info comes back -------			
								document.getElementById('errorstation').value = mygetrequest.responseText;
		 //	alert (mygetrequest.responseText); 
				//window.status = " ClickRosterNameOrContract loaded  ";

						  var partsArray = mygetrequest.responseText.split('@@@@');
								var studentRecordString = partsArray[0]; 
								var studentRecordArray = studentRecordString.split('%%%%');
								globalTopBlurb = partsArray[1];	
								globalOGCourseID = studentRecordArray[2] * 1;					  
								globalOGPretestID = studentRecordArray[21]*1;		
							//	alert('global upon loading = ' + globalOGPretestID)
					 //  globalTopLinkHTML = partsArray[2];	
					   globalButtonHTML = partsArray[3];		
						  teacherTableHTML = partsArray[4];
							//	alert(teacherTableHTML)
								var noteToStudentHTML = partsArray[5];
								var noteAboutStudentHTML = partsArray[6];
								var verticalMenuHTML = partsArray[7];
								var newStudentID = partsArray[8];
						//		var studentContractAssIDString = partsArray[5];
						//		var studentContractAssIDArray = studentContractAssIDString.split('%%%%');
							//	var studentContractStatusString = partsArray[5];
						//		var studentContractStatusArray = studentContractStatusString.split('%%%%');								
						//		alert('it is: ' + noteToStuHTML)
						//alert(studentRecordString);
						//alert(globalButtonHTML)
						  
								document.getElementById('mainalertdiv').innerHTML = globalTopBlurb;
								document.getElementById('mainrightdiv1').innerHTML = globalTopLinkHTML;
								document.getElementById('fullpagedatadiv').style.visibility = 'hidden';
								document.getElementById('fullpagedatadiv').style.top = '-1000px';
						  document.getElementById('fullpagedatadiv').innerHTML = teacherTableHTML;		
		      document.getElementById('mainbuttondiv').innerHTML = globalButtonHTML;									
								 document.getElementById('notetostudentdiv').innerHTML = noteToStudentHTML;
									document.getElementById('noteaboutstudentdiv').innerHTML = noteAboutStudentHTML;
									document.getElementById('verticalmenudiv').innerHTML = verticalMenuHTML;


								//--- Load many of the components of the data div (current course, current casual assignment name, etc) from
								//-- a combination of info retured from student record and the Help Available array (which has all the course
        //-- and assignment names already here in javascript. -----------------		
								globalStudentRecordActive = true;
								SetAssignmentNamePointer('on');
								switch(rosterOrContract){
								  case 'roster':
								
								    FillOutStudentRecord(studentRecordArray,scope);
											
												break;
										case 'contract':		
									
								    FillOutStudentContract(studentRecordArray,studentID);
												SaveOriginalContractStatusStrings();
												
												break;																						
								}
								
						  globalWaitingForStuRecToLoad = false;
							//	alert('loaded stu info')
								SizeImageAndCenterMainDivDetail();
				 	}//if (mygetrequest.status==200
				}//if (mygetrequest.readyState==4){
			}//mygetrequest.onreadystatechange=function()		
			mygetrequest.open("GET", "GetStudentRecord.php?s="+studentID+"&t="+teacherID+"&req="+rosterOrContract+"&cc="+classComp+"&gs="+globalSessionID+"&qwert="+new Date().getTime(), true);
			mygetrequest.send(null);				
	//}
} //studentRecordArray  globalOGCourseID  globalWaitingForStuRecToLoad

function ClickedCurrentStudentWorkForTeacher(studentID,teacherID){
	//window.status = window.status + '-qk'
	  document.getElementById('lastvertmenu').value = 'current';
	  //--- Loads the student's dataqlthe main viewport area --		
				var cc = GetCookie('cc');
				var tc = GetCookie('cc');
				var rc = GetCookie('cc');				
				var mygetrequest=new ajaxRequest();
				mygetrequest.onreadystatechange=function(){
				if (mygetrequest.readyState==4){
				  if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
						  //--- Here is where all the info comes back -------				
	    //alert (mygetrequest.responseText); 
					//window.status = "ClickedCurrentStudentWorkForTeacher loaded  ";
						  var partsArray = mygetrequest.responseText.split('@@@@');	
								globalMainTextHTML = partsArray[0]; //the entire mother fucker is in here in the case of scrolling 'n' problems that are being worked on
						  var docArrayString = partsArray[1]; //any docs (separated by ^^^^) that need to be shown		
								var rawContractStatus = partsArray[2]; //testnext 
								var verticalMenuHTML = partsArray[3];
								var docArray = docArrayString.split('^^^^');

								document.getElementById('fullpagedatadiv').style.visibility = 'hidden';
								document.getElementById('fullpagedatadiv').style.top = '-1000px';
						  document.getElementById('fullpagedatadiv').innerHTML = globalMainTextHTML;		
								document.getElementById('verticalmenudiv').innerHTML = verticalMenuHTML;

								SizeImageAndCenterMainDivDetail();
								SetFocusToCurrentRosterName();
				 	}//if (mygetrequest.status==200
				}//if (mygetrequest.readyState==4){
			}//mygetrequest.onreadystatechange=function()		
			mygetrequest.open("GET", "GetStudentCurrentWork.php?s="+studentID+"&gs="+globalSessionID+"&t="+teacherID+"&ut=teacher"+"&cc="+cc+"&tc="+tc+"&rc="+rc+"&qwert="+new Date().getTime(), true);
			mygetrequest.send(null);				

}


function ClickContract(studentID,teacherID){	  
	  //--- Loads the student's dataqzthe main viewport area --
   //window.status = window.status + '-qx'
			document.getElementById('lastvertmenu').value = 'contract';
				var mygetrequest=new ajaxRequest();
				mygetrequest.onreadystatechange=function(){
				if (mygetrequest.readyState==4){
				  if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
						  //--- Here is where all the info comes back -------			
							//	alert(mygetrequest.responseText);
							//window.status = "ClickContract loaded  ";
								if(teacherID == 0){
									 // -- it's a student ---
										var partsArray = mygetrequest.responseText.split('@@@@');
									 globalMainTextHTML = partsArray[0];
						   	globalButtonHTML = '';	
							   globalTopBlurb = partsArray[1];		 //the course name				
								  globalResponseTextHTML = '';
								  globalProblemSelectHTML = '';														
										LoadMainElements();
								}else{
									 //-- it's a teacher ----
										var partsArray = mygetrequest.responseText.split('@@@@');
										var contractHTML = partsArray[0];
										var verticalMenuHTML = partsArray[1];
								  document.getElementById('fullpagedatadiv').style.visibility = 'hidden';
								  document.getElementById('fullpagedatadiv').style.top = '-1000px';
						    document.getElementById('fullpagedatadiv').innerHTML = contractHTML;			
							//	document.getElementById('fullpagedatadiv').innerHTML = 'hey chas';
										document.getElementById('verticalmenudiv').innerHTML = verticalMenuHTML;
							  	globalStudentRecordActive = true;
								  SetAssignmentNamePointer('on');
										SaveOriginalContractStatusStrings();										
								}
								SizeImageAndCenterMainDivDetail();			
								SetFocusToCurrentRosterName();
								
				 	}//if (mygetrequest.status==200
				}//if (mygetrequest.readyState==4){
			}//mygetrequest.onreadystatechange=function()		
			mygetrequest.open("GET", "GetStudentContract.php?s="+studentID+"&t="+teacherID+"&gs="+globalSessionID+"&qwert="+new Date().getTime(), true);
			mygetrequest.send(null);						
}

function ClickedContractByStudent(studentID){	  
//window.status = window.status + '-qc'
   //--- this is the version that is just for student use --
			if(globalDocsForBrowseHelp == true){
			  globalDocsForBrowseHelp = false;
					LoadBrowseHelpContents(-1,'student')
			}
	   ClearAllTimers();
				var mygetrequest=new ajaxRequest();
				mygetrequest.onreadystatechange=function(){
				if (mygetrequest.readyState==4){
						if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
								//--- Here is where all the info comes back which ain't nothing in this case-------	
								//globalTopLinkHTML = //just leave it just the way it was	
								//window.status = "ClickedContractByStudent loaded  ";
						 	globalButtonHTML = '';	
								//alert(mygetrequest.responseText)
								globalTopBlurb = '';							
								globalResponseTextHTML = '';
								globalProblemSelectHTML = '';								
							 //-- the original student code --
						  var partsArray = mygetrequest.responseText.split('@@@@');																							
								globalMainTextHTML = partsArray[0]; //the entire mother fucker is in here in the case of scrolling 'n' problems that are being worked on
						  var entireSectionCorrect = partsArray[1]; //not used 0=not all correct, 1 = all correct 									
								LoadMainElements();								
									//alert('b4 ' + document.getElementById('maintextdiv').offsetWidth);
								//	alert('b4 ' + document.getElementById('mainleftdiv').offsetWidth);
								SizeImageAndCenterMainDivDetail();
							//	alert('after ' + document.getElementById('maintextdiv').offsetWidth);
							//	alert('after ' + document.getElementById('mainleftdiv').offsetWidth);																
						}//if (mygetrequest.status==200
				}//if (mygetrequest.readyState==4){
			}//mygetrequest.onreadystatechange=function()		
			//mygetrequest.open("GET", "GetStudentCheckoutMaterials.php?s="+studentID+"&gs="+globalSessionID+"&t="+teacherID+"&qwert="+new Date().getTime(), true);
			mygetrequest.open("GET", "GetStudentContract.php?s="+studentID+"&gs="+globalSessionID+"&qwert="+new Date().getTime(), true);
			mygetrequest.send(null);				
}

function ClickedSubSection(assignment, studentID, sentTrack, sentFrame, sentSubSectionTitle, userType,teacherID){
	//window.status = window.status + '-qb'
	      //  ClickedSubSection(68313,         2,        'n',       48,      'Page 39: Word Problems','teacher',0)
	//			alert(assignment + '--a--' +  studentID + '--b--' +  sentTrack + '--c--' +  sentFrame + '--d--' +  sentSubSectionTitle + '-e--' +  userType + '--f--' +  teacherID)			
	  UpdateSubSection(assignment, studentID, sentTrack, sentFrame, sentSubSectionTitle);
  //-- put in the new problems ----------		
	//	alert('usertype in clickedsubsecftion=' + userType)
		GetProblemsHTML(assignment,studentID,sentTrack,sentFrame,0,userType,teacherID);				
	//	GetProblemsHTML($sentAssignment,$studentID,$trackOfInterest,$initialFrame,$groupOfInterest,$userType,$teacherID)
}


function UpdateSubSection(assignment, studentID, sentTrack, sentFrame, sentSubSectionTitle){
	//window.status = window.status + '-qn'
  //alert(studentID + '---'+ sentTrack + '---'+ sentFrame + '---' + sentSubSectionTitle)
  $(".subsec").css("color", "black"); //make all the subsections the unselected color  jquery
		//$(".subsecdone").css("color", "gray"); //make all the subsections the unselected color  jquery
		$(".subsecdone").css("color", "black"); //make all the subsections the unselected color  jquery
		//-- highlight the just clicked subsection --
		var divIDName = 'subsec' + sentFrame;
		try{
			 //-- this div won't exist in the case of problem sets like tests ---
		  document.getElementById(divIDName).style.color = 'blue';
		  if(sentSubSectionTitle != ''){
		    //-- replace the subsection caption title with the just clicked one --
		    document.getElementById('currentworksubsectionblurbdiv').innerHTML = sentSubSectionTitle;
		  }					
		}
		catch(e){
					var x = 8; //for ie
		}						
}

function OpenPDF(sentPDF){	
//window.status = window.status + '-qm'
  var omyFrame = document.getElementById("myFrame");
  omyFrame.style.display="block";
  omyFrame.src = sentPDF;
}

function ClickedGetStudentCurrentWork(studentID,userType){	  
//window.status = window.status + '-1q'
  globalDocsForBrowseHelp = false;
	   ClearAllTimers();
				var cc = GetCookie('cc');
				var tc = GetCookie('cc');
				var rc = GetCookie('cc');
				var mygetrequest=new ajaxRequest();
				mygetrequest.onreadystatechange=function(){
				if (mygetrequest.readyState==4){
						if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
								//--- Here is where all the info comes back which ain't nothing in this case-------	
								//globalTopLinkHTML = //just leave it just the way it was	
								//window.status = "ClickedGetStudentCurrentWork loaded  ";
						 	globalButtonHTML = '';	
								globalTopBlurb = '';							
								globalResponseTextHTML = '';
								globalProblemSelectHTML = '';								
							 //-- the original student code --
						  var partsArray = mygetrequest.responseText.split('@@@@');	
								globalMainTextHTML = partsArray[0]; //the entire mother fucker is in here in the case of scrolling 'n' problems that are being worked on
						  var docArrayString = partsArray[1]; //any docs (separated by ^^^^) that need to be shown		
								var rawContractStatus = partsArray[2]; //testnext 
						
								var docArray = docArrayString.split('^^^^');
								numDocs = docArray.length - 1;
								if(numDocs > 0){
									 //--- if it needs doc(s) put in there, so we take out the help browse --						
										document.getElementById('helpselectordiv').innerHTML = '';
										//-- build the image html -----
										var imageHTML = ''		
										for (var i=0;i<numDocs;i++){		
												imageHTML = imageHTML + "<img src='"+docArray[i]+"' />"  
										}
								  document.getElementById('browseproblemdiv').innerHTML = imageHTML;				
										document.getElementById('browseproblemdiv').style.overflow = 'auto';
										globalDocsForBrowseHelp = true;
								}else{
									 globalDocsForBrowseHelp = false;
										LoadBrowseHelpContents(-1,'student'); 	
								}
								LoadMainElements();								  		
								SizeImageAndCenterMainDivDetail();
								
						}//if (mygetrequest.status==200
				}//if (mygetrequest.readyState==4){
			}//mygetrequest.onreadystatechange=function()		
			//mygetrequest.open("GET", "GetStudentCheckoutMaterials.php?s="+studentID+"&gs="+globalSessionID+"&t="+teacherID+"&qwert="+new Date().getTime(), true);
			
			mygetrequest.open("GET", "GetStudentCurrentWork.php?s="+studentID+"&gs="+globalSessionID+"&ut="+userType+"&cc="+cc+"&tc="+tc+"&rc="+rc+"&ut=student"+"&qwert="+new Date().getTime(), true);
			mygetrequest.send(null);			
}

function ClickedMaterial(regOrHigh, materialID){	 
//window.status = window.status + '-1w'
	 oMaterialItem = document.getElementById(materialID);
		oMaterialItemNum = document.getElementById(materialID + 'num');
		if(oMaterialItem.className != 'matnocopies'){
				if((oMaterialItem.className == 'matsel')||(oMaterialItem.className == 'matselnum')){
						oMaterialItem.className = regOrHigh;
						oMaterialItemNum.className = regOrHigh;
				}else{
						oMaterialItem.className	= 'matsel';
						oMaterialItemNum.className	= 'matselnum';
				}
		}

}

function ClickedRequestMat(matIDcopyNum){
	//window.status = window.status + '-1e'
 	//--- this just selects or deselects an item in the requested materials list --
	 var oddChar = "*|{`]^";  //this is identical to what's in GetMaterialsCheckout.php					
		var dataArray = matIDcopyNum.split(oddChar);
		var matID = dataArray[0];
		var copyNum = dataArray[1];	
		var stuID = dataArray[2];

  var rowID = 'requesttr' + matIDcopyNum;
		var oRow = document.getElementById(rowID);
		
		if(oRow.className == 'requesttr'){
			 oRow.className = 'requesttrsel';
				document.getElementById('checkoutbutton').disabled = false;
				document.getElementById('cancelrequestbutton').disabled = false;
		}else{
		  oRow.className = 'requesttr';
				//-- see if any more are still selected --
				var someSelected = false;
				var trs=document.getElementsByTagName('tr');
    for (var i=0;i<trs.length;i++){
      if(trs[i].className == 'requesttrsel'){
							 someSelected = true;
								break;
						}
    } 					
				if(someSelected == false){					 
					 document.getElementById('checkoutbutton').disabled = true; 
						document.getElementById('cancelrequestbutton').disabled = true; 
				}
		}//if else classname=requestrow		
}



function ClickedCheckedOutMat(matIDcopyNum){
	//window.status = window.status + '-1r'
	//--- this just selects or deselects an item in the checked out list --
	 var oddChar = "*|{`]^";  //this is identical to what's in GetMaterialsCheckout.php			
		var dataArray = matIDcopyNum.split(oddChar);
		var matID = dataArray[0];
		var copyNum = dataArray[1];	
		var stuID = dataArray[2];

  var rowID = 'checkedouttr' + matIDcopyNum;
		var oRow = document.getElementById(rowID);
		
		if(oRow.className == 'checkedouttr'){
			 oRow.className = 'checkedouttrsel';
				document.getElementById('returnbutton').disabled = false; 
		}else{
		  oRow.className = 'checkedouttr';
				//-- see if any more are still selected --
				var someSelected = false;
				var trs=document.getElementsByTagName('tr');
    for (var i=0;i<trs.length;i++){
      if(trs[i].className == 'checkedouttrsel'){
							 someSelected = true;
								break;
						}
    } 					
				if(someSelected == false){					 
					 document.getElementById('returnbutton').disabled = true; //
				}
		}//if else classname=checkedoutrow
}

function CheckoutMaterial(tchrID){
	//window.status = window.status + '-1t'
	 //-- makes an individual php call for each selected item in the materials requested list ---
		//-- Clears whatever is in the undo table and then does the checkout after that is accomplished --
			var mygetrequestOuter=new ajaxRequest();
			mygetrequestOuter.onreadystatechange=function(){
			if (mygetrequestOuter.readyState==4){
					if (mygetrequestOuter.status==200 || window.location.href.indexOf("http")==-1){
							//--- Here is where all the info comes back which ain't nothing in this case-------	
							//	alert (mygetrequest.responseText); 		
							//-- Reload the checkout page to reflect the update info when they're all updated---
       //------ the nested part below --------
							//-- makes an individual php call for each selected item in the materials requested list ---
							var trs=document.getElementsByTagName('tr');
							var selectedReqTrArray = new Array();		
							for (var i=0;i<trs.length;i++){
									if(trs[i].className == 'requesttrsel'){
											selectedReqTrArray.push(trs[i].id); 
									}
							}		
							lastOne = false;
							for (var i=0;i<selectedReqTrArray.length;i++){
									if(i==selectedReqTrArray.length-1){
												lastOne=true;
									}
									CheckoutMaterialDetail(selectedReqTrArray[i],lastOne);
							}							
							//-- the nested part above ---							
					}//if (mygetrequest.status==200
			}//if (mygetrequest.readyState==4){
		}//mygetrequest.onreadystatechange=function()		
	
		var urlString = "ClearMaterialsUndo.php?tchrid="+tchrID;
		mygetrequestOuter.open("GET" ,urlString+"&qwert="+new Date().getTime(), true);
		mygetrequestOuter.send(null);					
}

function CheckoutMaterialDetail(trIDName,lastOne){
	//window.status = window.status + '-1y'
			var oddChar = "*|{`]^";  //this is identical to what's in GetMaterialsCheckout.php
			var fullIDName = trIDName;
			var matIDcopyNum = fullIDName.replace('requesttr','');						
			var dataArray = matIDcopyNum.split(oddChar);
			var matID = dataArray[0];
			var copyNum = dataArray[1];	
			var stuID = dataArray[2];
			var tchrID = dataArray[3];
			var indef = dataArray[4];
			var mygetrequest=new ajaxRequest();
			mygetrequest.onreadystatechange=function(){
			if (mygetrequest.readyState==4){
					if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
							//--- Here is where all the info comes back which ain't nothing in this case-------	
							//window.status = "CheckoutMaterialDetail loaded  ";
							//	alert (mygetrequest.responseText); 		
							//-- Reload the checkou page to reflect the update info when they're all updated---
        if(lastOne == true){												
									 ClickedMaterials(tchrID,'checkout');
								}
					}//if (mygetrequest.status==200
			}//if (mygetrequest.readyState==4){
		}//mygetrequest.onreadystatechange=function()		
	
		var urlString = "CheckoutMaterialToStudent.php?matid="+matID+"&copynum="+copyNum+"&stuid="+stuID+"&tchrid="+tchrID+"&indef="+indef;
		mygetrequest.open("GET" ,urlString+"&qwert="+new Date().getTime(), true);
		mygetrequest.send(null);																			
}

function ReturnMaterial(tchrID){
	//window.status = window.status + '-1u'
	 //-- makes an individual php call for each selected item in the materials requested list ---
		//-- Clears whatever is in the undo table and then does the return after that is accomplished --
			var mygetrequestOuter=new ajaxRequest();
			mygetrequestOuter.onreadystatechange=function(){
			if (mygetrequestOuter.readyState==4){
					if (mygetrequestOuter.status==200 || window.location.href.indexOf("http")==-1){
							//--- Here is where all the info comes back which ain't nothing in this case-------	
							//	alert (mygetrequest.responseText); 		
							//-- Reload the checkou page to reflect the update info when they're all updated---
       //------ the nested part below --------
							//-- makes an individual php call for each selected item in the materials requested list ---
							var trs=document.getElementsByTagName('tr');
							var selectedReqTrArray = new Array();		
							for (var i=0;i<trs.length;i++){
									if(trs[i].className == 'checkedouttrsel'){
											selectedReqTrArray.push(trs[i].id); 
									}
							}		
							lastOne = false;
							for (var i=0;i<selectedReqTrArray.length;i++){
									if(i==selectedReqTrArray.length-1){
												lastOne=true;
									}
									ReturnMaterialDetail(selectedReqTrArray[i],lastOne);
							}						
							//-- the nested part above ---							
					}//if (mygetrequest.status==200
			}//if (mygetrequest.readyState==4){
		}//mygetrequest.onreadystatechange=function()		
	
		var urlString = "ClearMaterialsUndo.php?tchrid="+tchrID;
		mygetrequestOuter.open("GET" ,urlString+"&qwert="+new Date().getTime(), true);
		mygetrequestOuter.send(null);					
}

function ReturnMaterialDetail(trIDName,lastOne){
	//window.status = window.status + '-1i'
			var oddChar = "*|{`]^";  //this is identical to what's in GetMaterialsCheckout.php
			var fullIDName = trIDName;
			var matIDcopyNum = fullIDName.replace('checkedouttr','');				
			//alert(matIDcopyNum)
			var dataArray = matIDcopyNum.split(oddChar);
			var matID = dataArray[0];
			var copyNum = dataArray[1];	
			var stuID = dataArray[2];
			var tchrID = dataArray[3];
			var indef = dataArray[4];
			var mygetrequest=new ajaxRequest();
			mygetrequest.onreadystatechange=function(){
			if (mygetrequest.readyState==4){
					if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
							//--- Here is where all the info comes back which ain't nothing in this case-------	
							//	alert (mygetrequest.responseText); 		
							//window.status = "ReturnMaterialDetail loaded  ";
							//-- Reload the checkou page to reflect the update info when they're all updated---
							//alert('deep: ' + matID + '  ' + copyNum)
        if(lastOne == true){												
									 ClickedMaterials(tchrID,'checkout');
								}
					}//if (mygetrequest.status==200
			}//if (mygetrequest.readyState==4){
		}//mygetrequest.onreadystatechange=function()		
	
		var urlString = "ReturnMaterialFromStudent.php?matid="+matID+"&copynum="+copyNum+"&stuid="+stuID+"&tchrid="+tchrID+"&indef="+indef;
		mygetrequest.open("GET" ,urlString+"&qwert="+new Date().getTime(), true);
		mygetrequest.send(null);																			
}


function CancelMaterial(tchrID){
	//window.status = window.status + '-1o'
	 //-- makes an individual php call for each selected item in the materials requested list ---
		//-- Clears whatever is in the undo table and then does the cancel after that is accomplished --
			var mygetrequestOuter=new ajaxRequest();
			mygetrequestOuter.onreadystatechange=function(){
			if (mygetrequestOuter.readyState==4){
					if (mygetrequestOuter.status==200 || window.location.href.indexOf("http")==-1){
							//--- Here is where all the info comes back which ain't nothing in this case-------	
							//	alert (mygetrequest.responseText); 		
							//-- Reload the checkou page to reflect the update info when they're all updated---
       //------ the nested part below --------
							//-- makes an individual php call for each selected item in the materials requested list ---
							var trs=document.getElementsByTagName('tr');
							var selectedReqTrArray = new Array();		
							for (var i=0;i<trs.length;i++){
									if(trs[i].className == 'requesttrsel'){
											selectedReqTrArray.push(trs[i].id); 
									}
							}		
							lastOne = false;
							for (var i=0;i<selectedReqTrArray.length;i++){
									if(i==selectedReqTrArray.length-1){
												lastOne=true;
									}
									CancelMaterialRequestDetail(selectedReqTrArray[i],lastOne);
							}		
							//-- the nested part above ---							
					}//if (mygetrequest.status==200
			}//if (mygetrequest.readyState==4){
		}//mygetrequest.onreadystatechange=function()		
	
		var urlString = "ClearMaterialsUndo.php?tchrid="+tchrID;
		mygetrequestOuter.open("GET" ,urlString+"&qwert="+new Date().getTime(), true);
		mygetrequestOuter.send(null);					
}

function CancelMaterialRequestDetail(trIDName,lastOne){
	//window.status = window.status + '-1p'
			var oddChar = "*|{`]^";  //this is identical to what's in GetMaterialsCheckout.php
			var fullIDName = trIDName;
			var matIDcopyNum = fullIDName.replace('requesttr','');						
			var dataArray = matIDcopyNum.split(oddChar);
			var matID = dataArray[0];
			var copyNum = dataArray[1];	
			var stuID = dataArray[2];
			var tchrID = dataArray[3];
			var indef = dataArray[4];
			var mygetrequest=new ajaxRequest();
			mygetrequest.onreadystatechange=function(){
			if (mygetrequest.readyState==4){
					if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
							//--- Here is where all the info comes back which ain't nothing in this case-------	
							//	alert (mygetrequest.responseText); 		
							//window.status = "CancelMaterialRequestDetail loaded  ";
							//-- Reload the checkou page to reflect the update info when they're all updated---
        if(lastOne == true){												
									 ClickedMaterials(tchrID,'checkout');
								}
					}//if (mygetrequest.status==200
			}//if (mygetrequest.readyState==4){
		}//mygetrequest.onreadystatechange=function()		
	
		var urlString = "CancelMaterialRequestFromStudent.php?matid="+matID+"&copynum="+copyNum+"&stuid="+stuID+"&tchrid="+tchrID+"&indef="+indef;
		mygetrequest.open("GET" ,urlString+"&qwert="+new Date().getTime(), true);
		mygetrequest.send(null);																			
}


function UndoLastMaterialAction(tchrID){
	//window.status = window.status + '-1a'
			var mygetrequest=new ajaxRequest();
			mygetrequest.onreadystatechange=function(){
			if (mygetrequest.readyState==4){
					if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
							//--- Here is where all the info comes back which ain't nothing in this case-------	
							//	alert (mygetrequest.responseText); 		
							//window.status = "UndoLastMaterialAction loaded  ";
							//-- Reload the checkou page to reflect the update info when they're all updated---
									//-- this will be the last one --
									ClickedMaterials(tchrID,'checkout');									
							
					}//if (mygetrequest.status==200
			}//if (mygetrequest.readyState==4){
		}//mygetrequest.onreadystatechange=function()		
	
		var urlString = "UndoLastMaterialAction.php?tchrid="+tchrID;
		mygetrequest.open("GET" ,urlString+"&qwert="+new Date().getTime(), true);
		mygetrequest.send(null);		
}



function CheckoutSelectedItems(studentID){				
//window.status = window.status + '-1s'
				//-- loop through all the divs to find which are selected ---
				var selArrayString = '';
				var copyTypeArrayString = '';
    var divs=document.getElementsByTagName('div');
    for (var i=0;i<divs.length;i++){
      if(divs[i].className == 'matsel'){
							 matID = divs[i].id;
								selArrayString = selArrayString + '@' + matID.replace('mat','');								
						}
      if(divs[i].className == 'matselnum'){
							 if(divs[i].innerHTML == '&nbsp;'){
								  copyTypeArrayString = copyTypeArrayString + '@' + 'indef';		
						  }else{
									 copyTypeArrayString = copyTypeArrayString + '@' + '';	
								}
						}						
    } 			
				if(selArrayString != ''){
					  // -- picked something(s) -------------													
					  selArrayString = selArrayString.substr(1); //get off the first ampersand
							copyTypeArrayString = copyTypeArrayString.substr(1); //get off the first ampersand
							var mygetrequest=new ajaxRequest();
							mygetrequest.onreadystatechange=function(){
							if (mygetrequest.readyState==4){
									if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
											//--- Here is where all the info comes back which ain't nothing in this case-------	
								 	//alert (mygetrequest.responseText); 
										//window.status = "CheckoutSelectedItems loaded  ";
											var partsArray = mygetrequest.responseText.split('@@@@');
											globalTopBlurb = partsArray[0]; 									
									  teacherID = partsArray[1];	
											//-- available material(s) have been requested by the student ---
											WriteFileNotice(teacherID);	//for the audible notification										
									//		globalButtonHTML = partsArray[2];															
									//		globalResponseTextHTML = '';
									//		globalProblemSelectHTML = '';
			        //------ nested ajax -- reload the page with the new changes (keep the same global Top Blurb)------
													var mygetrequest2=new ajaxRequest();
													mygetrequest2.onreadystatechange=function(){
													if (mygetrequest2.readyState==4){
															if (mygetrequest2.status==200 || window.location.href.indexOf("http")==-1){
																	//--- Here is where all the info comes back which ain't nothing in this case-------	
															//	alert (mygetrequest2.responseText); 
																	var partsArray = mygetrequest2.responseText.split('@@@@');
																//	globalTopLinkHTML= partsArray[0]; 									
																	globalMainTextHTML = partsArray[1];																			
															//		globalButtonHTML = partsArray[2];								
																//	globalTopBlurb = partsArray[3];								
														//			globalResponseTextHTML = '';
																//	globalProblemSelectHTML = '';
									
																	LoadMainElements();
																	SizeImageAndCenterMainDivDetail();		
															}//if (mygetrequest2.status==200
													}//if (mygetrequest2.readyState==4){
												}//mygetrequest2.onreadystatechange=function()		
												//mygetrequest2.open("GET", "GetStudentCheckoutMaterials.php?s="+studentID+"&gs="+globalSessionID+"&t="+teacherID+"&qwert="+new Date().getTime(), true);
												mygetrequest2.open("GET", "GetStudentCheckoutMaterials.php?s="+studentID+"&gs="+globalSessionID+"&qwert="+new Date().getTime(), true);
												mygetrequest2.send(null);														
																						
											//--- end of nested ajax ---
											LoadMainElements();
											SizeImageAndCenterMainDivDetail();		
									}//if (mygetrequest.status==200
							}//if (mygetrequest.readyState==4){
						}//mygetrequest.onreadystatechange=function()		
						//mygetrequest.open("GET", "GetStudentCheckoutMaterials.php?s="+studentID+"&gs="+globalSessionID+"&t="+teacherID+"&qwert="+new Date().getTime(), true);
						mygetrequest.open("GET", "SaveSelectedMaterialItems.php?i="+studentID+"&sel="+selArrayString+"&ct="+copyTypeArrayString+"&qwert="+new Date().getTime(), true);
						mygetrequest.send(null);									
				}
	
}

function findHighestZIndex(elem)
{
	//window.status = window.status + '-1d'
	 //elem = 'div' etc
  var elems = document.getElementsByTagName(elem);
  var highest = 0;
  for (var i = 0; i < elems.length; i++)
  {
    var zindex=document.defaultView.getComputedStyle(elems[i],null).getPropertyValue("z-index");
    if ((zindex > highest) && (zindex != 'auto'))
    {
      highest = zindex;
    }
  }
		alert (highest)
  return highest;
}


function SizeImageAndCenterMainDivDetail(){   		
//window.status = window.status + '-1f'

		oTchrDataDivContent = document.getElementById('tchrdatadivcontent');	
		oFullMainDiv = document.getElementById('fullmaindiv');	
		switch(true){
		  case(oTchrDataDivContent != null):
			   //-- this is a teacher's full screen app program ---
				 	SetCurvedCorners(false); 
				 	SizeImageAndCenterMainDivDetailTeacher()
				  break;
		  case(oFullMainDiv != null):
			   //-- this is a special full page div like GED practice test ---
				 	SetCurvedCorners(false); 
				 	SizeImageAndCenterFullMainDiv();
				  break;						
		  default:
			   //-- this is a student (or the main sign-in page) which is the compact div program (the one you've used for everything up to now)--
					 SetCurvedCorners(true);
					 SizeImageAndCenterMainDivDetailRegular()
		}
}



function SizeImageAndCenterMainDivDetailRegular(){  	
//window.status = window.status + '-1h'
  if ((globalBrowseHelpDivWidth > 0) && (globalDocsForBrowseHelp == false)){
	  // -- this is needed in the event the PREVIOUS view had globalDocsForBrowseHelp = true.  We need to shrink the browse help div back to normal --
			//-- The 0 business is because this function will be called BEFORE globalBrowseHelpDivWidth had a chance to be determined. ---
			document.getElementById('browseproblemdiv').style.width = globalBrowseHelpDivWidth + 'px';
 }
	if(globalDocsForBrowseHelp == false){
	 //alert('its false alright')
}
									
 //var viewportH = GetViewportHeightIncludingScrollBar();			
 //	var viewportW = GetViewportWidthIncludingScrollBar();	
		
		var oMainDiv = document.getElementById('maindiv');	
		var oShadowDiv = document.getElementById('shadowmaindiv');
		var ofullpagedatadiv = document.getElementById('fullpagedatadiv');
		//var oOriginalWorkingTeacher = document.getElementById('originalworkingteacherdiv');
		
  //oMainDiv.style.visibility = 'hidden';		
	//	oShadowDiv.style.visibility = 'hidden';			
		//ofullpagedatadiv.style.visibility = 'visible'; /////////////////////
	//	document.getElementById('mainrightdiv').style.visibility = 'visible'; /////////////
	
		var oMainTextDiv = document.getElementById('maintextdiv');
		
		try{
    clearInterval(sizeImageTimerID);
		}
		catch(e){
    x = 8; //for IE						
		}	

		//---- Something that apparently is needed if an audio control is present (can't do in CSS since Audio might not be there) -
		if (document.getElementById('audioplayerdiv').innerHTML != ''){
		  document.getElementById('languagebuttondiv').style.height = document.getElementById('audioplayerdiv').style.height;
  	}
					
  //-- the pixel sizes in here are based on an EM-width = 14 --
		//-- so they are adjusted relative to that ------------		
		var emWidthHeight = document.getElementById('markerdiv').offsetWidth;
		var emFactor = emWidthHeight/14;
		fullpagedatadivHeight = 0;
		
		if(globalMaxState == 'normal'){		
				var minLeftWidth = 180*emFactor;
				var maxLeftWidth = 285*emFactor;			
				var minRightWidth = 350*emFactor;		//-- redefined below as wider if the topLengthWidth exceeds it
				var minImageW = 160;
				var minImageH = 100;		
				var mainDivBorderFactor = 0.05; //eg, if the main div comes out to be between the min and max, use this to get the border amt.		
				var maxMainWidth = 800*emFactor; 
				var maxMainHeight = 550*emFactor; //503*emFactor;
				var minMainHeight = 300*emFactor; //265*emFactor;
				var leftMargin = mainDivBorderFactor*globalViewportW;
				var topMargin = mainDivBorderFactor*globalViewportH;
		}else{ //globalMaxState == 'max'
				var minLeftWidth = 180*emFactor;
				var maxLeftWidth = 285*emFactor;		
				var minRightWidth = 350*emFactor;		//-- redefined below as wider if the topLengthWidth exceeds it
				var minImageW = 160;
				var minImageH = 100;		
				var mainDivBorderFactor = 0 ; //eg, if the main div comes out to be between the min and max, use this to get the border amt.		
				var maxMainWidth = globalViewportW; 
				var maxMainHeight = globalViewportH;
				var minMainHeight = 265*emFactor;
				var leftMargin = 0;
				var topMargin = 0;			
		}
		
  // --- Get the unchangeable heights and widths of the component parts on the right (note: maintextdiv is treated 
  // -- differently later since it wraps to the width you give it (thus increasing its height) ---

	//	var iconH = document.getElementById('maxicondiv').offsetHeight;
		var iconH = 0;
		//-- you don't have to worry about the width becuase it's way less than minImageW --
		
		var topLinkW1 = document.getElementById('toplinkdiv1').offsetWidth;
		var topLinkW2 = document.getElementById('toplinkdiv2').offsetWidth;
		var topLinkW3 = document.getElementById('toplinkdiv3').offsetWidth;
		var topLinkW4 = document.getElementById('toplinkdiv4').offsetWidth;
		var topLinkW5 = document.getElementById('toplinkdiv5').offsetWidth;
		var topLinkW6 = document.getElementById('toplinkdiv6').offsetWidth;		
		var topLinkW7 = document.getElementById('toplinkdiv7').offsetWidth;
  var topLinkWidth = topLinkW1 + topLinkW2 + topLinkW3 + topLinkW4 + topLinkW5 + topLinkW6 + topLinkW7;
		var topLinkHeight = document.getElementById('mainrightdiv1').offsetHeight;	
	//	if(topLinkWidth*emFactor > minRightWidth){
		//	 minRightWidth = topLinkWidth*emFactor;
			//	alert('a:' + minRightWidth)
	//	}
		

		//--- note: you'll always get about 1em height for audioPlayer since you use inline-table display for the parts... whatever
		var clickProbW = document.getElementById('clickproblemdiv').offsetWidth;
		var langButW = document.getElementById('languagebuttondiv').offsetWidth;
		if (globalAudioState == 'on'){
 	  var audioPlayerW = document.getElementById('audioplayerdiv').offsetWidth;
	   var audioW = clickProbW + langButW + audioPlayerW;		
    var audioH = document.getElementById('audiodiv').offsetHeight;
				if(audioH > 0){
				  //-- add onto the audioH for the little tab that's on top and isn't apparently counted in it's 				
				  audioH = audioH + (0.7*emWidthHeight); 
				}
		}else{
 	  var audioPlayerW = 0;
	   var audioW = 0;		
    var audioH = 0;			
		}
		var butW1 = document.getElementById('but1').offsetWidth;
		var butW2 = document.getElementById('but2').offsetWidth;
		var butW3 = document.getElementById('but3').offsetWidth;
		var butW4 = document.getElementById('but4').offsetWidth;
		var butW5 = document.getElementById('but5').offsetWidth;
		var buttonW = butW1 + butW2 + butW3 + butW4 + butW5;

		var buttonH = document.getElementById('mainbuttondiv').offsetHeight;
		if(document.getElementById('mainbuttondiv').innerHTML == ''){
			 buttonH = 0;
		}

		var respW1 = document.getElementById('resptext1').offsetWidth;
		var respW2 = document.getElementById('resptext2').offsetWidth;
		var respH1 = document.getElementById('resptext1').offsetHeight;
		var respH2 = document.getElementById('resptext2').offsetHeight;
		var responseTextW = respW1 + respW2;
/*		switch(true){
			  case (respH1 > 0):
						 var responseTextH = respH1;
							break;
			  case (respH2 > 0):
						 var responseTextH = respH2;
							break;
					default:
					  var responseTextH = 0;
		}
		*/
  responseTextH = document.getElementById('responsetextdiv').offsetHeight;
		if(document.getElementById('mainimagediv').innerHTML != ''){
			 var imageW = minImageW; //will be changed later.  This is just to see what the min needed is.
				var imageH = minImageH; //will be changed later.  This is just to see what the min needed is.
		}else{
		  var imageW = 0;
		  var imageH	= 0;		
		}

		//--- main alert will always wrap WITHIN the available space, so it's width isn't significant --
		var oMainAlertDiv = document.getElementById('mainalertdiv');
		if (oMainAlertDiv.innerHTML == ''){
			 var mainAlertH = 0;
		}else{
    var mainAlertH = oMainAlertDiv.offsetHeight;		
		}
	//	var mainAlertW = document.getElementById('mainalertdiv').offsetWidth;


 //-- mainTextW isn't really useful at this point because it'll wrap to the existing width of mainrightdiv --
 	

		if ((globalTextState == 'on')||(globalTextToggleEnabled == false) || (globalForceShowText == 1)){			
				oScrollerDiv = document.getElementById('scrollerdiv');
				if (oScrollerDiv != null){
					 //-- got a scroller here! ------
						 var mainTextH = 0; //not really but this will let the other values be computed.  The scroller will be sized to the final maindivheight at the end of theis func 							
				}else{
					 //-- no scroller present --
					 var mainTextH = oMainTextDiv.offsetHeight; //can possibly be tweaked later by changing width
				} //if-else scrollerDiv								  
		}else{		
			 var mainTextH = 0;
		}
  // ---- Redefine the minimum right width if there's too much stuff there ---
		if(topLinkWidth*emFactor > minRightWidth){
				minRightWidth = topLinkWidth*emFactor;
  }
		/*
		if(audioW*emFactor > minRightWidth){
			alert('two')
				minRightWidth = audioW*emFactor;
  }
		if(buttonW*emFactor > minRightWidth){
			alert('tree ' + buttonW)
				minRightWidth = buttonW*emFactor;
  }
		if(responseTextW*emFactor > minRightWidth){
			alert('fo')
				minRightWidth = responseTextW*emFactor;
  }
		*/
		if(ofullpagedatadiv.offsetWidth*emFactor > minRightWidth){
				minRightWidth = ofullpagedatadiv.offsetWidth*emFactor;		
  }

		// ---- Redefine the minimum overall height if there's too much stuff on the right (not final as image will be scaled to fit
  // --- and maintextdiv can be squished out or up --------																																																																													
		var totalMinReqHeight = iconH + topLinkHeight + audioH + buttonH + imageH + mainTextH + mainAlertH + responseTextH;		
		var nonImageVideoHeight = totalMinReqHeight - imageH;
		if(totalMinReqHeight > minMainHeight){
			  //minMainHeight = totalMinReqHeight;					//this causes maintextdiv table to grow ever higher rather in currentwork --will it screw up the regular image stuff?
		}
  //-- Redfine the maximum width if there is too much stuff in there ----
		if(minRightWidth + minLeftWidth > maxMainWidth){
			 // maxMainWidth = minRightWidth + minLeftWidth;  //this causes maintextdiv table to grow ever higher rather in currentwork --will it screw up the regular image stuff?
		}
		
		//----------------- Figure the widths ---------------
		if((globalDocsForBrowseHelp == true)||((globalMaxState == 'max')&&(minLeftWidth + minRightWidth <= globalViewportW))){			
		  // ------------------ max ---------------
				var leftMargin = 0;	
				switch(true){			
							case maxMainWidth < globalViewportW:
									//-- exceeding all maximums  -----
									if (globalDocsForBrowseHelp == true){
												//-- the browse window will be filled with docs needed by the user (test, hw, etc) --
												maxMainWidth = globalViewportW; 
												newRightWidth = minRightWidth;
												newLeftWidth = maxMainWidth - minRightWidth;	
												var vertScrollBarWidth = 30; //empirical approx
												var docWidth = newLeftWidth - vertScrollBarWidth;
												document.getElementById('browseproblemdiv').style.width = docWidth + 'px';
									}else{									
									  newLeftWidth = maxLeftWidth;
									  newRightWidth = globalViewportW - maxLeftWidth;					
									}
									break;
									
							case maxLeftWidth + minRightWidth < globalViewportW:
									//-- have plenty of width: give the right some of what the left doesn't need -----
									if (globalDocsForBrowseHelp == true){
												//-- the browse window will be filled with docs needed by the user (test, hw, etc) --
												maxMainWidth = globalViewportW; 
												newRightWidth = minRightWidth;
												newLeftWidth = maxMainWidth - minRightWidth;	
												var vertScrollBarWidth = 30; //empirical approx
												var docWidth = newLeftWidth - vertScrollBarWidth;
												document.getElementById('browseproblemdiv').style.width = docWidth + 'px';
									}else{												
									  var newLeftWidth = minLeftWidth + (maxLeftWidth - minLeftWidth)/2;
									  var newRightWidth = globalViewportW - newLeftWidth;		
											//document.getElementById('browseproblemdiv').style.width = globalInitialBrowseHelpDivWidth + 'px';											
									}
									break;
							
							default: 
									// -- have enough width if we make the left side less than its maximum --
									//-- Make left min and make right as wide as possible given everything else ---
									if (globalDocsForBrowseHelp == true){
												//-- the browse window will be filled with docs needed by the user (test, hw, etc) --
												maxMainWidth = globalViewportW; 
												newRightWidth = minRightWidth;
												newLeftWidth = maxMainWidth - minRightWidth;	
												var vertScrollBarWidth = 30; //empirical approx
												var docWidth = newLeftWidth - vertScrollBarWidth;
											//	document.getElementById('browseproblemdiv').style.width = docWidth + 'px';
									}else{										
									  var newLeftWidth = minLeftWidth;
									  var newRightWidth = globalViewportW - newLeftWidth;			
									}
									break;																								
				}
				var newMainDivWidth = globalViewportW;
				
	 	}else{  //-- either globalMaxState = 'normal' OR it's too cramped horizontally to use the max state ---
						  
			 	switch(true){		

							case maxMainWidth + 2*leftMargin < globalViewportW:
								 	//-- viewport exceeds both maximums (Max button not clicked): make it as wide as you want -----

									    var newLeftWidth = maxLeftWidth;
									    var newRightWidth = maxMainWidth - maxLeftWidth;				
																		
									leftMargin = (globalViewportW - maxMainWidth)/2;							
									break;
									
							case maxLeftWidth + minRightWidth + 2*leftMargin < globalViewportW:
									//-- have plenty of width: give the right some of what the left doesn't need -----
										//alert('2')
									var newLeftWidth = minLeftWidth + (maxLeftWidth - minLeftWidth)/2;
									var newRightWidth = globalViewportW - (newLeftWidth + 2*leftMargin);		
									break;
							
							case minLeftWidth + minRightWidth + 2*leftMargin < globalViewportW:
								//alert('3')
									// -- have enough width if we make the left side less than its maximum --
									//-- Make left min and make right as wide as possible given everything else ---
							
											var newLeftWidth = minLeftWidth;
										var newRightWidth = globalViewportW - (minLeftWidth + 2*leftMargin);			
								
									break;						
									
							case minLeftWidth + minRightWidth >= globalViewportW:
								//alert('4')
									//-- have enough if we give up the margins ---------
									leftMargin = 0;
											
									  var newLeftWidth = minLeftWidth;
									  var newRightWidth = globalViewportW - (minLeftWidth);
							
									break;			
									
							case minLeftWidth + minRightWidth + 2*leftMargin >= globalViewportW:
								//alert('5')
									// -- Can't fit it all in:set all widths to their miniumm and let there be horizontal browser scroll bars  ---
									leftMargin = 0;
											
									  leftMargin = 0;
									  var newLeftWidth = minLeftWidth;
									  var newRightWidth = minRightWidth;
								
									break;													
				}
				//-- Reconfigures (teacherdata causes this)---
				if(newRightWidth < minRightWidth){
					 newRightWidth = minRightWidth;
						leftMargin = (globalViewportW - (newLeftWidth + newRightWidth))/2;
				}
				var newMainDivWidth = newLeftWidth + newRightWidth;			
		 }
						//minRightWidth
			
				//------------------------ Figure the heights -------------------------
			if((globalDocsForBrowseHelp == true)||((globalMaxState == 'max')&&(globalViewportH > minMainHeight))){	
				  ///------ max -----------------------
				  var topMargin = 0;
				  newMainDivHeight = globalViewportH;
						
		 }else{ 
		  // ----------- globalMaxState = 'normal' or it's too cramped to max verticallly --------------
				switch (true){
						case (globalViewportH > maxMainHeight + 2*topMargin):
									//-- have more than enough for maximum height ---
									var newMainDivHeight = maxMainHeight; //Max button is considrered to be off 
									topMargin = (globalViewportH - newMainDivHeight)/2;
									break;
							
						case (globalViewportH > minMainHeight + 2*topMargin):
								//-- have more than enough for minumum height --
									var newMainDivHeight = globalViewportH - 2*topMargin;									
									break;						
									
						case (globalViewportH > minMainHeight):
								//-- have enough if we give up the margins --
									var newMainDivHeight = globalViewportH;
									topMargin = 0;
									break;							
									
						case (globalViewportH <= minMainHeight):
								//-- it's cramped: bring on the scroll bars --
									var newMainDivHeight = minMainHeight;
									topMargin = 0;									 
									break;													
				}						
		}

		//-------- student scroller (coming in 2/3/11) --------
		oScrollerDiv = document.getElementById('scrollerdiv');
		if (oScrollerDiv != null){
				//-- got a scroller here! ------		
					var nonScrollHeight = topLinkHeight + mainAlertH + buttonH; //these are the only ones I think you'd ever use with a scroller div...				
					var badEmpiricalNudge = 25; //for unaccounted for height
					var availableForScrollDiv = newMainDivHeight  - nonScrollHeight - badEmpiricalNudge;
					var scrollContentHeight = document.getElementById('scrollcontentdiv').offsetHeight;						

					if(scrollContentHeight <= availableForScrollDiv){
								//-- set the scroller's height to the content it contains --
								
								oScrollerDiv.style.height = scrollContentHeight + 'px';
								oScrollerDiv.style.width = newRightWidth + 'px';
								mainTextH = scrollContentHeight; //this may or may not be needed below
					}else{
								//-- set the scroller's height to the available height (scroll bars will take care of the rest) -------
								
								var scrollBarRightOffset = 20;
								oScrollerDiv.style.height = availableForScrollDiv + 'px';
								var scrollerWidth = newRightWidth - scrollBarRightOffset;
								oScrollerDiv.style.width = scrollerWidth + 'px';								
								mainTextH = availableForScrollDiv; //this may or may not be needed below
					}
						
		}else{

		}

	 switch(true){  //-- image/video,  teacher area,  or nothing ---
		
		  case document.getElementById('fullpagedatadiv').innerHTML != '':
				  //--- something is in the teacher data area so that's what we'll size ---
				  //--- Treat it like an image sort of.  It will auto-stretch to 100% of width and the height OF WHAT INSIDE IT IS PUSHING OUT and so will come out to whatever --
						var ofullpagedatadiv = document.getElementById('fullpagedatadiv');
					 var availHeight = maxMainHeight - totalMinReqHeight;
						var availWidth = newRightWidth;
						
						oProblemSetDiv = document.getElementById('problemsettable');						 
						if (oProblemSetDiv != null){
							 //--- if this is a student problem set, strecth it to fill the available space --- 
					  	//-- This will increase the height of the div inside fullpagedatadiv, increasing IT'S height, which will be used for determining the height of the overall box
								
								//--THIS MIGHT BE SCREWED UP SINCE YOU MADE FULLPAGEDATADIV HAVE AUTO OVERFLOW 1/23/11--
								oProblemSetDiv.style.width = availWidth + 'px';
								ofullpagedatadiv.style.left = '0px';      
								//--- And while we're here, resize all the images in the problemsettable ----
								var cumulativeImageAndTextHeight = 0;
								var numberOfImages = document.problemsetform.numstuprobs.value;
								for (var i = 1; i<=numberOfImages; i++) {
								  var imageName = 'probsetimg' + i;
										oImage = document.getElementById(imageName);					
										var likelyScrollBarWidth = 30; //also to accomodate borders around problems
										var newImageWidth = availWidth - likelyScrollBarWidth;
										//newImageWidth = 200;
										oImage.style.width = newImageWidth  + 'px';
										oImage.style.height = 'auto';  
										var imageHeight = oImage.offsetHeight;
										cumulativeImageAndTextHeight = cumulativeImageAndTextHeight + imageHeight;
										
								}								
								if(cumulativeImageAndTextHeight > availHeight){
          //-- if the new height of the contents is less than the height of the available area, we increase it to the fullest height available---
	         oProblemSetDiv.style.height = availHeight + 'px';										
								}
							//	alert('in here')
						}
						
						
						//--- THE AREA BELOW IS WHERE ALL THE TEACHER DATA DIVS LIVE -------
						oTchrDataDivContent = document.getElementById('tchrdatadivcontent');	

						if(oTchrDataDivContent != null){
									var tchrDataDivContentHeight = oTchrDataDivContent.offsetHeight;
									var tchrDataDivContentWidth = oTchrDataDivContent.offsetWidth;
						}else{
							  var tchrDataDivContentHeight = 0;
									var tchrDataDivContentWidth = 0;
						}
					
					 
					 
						//-- height --
		    newMainDivHeight = globalViewportH;
		    newDataDivHeight = globalViewportH - topLinkHeight;
	     topMargin = 0; //for the main div
						var topDrop = (newDataDivHeight - tchrDataDivContentHeight)/2; //the amount under the topLinks
						if (topDrop < 0){
							  topDrop = 0;
						}
      newDataDivTop = topLinkHeight + topDrop;						
						
						//-- width --
						newMainDivWidth = 960; //based on materials being the widest //note:96% have 1024 or higher (74% higher!)
						leftMargin = (globalViewportW - newMainDivWidth)/2;
						if (leftMargin < 0){
						  leftMargin = 0;
		    }
				
		//			 ofullpagedatadiv.style.width = newDataDivWidth + 'px';
						ofullpagedatadiv.style.height = newDataDivHeight + 'px';						
						ofullpagedatadiv.style.top = newDataDivTop + 'px';
					
			//			ofullpagedatadiv.style.left = newDataDivLeft + 'px';
					
		//		ofullpagedatadiv.style.height = '300px';
				//ofullpagedatadiv.style.top = '19px';
					
					 //----- THE AREA ABOVE (AND THE VERY SHORT ONE IMMEDIATELY BELOW IS WHERE ALL THE TEACHERDATADIVS LIVE ----
						//-- vertical centering is different for students and teachers (who have no mainAlert or buttons (outside of datadiv)) ---
						if(mainAlertH + buttonH == 0){							 
							  // -- it's a teacher (use this new code) --
					  	if (newMainDivHeight < fullpagedatadivHeight){
							    newMainDivHeight = fullpagedatadivHeight + iconH + topLinkHeight;
					  	}		 
								var topPos = topLinkHeight + iconH + (newMainDivHeight - fullpagedatadivHeight - topLinkHeight - iconH)/2;
								//ofullpagedatadiv.style.top = topPos + 'px';
								ofullpagedatadiv.style.visibility = 'visible';
						}else{
							 //------- it's a student (use this old code)--------
					  	if (newMainDivHeight < fullpagedatadivHeight + buttonH + iconH + mainAlertH + topLinkHeight){
							    newMainDivHeight = fullpagedatadivHeight + buttonH + iconH + mainAlertH + topLinkHeight;
					  	}																	   
								var extraHeight = newMainDivHeight - (fullpagedatadivHeight + buttonH + iconH + mainAlertH); 
								var vertGap = extraHeight/3;
								
								var mainAlertTop = iconH + topLinkHeight + vertGap;
								oMainAlertDiv.style.top = mainAlertTop + 'px';
		
								var teacherDataTop = mainAlertTop + mainAlertH + vertGap;
								ofullpagedatadiv.style.top = teacherDataTop + 'px';
								
								var oButtonDiv = document.getElementById('mainbuttondiv');
								var newButtonTopPos = newMainDivHeight - buttonH;
								oButtonDiv.style.top = newButtonTopPos + 'px';
											
								//--- make everything visible --
								document.getElementById('responsetextdiv').style.visibility = 'hidden';
								oButtonDiv.style.visibility = 'visible';
								oMainAlertDiv.style.visibility = 'visible';	
								ofullpagedatadiv.style.visibility = 'visible';	
						}

						
						
     break; 
					
    case ((globalVideoName != '')||(globalImageName != '')):	 
						//----- If there is an image, maximize its size ----
						var availH = newMainDivHeight - nonImageVideoHeight;  
						var availW = newRightWidth;					
						if(globalVideoName != ''){
								var aspectRatio = 1.333333; //all the videos are 640x480 aspect plus the timeline controller (28px for flash; 0 for html5 video) 
						//		var aspectRatio = 1.78 // big buck bunny example video
						}else{
								var aspectRatio = 1.6; // all my images are 1.6: 1 (golden rectangle)		120 x 75 in flash seems good				
						}
		
						if(availW/availH < aspectRatio){
								//-- all my images are 1.62: 1 (golden rectangle) --- 
								//-- the width is the constraining factor --
								var constrain = 'width';
								var imageVideoW = availW; 
								var imageVideoH = availW/aspectRatio;
						}else{
								//-- the height is the constraining factor ---
								var constrain = 'height';
								var imageVideoH = availH;
								var imageVideoW = imageVideoH * aspectRatio;		
						}						
				
						if(globalVideoName != ''){	 
								//-- its a video, so set its size (one dimension enough since it'll automatically scale)--
								if(videoTagSupport == true){
										var myVideo = document.getElementsByTagName('video')[0];
										if(constrain == 'height'){
											myVideo.height = imageVideoH;										
											var actualHeight = myVideo.height;
											imageVideoW = myVideo.width;
										}else{									 
												myVideo.width = imageVideoW;		
												myVideo.height = imageVideoH;
												var actualHeight = myVideo.height;
										}								
								}else{
										//-- using flash ---
										var oFlashDiv = document.getElementById('flashvideodiv');
										//imageVideoH = imageVideoH + 24; //for the navigation bar
										if(constrain = 'height'){
												oFlashDiv.style.height = imageVideoH + 'px';
												imageVideoW = oFlashDiv.offsetWidth;
										}else{
												oFlashDiv.style.width = imageVideoW + 'px';
												imageVideoH = oFlashDiv.offsetHeight;
										}												
								}
		
						}else{
									// -- its an image, so set its size --							
					//				if(globalglobalAudioFileNameRoot != ''){
												//----- this frame has audio ---
					//							if(globalAutoNext == true){
					//						   SWFImageDelay(globalImageName,imageVideoH,imageVideoW);		
					//						}else{
													SWFImage(globalImageName,imageVideoH,imageVideoW); 
									//			}
							//		}else{
												// -- this frame does not have audio --
										SWFImage(globalImageName,imageVideoH,imageVideoW);	
					//				}						 	  
									//document.getElementById('mainimagediv').style.visibility = 'visible';						 
						}	
						break;
				
		  default:
			   //-- no video or image or teacher stuff--
			   // -- the standard layout w/o an image or video present---
			   SWFImage('',0,0);
				 	var imageVideoH = 0;
					 var imageVideoW = 0;							
		}		

  // ----------- Size them ----------------------
		var oMainDivLeft = document.getElementById('mainleftdiv');
		var oMainDivRight = document.getElementById('mainrightdiv');
		
		//-------------- the main div ----------------
		oMainDiv.style.width = newMainDivWidth + 'px';
		oShadowDiv.style.width =  newMainDivWidth + 'px';					
		oMainDiv.style.height = newMainDivHeight + 'px';  //newMainDivHeight	
	 oShadowDiv.style.height =  newMainDivHeight + 'px';	
		oMainDiv.style.top =  topMargin + 'px';
		oShadowDiv.style.top =  topMargin + 'px';
		oMainDiv.style.left = leftMargin + 'px';
		oShadowDiv.style.left = leftMargin + 'px';			
		
		
		//---------- the left and right divs ------------
		oMainDivLeft.style.width = newLeftWidth + 'px';
		oMainDivLeft.style.height = newMainDivHeight + 'px';
		oMainDivRight.style.width = newRightWidth + 'px';		
		oMainDivRight.style.height = newMainDivHeight + 'px';		
		//-- New to accomodate absolute positioning ---
		oMainDivRight.style.left = newLeftWidth + 'px';
	//	document.getElementById('mainrightdiv2').style.top = topLinkHeight + 'px'

  // ------ new below March 2011 ---------------
  // -- size the scroller divs if this is the current work problems screen --
		var pegTopForScrollers = false;
	 if ($("#currentworkproblemsscrollerdiv").length > 0){//using jquery to check for existence of a particular object	
		  oCurrentProblemsContentDiv = document.getElementById('currentworkproblemscontentdiv');	 
			 //-- figure the used up vertical space --
				var a =  document.getElementById('currentworkcoursenamediv').offsetHeight;	
				var b =  document.getElementById('currentworkassnamediv').offsetHeight;	
				var c =  document.getElementById('currentworksubsectionblurbdiv').offsetHeight;   
				var d =  document.getElementById('currentworkdoingblurbdiv').offsetHeight; 		
				if ($("#currentworkicondiv").length > 0){//using jquery to check for existence of a particular object
				  var e = document.getElementById('currentworkdoingblurbdiv').offsetHeight; 
				}else{
					 var e = 0;
				}
				if ($("#documenticondiv1").length > 0){//using jquery to check for existence of a particular object
				  var f = document.getElementById('documenticondiv1').offsetHeight; 
				}else{
						if ($("#documenticondiv2").length > 0){//using jquery to check for existence of a particular object
								var f = document.getElementById('documenticondiv2').offsetHeight; 
						}else{
								var f = 0;
						}									
				}				
				if ($("#currentworkstunamediv").length > 0){//using jquery to check for existence of a particular object
				  var g =  document.getElementById('currentworkstunamediv').offsetHeight;
				}else{	
				  var g = 0;
				}
				if ($("#generalbuttondivdiv").length > 0){//using jquery to check for existence of a particular object
				  var h =  document.getElementById('generalbuttondivdiv').offsetHeight;
				}else{	
				  var h = 0;
				}
				if ($("#currentworksectioncontentdiv").length > 0){//using jquery to check for existence of a particular object
				  var i =  document.getElementById('currentworksectioncontentdiv').offsetHeight;
				}else{	
				  var i = 0;
				}				
				
				var usedVertSpace = mainAlertH + topLinkHeight + a + b + c + d + e + f + g + h + i;
				//alert(mainAlertH + '   ' +  topLinkHeight + '   ' +  a + '   ' +  b + '   ' +  c + '   ' +  d + '   ' +  e + '   ' +  f + '   ' +  g + '   ' +  h + '   ' +  i)
				var topBottomCombinedMargin = 30; //so things are 100% top and bottom flush
				var scrollBarWidth = 17; //firefox 			
			//	usedVertSpace = usedVertSpace + document.getElementById('gradeanswersbuttondiv').offsetHeight;
				var availVertSpaceForScrollers = newMainDivHeight - usedVertSpace - topBottomCombinedMargin;
				var remainingSpace = availVertSpaceForScrollers;				
				if (oCurrentProblemsContentDiv.offsetHeight > availVertSpaceForScrollers){					  
					// var newWidth = oCurrentProblemsContentDiv.offsetWidth + scrollBarWidth;
					 //oCurrentProblemsContentDiv.style.width = newWidth + 'px';
					 document.getElementById('currentworkproblemsscrollerdiv').style.height = availVertSpaceForScrollers + 'px';
						mainTextH = availVertSpaceForScrollers;
						pegTopForScrollers = true;
				}else{
			   var innerDivHeight = document.getElementById('currentworkproblemscontentdiv').offsetHeight; 
			   var scrollerHeight = innerDivHeight + 10;  //10 is totally empirical to avoid scroll bars for divs that fit just fine!
			   document.getElementById('currentworkproblemsscrollerdiv').style.height = scrollerHeight + 'px';					
				}
				//----- this is used when there's a section table of contents on the left with the problems on the right ---
				//--- What's below applies to the table of contents part.  It's not there for instructional probs, tests or test review
				//-------- or hw when there is not multiple sections -----------------
				if ($("#currentworksectioncontentdiv").length > 0){//using jquery to check for existence of a particular object
						oCurrentWorkSectionContentDiv = document.getElementById('currentworksectioncontentdiv');				
						if (oCurrentWorkSectionContentDiv.offsetHeight > availVertSpaceForScrollers){
								//var newWidth = oCurrentWorkSectionContentDiv.offsetWidth + scrollBarWidth;
								//oCurrentWorkSectionContentDiv.style.width = newWidth + 'px';
								document.getElementById('currentworksectionscrollerdiv').style.height = availVertSpaceForScrollers + 'px';
								mainTextH = availVertSpaceForScrollers;
								pegTopForScrollers = true;
						}else{
								document.getElementById('currentworksectionscrollerdiv').style.height = oCurrentWorkSectionContentDiv.offsetHeight + 'px';
						}
				}
				document.getElementById('currentproblemstd').style.height = availVertSpaceForScrollers + 'px';
				
	} //if oCurrentProblemsContentDiv

  //------- new above March 2011 ----------

		//-------------- the left is in 2 sections --------------
  var oHelpSelectorDiv = document.getElementById('helpselectordiv');
		var oBrowseProblemDiv = document.getElementById('browseproblemdiv');
		var newHelpHeight = newMainDivHeight - oHelpSelectorDiv.offsetHeight;
		oBrowseProblemDiv.style.height = newHelpHeight + 'px';
  
		if(fullpagedatadivHeight == 0){
				//-------- vertically place the components inside the right div for a good look ----------
				//---- buttons go on the very bottom --		
				var oButtonDiv = document.getElementById('mainbuttondiv');
				if(buttonH > 0){			 
						var newButtonTopPos = newMainDivHeight - buttonH;
						oButtonDiv.style.top = newButtonTopPos + 'px';
						oButtonDiv.style.visibility = 'visible';
				}else{
							// -- to get rid of it from the prvevious screen --
							oButtonDiv.style.visibility = 'hidden';
				}
				//-- the audio goes on top of the buttons ---
				var oAudioDiv = document.getElementById('audiodiv');
				if(audioH > 0){	 	 
						var newAudioTopPos = newMainDivHeight - audioH - buttonH;
						//--- add a bit for the moving tab that nobody seems to count -------
						newAudioTopPos = newAudioTopPos + (0.7*emWidthHeight);
						oAudioDiv.style.top = newAudioTopPos + 'px';
						oAudioDiv.style.visibility = 'visible';
				}else{
							// -- to get rid of it from the prvevious screen --
							oAudioDiv.style.visibility = 'hidden';
				}
				//-- the response text goes on top of the audio ---
				var oResponseTextDiv = document.getElementById('responsetextdiv');
				if(responseTextH > 0){	 	 
						var newResponseTextTopPos = newMainDivHeight - audioH - buttonH - responseTextH;
						oResponseTextDiv.style.top = newResponseTextTopPos + 'px';
						oResponseTextDiv.style.visibility = 'visible';
				}else{
							// -- to get rid of it from the prvevious screen --
							oResponseTextDiv.style.visibility = 'hidden';
				}
				//--- the remaining space is aestheticallly divided up among maintextdiv, mainimagediv(image or video), and mainAlert --
				//-- Logic of spacing: if text and image are present, they are treated as a block with 1em space between them.  --
				// ------------------  if text or image alone are present, they are placed in the middle

				  var remainingSpace = newMainDivHeight - (iconH + topLinkHeight + buttonH + audioH + responseTextH + mainAlertH + mainTextH + imageVideoH);


			//	var highestFromBottomTop = newMainDivHeight - audioH - buttonH - responseTextH;
				var workingTopPos = iconH + topLinkHeight;
			//	var remainingSpaceFromWorkingTop = remainingSpace - workingTopPos;
				oMainImageDiv = document.getElementById('mainimagediv'); //also includes video which will be inside this div
				//-- oMainTextDiv and oMainAlertDiv also exist at this point -- mainTextH
//alert('6')

					if(mainAlertH > 0){
								// -- alert is present --

							oMainAlertDiv.style.visibility = 'visible';	
						
							switch(true){
										case ((mainTextH == 0) && (imageVideoH == 0)):
												//-- just the alert: place it 1/3 down from the top ---
												var oneThird = remainingSpace/3;
												var newMainAlertTopPos = workingTopPos + oneThird;				
												break;									
										case ((mainTextH > 0) && (imageVideoH == 0)):
										//-- just text ------
										var oneFifth = remainingSpace/5;
										var newMainAlertTopPos = workingTopPos + oneFifth;	
										var newMainTextTopPos = workingTopPos + 3*oneFifth + mainAlertH;				
										oMainTextDiv.style.top = newMainTextTopPos + 'px';
										break;		
								case ((mainTextH == 0) && (imageVideoH > 0)):
										//-- just the image or video ------			
										var oneFifth = remainingSpace/5;
										var newMainAlertTopPos = workingTopPos + oneFifth;	
										var newMainImageTopPos = workingTopPos + 3*oneFifth + mainAlertH;				
										oMainImageDiv.style.top = newMainImageTopPos + 'px';				
										break;
								case ((mainTextH > 0) && (imageVideoH > 0)):
										//-- alert, text and image ---			   
										var gap = remainingSpace/4;
										var newMainAlertTopPos = workingTopPos + gap;	
										var newMainTextTopPos = newMainAlertTopPos + mainAlertH + gap;		
										var newMainImageTopPos = newMainTextTopPos + mainTextH + gap;
										oMainTextDiv.style.top = newMainTextTopPos + 'px';
										oMainImageDiv.style.top = newMainImageTopPos + 'px';	
										break;														
							}
							oMainAlertDiv.style.top = newMainAlertTopPos + 'px';
	
					}else{
  
							switch(true){
									case ((mainTextH == 0) && (imageVideoH == 0)):
												//-- no alert ---	
												break;									
								case ((mainTextH > 0) && (imageVideoH == 0)):
										//-- just text: center it ------				
										//-- this pegtotop business is to accomodate newer full page with scroller parts			
										if ($("#currentworkproblemscontentdiv").length > 0){//using jquery to check for existence of a particular object													
													var newMainTextTopPos = mainAlertH + topLinkHeight;																
										}else{
											
													var oneHalf = remainingSpace/2;							
													var newMainTextTopPos = workingTopPos + oneHalf;																		
										} 
										oMainTextDiv.style.top = newMainTextTopPos + 'px';
										break;		
								case ((mainTextH == 0) && (imageVideoH > 0)):
										//-- just the image or video: center it ------			
										var oneHalf = remainingSpace/2;
										var newMainImageTopPos = workingTopPos + oneHalf;
										oMainImageDiv.style.top = newMainImageTopPos + 'px';				
										
										break;
								case ((mainTextH > 0) && (imageVideoH > 0)):
										//-- both text and image or video (treat them as a block and center) ------			
										// -- (put an em space between them if there is room) --							
										if (emWidthHeight <= remainingSpace){
												var textImageGap = emWidthHeight;
												remainingSpace = remainingSpace - textImageGap;
												var oneHalf = remainingSpace/2;
												var newMainTextTopPos = workingTopPos + oneHalf;	
												var newMainImageTopPos = newMainTextTopPos + mainTextH + textImageGap;									
										}else{
												var newMainTextTopPos = workingTopPos + remainingSpace;	
												var newMainImageTopPos = newMainTextTopPos + mainTextH;;												
										}
										oMainTextDiv.style.top = newMainTextTopPos + 'px';
										oMainImageDiv.style.top = newMainImageTopPos + 'px';	
										break;														
							}				
								
					}
					
				//---- Horizontally center the components that don't automatically center ----		
				if (topLinkWidth > 0){
						var oDiv = document.getElementById('mainrightdiv1');
						newDivLeft = (newRightWidth - oDiv.offsetWidth)/2;
						oDiv.style.left = newDivLeft + 'px';				
				}
				if (audioW > 0){
						var oDiv = document.getElementById('audiodiv');
						newDivLeft = (newRightWidth - oDiv.offsetWidth)/2;
						oDiv.style.left = newDivLeft + 'px';
				}
				if (responseTextW > 0){
						//var oDiv = document.getElementById('responsetextdiv');
					//	newDivLeft = (newRightWidth - responseTextW)/2;
					//	oDiv.style.left = newDivLeft + 'px';
				}
				//workinghere	
				if (mainTextH > 0){
						var mainTextW = oMainTextDiv.offsetWidth; 
					//	var oDiv = document.getElementById('responsetextdiv');
						newDivLeft = (newRightWidth - mainTextW)/2;
						oMainTextDiv.style.left = newDivLeft + 'px';
				}		
				if (buttonW > 0){
						var oDiv = document.getElementById(	'mainbuttondiv');
						newDivLeft = (newRightWidth - oDiv.offsetWidth)/2;
						oDiv.style.left = newDivLeft + 'px';		
				}
			
				if((globalVideoName != '')||(globalImageName != '')){			 
						// -- all these variable values come from above --
						if(constrain == 'height'){
									var newImageLeftPos = (availW - imageVideoW)/2;
									oMainImageDiv.style.left = newImageLeftPos + 'px';
		
		
						}else{
							oMainImageDiv.style.left = '0px';
						}
				}
		} //if fullpagedatadivHeight = 0
		
		var oSitOnTopDiv = document.getElementById('sitontopdiv');
		oSitOnTopDiv.style.width = oMainDiv.offsetWidth + 'px';
		oSitOnTopDiv.style.left = oMainDiv.offsetLeft + 'px';
		var newSitOnTopTop = oMainDiv.offsetTop - oSitOnTopDiv.offsetHeight;
		oSitOnTopDiv.style.top = newSitOnTopTop + 'px';
		
  oMainDiv.style.visibility = 'visible';		
		oShadowDiv.style.visibility = 'visible';	
		if(document.getElementById('fullpagedatadiv').innerHTML != ''){ 
		  document.getElementById('fullpagedatadiv').style.visibility = 'visible';	
		}	
	//	alert(newMainDivHeight)

}  //visibility style.height   style.top maintextdiv  currentworkproblemscontentdiv


function SWFImageDelay(globalImageName,imageVideoH,imageVideoW){
	//window.status = window.status + '-1j'
		//-- this delays the image so it comes on a bit after the sound.  Makes it seem more lifelike --
		try{
    clearInterval(swfImageDelayTimerID);
		}
		catch(e){
    x = 8; //for IE
		}				
		swfImageDelayTimerID = setInterval("CallSWFImage('"+globalImageName+"',"+imageVideoH+","+imageVideoW+")",400);
}
function CallSWFImage(globalImageName,imageVideoH,imageVideoW){
	//window.status = window.status + '-1k'
		//-- this delays the image so it comes on a bit after the sound.  Makes it seem more lifelike --
		clearInterval(swfImageDelayTimerID);
		SWFImage(globalImageName,imageVideoH,imageVideoW);
}

function AllTrim(sentString){
	//window.status = window.status + '-1l'
  //--- this trims off leading and trailing spaces (eg, good ol AllTrim() )----
		// ----- But it's kind of slow -------------
		var singleChar;		
		//--- cut off leading spaces ---
		var firstCharPos = 0;
		var lastCharPos = sentString.length-1;
  for (var i = 0; i<sentString.length; i++) {
		   singleChar = sentString.substring(i,i+1);
					if (singleChar !=  ' '){
					  firstCharPos = i;							
							break;
					}				   
		}
		sentString = sentString.substring(firstCharPos);
				
		//--- cut off trailing spaces ---
  for (var i = sentString.length-1; i>=0; i--) {
		   singleChar = sentString.substring(i,i+1);
					if (singleChar !=  ' '){
					  lastCharPos = i;							
							break;
					}				   
		}  
		 sentString = sentString.substring(0,lastCharPos+1);
			return sentString;
			
}	

//leftSideH shadow  oMainDivRight1 oMainDivRight2

function PrintProblem(){
	//window.status = window.status + '-1z'
	
}


function SizeImageAndCenterFullMainDiv(){
	////oFullMainDiv = document.getElementById('fullmaindiv');	
  var globalViewportW = GetViewportWidthIncludingScrollBar(); //only needed for testlayout.html work
  var globalViewportH = GetViewportHeightIncludingScrollBar();	//only needed for testlayout.html work

		try{
    clearInterval(sizeImageTimerID);
		}
		catch(e){
    x = 8; //for IE						
		}	

		var oSitOnTopDiv = document.getElementById('sitontopdiv');
		oSitOnTopDiv.style.top = '-5000px';		
		oSitOnTopDiv.style.left = '-5000px';	
	
  var minWidth = 400;
		var minHeight = 300;
		if(globalViewportW < minWidth){
		  var setWidth = minWidth;
		}else{
			 var setWidth = globalViewportW;
		}
		if(globalViewportH < minHeight){
		  var setHeight = minHeight;
		}else{
			 var setHeight = globalViewportH;
		}		

		var oMainDiv = document.getElementById('maindiv');	
		var oShadowDiv = document.getElementById('shadowmaindiv');				
		oMainDiv.style.height = setHeight + 'px';
		oShadowDiv.style.height = setHeight + 'px';
		oMainDiv.style.width = setWidth + 'px';
		oShadowDiv.style.width = setWidth + 'px';
		oMainDiv.style.top = '0px';
		oShadowDiv.style.top = '0px';
		oMainDiv.style.left = '0px';
		oShadowDiv.style.left = '0px';		


		
}

function Chasman(){
	   
}

function SizeImageAndCenterMainDivDetailTeacher(){  
//window.status = window.status + '-1g'
//document.getElementById('mainalertdiv').innerHTML = "THis is a long thing to read.";
  var highestZ = 51; //this can change.  If Problems, run findHighestZIndex('div'); //this won't work in IE so that's why we're hardcoding it here
		var oSitOnTopDiv = document.getElementById('sitontopdiv');
		oSitOnTopDiv.style.top = '-5000px';
		oSitOnTopDiv.style.left = '-5000px';
 	//var viewportH = GetViewportHeightIncludingScrollBar();			
 //	var viewportW = GetViewportWidthIncludingScrollBar();	
		
	if ($("#currentworkproblemsscrollerdiv").length > 0){//using jquery to check for existence of a particular object	
	  //-- set it to the height of the content (and later reduce its height if necessary) 
			// -- You have to do it this way otherwise the scroller could MAKE the content fit from a previous scroller squish --
			var innerDivHeight = document.getElementById('currentworkproblemscontentdiv').offsetHeight; 
			var scrollerHeight = innerDivHeight + 10;  //10 is totally empirical to avoid scroll bars for divs that fit just fine!
			document.getElementById('currentworkproblemsscrollerdiv').style.height = scrollerHeight + 'px';
	}	
	 
		//var mainDivWidth = 960; //based on materials being the widest plus extra //note:96% have 1024 or higher (74% higher!)
		
		var mainDivWidth = globalViewportW;
		//var leftDivWidth = 285; //based on what's needed to see student names well
		var rosterNamesWidth = document.getElementById('rosterselect').offsetWidth;
	//	alert(rosterNamesWidth)
		document.getElementById('browseproblemdiv').style.width = rosterNamesWidth + 'px';
		leftDivWidth = rosterNamesWidth + scrollbarWidth();
		
		var rightDivWidth = mainDivWidth - leftDivWidth;
		document.getElementById('mainrightdiv').style.width = rightDivWidth + 'px';
		//alert('tchr: ' + globalViewportW + '  ' + leftDivWidth + '  ' + rightDivWidth);
		
		var oMainDiv = document.getElementById('maindiv');	
		var oShadowDiv = document.getElementById('shadowmaindiv');
		var ofullpagedatadiv = document.getElementById('fullpagedatadiv');
	//	var oOriginalWorkingTeacher = document.getElementById('originalworkingteacherdiv');
		oTchrDataDivContent = document.getElementById('tchrdatadivcontent');
	 var tchrDataDivContentHeight = oTchrDataDivContent.offsetHeight;
		var tchrDataDivContentWidth = oTchrDataDivContent.offsetWidth;
		var verticalScrollBarAccomodation = scrollbarWidth();

		//alert(leftDivWidth)
		try{
    clearInterval(sizeImageTimerID);
		}
		catch(e){
    x = 8; //for IE						
		}	
		var leftMargin = (globalViewportW - mainDivWidth)/2;
  topLinkHeight = document.getElementById('mainrightdiv1').offsetHeight;
		availHeight = globalViewportH - topLinkHeight;

		
  //--- size the inner scrollers (yikes) ----
		oScrollerDiv = document.getElementById('scrollerdiv');
		var debugBlurb = '';

		if (oScrollerDiv != null){			
    oPreScrollDiv1 = document.getElementById('prescroll1');
				oPreScrollDiv2 = document.getElementById('prescroll2');
				oPreScrollDiv3 = document.getElementById('prescroll3');
				oPreScrollDiv4 = document.getElementById('prescroll4');
				oPreScrollDiv5 = document.getElementById('prescroll5');				
    oPostScrollDiv1 = document.getElementById('postscroll1');
				oPostScrollDiv2 = document.getElementById('postscroll2');
				var nonScrollHeight = 0;
				if(oPreScrollDiv1 != null){
					 nonScrollHeight = nonScrollHeight + oPreScrollDiv1.offsetHeight;
				}				
				if(oPreScrollDiv2 != null){
					 nonScrollHeight = nonScrollHeight + oPreScrollDiv2.offsetHeight;
				}
				if(oPreScrollDiv3 != null){
					 nonScrollHeight = nonScrollHeight + oPreScrollDiv3.offsetHeight;
				}				
				if(oPreScrollDiv4 != null){
					 nonScrollHeight = nonScrollHeight + oPreScrollDiv4.offsetHeight;
				}
				if(oPreScrollDiv5 != null){
					 nonScrollHeight = nonScrollHeight + oPreScrollDiv5.offsetHeight;
				}						
				if(oPostScrollDiv1 != null){
					 nonScrollHeight = nonScrollHeight + oPostScrollDiv1.offsetHeight;
				}				
				if(oPostScrollDiv2 != null){
					 nonScrollHeight = nonScrollHeight + oPostScrollDiv2.offsetHeight;
				}
					var badEmpiricalNudge = 25; //for unaccounted for height
					var badEmpiricalWidthIncrease = 25; //keep getting a hor scroll bar I don't know why				
					var availableForScrollDiv = availHeight - nonScrollHeight - badEmpiricalNudge;
     var scrollContentHeight = document.getElementById('scrollcontentdiv').offsetHeight;						
					if(scrollContentHeight <= availableForScrollDiv){
						  //-- set the scroller's height to the content it contains --
							//	alert(scrollContentHeight + '   ' +availableForScrollDiv +  '   ' + nonScrollHeight)
							 var scrollerDivHeight = availableForScrollDiv - oScrollerDiv.top;
								document.getElementById('scrollerdiv').style.height = scrollerDivHeight + 'px';
								oScrollerDiv.style.borderBottomStyle = 'none';								
					}else{
						  //-- set the scroller's height to the available height (scroll bars will take care of the rest) -------
				   document.getElementById('scrollerdiv').style.height = availableForScrollDiv + 'px';
							oScrollerDiv.style.borderBottomStyle = 'none';
							oScrollerDiv.style.borderBottomWidth = '1px';
							oScrollerDiv.style.borderBottomStyle = 'solid';
						//	oScrollerDiv.scrollTop = 0;
					}					
					var scrollerDivWidth = document.getElementById('scrollerdiv').offsetWidth + badEmpiricalWidthIncrease;
				//	document.getElementById('scrollerdiv').style.width =  scrollerDivWidth + 'px'; 
		} //if scrollerDiv


  if ($("#mainconcurmenu").length > 0){//using jquery to check for existence of a particular object			
			 var oVerticalMenu = document.getElementById('mainconcurmenu');
				var verticalMenuHeight = oVerticalMenu.offsetHeight;
				var verticalMenuWidth = oVerticalMenu.offsetWidth;
				var verticalMenuTop = (availHeight - verticalMenuHeight)/2;
				oVerticalMenu.style.top = verticalMenuTop + 'px';
		}else{
				var verticalMenuHeight = 0;
				var verticalMenuWidth = 0;			
		}		

 	//-- the scroller below is not the same as the scroller referred to above --   
		if(tchrDataDivContentHeight < availHeight){
		  // -- plenty of room: center the teacher data div --
				var teacherDataDivTop = topLinkHeight + (availHeight - tchrDataDivContentHeight)/2;
				var teacherDataDivHeight = tchrDataDivContentHeight;
				
		}else{			 
		  //-- squished --
				if ($("#currentworkproblemsscrollerdiv").length > 0){//using jquery to check for existence of a particular object
				  //-- If this scroller is there, we should size it since its probably what's causing the content to be too high --
						// -- Other objects that may be in vertical alignment with the scroller and so will affect the available height --								
						var takeAwayFromScroller = topLinkHeight; //this is wrong but it works pretty much OK
						if ($("#currentworkassnamediv").length > 0){//using jquery to check for existence of a particular object
								takeAwayFromScroller = takeAwayFromScroller + document.getElementById('currentworkassnamediv').offsetHeight;
						}
						if ($("#currentworkstunamediv").length > 0){//using jquery to check for existence of a particular object
								takeAwayFromScroller = takeAwayFromScroller + document.getElementById('currentworkstunamediv').offsetHeight;
						}							
						if ($("#currentworkcoursenamediv").length > 0){//using jquery to check for existence of a particular object
								takeAwayFromScroller = takeAwayFromScroller + document.getElementById('currentworkcoursenamediv').offsetHeight;
						}		
						if ($("#currentworkassnamediv").length > 0){//using jquery to check for existence of a particular object
								takeAwayFromScroller = takeAwayFromScroller + document.getElementById('currentworkassnamediv').offsetHeight;
						}	
						if ($("#currentworksubsectionblurbdiv").length > 0){//using jquery to check for existence of a particular object
								takeAwayFromScroller = takeAwayFromScroller + document.getElementById('currentworksubsectionblurbdiv').offsetHeight;
						}					
						if ($("#currentworkdoingblurbdiv").length > 0){//using jquery to check for existence of a particular object
								takeAwayFromScroller = takeAwayFromScroller + document.getElementById('currentworkdoingblurbdiv').offsetHeight;
						}							
						var scrollerHeight = availHeight - takeAwayFromScroller;
						document.getElementById('currentworkproblemsscrollerdiv').style.height = scrollerHeight + 'px';
				}
			 var teacherDataDivTop = topLinkHeight;
				teacherDataDivHeight = availHeight;
		}
		
		
		ofullpagedatadiv.style.height = teacherDataDivHeight + 'px';
		ofullpagedatadiv.style.top = teacherDataDivTop + 'px';  
		
		if(tchrDataDivContentWidth + verticalMenuWidth < rightDivWidth){
		  // -- plenty of room: center the teacher data div --
				var teacherDataDivLeft = verticalMenuWidth + (rightDivWidth - verticalMenuWidth - tchrDataDivContentWidth)/2;				
		}else{
			  //-- this should NEVER happen since you design the content's width to not exceed something reasonable--
			 var teacherDataDivLeft = verticalMenuWidth;
		}
 	ofullpagedatadiv.style.left = teacherDataDivLeft + 'px';
  
	//	var fullPageDataDivWidth = rightDivWidth - verticalMenuWidth;
 	//ofullpagedatadiv.style.width = fullPageDataDivWidth + 'px';	
	//	ofullpagedatadiv.style.width = '400px';	
 		
		//-- these changes affect particular items within the tchrdatadivcontent ----
		oContractAssignmentsSelect = document.getElementById('contractassignments');
		if(oContractAssignmentsSelect != null){
					var contractButtonsTdWidth = document.getElementById('contractbuttonstd').offsetWidth;
			  var neededWidth = oContractAssignmentsSelect.offsetWidth + verticalMenuWidth;
					if (rightDivWidth < verticalMenuWidth + oContractAssignmentsSelect.offsetWidth + contractButtonsTdWidth){
						 //-- squish down the contract width so it fits.  Truncation is all you got right now --
							var lameEmpiricalExtra = 80;
							var reducedContractWidth = rightDivWidth - verticalMenuWidth - contractButtonsTdWidth - lameEmpiricalExtra;
							oContractAssignmentsSelect.style.width = reducedContractWidth + 'px';
					}  
		}		
		
		oBarCodeScannerDiv = document.getElementById('barcodescanerdiv');
		if(oBarCodeScannerDiv != null){
			  //-- use up all the avaliable space to show the big message (this COULD be used for a lot of other things too that you want centered and maxed out) ---		
					var barCodeScannerWidth = rightDivWidth - verticalMenuWidth;
			  oBarCodeScannerDiv.style.width = barCodeScannerWidth + 'px';					
					oBarCodeScannerDiv.style.height = availHeight + 'px';
			  ofullpagedatadiv.style.left = verticalMenuWidth + 'px';
					ofullpagedatadiv.style.top = topLinkHeight + 'px';
		}
				
		oHelpIFrame = document.getElementById('helpiframe');
		if(oHelpIFrame != null){
			  
		  	var empiricalNudge = 5;
			  var helpHeight = availHeight - empiricalNudge;
					var helpWidth = rightDivWidth - empiricalNudge;
			  oHelpIFrame.style.width = helpWidth + 'px';					
					oHelpIFrame.style.height = helpHeight + 'px';
			  ofullpagedatadiv.style.left = verticalMenuWidth + 'px';
					ofullpagedatadiv.style.top = topLinkHeight + 'px';
					
				 //document.getElementById('mainrightdiv').style.backgroundColor = 'white';
		}
		
		
		oContractDiv = document.getElementById('contractdiv');
		if(oContractDiv != null){
    oContractDiv.style.width = '300px';
		}		
	  
  // ----------- Size them ----------------------
		var oMainDiv = document.getElementById('maindiv');	
		var oShadowDiv = document.getElementById('shadowmaindiv');
		var oMainDivLeft = document.getElementById('mainleftdiv');
		var oMainDivRight = document.getElementById('mainrightdiv');
		
		//-------------- the main div ----------------
		oMainDiv.style.width = mainDivWidth + 'px';
		oShadowDiv.style.width =  mainDivWidth + 'px';					
		oMainDiv.style.height = globalViewportH + 'px';
	 oShadowDiv.style.height =  globalViewportH + 'px';	
		oMainDiv.style.top = '0px';
		oShadowDiv.style.top = '0px';
		oMainDiv.style.left = leftMargin + 'px';
		oShadowDiv.style.left = leftMargin + 'px';			
		
//		oOriginalWorkingTeacher.style.top = '-50px'; //cant see from teacher's screen
	//	oOriginalWorkingTeacher.style.left = '-100px'; // ""
		
		//---------- the left and right divs ------------
		oMainDivLeft.style.width = leftDivWidth + 'px';
		oMainDivLeft.style.height = globalViewportH + 'px';
		oMainDivRight.style.width = rightDivWidth + 'px';		
		oMainDivRight.style.height = globalViewportH + 'px';		
		//-- New to accomodate absolute positioning ---
		oMainDivRight.style.left = leftDivWidth + 'px';

		//-------------- the left is in 2 sections --------------
  var oHelpSelectorDiv = document.getElementById('helpselectordiv');
		var oBrowseProblemDiv = document.getElementById('browseproblemdiv');
		var newHelpHeight = globalViewportH - oBrowseProblemDiv.offsetTop - scrollbarWidth();
		oBrowseProblemDiv.style.height = newHelpHeight + 'px';
		
		oBrowseHelpList = document.getElementById('browsehelplist');
		oBrowseHelpList.style.height = newHelpHeight + 'px';		
		
		//-- Set the height of the roster list (in terms of number of names shown!) using two hidden sample
		//-- rosters that have been saved ------------
		document.getElementById('rostermetric1name').style.width = oHelpSelectorDiv.offsetWidth + 'px';
		document.getElementById('rostermetric5names').style.width = oHelpSelectorDiv.offsetWidth + 'px';
		var rosterHeight1Name = document.getElementById('rostermetric1name').offsetHeight;
		var rosterHeight5Names = document.getElementById('rostermetric5names').offsetHeight;
		var heightPerName = (rosterHeight5Names - rosterHeight1Name)/4;
		var numberOfNames = ((newHelpHeight - rosterHeight1Name)/heightPerName) + 1;
		//numberOfNames = numberOfNames - 2; //empirical!
		var cNumberOfNames = '' + numberOfNames + '';
		document.getElementById('rosterselect').size = cNumberOfNames;


 //alert(globalViewportH + '    ' + oBrowseProblemDiv.offsetTop)
  oMainDiv.style.visibility = 'visible';		
		oShadowDiv.style.visibility = 'visible';	
		document.getElementById('fullpagedatadiv').style.visibility = 'visible';	

}  //end of teacher tchrDataDivContentWidth  teacherDataDivWidth

