// JavaScript Document
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
//--------------DROPDOWN MENU FUNCTIONS-------------------//
//make sure to include all 'submenu id' and 'submenu_sub id' you needed to the arrays bellow
//do not forget all submenus divs id MUST begin with the string 'submenu' + whatever
//all submenus_Sub divs id MUST begin with the string 'submenu_Sub' + whatever

var submenu_array = ["submenu1","submenu2","submenu3"];
//var submenu_Sub_array = ["submenu1_Sub1","submenu1_Sub2","submenu2_Sub1","submenu2_Sub2"];
var submenu_Sub_array = [];

function setLyr(obj,lyr)  //controls the positioning of the submenu layer lets you adjust x,y positioning for ie-mac and safari separately
{

	var newX = findPosX(obj);
	var newY = findPosY(obj);
	var x = new getObj(lyr);
//window.alert(newX);
	var fixX //adjasting the diference between ie-mac and other browsers
	var fixY  //adjasting the diference between ie-mac and other browsers
	x.style.top = newY +25+ 'px'; //top positioning
	x.style.left =newX+0 + 'px';  //left positioning
}

function setLyr2(obj,lyr)   //controls the positioning of the submenu_Sub layer let you adjust ie-mac x,y positioning separately
{
		var newX = findPosX(obj)-1;
		var newY = findPosY(obj);
		var x = new getObj(lyr);
		var addX = obj.offsetWidth;
		var fixX
		var fixY

	x.style.top = newY + fixX + 'px';
	x.style.left = newX+ fixY + addX + 'px';
	
}

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 getObj(name){
 if (document.getElementById)
 {
	   this.obj = document.getElementById(name);
	   this.style = document.getElementById(name).style;
 }
 else if (document.all)
 {
	   this.obj = document.all[name];
	   this.style = document.all[name].style;
 }
 else if (document.layers)
 {
	   if (document.layers[name])
	   {
	   	this.obj = document.layers[name];
	   	this.style = document.layers[name];
	   }
 }
}

function FW_clearTimeout(){
	if (fwHideMenuTimer) clearTimeout(fwHideMenuTimer);
	fwHideMenuTimer = null;
	fwDHFlag = false;
}

function FW_startTimeout(){
	fwStart = new Date();
	fwDHFlag = true;
	fwHideMenuTimer = setTimeout("fwDoHide()", 1000);
}

function fwDoHide(){
	var printstring = '';
	printstring +=fwStart+' fwHideMenuTimer:'+fwHideMenuTimer+' layers: ';
	/*window.status = printstring;*/
	if (!fwDHFlag) return;
	var elapsed = new Date() - fwStart;
	if (elapsed < 40) {
		fwHideMenuTimer = setTimeout("fwDoHide()", 40-elapsed);
		return;
	}
	fwDHFlag = false;
	hideActiveMenus();
	window.ActiveMenuItem = 0;
}



function hideActiveMenus() {  //goes over each of the submenus in the arrays and hide them
	for (i=0; i<(submenu_array.length); i++){
		  var name=submenu_array[i]; 
			var removeLayer = document.getElementById(name);
			removeLayer.style.visibility="hidden";
		}
		for (i=0; i<(submenu_Sub_array.length); i++){
		  var name=submenu_Sub_array[i]; 
			var removeLayer = document.getElementById(name);
			removeLayer.style.visibility="hidden";
		}
}

function ShowNav(layerName){  // show named layer and hide All other layers from the submenu_array
	
	for (i=0; i<(submenu_array.length); i++){
		var name=submenu_array[i]; 
		var subname=name.substr(0,7); 
		 if(subname=="submenu"){ 
			   if (layerName==name){
				   MM_showHideLayers(layerName,'','show');
			   } else {
				   var removeLayer = document.getElementById(name);
				   removeLayer.style.visibility="hidden";
				}
			}
	}
}

function hideSubNav(){  // hides all sub sub nav
	
	for (i=0; i<(submenu_Sub_array.length); i++){
		  var name=submenu_Sub_array[i]; 
			var removeLayer = document.getElementById(name);
			removeLayer.style.visibility="hidden";
		}
}

function showSubNav(layerName){ // show named layer and hide All other layers from the submenu_Sub_array
	for (i=0; i<(submenu_Sub_array.length); i++){
		var name=submenu_Sub_array[i]; 
		var subname=name.substr(8,4);
		if(subname=="_Sub"){ 
			if (layerName==name){
				MM_showHideLayers(layerName,'','show');
			} else {
				var removeLayer = document.getElementById(name);
				removeLayer.style.visibility="hidden";
			}
		}
	}
}

function mouseoutMenu(){
	fwDHFlag = false;
	return true;
}

