// JavaScript Document
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function copyPop(){
		copyWin=window.open('copyright.htm', 'copyright', 'personalbar=no,toolbar=no,status=no,scrollbars=no,resizable=no,menubar=no,width=332,height=208,top=50,left=50');
		if(window.focus) {
			copyWin.focus();
		}
}

function teacherViewPop(){
		teacherViewWin=window.open('teacher_view.htm', 'teacherview', 'personalbar=no,toolbar=no,status=no,scrollbars=no,resizable=no,menubar=no,width=400,height=340,top=50,left=50');
		if(window.focus) {
			teacherViewWin.focus();
		}
}

function studentViewPop(){
		studentViewWin=window.open('student_view.htm', 'studentview', 'personalbar=no,toolbar=no,status=no,scrollbars=no,resizable=no,menubar=no,width=400,height=340,top=50,left=50');
		if(window.focus) {
			studentViewWin.focus();
		}
}

//--------------DROPDOWN MENU FUNCTIONS-------------------//
//make sure to include all 'submenu id' and 'submenu_sub id' you needed to the arrays bellow
//do not forget all submenus divs id MUST begin with the string 'submenu' + whatever
//all submenus_Sub divs id MUST begin with the string 'submenu_Sub' + whatever

var submenu_array = ["submenu1","submenu2","submenu3","submenu4","submenu5"];
var submenu_Sub_array = ["submenu1_Sub1","submenu3_Sub1","submenu3_Sub2","submenu3_Sub3","submenu3_Sub4"];

function setLyr(obj,lyr)  //controls the positioning of the submenu layer lets you adjust x,y positioning for ie-mac and safari separately
{

	var newX = findPosX(obj);
	var newY = findPosY(obj);
	var x = new getObj(lyr);
//window.alert(newX);
	var fixX //adjasting the diference between ie-mac and other browsers
	var fixY  //adjasting the diference between ie-mac and other browsers
	if ((is_ie5up) && (is_mac)){  // fix for ie-mac
		fixX = 0;
		fixY = -15;
	
	}	
	else if (is_safari){ // fix for safari
		fixX = -1;
		fixY = -1;
	} 
		else if (is_opera){ // fix for opera
		fixX = 3;
		fixY = 2;
	} 
	else {
		fixX = 0;
		fixY = 0;
	}
	x.style.top = newY + fixX + 17 + 'px';
	x.style.left = newX + fixY -1 + 'px';
}

function setLyr2(obj,lyr)   //controls the positioning of the submenu_Sub layer let you adjust ie-mac x,y positioning separately
{
		var newX = findPosX(obj)-1;
		var newY = findPosY(obj);
		var x = new getObj(lyr);
		var addX = obj.offsetWidth;
		var fixX
		var fixY
			//window.alert(addX);
	if ((is_ie5up) && (is_mac)){ //fix for ie-mac
		fixX = -1;
		fixY = -10;
	}	
	else {
		fixX = 0;
		fixY = 0;
	}
	x.style.top = newY + fixX +5+ 'px';
	x.style.left = newX+ fixY + addX -12+ 'px';
	
}

function findPosX(obj){
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj){
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

function getObj(name){
 if (document.getElementById)
 {
	   this.obj = document.getElementById(name);
	   this.style = document.getElementById(name).style;
 }
 else if (document.all)
 {
	   this.obj = document.all[name];
	   this.style = document.all[name].style;
 }
 else if (document.layers)
 {
	   if (document.layers[name])
	   {
	   	this.obj = document.layers[name];
	   	this.style = document.layers[name];
	   }
 }
}

function FW_clearTimeout(){
	if (fwHideMenuTimer) clearTimeout(fwHideMenuTimer);
	fwHideMenuTimer = null;
	fwDHFlag = false;
}

function FW_startTimeout(){
	fwStart = new Date();
	fwDHFlag = true;
	fwHideMenuTimer = setTimeout("fwDoHide()", 1000);
}

function fwDoHide(){
	var printstring = '';
	printstring +=fwStart+' fwHideMenuTimer:'+fwHideMenuTimer+' layers: ';
	/*window.status = printstring;*/
	if (!fwDHFlag) return;
	var elapsed = new Date() - fwStart;
	if (elapsed < 40) {
		fwHideMenuTimer = setTimeout("fwDoHide()", 40-elapsed);
		return;
	}
	fwDHFlag = false;
	hideActiveMenus();
	window.ActiveMenuItem = 0;
}



function hideActiveMenus() {  //goes over each of the submenus in the arrays and hide them
	for (i=0; i<(submenu_array.length); i++){
		  var name=submenu_array[i]; 
			var removeLayer = document.getElementById(name);
			removeLayer.style.visibility="hidden";
		}
		for (i=0; i<(submenu_Sub_array.length); i++){
		  var name=submenu_Sub_array[i]; 
			var removeLayer = document.getElementById(name);
			removeLayer.style.visibility="hidden";
		}
}

function ShowNav(layerName){  // show named layer and hide All other layers from the submenu_array
	
	for (i=0; i<(submenu_array.length); i++){
		var name=submenu_array[i]; 
		var subname=name.substr(0,7); 
		 if(subname=="submenu"){ 
			   if (layerName==name){
				   MM_showHideLayers(layerName,'','show');
			   } else {
				   var removeLayer = document.getElementById(name);
				   removeLayer.style.visibility="hidden";
				}
			}
	}
}
function hideSubNav(){  // hides all sub sub nav
	
	for (i=0; i<(submenu_Sub_array.length); i++){
		  var name=submenu_Sub_array[i]; 
			var removeLayer = document.getElementById(name);
			removeLayer.style.visibility="hidden";
		}
}

function showSubNav(layerName){ // show named layer and hide All other layers from the submenu_Sub_array
	for (i=0; i<(submenu_Sub_array.length); i++){
		var name=submenu_Sub_array[i]; 
		var subname=name.substr(8,4);
		if(subname=="_Sub"){ 
			if (layerName==name){
				MM_showHideLayers(layerName,'','show');
			} else {
				var removeLayer = document.getElementById(name);
				removeLayer.style.visibility="hidden";
			}
		}
	}
}

function mouseoutMenu(){
	fwDHFlag = false;
	return true;
}

/*------------------------flash on opera & netscape6-------------------------------*/
function showFlash(){
	
	if (is_nav6||is_opera){
		document.write('<img src="swf/rotating-arrow.gif">');
		}else{
	
		  document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="62" height="62">');
             document.write('<param name="movie" value="swf/arrow.swf" />');
             document.write('<param name="quality" value="high" />');
			 document.write('<param name="wmode" value="transparent" />');
            document.write(' <embed src="swf/arrow.swf" quality="high" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="62" height="62"></embed>');
	      document.write(' </object>');
			}
	}

function showIndexFlash(){
	if (is_nav6||is_opera){
		document.write('<img src="i/mainpics/index.jpg">');
		}else{
			   document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="617" height="182">');
				document.write('<param name="movie" value="swf/evolution.swf" />');
				document.write('<param name="quality" value="high" />');
				document.write('<param name="wmode" value="transparent" />');
				document.write('<embed src="swf/evolution.swf" quality="high"  wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="617" height="182"></embed>');
			  document.write('</object>');
			}
	}