/* MAIN NAV FUNCTION - LETS IE UNDERSTAND HOVER STATE FOR DROPDOWNS*/
function startList() {
		if (document.all&&document.getElementById) {
			navRoot = document.getElementById("navList");
			for (i=0; i<navRoot.childNodes.length; i++) {
				node = navRoot.childNodes[i];
				if (node.nodeName=="LI") {
					node.onmouseover=function() {
						this.className+=" over";
					}
  					node.onmouseout=function() {
  						this.className=this.className.replace(" over", "");
   					}
   				}
  			}
 		}
	}
/* END MAIN NAV FUNCTION */

if (!document.getElementById)
    document.getElementById = function() { return null; }

function initializeExpandMenu(menuId, actuatorId) {
    var menu = document.getElementById(menuId);
    var actuator = document.getElementById(actuatorId);

    if (menu == null || actuator == null) return;

    actuator.onclick = function() {
		var display = menu.style.display;
		for (i=0; i<expandMenuArray.length;i++){
				var closeMenuRef = expandMenuArray[i] + "ExpandMenu";
				if (closeMenuRef != this){
					var closeMenu = document.getElementById(closeMenuRef);
					closeMenu.style.display = "none";
					closeMenu.parentNode.style.backgroundImage = "url(/images/sideNav_plus.gif)"
				}
			}
        this.parentNode.style.backgroundImage =
            (display == "block") ? "url(/images/sideNav_plus.gif)" : "url(/images/sideNav_minus.gif)";
        menu.style.display = (display == "block") ? "none" : "block";
				
        return false;
    }
}

/* STRIPED TABLE FUNCTIONS
 * Thank You Dave Bowman (http://www.stopdesign.com/) for your help!
 */
 
function createStripedTable(idArray) {
	// if this browser doesn't have this function, then just bail out
	if (document.getElementById == null) return;
	
	// for each table ID that we're given, stripe all the rows.
	for (var indx = 0; indx < idArray.length; indx++) {
		var id = idArray[indx];
		// get the table that corresponds to this ID
		var oTable = document.getElementById(id);
		if (oTable == null) 
			return;
		
		// get its table head, and color it
		var aTHEAD = oTable.getElementsByTagName("thead");
		var aTRhead = aTHEAD[0].getElementsByTagName("tr");
		var lastItem = aTRhead.length - 1;
		aTRhead[lastItem].className = "stripeHead";

		// get its table body, which contains all the TR tags
		var aTBODY = oTable.getElementsByTagName("tbody");

		// set the CSS class for each one of the TR tags 
		for (var i = 0; i < aTBODY.length; i++) {
			// get an array of all the TR tags in the TBODY
			var aTR = aTBODY[i].getElementsByTagName("tr");

			for (var j = 0; j < aTR.length; j++) {	
				// the % operator divides the given number by another
				// and returns the remainder. This is how we alternate the
				// rows. If you want to alternate every third row, change
				// the 2 to a 3.
				aTR[j].className = (j % 2 == 1) ? "stripe1" : "stripe2";
			}
		}
	}
}


var currentTR = null; // if the user clicks on a row, we store it aside so we can unhilite it later.

function createAutoHiliteTableRows(idArray)
{
	// check for DOM-capable browser. If this method isn't available, don't do anything.
	if (document.getElementById != null)
	{
		for (var indx = 0; indx < idArray.length; indx++) {
			var id = idArray[indx];
		
			// get each table that has the ID that we were given
			var oTable=document.getElementById(id);
			if (oTable != null)
			{
				// get all the TR tags in the table.
				var aTRs=oTable.getElementsByTagName('tr');
				for(var j=0;j<aTRs.length;j++)
				{
					// only highlight those TRs that are children of the TBODY.
					// remove this "if" statement if you want to highlight ALL rows.
					if(aTRs[j].parentNode.nodeName=='TBODY')
					{
						// add event handlers for each TR to handle mouseover, mouseout,
						// and mousedown events. For each event, set the inline style
						// of the tag to whatever you want to happen when that event occurs.
						// Using inline styles instead of classes makes it easy to combine
						// this code with other functions, like the table striping example,
						// since when the inline style is removed, the class applied by
						// the striping code won't be affected.
						aTRs[j].onmouseover=function() {
							if (currentTR == this) return false;
							this.style.backgroundColor="#ffc";
							this.style.fontWeight="";
							return false;}
						aTRs[j].onmouseout=function(){
							if (currentTR == this) return false;
							this.style.backgroundColor="";
							this.style.fontWeight="";
							return false;}
						//aTRs[j].onmousedown=function(){
							// if there is already another row that the user clicked on,
							// remove its style before highlighting the one that was clicked.
							//if (currentTR != null) {
								//currentTR.style.backgroundColor="";
								//currentTR.style.fontWeight="";
								// if the row the user clicked on was already highlighted, then
								// just remove the styling and return.
								//if (currentTR == this) {
									//currentTR = null;
									//return false;
								//}
							//}
							//currentTR = this; // remember which row was clicked
							// highlight the row
							//this.style.backgroundColor="#B1C2EB";
							//this.style.fontWeight="bold";
							//return false;}
					}
				}
			}
		}
	}
}
/* END STRIPED TABLE FUNCTIONS */

/* ONLOAD FUNCTION THAT CALLS THE ABOVE FUNCTIONS AS NECESSARY */
var showSubmenu, tableArray, expandMenuArray;

window.onload = function(){
	/* initialize header (main) nav */
	startList();
	/* initialize side nav */
	if (showSubmenu){
		var submenu = document.getElementById(showSubmenu);
		submenu.style.display = "block";
	}
	/* initialize expandNav if necessary */
	if (expandMenuArray){
		for (i=0; i<expandMenuArray.length;i++){
				var menuRef = expandMenuArray[i] + "ExpandMenu";
				var actuatorRef = expandMenuArray[i] + "Expander";
            	initializeExpandMenu(menuRef, actuatorRef);
			}
	}
	/* stripe tables if necessary */
	if (tableArray){
		createStripedTable(tableArray);
		createAutoHiliteTableRows(tableArray);
	}
}
/* END ONLOAD FUNCTION */

/* POP UP WINDOW FUNCTIONS */
function popUpResize(path,w,h,r) {
	w = w + 50
	h = h + 50
	if (r == "") {
		r = "no"
	}
	var popUpResized=window.open(path,"popUpResized","height="+h+",width="+w+",scrollbars=yes,resizable="+r+",menubar=no,toolbar=no,location=no,status=no,screenx=40,screeny=40,left=40,top=40");
	popUpResized.focus();
}

function returnToOpener(path) {
	var popUpReturn=window.opener.location.href(path);
	this.blur();
}
/* END POP UP WINDOW FUNCTIONS */
/* POP UP WINDOW FUNCTIONS 2 */
function popUpResize2(path,w,h,r) {
	w = w + 50
	h = h + 50
	if (r == "") {
		r = "no"
	}
	var popUpResized2=window.open(path,"popUpResized","height="+h+",width="+w+",scrollbars=yes,resizable="+r+",menubar=yes,toolbar=yes,location=no,status=no,screenx=40,screeny=40,left=40,top=40");
	popUpResized2.focus();
}

function popUpResize3(path,w,h,r) {
	w = w + 50
	h = h + 50
	if (r == "") {
		r = "no"
	}
	var popUpResized3=window.open(path,"popUpResized","height="+h+",width="+w+",scrollbars=no,resizable="+r+",menubar=no,toolbar=no,location=no,status=no,screenx=40,screeny=40,left=40,top=40");
	popUpResized.focus();
}

function returnToOpener(path) {
	var popUpReturn=window.opener.location.href(path);
	this.blur();
}
/* END POP UP WINDOW FUNCTIONS 2 */

/* TABLES */
function alternate(id){ 
 if(document.getElementsByTagName){  
   var table = document.getElementById(id);   
   var rows = table.getElementsByTagName("tr");   
   for(i = 0; i < rows.length; i++){           
 //manipulate rows 
     if(i % 2 == 0){ 
       rows[i].className = "even"; 
     }else{ 
       rows[i].className = "odd"; 
     }       
   } 
 } 
}
<!--
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];}
}
//-->