// JavaScript Document
function attach_events() {
	//alert('attach');
	prep_vc();
	
	//fix only for IE ... menu rollover
	if(document.all&&document.getElementById) {
		//alert()
		menu_hover();
	}
}

function menu_hover() {
	var mMenu_obj = document.getElementById("mainMenu");
	var mMenu_items = mMenu_obj.childNodes;
	var mMenu_items_len = mMenu_obj.childNodes.length
	for(i=0;i<mMenu_items_len;i++) {
		//alert(mMenu_items[i].nodeName)
		if(mMenu_items[i].nodeName.toLowerCase()=='li') {
			mMenu_items[i].firstChild.onmouseover = function() {
					this.className = "hovered";
			}
			mMenu_items[i].firstChild.onmouseout = function() {
					this.className = "";
			}
		}
		
	}
}

function prep_vc() {
	if (document.all&&!document.getElementById) {
		var body_node= document.all;
	} else {
		var body_node = document.getElementsByTagName("body")[0];
	}
	if(body_node.className=="frontPage") {
		//alert(get_height());
		window.onresize = keep_vc;
		
		for(i=0;i<body_node.childNodes.length;i++) {
			if(body_node.childNodes[i].nodeName.toLowerCase()=="div") body_node.childNodes[i].style.visibility = "visible";
		}
			keep_vc();
	}

}
function keep_vc() {
	//var body_node = document.getElementsByTagName("body")[0];
	if (document.all&&!document.getElementById) {
		var head_div= document.all["header"];
	} else {
		var head_div = document.getElementById("header");
	}
	var browser_height = get_height();
	//alert(head_div.style)
	//head_div.style.marginTop = "25px";
	head_div.style.marginTop = (browser_height-400)/2 + "px";
	//document.getElementById("mainMenu").style.marginTop =  88 + "px";
	var detect = navigator.userAgent.toLowerCase();
	
	/*
	if(!document.all&&document.getElementById) {
		if(detect.indexOf('mac')==-1) {
			//document.getElementById("mainMenu").style.marginTop = ((browser_height-400)/2)+ 88 + "px";
		} else {
			//alert(((browser_height-400)/2)+ 88)
			//document.getElementById("mainMenu").style.marginTop =  88 + "px";
			//alert(document.getElementById("mainMenu").style.marginTop)
			//setTimeout('another_set()', 500) 
		}
	}
	*/
	//alert(head_div.style.marginTop)
}

function another_set() {
	alert("> "+document.getElementById("mainMenu").style.marginTop)
	var browser_height = get_height();
	
	document.getElementById("mainMenu").style.marginTop =  88 + "px";
	head_div.style.marginTop = (browser_height-400)/2 + "px";
}

function get_height() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
	//alert("Non-IE")
    //myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement &&
      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
	//alert('standards compliant mode')
    //myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
	//alert(document.body.clientHeight)
    //myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
	return myHeight;
}

function OpenBrWindow(theURL,winName, myWidth, myHeight, isCenter) {
  features = ' ,';
  if(window.screen&&(isCenter||isCenter=="true")){
    var myLeft = (screen.width-myWidth)/2;
    var myTop = (screen.height-myHeight)/2;
    features ='left='+myLeft+',top='+myTop+' ,';
  }
  window.open(theURL,winName,features+'width='+myWidth+',height='+myHeight);
}


//alert()
window.onload = attach_events;