// This cross platform script and centered DHTML menu contributed by Greg Grasmehr
// Provides centering of DHTML elements and drop down menus based on client browser window size
// Allows use of absolute DHTML element placement and drop down menus on a center justified web site
// Additional browser support available by adding navigator.appName statement

// adjusts center alignment for 10 pixel width browser scroll bar
function calcCenterCSS() {

var scrolladjust = 10;

if ((navigator.appName=="Netscape")||(navigator.appName=="Opera")) {
  var winW = window.innerWidth;
  var winH = window.innerHeight;
  if (navigator.appName=="Opera") {
  scrolladjust = 0;
  }
 }
 if (navigator.appName.indexOf("Microsoft")!=-1) {
  var winW = document.body.offsetWidth;
  var winH = document.body.offsetHeight;
 }

// the max width of the outer table inside each layer
dhtmlWidth = 840;
sidebarWidth = 20;

// ((((winW - dhtmlWidth)/2) + 0) - scrolladjust) is the base formula used to find the x coordinates for all elements in order to center them in the window
// the + 0 is used to indent from base calculation returned by the formula
// each subsequent menu item on the same x axis is the formula + the width of the preceding element
// the widths of all our menu elements for this example is 150

baseContentWidth = (((winW - dhtmlWidth)/2) - scrolladjust + sidebarWidth);
/*
if (winW-dhtmlWidth >= 0) {
navOneWidth = ((((winW - dhtmlWidth )/2) + 0) - scrolladjust + sidebarWidth);
navTwoWidth = ((((winW - dhtmlWidth)/2) + 150) - scrolladjust + sidebarWidth);
navThreeWidth = ((((winW - dhtmlWidth)/2) + 300) - scrolladjust + sidebarWidth);
navFourWidth = ((((winW - dhtmlWidth)/2) + 450) - scrolladjust + sidebarWidth);
}
else {
navOneWidth = sidebarWidth;
navTwoWidth = 150 - scrolladjust + sidebarWidth;
navThreeWidth = 300 - scrolladjust + sidebarWidth;
navFourWidth = 450 - scrolladjust + sidebarWidth;
}
*/
navOneWidth = (winW - scrolladjust - dhtmlWidth )/2 + sidebarWidth - 2;
if (navOneWidth < sidebarWidth) {
navOneWidth = sidebarWidth;
}
navTwoWidth = navOneWidth + 150 - 1;
navThreeWidth = navOneWidth + 300 + 4;
navFourWidth = navOneWidth + 450 + 8;


//alert ("winW, Widths = " + winW + " " + navOneWidth + " " + navTwoWidth + " " + navThreeWidth + " " + navFourWidth);

document.write("<style type=\"text/css\">" +
"#navOne { top: 80px; left: "+navOneWidth+"px; width: 150px; height: 30; position: absolute; color: black; background-color: #9ba89f; z-index: 1;} " +
"#navOneMenu { position: absolute; top: 110px; left: "+navOneWidth+"px; background-color:#ffffff; width: 150px; border-width: 0px 1px 1px 1px; border-style: solid; border-color: #02445E; visibility: hidden; } " +
"#navTwo { top: 80px; left: "+navTwoWidth+"px; width: 150px; height: 30px;  position: absolute; color: black; background-color: #9ba89f; z-index: 1;} " +
"#navTwoMenu { position: absolute; top: 110px; left: "+navTwoWidth+"px; background-color:#ffffff; width: 150px; border-width: 0px 1px 1px 1px; border-style: solid; border-color: #02445E; visibility: hidden;} " +
"#navThree { top: 80px; left: "+navThreeWidth+"px; width: 150px; height: 30px;  position: absolute; color: black; background-color: #9ba89f; z-index: 1;} " +
"#navThreeMenu { position: absolute; top: 110px; left: "+navThreeWidth+"px; background-color:#ffffff; width: 150px; border-width: 0px 1px 1px 1px; border-style: solid; border-color: #02445E; visibility: hidden;} " +
"#navFour { top: 80px; left: "+navFourWidth+"px; width: 150px; height: 30px;  position: absolute; color: black; background-color: #9ba89f; z-index: 1;} " +
"#navFourMenu { position: absolute; top: 110px; left: "+navFourWidth+"px; background-color:#ffffff; width: 150px; border-width: 0px 1px 1px 1px; border-style: solid; border-color: #02445E; visibility: hidden; } </style>");
}

function hideDiv(object) {
  if (document.getElementById) {
    document.getElementById(object).style.visibility = 'hidden';
  }
  else if (document.layers && document.layers[object]) {
    document.layers[object].visibility = 'hidden';
  }
  else if (document.all) {
    document.all[object].style.visibility = 'hidden';
  }
}

function showDiv(object) {
  if (document.getElementById) {
    document.getElementById(object).style.visibility = 'visible';
  }
  else if (document.layers && document.layers[object]) {
    document.layers[object].visibility = 'visible';
  }
  else if (document.all) {
    document.all[object].style.visibility = 'visible';
  }
}

function createCSS() {
document.write("<style type=\"text/css\">#navOne { top: 80px; left: "+navOneWidth+"px; width: 150px; height: 30; position: absolute; } #navOneMenu { position: absolute; top: 110px; left: "+navOneWidth+"px; width: 150px;  visibility: hidden; border-width: 0px 1px 1px 1px; border-style: solid; border-color: #02445E; } #navTwo { top: 80px; left: "+navTwoWidth+"px; width: 150px; height: 60px;  position: absolute;} #navTwoMenu { position: absolute; top: 110px; left: "+navTwoWidth+"px; width: 150px; visibility: hidden; border-width: 0px 1px 1px 1px;; border-style: solid; border-color: #02445E; } #navThree { top: 80px; left: "+navThreeWidth+"px; width: 150px; height: 50px;  position: absolute; } #navThreeMenu { position: absolute; top: 110px; left: "+navThreeWidth+"px; background-color:#ffffff; width: 150px; border-width: 0px 1px 1px 1px; border-style: solid; border-color: #02445E; visibility: hidden;} #navFour { top: 80px; left: "+navFourWidth+"px; width: 150px; height: 50px;  position: absolute;} #navFourMenu { position: absolute; top: 110px; left: "+navFourWidth+"px; background-color:#ffffff; width: 150px; border-width: 0px 1px 1px 1px; border-style: solid; border-color: #02445E; visibility: hidden; } </style>");
}

