// JavaScript Document
//Get width and heigth of the window
function set_wwidth () 
{ 
	var x,y;
	if (self.innerHeight) // all except Explorer
	{
		x = self.innerWidth;
		y = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
		// Explorer 6 Strict Mode
	{
		x = document.documentElement.clientWidth;
		y = document.documentElement.clientHeight;
	}
	else if (document.body) // other Explorers
	{
		x = document.body.clientWidth;
		y = document.body.clientHeight;
	}
	
	xmain = x - 225;
	ymain = y - 65;
	
	xlay = x - 10;
	ylay = y - 10;
	document.getElementById("layer_main").style['width'] = xmain+"px"; 
	document.getElementById("layer_main").style['height'] = ymain+"px";
	
	document.getElementById("layout_main").style['height'] = ylay+"px"; 
}

var subs=new Array('submenu_ascotel_systeme','submenu_office_engeraete');
var zeit='';
var zeit2='';
var last_child = '';
var last_parent = '';
var last_grandchild = '';
var last_grandparent = '';

function tmeout()
{
	zeit=setTimeout('hide_child()',800);
	zeit2=setTimeout('hide_grandchild()',800);
}
function hide_child()
{
	if (last_child != '') { document.getElementById(last_child).style.visibility='hidden'; }
	if (last_parent != '') { document.getElementById(last_parent).className = 'menu_normal'; }
}
function hide_grandchild()
{
	if (last_grandchild != '') { document.getElementById(last_grandchild).style.visibility='hidden'; }
	if (last_grandparent != '') { document.getElementById(last_grandparent).className = 'menu_normal'; }
}
function show_child(parent,child)
{
	clearTimeout(zeit);
	clearTimeout(zeit2);
	if (last_child != '') { document.getElementById(last_child).style.visibility='hidden'; }
	if (last_parent != '') { document.getElementById(last_parent).className = 'menu_normal'; }
	
	if (last_grandchild != '') { document.getElementById(last_grandchild).style.visibility='hidden'; }
	if (last_grandparent != '') { document.getElementById(last_grandparent).className = 'menu_normal'; }
	
	last_child = child;
	last_parent = parent;
	document.getElementById(child).style.visibility='visible';
	document.getElementById(parent).className = 'menu_hover';
}
function show_grandchild(grandparent,grandchild)
{
	clearTimeout(zeit);
	clearTimeout(zeit2);
	//if (last_child != '') { document.getElementById(last_child).style.visibility='hidden'; }
	//if (last_parent != '') { document.getElementById(last_parent).className = 'menu_normal'; }
	
	if (last_grandchild != '') { document.getElementById(last_grandchild).style.visibility='hidden'; }
	if (last_grandparent != '') { document.getElementById(last_grandparent).className = 'menu_normal'; }
	
	last_grandchild = grandchild;
	last_grandparent = grandparent;
	document.getElementById(grandchild).style.visibility='visible';
	document.getElementById(grandparent).className = 'menu_hover';
}

function activate_sub (asub)
{
	document.getElementById(asub).className = 'menu_hover';
	clearTimeout(zeit);
	clearTimeout(zeit2);
	
	if (last_grandchild != '') { document.getElementById(last_grandchild).style.visibility='hidden'; }
	if (last_grandparent != '') { document.getElementById(last_grandparent).className = 'menu_normal'; }
	
	last_grandchild = '';
	last_grandparent = '';
}

function deactivate_sub (asub)
{
	document.getElementById(asub).className = 'menu_normal';
	tmeout();
}

function activate_grandsub (agsub)
{
	document.getElementById(agsub).className = 'menu_hover';
	clearTimeout(zeit);
	clearTimeout(zeit2);
}

function deactivate_grandsub (agsub)
{
	document.getElementById(agsub).className = 'menu_normal';
	tmeout();
}

function activate_main (amain)
{
	document.getElementById(amain).className = 'menu_hover';
	if (last_child != '') { document.getElementById(last_child).style.visibility='hidden'; }
	if (last_parent != '') { document.getElementById(last_parent).className = 'menu_normal'; }
	
	if (last_grandchild != '') { document.getElementById(last_grandchild).style.visibility='hidden'; }
	if (last_grandparent != '') { document.getElementById(last_grandparent).className = 'menu_normal'; }
	
	last_parent = amain;
	last_child = '';
	last_grandchild = '';
	last_grandparent = '';
}

function deactivate_main (amain)
{
	document.getElementById(amain).className = 'menu_normal';
}
