<!--

/* is menu currently open? */
var isopen;
/* is it the full bar style? */
var isbar;
/* does browser have document.all? implies different properties */
var docall = document.all?true:false;


/* useful if you want a link or event function that does nothing */
function doNothing() {

}

/* hide the menu. also move it the top to zero so that if we resize the
page, it won't hold up the vertical scroll bar (cause blank space after content) */
function menuClose() {
  var the_style = getStyleObject("LeftNav");
  var the_con = getObject("content");
  var the_bar = getObject("LeftStrip");
  var the_nav_top = 0;
  var con_left = 0;
  
    	  
  if (isbar)
	con_left = the_bar.offsetWidth;
  
  /*if (document.layers)
  {*/
	    the_style.top = the_nav_top;
	    if (isbar)
	    	the_con.style.left = con_left;
  /*}
  else 
  {
    	the_style.top = the_nav_top + "px";
	    if (isbar)
	    	the_con.style.left = con_left + "px";
  }*/
  the_style.visibility = 'hidden';
  isopen = 0;
}

function menuOpen(event, barstyle) {
  var the_nav = getObject("LeftNav");
  var the_con = getObject("content");
  var the_bar = getObject("LeftStrip");
  var the_nav_top = 0;
  var con_left = 0;
  var nheight, winheight, poff, adj;
  
  nheight = the_nav.offsetHeight;
  winheight = getWindowHeight();
  
  isbar = barstyle;
  
  /* different browsers have basic y position attribute in different places */
  if (docall) {
  	if (event.clientY || (event.clientY == 0))
	  	the_nav_top = event.clientY;
	else
  		the_nav_top = event.pageY;
  } else {
  	if (event.pageY || (event.pageY == 0))
	  	the_nav_top = event.pageY;
	else
  		the_nav_top = event.clientY;
  }
  
  //alert("docall: "+docall+"   event.clientY: "+event.clientY+"   event.pageY: "+event.pageY);
    	
  /* this pushes the menu up so you can move right directly into the box,
  instead of hitting the top edge */
  the_nav_top = the_nav_top - 10;
  
  poff = the_nav_top;
  /*if (event.pageY && (!docall))*/
  /* doesn't subtract for opera 6.03 osx pretending to be IE. need to subtract, but no way to identify */
  if (!docall)
  	poff = poff - document.body.scrollTop;
  
  /* make sure we're not at the absolute top of the screen, or running
  off the bottom */
  if (poff + nheight > winheight - 5) {
  	adj = (poff + nheight) - (winheight - 5);
  	the_nav_top = the_nav_top - adj;
  	poff = poff - adj;
  }
  if (poff < 5) {
  	adj = 5 - poff;
  	the_nav_top = the_nav_top + adj;
  	poff = poff + adj;
  }

  
  /* some browsers give us Y relative to the whole page, some only relative
  to the visible portion. This test seems to give proper results. */
  //if ((!event.pageY) || (event.pageY && docall)) {
  if (docall) {
  	  the_nav_top = the_nav_top + document.body.scrollTop;
  	  //alert("adding scrollTop");
  }
  //alert("the_nav_top: " + the_nav_top);
  	  
  if (isbar) {
  	/* if using the bar style, force menu to start at top of window.
  	we'll also shove the contents over */
  	the_nav_top = document.body.scrollTop;
	con_left = the_nav.offsetWidth + the_bar.offsetWidth;
  }
  	  
  /* set top of menu and make it visible */
  /*if (document.layers)
  {*/
	    the_nav.style.top = the_nav_top;
	    if (isbar)
	    	the_con.style.left = con_left;
  /*}
  else 
  {
    	the_nav.style.top = the_nav_top + "px";
    	if (isbar)
    		the_con.style.left = con_left + "px";
  }*/
  the_nav.style.visibility = 'visible';
  isopen = 1;
} 

/* toggle function, currently used by click in blue bar */
function menuToggle(event, barstyle) {
  if (isopen)
  	menuClose();
  else
  	menuOpen(event, barstyle);
  
}

/* only open if it's not already open. prevents menu from drifting / jumping
back and forth */
function menuCondOpen(event, barstyle) {
	if (!isopen)
		menuOpen(event, barstyle);
}

function getObject(objectId) {
    // cross-browser function to get an object
    if(document.getElementById && document.getElementById(objectId)) {
	// W3C DOM
	return document.getElementById(objectId);
    } else if (document.all && document.all(objectId)) {
	// MSIE 4 DOM
	return document.all(objectId);
    } else if (document.layers && document.layers[objectId]) {
	// NN 4 DOM.. note: this won't find nested layers
	return document.layers[objectId];
    } else {
	return false;
    }
} // getObject

function getStyleObject(objectId) {
    // cross-browser function to get an object's style object given its id
    if(document.getElementById && document.getElementById(objectId)) {
	// W3C DOM
	return document.getElementById(objectId).style;
    } else if (document.all && document.all(objectId)) {
	// MSIE 4 DOM
	return document.all(objectId).style;
    } else if (document.layers && document.layers[objectId]) {
	// NN 4 DOM.. note: this won't find nested layers
	return document.layers[objectId];
    } else {
	return false;
    }
} // getStyleObject

function getDocHeight() {
  	var the_con = getObject("content");
  	
	/* two ways we might find the total doc height */
	if (document && document.height)
		height = document.height;
	else if (the_con && the_con.offsetHeight)
		height = the_con.offsetHeight;
	else
		height = 0;
		
	return height;
}
function getWindowHeight() {
	/* three ways we might find the total window height */
	if (window && window.innerHeight) /* safari, netscape derivatives ? */
		height = window.innerHeight;
	else if (document && document.body && document.body.clientHeight) /* ie */
		height = document.body.clientHeight;
	else if (document && document.body && document.body.offsetHeight) /* other */
		height = document.body.offsetHeight;
	else {
		/*alert("didn't get window height!");*/
		height = 0;
	}
	return height;
}
/* function to adjust the height of the blue bar to match the current height
of the contents. cleaner way would be use a table, but safari won't do 
it properly */
function adjustSize() {
  	var the_bar_style = getStyleObject("LeftStrip");
  	var the_table = getObject("leftbartable");
  	var height, winheight;
  	
  	height = getDocHeight();
		
	/* make height of left bar a bit shorter than entire page.
	why? mainly because if we don't, when we resize wider, Safari and mac IE
	create blank white space at the bottom following the contents. I think this
	is because the full length bar causes the height to not have changed yet when
	it is queried. */
	height = height - 60;
	
	winheight = getWindowHeight();
	if (height < winheight)
		height = winheight;
		
	/* set the height of the div, as well as the table inside it */
	if (height != 0) {
		//alert("height: " + height);
		/*if (document.layers)
			alert("document.layers true");
	  	if (1) { //document.layers) {*/
		  	the_bar_style.height = height;
		  	the_table.height = height;
		/*} else {
		  	the_bar_style.height = height + "px";
		  	the_table.height = height + "px";
		}*/
	}
	
	/* close the menu if it was open. just cuz.
	actually this is important if it is open at the bottom of the window when
	we go to resize wider */
	menuClose();
}

/* when we load, set up a couple more events, and adjust the left bar height
for the first time */
function doLoad() {	
	/* safari doesn't recognize onscroll, but this is nice on other browsers */
	window.onscroll = menuClose;
	window.onresize = adjustSize;
	//setTimeout("adjustSize()",1000);
	adjustSize();
}

/* this function lets us do something useful on Netscape 4.7 and earlier.
problems: no mouseOver or click events in divs or tables.
		  can't resize left bar.
		  document.write screws things up.
was going to put the bar up with some clickable images. but because of 
document.write problems, can't do that unless i do it for all browsers.
(bar would disappear on resize).
so instead, for netscape we just shove the menu stuff into the contents div. */
function maybeStartNavDiv() {
	adjustSize();
	if (!(navigator.appName=="Netscape"&&parseFloat(navigator.appVersion)<4.8)) {
		document.write("</div>");
		document.write("<div class='platformPosition' id='LeftNav' onMouseOver='return false;'>");
	} else {
		/* a seperator might be nice, but it doesn't show up. stupid netscape */
		/* document.write("<hr>"); */
	}
}

function writeLeftBar(barstyle) {
	/* write the left bar unless it's Netscape 4.7 */
	/* also nice to hide this garbage from the main html page */
	if (!(navigator.appName=="Netscape"&&parseFloat(navigator.appVersion)<4.8)) {
		document.write("<div class='platformPosition' id='LeftStrip' onMouseOver='menuCondOpen(event, ");
		document.write(parseInt(barstyle));
		document.write("); return false;' onClick='menuToggle(event, ");
		document.write(parseInt(barstyle));
		document.write("); return false;'>");
		document.write("<ilayer><layer>");
		document.write("<table id='leftbartable' width=15 height='100%' border=0 cellpadding=0 cellspacing=0>");
		document.write("<tr valign=top><td valign=top>");
		/*document.write("<a href='javascript:doNothing()' onClick='menuToggle(event); return false;'>");
		document.write("<img src='images/littlekey.gif' alt=' width='15' height='11' border='0' padding='0'>");
		document.write("</a>");*/
		document.write("</td></tr>");
		document.write("</table>");
		document.write("</layer></ilayer>");
		document.write("<br></div>");
	}
	
	/* approximate html this function writes. included here for easy copy/paste
	during testing. */
	
/*
	<div class="platformPosition" id="LeftStrip" onMouseOver="menuCondOpen(event, 0); return false;" onClick="menuToggle(event, 0); return false;">
		<ilayer><layer>
		<table id='leftbartable' width=15 height='100%' border=0 cellpadding=0 cellspacing=0>
		<tr valign=top><td valign=top>
		<a href="javascript:doNothing()" onClick="menuToggle(event, 0); return false;">
		<img src="images/littlekey.gif" alt="" width="15" height="11" border="0" padding="0">
		</a>
		</td></tr>
		</table>
		</layer></ilayer>
		<br></div>
		*/
}

window.onload = doLoad;

// -->

