/* get's the x position of the div obj*/
function getX(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;
}

/* get's the y position of the div obj*/
function getY(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 showMenu(menu, parent, fixWidth, alignRight){
	var m = document.getElementById(menu);
	var p = document.getElementById(parent);

	p.style.backgroundColor = "#B9BDC0";
	p.style.color = "#FFFFFF";
	m.style.visibility = "visible";
	
	if(fixWidth){ m.style.width = p.offsetWidth - 2 + "px"; }
	else{ m.style.width = m.offsetWidth - 2 + "px"; }
	
	if(alignRight){
		var fix = 0;
		if(isIE()){
			fix = 10; // Because ie counts the padding as width
		}
		m.style.left = fix + (getX(p) + p.offsetWidth - 2) - (m.offsetWidth - 2) + "px";
	}
}

function hideMenu(menu, parent){
	var m = document.getElementById(menu);
	var p = document.getElementById(parent);

	m.style.visibility = "hidden";
	p.style.color = "";
	p.style.backgroundColor = "";
}

var isIE = function(){
	return (navigator.appName.toLowerCase().indexOf("explorer") >= 0 );
}