// Script to create a drop-down menu effect using layers.
// Modification of Apple and Darren Craddock code
//(c)Copyright Daren Craddock 2002
//You may use this code in any application, no limits,
//provided that you acknowledge Daren Craddock as the originator.
//sd's open menu stuff

function startMenu() {
/* work out width of page for simon centering code*/

var x
if (window.innerWidth!=window.undefined) {
x = window.innerWidth;
}
if (document.compatMode=='CSS1Compat') {
x =  document.documentElement.clientWidth;
}
if (document.body) {
x = document.body.clientWidth;
}

theWidth = x;

topoff = 54
toplogo = 25
temp1a=(((theWidth-760)/2)+32);
temp1=Math.max(42,temp1a);
//temp1 = temp1a;
layer1L=temp1;
layer2L=(temp1+50);
layer3L=(temp1+118);
layer4L=(temp1+188);
layer5L=(temp1+250);
layer6L=(temp1+355);

  var the_style_H = getStyleObject("Layerhome");
  var the_style_A = getStyleObject("Layer1");
  var the_style_B = getStyleObject("Layer2");
  var the_style_C = getStyleObject("Layer3");
  var the_style_D = getStyleObject("Layer4");
  var the_style_E = getStyleObject("Layer5");
  if (document.layers)
  {
    the_style_H.left = layer1L;
    the_style_H.top = topoff;
    the_style_H.visibility = "visible";
    the_style_A.left = layer1L;
    the_style_A.top = topoff;
    the_style_A.visibility = "hidden";
    the_style_B.left = layer2L;
    the_style_B.top = topoff;
    the_style_B.visibility = "hidden";
    the_style_C.left = layer3L;
    the_style_C.top = topoff;
    the_style_C.visibility = "hidden";
    the_style_D.left = layer4L;
    the_style_D.top = topoff;
    the_style_D.visibility = "hidden";
    the_style_E.left = layer5L;
    the_style_E.top = topoff;
    the_style_E.visibility = "hidden";
  }
  else 
  {
    the_style_H.left = layer1L + "px";
    the_style_H.top = topoff + "px";
    the_style_H.visibility = "visible";
    the_style_A.left = layer1L + "px";
    the_style_A.top = topoff + "px";
    the_style_A.visibility = "hidden";
    the_style_B.left = layer2L + "px";
    the_style_B.top = topoff + "px";
    the_style_B.visibility = "hidden";
    the_style_C.left = layer3L + "px";
    the_style_C.top = topoff + "px";  
    the_style_C.visibility = "hidden";
    the_style_D.left = layer4L + "px";
    the_style_D.top = topoff + "px";  
    the_style_D.visibility = "hidden";
    the_style_E.left = layer5L + "px";
    the_style_E.top = topoff + "px";  
    the_style_E.visibility = "hidden";
  }
}
// big() makes selected layer longer (height property)
function big(lyr) {

  var the_style = getStyleObject(lyr);
  if (document.layers)
  {
    the_style.visibility = "visible";
  }
  else 
  {
    the_style.visibility = "visible";
  }
}

/* small() makes selected layer shorter (height property)*/
function small(lyr) {
  var the_style = getStyleObject(lyr);
  if (document.layers)
  {
    the_style.visibility = "hidden";
  }
  else 
  {
    the_style.visibility = "hidden";
  }
}

  function getStyleObject(objectId) {
    // cross-browser function to get an object's style object given its
    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
