	function getObj(strId)
	{
		var obj;
		if(document.all) {
			return document.all[strId];
		} else if(document.getElementById) {
			return document.getElementById(strId);
		} else if(document.layers) {
			return document.layers[strId];
		} else {
			return;
		}
	}
	
	function getKey(e)
	{
		if (window.event) {
			//alert('window.event.keyCode='+window.event.keyCode);
			return window.event.keyCode;
		}
		else if (e)
		{
			//alert('e.which='+e.chich);
			return e.which;
		}
		else
		{
			//alert('returning null');
			return null;
		}
	}
	
	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 printerFriendly() {
		var ruler = getObj('ruler');
		ruler.id = 'rulerPrint';
		
		var frame = getObj('frame');
		frame.id = 'framePrint';
		
		var header = getObj('header');
		header.id = 'headerPrint';
		
		var tabBar = getObj('tabBar');
		tabBar.id = 'tabBarPrint';
		
		var bgLayer = getObj('backgroundLayer');
		bgLayer.id = 'backgroundLayerPrint';
		
		var mW = getObj('middleWrapper');
		mW.id = 'middleWrapperPrint';
		
		var lB = getObj('leftBar');
		lB.id = 'leftBarPrint';
		
		var cW = getObj('contentWrapper');
		cW.id = 'contentWrapperPrint';
		
		var c = getObj('content');
		c.id = 'contentPrint';
		
		var footer = getObj('footer');
		footer.id = 'footerPrint';
		
		var pFL = getObj('printerFriendlyLink');
		pFL.id = 'printerFriendlyLinkPrint';
		
		var nPFL = getObj('nonPrinterFriendlyLink');
		nPFL.id = 'nonPrinterFriendlyLinkPrint';
		
		//window.print();
		
		//nonPrinterFriendly();
	}
	
	function nonPrinterFriendly() {
		var ruler = getObj('rulerPrint');
		ruler.id = 'ruler';

		var frame = getObj('framePrint');
		frame.id = 'frame';

		var header = getObj('headerPrint');
		header.id = 'header';

		var tabBar = getObj('tabBarPrint');
		tabBar.id = 'tabBar';

		var bgLayer = getObj('backgroundLayerPrint');
		bgLayer.id = 'backgroundLayer';

		var mW = getObj('middleWrapperPrint');
		mW.id = 'middleWrapper';

		var lB = getObj('leftBarPrint');
		lB.id = 'leftBar';

		var cW = getObj('contentWrapperPrint');
		cW.id = 'contentWrapper';
		
		var c = getObj('contentPrint');
		c.id = 'content';

		var footer = getObj('footerPrint');
		footer.id = 'footer';

		var pFL = getObj('printerFriendlyLinkPrint');
		pFL.id = 'printerFriendlyLink';

		var nPFL = getObj('nonPrinterFriendlyLinkPrint');
		nPFL.id = 'nonPrinterFriendlyLink';

		//alert('End Printer Friendly Mode Function');
	}
		
	
	function GetXmlHttpObject()
	{ 
		var objXMLHttp=null
		if (window.XMLHttpRequest){
			objXMLHttp=new XMLHttpRequest()
		} else if (window.ActiveXObject) {
			objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
		}
		return objXMLHttp
	} 
	
	
	// style switching functions:
	function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
  if(title=="print")
  	print();
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

/* window.onload = function(e) {
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);
*/
// end style switching functions
	





	
// LEFT NAV MENU CODE HERE

// adds multiple functions to the onload event
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}



// add,check,remove or swap  css class(s) on an object
function cssjs(a,o,c1,c2)
{
	switch (a){
		case 'swap':
			o.className=!cssjs('check',o,c1)?o.className.replace(c2,c1):o.className.replace(c1,c2);
		break;
		case 'add':
			if(!cssjs('check',o,c1)){o.className+=o.className?' '+c1:c1;}
		break;
		case 'remove':
			var rep=o.className.match(' '+c1)?' '+c1:c1;
			o.className=o.className.replace(rep,'');
		break;
		case 'check':
			return new RegExp('\\b'+c1+'\\b').test(o.className)
		break;
	}
}

// register our leftnav script with the onload event	
// commented out JPR 4/5/07
//addLoadEvent(hideAll);

var mh = new Array();

function hideAll(){
  var obj;
  var objSpan;
  var objMenuLinks;
  var objAnchor;
  var objContent;
  var em;

  // get all li tags
  obj=getObj("leftNav").getElementsByTagName('li');
	
	// make sure that the leftNav has <LI> elements and that the obj is full of them
	if(obj)
	{		
		// run through them
		for (var i=0;i<obj.length;i++){

			// check the LI and make sure that it has a class of 'leftNavPrimaryOn'
			// Also check to make sure that if it has a class of 'leftNavPrimaryOn' that it doesn't also
			// have a class of 'link'.  this allows us to setup links that match menu header elements
			// but don't get click events or trigger icons attached to them.
			if(/leftNavPrimary/.test(obj[i].className) && !/link/.test(obj[i].className)){
				
				// get the header text inside the span: <span>header text</span>
				objSpan = obj[i].getElementsByTagName('span');
				objContent = objSpan[0].innerHTML;
				
				
				// now create a link
				objAnchor = document.createElement('a');
				objAnchor.href = "#";
				objAnchor.innerHTML = objContent;
				objAnchor.className = obj[i].className;
				
				// set a reference to this anchors parent object
				objAnchor.objParent = obj[i];
				
				// set the onclick event for this anchor, which toggles the visibillity of
				// sub menu as well as changing the title attribute of the anchor itself
				objAnchor.onclick= function(){
					showHide(this.objParent);
					changeTitle(this);
					//showCSS(this.parent);
					return false;
				}

				// replace span with created link
				obj[i].replaceChild(objAnchor,objSpan[0]);
				
			}
		}
	}
	
}
function showCSS(o)
{
	alert("node: " + o.nodeName +"\nclassName: " + o.className + "\nparentNode: " );
}

function changeTitle(obj){
  if(obj)
    obj.title = obj.title=='Click to show menu links' ? 'Click to hide menu links' : 'Click to show menu links';
}

function showHide(obj){
	var objOtherMenus = document.getElementById("leftNav").getElementsByTagName("li");
	var intNumOfListItems = objOtherMenus.length;
	var i;
	var anc = obj.firstChild;
	var objClassName = obj.className;
	while(anc.nodeType!=1) anc=anc.nextSibling;
	
	
	// close the rest of the menus	
	for(var i = 0; i<intNumOfListItems;i++)
	{
		if(/leftNavPrimary/.test(objOtherMenus[i].className)){
			if(!/_wrap/.test(objOtherMenus[i].className)){
				objOtherMenus[i].className = "leftNavPrimaryOff";
				objOtherMenus[i].getElementsByTagName("a")[0].className = "leftNavPrimaryOff";
			} else {
				objOtherMenus[i].className = "leftNavPrimaryOff_wrap";
				objOtherMenus[i].getElementsByTagName("a")[0].className = "leftNavPrimaryOff_wrap";
			}
		}
	}
	
	if(/Off/.test(objClassName)){
		if(!/_wrap/.test(objClassName)){
			anc.className = obj.className='leftNavPrimaryOn';	
		} else {
			anc.className = obj.className='leftNavPrimaryOn_wrap';
		}
	} else {
		if(!/_wrap/.test(objClassName)){
			anc.className = obj.className='leftNavPrimaryOff';	
		} else {
			anc.className = obj.className='leftNavPrimaryOff_wrap';
		}
	}
	
}



/*
For Internet explorer 5.01 which doesn't support the array.push and array.splice method(s) out of the box:
*/
if (typeof Array.prototype.push == "undefined") {
  Array.prototype.push = function(str) {
    this[this.length] = str;
  }
}

if (typeof Array.prototype.splice == "undefined") {
  Array.prototype.splice = function(offset, length) {
    var temp = [];
    for (var i = this.length - 1; i >= 0; i--) {
      if (i < offset || i > (offset + length - 1)) {
        temp[temp.length] = this[i];
      }
      this.length--;
    }
    for (i = temp.length - 1; i >= 0; i--) {
      this[this.length] = temp[i];
    }
  }
}
