/*
ribamenüü 14.apr.2008
richard tõnnis
rix@multiscript.net
*/
document.onclick = new Function("closemenu();");
var active = 0;
/*esimene variant*/
function showdiv(id){
	closemenu();
	//naita_tausta(id,1);
	var xid = document.getElementById('x'+id);
	var fid = document.getElementById('f'+id);
	xid.style.display = 'block';
	var pos = fPos(fid);
	var browser=navigator.appName;
	var temp=navigator.appVersion.split("MSIE");
	var vers=parseFloat(temp[1]);

	if (browser=="Microsoft Internet Explorer" && vers != 8){
		xid.style.left = pos[0]+110+'px';
		xid.style.top = pos[1]-1+'px';
	}
	else if (browser=="Opera"){
		xid.style.left = pos[0]+150+'px';
		xid.style.top = pos[1]-13+'px';
	}
	else{
		xid.style.left = pos[0]+150+'px';
		xid.style.top = pos[1]-13+'px';
	}
	active = id;
}
/*teine variant*/
function naita_tausta(cid,mode){
	var taust = 'menpadding top_menupunane_ovr';
	if (mode == 1){
		taust = 'menpadding top_menupunane';
	}
	var li_elem = document.getElementById('f'+cid);
	li_elem.className = taust;
}
function closemenu(){
	if (active != 0){
		var act = document.getElementById('x'+active);
		//naita_tausta(active,0);
		act.style.display = 'none';
	}
}
function fPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	var arr = new Array(2);
	arr[0] = curleft;
	arr[1] = curtop;
	return arr;
}
function showmenuthis(menu){
	menu.style.display = 'block';
	if (active != 0){
		//naita_tausta(active,1);
	}
}
function closemenuthis(menu){
	menu.style.display = 'none';
	if (active != 0){
		//naita_tausta(active,0);
	}
}
function ch_class(element,mode) {
	var cl = 'fl1';
	if (mode == 1){
		var cl = 'fl2';
	}
	element.className = cl;
}
function ch_bg_modul_menu(element,col,textcol) {	
	element.style.backgroundColor=col;
	element.style.color = textcol;
}

