// JavaScript Document
/*
  last update by don ... change out the "GRAY" and "DARK BLUE" colors 
  Judy: 12/18/06 - fixed init
*/

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;
}
var DARK_BLUE = "#5480BF";
var GRAY = "#4A4B4D";
var OPEN_ARROW  = "url(/images/tickOpenBlue_v2.gif)";
var CLOSED_ARROW = "url(/images/tickClosedGray_v2.gif)";

var lastDiv = 0;
var lastDivLink = 0;
function showDiv( name, effect ){
  if (lastDiv != name){
   if(lastDiv != 0){
     //hide last one
	 if( effect ){
	   Effect.BlindUp( lastDiv );
	 }
	 else{
		 tmpDiv = MM_findObj( lastDiv );
		 tmpDiv.style.display = 'none';
	 }
	 lastDivLink.style.color = GRAY;
   }
     lastDiv = name;
     lastDivLink = MM_findObj( name + "Lnk" );   
     //alert( "showDiv => " + lastDiv );
	 if( effect ){
		 Effect.BlindDown( lastDiv );
	 }else{
		 tmpDiv = MM_findObj(name);
		 tmpDiv.style.display = "block";
	 }
     lastDivLink.style.color = DARK_BLUE;
  }
 }
 
 function swapDiv( d1, d2 ){
   var d1Obj = MM_findObj( d1 );
   d1Obj.style.display = "none";
   var d2Obj = MM_findObj( d2 );
   d2Obj.style.display = "inherit";
 }
 
function init(section, page, showOverview, parent){
	//Turn the right top level item Blue
	//alert( "init::" + section + ", "+ page + ", " + showOverview );
	menuLI = MM_findObj( section + "MI" );
	if( menuLI != null ){
	 menuLI.style.listStyleImage = OPEN_ARROW;

	 menuLnk = MM_findObj( section + "Lnk" );
	 menuLnk.style.color = DARK_BLUE;
	 menuLnk.style.fontWeight = "bold";

	 var moveMenu = false;
	 var ref = document.referrer;
	 //alert( "referrer:: " + ref);
	 if( ref.indexOf( section ) == -1 ){
	   //calling page is a different section - animate the menu
	   moveMenu = true;
	 }
	 //Show the submenu
	 //if it's a sub page: turn the submenu item blue & show disc.
	 //use parent if page not on menu...
	 if( page != "top" ){
	   if( parent != "" ){
	 	subMenuItem = section +"-"+ parent;
	   }else{
		 subMenuItem = section +"-"+ page;
	   }
	   //alert( "menu Item: " + subMenuItem );
	    pageLI = MM_findObj( subMenuItem );
	    if( pageLI != null ){
		 pageLI.style.listStyleType = "disc";
		 pageLI.style.color = DARK_BLUE;
		 pageLnk = MM_findObj( subMenuItem + "Lnk" );
		 pageLnk.style.color = DARK_BLUE;
		 pageLnk.style.fontWeight = "bold";
	    }
	  }
	  if( moveMenu ) { Effect.BlindDown( section + "Sub" ); }
	}

    //skip this to leave contact options closed on page open
    var contactMenu = MM_findObj( "optIn" );
	if( contactMenu != null ){
	  toggleDiv( "optIn" );//
	}
    var curriculumMenu = MM_findObj( "cg" );
	if( contactMenu != null ){
	  toggleDiv( "cg" );//
	}
	
    if( showOverview ){
	  showDiv( "overview", false );
	}
}

function toggleDiv( name ){
	/****
	  This routine takes in the name of a div and builds the name of the corresponding
	  <A> & <LI> tags with the name as the base.
	  A variable is added to the LI object indicating that the div has been SHOWN
	  the first time the function is called for that DIV/LI/A set.	
	****/
   divLink = MM_findObj( name + "Lnk" );   
   divLI = MM_findObj( name + "LI" );   
   if( divLI.shown == true ){
	   //already open, close it
	   Effect.BlindUp( name );
	   divLink.style.color = GRAY;
	   divLI.style.listStyleImage = CLOSED_ARROW;
	   divLink.style.fontWeight = "normal";
	   divLI.shown = false;
   }else{
       Effect.BlindDown( name );
	   divLink.style.color = DARK_BLUE;
	   divLI.style.listStyleImage = OPEN_ARROW;
	   divLink.style.fontWeight = "bold";
	   divLI.shown = true;
   }
}
