var iDelay=100, iTimer=-1, yPos = 180, nRootID = 0, objElement = 0, d=document;

var ns6 = document.getElementById && !document.all ? true:false;
var ns4 = document.layers ? true:false;
var ie4 = document.all && !document.getElementById ? true:false;
var ie5 = document.all && document.getElementById ? true:false;

function show(div, rp) {
	var dom;
	if (objElement) hide();

	if (ns4) {
		dom = d.layers[div];
		dom.left = d.layers['hotNS'+rp].pageX;
		dom.top = yPos;

		dom.visibility = "show";
		dom.onmouseover = function(){ if (iTimer > -1) { clearTimeout(iTimer); iTimer=-1; } };
		dom.onmouseout = function(){ spawnHide(div); };
	}
	else if (ns6) {
		d.getElementById('mRoot'+rp).style.backgroundImage = "url('images/bg_mainmenu_a.gif')";
		
		dom = d.getElementById(div);
		dom.style.left = d.getElementById('hotIE'+rp).offsetLeft;
		dom.style.top = yPos;
		dom.style.visibility = "visible";
		dom.onmouseover = function(){ if (iTimer > -1) { clearTimeout(iTimer); iTimer=-1; } };
		dom.onmouseout = function(){ spawnHide(div); };
	}
	else if (ie5 || ie4) {
		
		//d.all['mRoot'+rp]=d.all['mRoot'+rp]?d.all['mRoot'+rp]:alert("d.all['mRoot'+"+rp+"] är inget objekt");
		//d.all['mRoot'+rp].style.backgroundImage = d.all['mRoot'+rp].style.backgroundImage ? "url('images/bg_mainmenu_a.gif')":alert("Error!!! d.all['mRoot'"+rp+"].style.backgroundImage är inget objekt...");
		d.all['mRoot'+rp].style.backgroundImage = "url('images/bg_mainmenu_a.gif')";
			
				
		dom = d.all[div];
		dom.style.pixelLeft = d.all['hotIE'+rp].offsetLeft;
		dom.style.pixelTop = yPos;
		dom.style.visibility = "visible";
		dom.onmouseover = function(){ if (iTimer > -1) { clearTimeout(iTimer); iTimer=-1; } };
		dom.onmouseout = function(){ spawnHide(div); };
	}
	
	nRootID = rp;
}

function spawnHide(div) {
	if (ns4) objElement = d.layers[div];
		else if (ns6) objElement = d.getElementById(div);
		else if (ie4 || ie5) objElement = d.all[div];
	
	if (iTimer > -1) clearTimeout(iTimer);
	iTimer = setTimeout("hide()", iDelay);
}

function hide() {
	if (iTimer > -1) {
		clearTimeout(iTimer);
		iTimer = -1;
	}
	
	if (ns6 && nRootID) {
		d.getElementById('mRoot'+nRootID).style.backgroundImage = "";
	}
	else if ((ie4 || ie5) && nRootID) {
		d.all['mRoot'+nRootID].style.backgroundImage = "";
	}
	
	nRootID = 0;

	if (ns4) objElement.visibility = "hidden";
		else if (ns6) objElement.style.visibility = "hidden";
		else if (ie4 || ie5) objElement.style.visibility = "hidden";
}

function swBg(hTD, bState)
{
	var url;
	bState ? url = "url('images/menu_bg_a.gif')" : url = "url('images/menu_bg_n.gif')";
	
	if ( ie4 || ie5 ) {
		document.all[hTD].style.backgroundImage = url;
	}
	else if ( ns6 ) {
		document.getElementById(hTD).style.backgroundImage = url;
	}
}


function clkOnTD(hTD)
{
	if (ns6) {
		document.location = document.getElementById(hTD).getElementsByTagName('A').item(0).href;
	}
	else if (ie4 || ie5) {
		document.location = document.all[hTD].children[0].children[0].href;
	}
}