MENU_loaded=true;

//Variables
MENU_width1=150;
MENU_width2=250;
MENU_width3=250;
MENU_color="transparent";
MENU_color_over="rgb(205,225,205)";
MENU_color_over="white";

MENU_X_bg="url('/image/zalozka.jpg') bottom left no-repeat";
MENU_X_bg="rgb(256,247,158)";
MENU_X_bg_over="url('/image/zalozka_over.jpg') bottom left no-repeat";
MENU_X_bg_over="rgb(256,256,198)";
MENU_X_bg_over="orange";

MENU_border="transparent";
MENU_timeout=1000;
MENU_sens=500;
CURSOR_over='pointer';

//Initialise
MENU_level1=MENU_level2=MENU_level3=null;
MENU_sub1=MENU_sub2=MENU_sub3=null;
MENU_op1=MENU_op2=null;
MENU_name1=MENU_name2=MENU_name3=null;
MENU_timer=MENU_timer_o1=MENU_timer_o2=MENU_link=null;
MENU_DOM = (document.getElementById) ? true : false;
EXT_window=null;
//ep091002 zalozka=null;

function getlayer(layer) {
	if (MENU_DOM) {
		return document.getElementById(layer);
	} else {
		return document.all[layer];
	}
}

function MENU_offset(name,n1,n2,n3) {
	//if (n2==0 || n3==0) return n1+n2+n3-1;
	//else return n2+n3-1;
	if(name=='M')	return n1+n3+3;
	else if(name.length=='1') return n1+n3+20;
	else 	return n1+n3-2;
}

function menu() {
	MENU_level1=getlayer('M');
//ep091002 	if(menu=='E')	zalozka=getlayer('E');
//ep091002 	else zalozka=getlayer('login');
	/*MENU_level1.style.left=document.body.scrollLeft;
	MENU_level1.style.left=14;
	MENU_level1.style.top=document.body.scrollTop;
	MENU_level1.style.top=160;*/
	MENU_level1.style.visibility="visible";
	document.onmousedown = MENU_mousedown;
	document.onmouseup   = MENU_mouseup;
}


function MENU_mousedown() {
	if (MENU_link==null) MENU_hideAll();
	return true;
}

function MENU_mouseup() {
//	alert (MENU_link);
	if (MENU_link!=null) 
	{ 
		MENU_hideAll();
		if(EXT_window==1)
			window.open(MENU_link,"new_win");
		else 
		  self.location.href=MENU_link;
	}
	return true;
}

function MENU_over1(id,name,link,ext) {
	if (MENU_sub1!=null) {
		MENU_sub1.style.backgroundColor = MENU_color;
//ep091002 		zalozka.style.color=MENU_X_bg;
	}
//	id.style.backgroundColor = MENU_color_over;
//ep091002 	if(id.id.substring(0,1)!='M'){ 
//ep091002 			zalozka=getlayer(id.id.substring(0,1));
//ep091002 			zalozka.style.color= MENU_X_bg_over;
//ep091002 		}
//ep091002 	else 
	id.style.backgroundColor = MENU_color_over;
	id.style.cursor=CURSOR_over;
	EXT_window=ext;
	MENU_link=link;
	window.status=link;
	clearTimeout(MENU_timer);
	clearTimeout(MENU_timer_o1);
	MENU_sub1=id;
	MENU_name1=name;
	MENU_timer_o1=setTimeout("MENU_open1(MENU_sub1,MENU_name1)",MENU_sens);
}

function MENU_open1(id,name) {
	MENU_op1=id;
	if (MENU_level2!=null) {
		if (MENU_sub2!=null) MENU_sub2.style.backgroundColor = MENU_color;
		MENU_level2.style.visibility="hidden";
		MENU_level2=MENU_sub2=null;
		if (MENU_level3!=null) {
			if (MENU_sub3!=null) MENU_sub3.style.backgroundColor = MENU_color;
			MENU_level3.style.visibility="hidden";
			MENU_level3=MENU_sub3=null;
		}
	}
	if (name!='') {
		MENU_level2=getlayer(name);
		//if(name.substring(0,1)!='M')		
		MENU_level1=getlayer(name.substring(0,1));
	  MENU_level2.style.top=MENU_offset(name.substring(0,1),MENU_level1.offsetTop,id.offsetParent.offsetTop,id.offsetTop)+"px";
		
		//MENU_level2.style.left=(MENU_width1+2)+"px";
		MENU_level2.style.visibility="visible";
	}
}

function MENU_over2(id,name,link,ext) {
	if (MENU_sub2!=null) MENU_sub2.style.backgroundColor = MENU_color;
	id.style.backgroundColor = MENU_color_over;
	id.style.cursor=CURSOR_over;
	EXT_window=ext;
	MENU_link=link;
	window.status=link;
	clearTimeout(MENU_timer_o1);
	clearTimeout(MENU_timer);
	MENU_sub1.style.backgroundColor = MENU_color;
//	if(name!='' && name.substring(0,1)!='M'){ 
//			zalozka=getlayer(name.substring(0,1));
//			zalozka.style.backgroundColor= MENU_X_color_over;
//		}
//ep091002 		if(MENU_op1.id.substring(0,1)!='M')zalozka.style.color= MENU_X_bg_over;
//	if(MENU_op1.id.substring(0,1)!='M') MENU_op1.style.backgroundColor = MENU_X_color_over;
//ep091002 	else 
	MENU_op1.style.backgroundColor = MENU_color_over;
	//MENU_op1.style.backgroundColor = MENU_color_over;

	MENU_sub1=MENU_op1;
	clearTimeout(MENU_timer_o2);
	MENU_sub2=id;
	MENU_name2=name;
	MENU_timer_o2=setTimeout("MENU_open2(MENU_sub2,MENU_name2)",MENU_sens);
}

function MENU_open2(id,name) {
	MENU_op2=id;
	if (MENU_level3!=null) {
		if (MENU_sub3!=null) MENU_sub3.style.backgroundColor = MENU_color;
		MENU_level3.style.visibility="hidden";
		MENU_level3=MENU_sub3=null;
	}
	if (name!='') {
		MENU_level3=getlayer(name);
		MENU_level3.style.top=MENU_offset('xxx',MENU_level2.offsetTop,id.offsetParent.offsetTop,id.offsetTop)+"px";
//		MENU_level3.style.left=(MENU_width1+MENU_width2+4)+"px";
		MENU_level3.style.visibility="visible";
	}
}

function MENU_over3(id,name,link,ext) {
	if (MENU_sub3!=null) MENU_sub3.style.backgroundColor = MENU_color;
	id.style.backgroundColor = MENU_color_over;
	id.style.cursor=CURSOR_over;
	EXT_window=ext;
	MENU_link=link;
	window.status=link;
	clearTimeout(MENU_timer_o2);
	clearTimeout(MENU_timer);
	MENU_sub2.style.backgroundColor = MENU_color;
	MENU_op2.style.backgroundColor = MENU_color_over;
	MENU_sub2=MENU_op2;
	MENU_sub3=id;
}

function MENU_out() {
	MENU_link=null;
	window.status="";
	MENU_timer=setTimeout("MENU_hideAll()",MENU_timeout);
}

function MENU_hideAll() {
	if (MENU_sub1!=null) MENU_sub1.style.backgroundColor = MENU_color;
	//if (MENU_level1!=null) MENU_level1.style.visibility="hidden";
	if (MENU_sub2!=null) MENU_sub2.style.backgroundColor = MENU_color;
	if (MENU_level2!=null) MENU_level2.style.visibility="hidden";
	if (MENU_sub3!=null) MENU_sub3.style.backgroundColor = MENU_color;
	if (MENU_level3!=null) MENU_level3.style.visibility="hidden";
//ep091002 	zalozka.style.color=MENU_X_bg;
	MENU_level1=MENU_level2=MENU_level3=null;
	MENU_sub1=MENU_sub2=MENU_sub3=null;
	MENU_level1=MENU_level2=MENU_level3=null;
	menu();
	}
menu();

