var disappeardelay=250  //menu disappear speed onMouseout (in miliseconds)
var enableanchorlink=1 //Enable or disable the anchor link when clicked on? (1=e, 0=d)
var hidemenu_onclick=1 //hide menu when user clicks within menu? (1=yes, 0=no)
//var mousedOverButtonColor = "#9A0000";
var mousedOverButtonColor = "white";
var mousedOverButtonTextColor = "#666666";
var originalButtonTextColor = "#910301";
var subMenuBgColor = "#F9F9F9";
var subMenuTextColor = "#666666";
/////No further editting needed


/************************************
Bounce the page
************************************/
function goToUrl(url){
	document.location.href=url;
}
/************************************
All functions for the drop down menus
************************************/

var ie5=document.all
var ns6=document.getElementById&&!document.all

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
//alert(totaloffset);
}

function showhide(obj, e, visible, hidden, xobj){
orCol1 = xobj.style.backgroundColor;
orTextCol1 = xobj.style.color;
if (ie5||ns6){
dropmenuobj.style.left=dropmenuobj.style.top=-500
}
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover"){
  obj.visibility=visible;
  changeCol(xobj, mousedOverButtonColor);
  xobj.style.color = mousedOverButtonTextColor;
}else if (e.type=="click"){
 obj.visibility = hidden;
 xobj.style.backgroundColor = orCol1
 xobj.style.color = orTextCol1;
}
}

function changeCol(obj, xcolor){
	obj.style.backgroundColor = xcolor;
}


function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=ie5 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var topedge=ie5 && !window.opera? iecompattest().scrollTop : window.pageYOffset
var windowedge=ie5 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
}
}
return edgeoffset
}



function dropdownmenu(obj, e, dropmenuID){
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()

if (typeof xobj!="undefined"){ //hide previous menu
xobj.style.backgroundColor=orCol;
xobj.style.color=orTextCol;
}

if (typeof dropmenuobj!="undefined") //hide previous menu
dropmenuobj.style.visibility="hidden";
clearhidemenu()
if (ie5||ns6){

dropmenuobj=document.getElementById(dropmenuID)
xobj = obj;
orCol = xobj.style.backgroundColor;
orTextCol = xobj.style.color;
obj.onmouseout=delayhidemenu;


if (hidemenu_onclick) dropmenuobj.onclick=function(){
	dropmenuobj.style.visibility='hidden';
	}
dropmenuobj.onmouseover=clearhidemenu;
dropmenuobj.onmouseout=ie5? function(){ dynamichide(event)} : function(event){ dynamichide(event)}
showhide(dropmenuobj.style, e, "visible", "hidden", obj)

// offset depending on the available screen realestate
// bogus script for accountig for the visitors button - do not reuse!
if(getposOffset(obj, "left") > 959 && dropmenuobj.id == "contactmenu"){
	dropmenuobj.x=(getposOffset(obj, "left")-116);
}else{
    dropmenuobj.x=getposOffset(obj, "left");	
}

dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
}



return clickreturnvalue()
}

function clickreturnvalue(){
if ((ie5||ns6) && !enableanchorlink) return false
else return true
}

function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function dynamichide(e){
if (ie5&&!dropmenuobj.contains(e.toElement))
delayhidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhidemenu()
}

function delayhidemenu(){
delayhide=setTimeout("dropmenuobj.style.visibility='hidden'",disappeardelay);
delayhideCol=setTimeout("xobj.style.backgroundColor='" + orCol + "'",disappeardelay); // xobj.style.color='#910301';
delayhideText=setTimeout("xobj.style.color='" + orTextCol + "'",disappeardelay);
}
function clearhidemenu(){
if (typeof delayhide!="undefined"){
clearTimeout(delayhide);
clearTimeout(delayhideCol);
clearTimeout(delayhideText);
}
}


/********************************
Show and hide the left nav items
********************************/
function showAndHide(xitm, xparent){

 if(document.getElementById(xitm).style.display == "none"){
  document.getElementById(xitm).style.display="block";
  xparent.style.backgroundImage = "url(" + imgpath + "bodyparts/star_minus.gif)";
    xparent.onmouseover = function(){
    xparent.style.backgroundImage = "url(" + imgpath + "bodyparts/star_minus_over.gif)";
    } 
    xparent.onmouseout = function(){
    xparent.style.backgroundImage = "url(" + imgpath + "bodyparts/star_minus.gif)";
    } 
	cookieVal = "block";
	createCookie(xitm,cookieVal,365);
 }else{
  document.getElementById(xitm).style.display="none";
  xparent.style.backgroundImage="url(" + imgpath + "bodyparts/star_plus.gif)";
    xparent.onmouseover = function(){
    xparent.style.backgroundImage = "url(" + imgpath + "bodyparts/star_plus_over.gif)";
    } 
    xparent.onmouseout = function(){
    xparent.style.backgroundImage = "url(" + imgpath + "bodyparts/star_plus.gif)";
	cookieVal = "none";
	createCookie(xitm,cookieVal,365);
    } 
 }
 
}


/********************************
Read the cookie into the div tag
********************************/
function ReadCookieIntoDivDisplay(xcookiename, xxlink){

 
 if(readCookie(xcookiename)){

    chosen = readCookie(xcookiename);
	document.getElementById(xcookiename).style.display = chosen;
	
	if(chosen == "none"){

      document.getElementById(xxlink).style.backgroundImage = "url(" + imgpath + "bodyparts/star_plus.gif)"; 
	  document.getElementById(xxlink).onmouseover = function(){
      document.getElementById(xxlink).style.backgroundImage = "url(" + imgpath + "bodyparts/star_plus_over.gif)";
      } 
      document.getElementById(xxlink).onmouseout = function(){
      document.getElementById(xxlink).style.backgroundImage = "url(" + imgpath + "bodyparts/star_plus.gif)";
      } 
    }else if(chosen == "block"){
      document.getElementById(xxlink).style.backgroundImage = "url(" + imgpath + "bodyparts/star_minus.gif)"; 
	  document.getElementById(xxlink).onmouseover = function(){
      document.getElementById(xxlink).style.backgroundImage = "url(" + imgpath + "bodyparts/star_minus_over.gif)";
      } 
	  
      document.getElementById(xxlink).onmouseout = function(){
      document.getElementById(xxlink).style.backgroundImage = "url(" + imgpath + "bodyparts/star_minus.gif)";
      } 
    }

 }else{
  return;
 }
}


/********************************
Open the menu by default
********************************/
function openBYDefault(xsubmenuid){
	document.getElementById(xsubmenuid).style.display = "block";
}


/********************************
All the cookie functions
********************************/
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 var 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;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

/**********************************************************
Change the bg color of the nav item if they are on the page
**********************************************************/
function retButtonStyle(linkID){
	linkID = document.getElementById(linkID);
	linkID.style.backgroundColor = mousedOverButtonColor;
	linkID.style.color = mousedOverButtonTextColor;
}

/*************************************************************************************************************************
Change the bg color of the subnav and its parent button given a div id and a parent button id item if they are on the page
*************************************************************************************************************************/
function retSubNavStyle(subMenuId, parentId){
	currURL = document.location.href;
	if(currURL.indexOf("#") > 0){
		currURL = currURL.substr(0,currURL.indexOf("#")); // account for anchors
	}
	parentLink = document.getElementById(parentId);
	xsubMenu=document.getElementById(subMenuId); // the sub menus
 	menuLinks = xsubMenu.getElementsByTagName("a");
 		for(i = 0; i < menuLinks.length; i++){
 			if(menuLinks[i] == currURL){
				menuLinks[i].style.backgroundColor = subMenuBgColor;
				menuLinks[i].style.color = subMenuTextColor;
				parentLink.style.backgroundColor = mousedOverButtonColor;
				parentLink.style.color = mousedOverButtonTextColor;
				xsubMenu.style.display = "block"; // open the menu if it is closed by a cookie
				break;
			}
 		}	
}


/**********************************************************
for hiding and showing tooltips throughout the site
**********************************************************/
function hideShowTip(xid, xvis, xoffset, yoffest){
 d = document;
 theTip = d.getElementById(xid);
 theTip.style.visibility = xvis;
 theTip.style.left=xoffset;
 theTip.style.top=yoffest;
}


/***********************************************************************************************************
for setting the background color so that the user knows what page they are on in reference to the sub menu
***********************************************************************************************************/
function setNavOverState(xid){
	theId = document.getElementById(xid);
	theId.style.backgroundColor = subMenuBgColor;
	theId.style.color = mousedOverButtonTextColor;
}

/***********************************************************************************************************
for changing the border color on input text boxes
***********************************************************************************************************/
function changeBorder(xobj, xcol){
	currentCol = xobj.style.borderColor;
	newCol = xcol;
	xobj.style.borderColor = newCol;
	xobj.onblur = function(){
			xobj.style.borderColor = currentCol;
	}
}


/***************************************
 for making selections on drop menus
***************************************/
 function setSelectedIndex(optionId, checkVal){
 	theOption = document.getElementById(optionId);
	if(theOption && typeof(theOption)!='undefined'){
		for(var i = 0; i < theOption.length; i++){ 
			if(theOption.options[i].value==checkVal){ 
				theOption.selectedIndex=i; 
				return; 
			} 
		} 
	}
 }
 
 
 
/*****************************************************************
 for jumping to a page based on a selection of a drop down menu
*****************************************************************/
 function jumpMenu(xfield, xurl, xindex) { 
	var newIndex = xfield.selectedIndex; 
	if ( newIndex == xindex ) { 
		goToUrl(xurl);
	} 
} 

/*****************************************************************
 for dynamically showing and hiding an object
*****************************************************************/
function showHideDyn(xdiv){
	xxobj = document.getElementById(xdiv);
	if(xxobj.style.display == 'none'){
		xxobj.style.display = 'block'
	}else{
		xxobj.style.display = 'none';
	}
}