function go(t){
	t.className = 'menu_sel';
}

function stop(t){
	t.className = 'menu';
}

var div = null;
var divStyle = null;
var hideTimerID = null;
var overpopupmenu = false;

function getAbsolutePos(el) {
	var r = { x: el.offsetLeft, y: el.offsetTop };
	if (el.offsetParent) {
		var tmp = getAbsolutePos(el.offsetParent);
		r.x += tmp.x;
		r.y += tmp.y;
	}
	return r;
};


function flags_init() {
	div = document.getElementById('langs_div');
	if(div) {
		divStyle = div.style;
		iconPos = getAbsolutePos(document.getElementById('langs_icon'));
		divStyle.left = iconPos.x + 'px';
		divStyle.top = iconPos.y + 25 + 'px';
	}	
}  

function startTimer() {
	if (hideTimerID != null) {
		clearTimeout(hideTimerID);
		hideTimerID = null;
	}  
	hideTimerID = setTimeout("hidemenu()", 5000);
}

function setOver(val) {
	overpopupmenu = val;
	if(!overpopupmenu) startTimer();
}

function showmenu()
{
	divStyle.display = "";
	startTimer();
	return true;
}

function hidemenu() {
	if (!overpopupmenu) {
		divStyle.display = "none";
		return true;
	}
	return false;
}

var tmp = window.onload;
window.onload = function () {
	if (tmp) tmp();
	flags_init();
}

if(div) document.onmousedown = hidemenu;