/*
 * Copyright (c) 2002-2003 Bramhall Software Solutions Ltd 
 *
 * Version:	2.1b
 * Date:	5 Febuary 2003
 */
 
var gSubmenuChoice;	// related TR element
var gMainMenuText,gImgMainMenuBtn;
var goNav=window.navigator;
var gbIsIE  =(-1 != goNav.userAgent.indexOf("MSIE"));
var gbIsIE4 =(-1 != goNav.userAgent.indexOf("MSIE 4"));
var gbIsNav4=((goNav.appName=="Netscape")&&(parseInt(goNav.appVersion)==4));

function MM_reloadPage(init) {
  //reloads window if Nav4 resized
  if (init==true) with (goNav) {if (gbIsNav4) {
  document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

MM_reloadPage(true);

function MM_swapImgRestore() {
  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_preloadImages() {
  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_findObj(n, d) {
  var p,i,x;  if(!d) d=document; if(n&&(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 && document.getElementById) x=document.getElementById(n); return x;
}

function GR_swapImage() {
  var i,j=0,x,a=GR_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_swapImage(imgName,dummy,rollgif) {
  GR_swapImage(gMainMenuText,'',gImgMainMenuBtn,imgName,dummy,rollgif,1);
}

function GR_mouseOver(node) {
  if (gbIsNav4) {
	// don't know how to highlight
  }
  else {
	node.bgColor='#ffff9c'; // highlight
  }
  if ((gSubmenuChoice!=null) && (gSubmenuChoice!=node)) {
	gSubmenuChoice.bgColor='#ffcc00'; // remove highlight
  }
}

function GR_mouseOut(node) {
  if (gbIsNav4) {
  }
  else {
	node.bgColor='#ffcc00';
  }
}

function GR_outsideSubmenu() {
  if (gSubmenuChoice!=null) {
	gSubmenuChoice.bgColor='#ffff9c'; // highlight;
  }
}

function GR_onloadHighlightMenuChoice(image) {
  var sPageRoute=null;
 
  // "home" IMG used to find image dir 
  var homeButtonSrc=MM_findObj("home").src;
  var imagesIndex=homeButtonSrc.lastIndexOf("images");
  var imageSubdir=homeButtonSrc.substring(0,imagesIndex+7);
  
  if (gbIsIE) {
	sPageRoute=pageRoute.innerText;
  }
  else {
	var pageRouteTD;
	pageRouteTD=MM_findObj("pageRoute");
	if (pageRouteTD!=null)
	  sPageRoute=pageRouteTD.childNodes.item(2).nodeValue;
  }	

  if (sPageRoute!=null) {
	// Highlight main menu choice

	gMainMenuText=sPageRoute.split(">")[0].toLowerCase().replace(/\s/g,"");  //strip whitespace
	gImgMainMenuBtn=imageSubdir+'Navbar_'+gMainMenuText+'.gif';

 	var imageObject=MM_findObj(gMainMenuText);
	if (imageObject!=null) {
	  imageObject.src=imageSubdir+'Navbar_'+gMainMenuText+'_f2.gif';
	}
    //alert(subdir+'Navbar_'+gMainMenuText+'_f2.gif');
	// Highlight submenu choice  
	var linkCollection=document.links;
	var count;
	var sSubmenuChoice=sPageRoute.split(">")[1].toLowerCase().replace(/\s/g,"");
	
	for (count=0; (count<linkCollection.length) && (gSubmenuChoice==null); count++) {
	  if (linkCollection.item(count).innerHTML.toLowerCase().replace(/\s/g,"")==sSubmenuChoice) {
		if (gbIsIE4)  
	 	  gSubmenuChoice=linkCollection.item(count).parentElement;
		else
		  gSubmenuChoice=linkCollection.item(count).parentNode;
	  }
	}	    
	if (gSubmenuChoice!=null) {
	  //alert("Value trace:" + gSubmenuChoice.innerHTML + ";");
	  gSubmenuChoice.bgColor='#ffff9c'; // highlight
	}
  }
  else { //Nav4
	gMainMenuText='Home';
	gImgMainMenuBtn=imageSubdir+'Navbar_'+gMainMenuText+'.gif';
  }
}

function showCurrentDate() {
  var days=new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
  var months=new Array('January','February','March','April','May','June','July','August',
	'September','October','November','December');
  var now=new Date();
  var day=now.getDay();
  var today=now.getDate();
  var month=now.getMonth();
  var year=now.getFullYear();

  dateStamp=days[day]+' '+two_digit(today)+', '+months[month]+' '+ year;
  document.write('<span class="date"> '+dateStamp+'</span>');
}

// Used by showDate
function two_digit(value) {
  var s=value+'';
  if (s.length==1)
	return('0'+s);
  else
	return(s);
}

// Used by submenu onClick to find href; <a> must be 1st node below <td>
function GR_followLink(tdNode) {
  var length=tdNode.childNodes.length;
  var text=tdNode.childNodes.item(length - 1).href;
  location.href=text;
}