/**
 * Project  : Amarcon
 * Author   : C.A. Nouta
 * Created  : May, 26th 2009
 * Modified : May, 26th 2009
 *
 * Copyright (c) 2009 Cumpinent. Alle rights reserved.
 **/ 

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 adjustContainer() {
  var wWidth = 0, wHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    wWidth = window.innerWidth;
    wHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    wWidth = document.documentElement.clientWidth;
    wHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    wWidth = document.body.clientWidth;
    wHeight = document.body.clientHeight;
  }
  var con = MM_findObj("container");
  /* if (wHeight<588&&wWidth<994) { con.style.top = "0px"; con.style.marginTop = "0px"; con.style.left = "0px"; con.style.marginLeft = "0px"; }
  else if (wHeight<588) { con.style.top = "0px"; con.style.marginTop = "0px"; con.style.left = "50%"; con.style.marginLeft = "-497px"; }
  else if (wWidth<994) { con.style.top = "50%"; con.style.marginTop = "-294px"; con.style.left = "0px"; con.style.marginLeft = "0px"; }
  else { con.style.top = "50%"; con.style.marginTop = "-294px"; con.style.left = "50%"; con.style.marginLeft = "-497px"; } */  
  if (wWidth<994) { con.style.left = "7px"; con.style.marginLeft = "0px"; }
  else { con.style.left = "50%"; con.style.marginLeft = "-491px"; }
}

function initPage() {
  adjustContainer();
  window.onresize = adjustContainer;
}  

function activateA(cur) {
	var t = cur;
	if (t) {
		t=t.firstChild;
		if (t) {
			var pos = t.className.indexOf('nav_item_level_1');
			if (pos>=0) { t.className += ' hoveratag'; }
		}
	}
}

function deActivateA(cur) {
	var t = cur;
	if (t) {
		t=t.firstChild;
		if (t) {
			var pos = t.className.indexOf('nav_item_level_1');
			if (pos>=0) { t.className=t.className.replace(" hoveratag", ""); }
		}
	}
}


activateMenu = function(nav) {
	var navroot = document.getElementById(nav);
	var lis=navroot.getElementsByTagName("LI");  
	for (i=0; i<lis.length; i++) {
		if(lis[i].lastChild.tagName=="UL"){
			lis[i].onmouseover=function() {	
				this.lastChild.style.display="block";
				activateA(this);
			}
			lis[i].onmouseout=function() {                       
				this.lastChild.style.display="none";
				deActivateA(this);
			}
		}
	}
}

window.onload= function(){
	activateMenu('nav_menu'); 
}
