

function init(offsetfromid)
{
	popuplayer('menlayer',0,0,offsetfromid);
	popuplayer('flashlayer',0,0,offsetfromid);	
		
	openlayer();
							
}

// Show a popup layer at a given position
function popuplayer(layertoshow,Xoff,Yoff,offsetfromid) {
  
  offsettfromlayer = document.getElementById(offsetfromid);
  ContentArea = document.getElementById(layertoshow);
  if (ContentArea &&  offsettfromlayer) // we have the layer and main content
  {
	  contentPos = getLayerCoords(offsetfromid);
    ContentArea.style.top = parseInt(contentPos.y)+parseInt(Yoff);
    ContentArea.style.left = parseInt(contentPos.x)+parseInt(Xoff);
	}
}

// hides a layer
function hidelayer(layer) {
	document.getElementById(layer).style.visibility = 'hidden';
}

// Get the highest zindex of DIVs
function findHighestZ() {
  var documentDivs = new Array();
  documentDivs = document.getElementsByTagName("DIV");
  var highestZ = 0;
  for (var i = 0; i < documentDivs.length; i++) {
	 var zIndex = documentDivs[i].style.zIndex;
     highestZ = (zIndex > highestZ) ? zIndex : highestZ;
  }
  return highestZ;
}

// shows a layer
function showlayer(layer) {
		var highz= findHighestZ();
		document.getElementById(layer).style.zIndex = parseInt(highz) + 1;		
		document.getElementById(layer).style.visibility = 'visible'; 
}

// get the top and left position of a layer
function getLayerCoords(layerName) {
  var layerElement = document.getElementById(layerName);
  var coords = {x:0 ,y:0};
  if (layerElement != null)
  {
		do {coords.x += parseInt(layerElement.offsetLeft);
      coords.y += parseInt(layerElement.offsetTop);
      layerElement = layerElement.offsetParent;
		} while (layerElement);
  }
  return coords
}


	
















