var hide_delay=500;
var z1_typ_menu_load;
if(z1_typ_menu_load==null) z1_typ_menu_load=1000;
var typ_menu_load;
if(typ_menu_load==null) typ_menu_load=1000;

if(typ_menu_load==1)
{
	typ_menu_load=3;
	mstep=400;
}
if(z1_typ_menu_load==1)
{
	z1_typ_menu_load=3;
	z1_mstep=400;
}

var mstatus=true;
var timer1=false; 
var cm=null;
var tstat=0;


function switchDiv2(objElement){
	objElement.style.clip='rect(' + 0 + ' '+ 0 + ' ' + 0 +' '+ 0 +')';
	return 1;
}


function switchDiv(objElement,bolVisible){
	if(!bolVisible){
		objElement.style.display = "none";
	} else {
		objElement.style.display = "";
	}
	return 1;
}

function getPos(el,sProp) {
	var iPos = 0;
	while (el!=null) {
		iPos+=el["offset" + sProp]
		el = el.offsetParent
	}
	return iPos
}


function getelementbyid(myid) {
	objElement = document.getElementById(myid);
	return(objElement);
}

function showmenu(el,m,typ_menu) {

	if(typ_menu==null) typ_menu=1;

	if (m!=null) {
		m=getelementbyid(m);
	}

        if ((el==null) && (cm)) {
        	mstatus=false;
        	movefx(typ_menu);
        } else if ((m!=cm) && (m)) {
        	if (cm!=null) switchDiv(cm,false);
		if(typ_menu==1)
		{
			m.style.filter="alpha(opacity="+opasityinvis+")";
			m.style.opacity = eval(opasityinvis+"/100");
		}
		else
		{
			m.style.filter="alpha(opacity="+z1_opasityinvis+")";
			m.style.opacity = eval(z1_opasityinvis+"/100");
		}

        	switchDiv(m,true); // сделать видимым  слой m
        	fxel=el;             
        	fxm=m;
        	fxrect=0; // текущая высота области отсечения (см. ниже)

        	mstatus=true; // будем открывать меню с помощью movefx
        	movefx(typ_menu);
	} else if(m!=cm){
        	if (cm!=null) switchDiv(cm,false);
		cm=null;
	}
        if (m) cm=m; 

  	if (tstat==1) {
  		clearTimeout(timer1);
  		tstat=0
  	}

}

function hidemenu(b,typ_menu) {
 if (b)  {
 	tstat=1;
 	timer1=setTimeout("showmenu(null,null,"+typ_menu+")",hide_delay);
 } else {
 	tstat=0;
 	showmenu(null);
 }

}

function cancelhide() {
	if (!mstatus) {
		mstatus=1;
	}
	tstat=0;
	clearTimeout(timer1);
}


function movefx(typ_menu) {

	if(  ( (typ_menu_load==2 || typ_menu_load==3) && typ_menu==1) || ( (z1_typ_menu_load==2 || z1_typ_menu_load==3) && typ_menu==2)  )
	{
		if(typ_menu==1)
		{
			if ((mstatus) && (fxrect>fxm.offsetWidth) && (fxrect<fxm.offsetWidth+mstep) ) {
				fxrect=fxm.offsetWidth;
			}
			if ((mstatus) && (fxrect>fxm.offsetWidth)) {
				fxrect=fxm.offsetWidth;
				return 1;
			} 
		}
		else
		{
			if ((mstatus) && (fxrect>fxm.offsetHeight) && (fxrect<fxm.offsetHeight+z1_mstep) ) {
				fxrect=fxm.offsetHeight;
			}
			if ((mstatus) && (fxrect>fxm.offsetHeight)) {
				fxrect=fxm.offsetHeight;
				return 1;
			} 
		}

	}
	else if(typ_menu_load==4 || z1_typ_menu_load==4)
	{
		if(typ_menu==1)
		{
			if ((mstatus) && (fxrect>opasityinvis) && (fxrect<opasityinvis+mstep) ) {
				fxrect=opasityinvis;
			}
			if ((mstatus) && (fxrect>opasityinvis)) {
				fxrect=opasityinvis;
				return 1;
			}
		}
		else
		{
			if ((mstatus) && (fxrect>z1_opasityinvis) && (fxrect<z1_opasityinvis+z1_mstep) ) {
				fxrect=z1_opasityinvis;
			}
			if ((mstatus) && (fxrect>z1_opasityinvis)) {
				fxrect=z1_opasityinvis;
				return 1;
			}
		}
	}


	if ((!mstatus) && (fxrect<0)) {
		fxrect=0;
		switchDiv(fxm,false);
		mstatus=true;
		cm=null;
		return 1;
	}

	if( (typ_menu_load==2 && typ_menu==1) || (z1_typ_menu_load==2 && typ_menu==2) )
	{
		if(typ_menu==1)
		{
			if(right_left_menu==1)
			{
				fxm.style.left = getPos(fxel,"Left")+lm_otstup_menu+fxel.offsetWidth-fxm.offsetWidth+fxrect+"px";
				fxm.style.clip='rect(' + 0 + ' '+ fxm.offsetWidth + ' ' + fxm.offsetHeight +' '+ (fxm.offsetWidth-fxrect) +')';
			}
			else
			{
				fxm.style.left = getPos(fxel,"Left")-lm_otstup_menu-fxrect+"px";
				fxm.style.clip='rect(' + 0 + ' '+ fxrect + ' ' + fxm.offsetHeight +' '+ 0 +')';
			}
			fxm.style.top = getPos(fxel,"Top")+"px";
		}
		else
		{
			var xxx=fxel.offsetWidth/2 - fxm.offsetWidth/2;
			fxm.style.left = getPos(fxel,"Left")+xxx+"px";
			fxm.style.clip='rect(' + (fxm.offsetHeight-fxrect) + ' '+ fxm.offsetWidth + ' ' + fxm.offsetHeight +' '+ 0 +')';
			fxm.style.top = getPos(fxel,"Top")+z1_lm_otstup_menu+fxel.offsetHeight-fxm.offsetHeight+fxrect+"px";
		}
	}
	else if( (typ_menu_load==3 && typ_menu==1) || (z1_typ_menu_load==3 && typ_menu==2) )
	{
		if(typ_menu==1)
		{
			if(right_left_menu==1)
			{
				fxm.style.left = getPos(fxel,"Left")+lm_otstup_menu+fxel.offsetWidth+"px";
				fxm.style.clip='rect(' + 0 + ' '+ fxrect + ' ' + fxm.offsetHeight +' '+ 0 +')';
			}
			else
			{
				fxm.style.left = getPos(fxel,"Left")+lm_otstup_menu-fxm.offsetWidth+"px";
				fxm.style.clip='rect(' + 0 + ' '+ fxm.offsetWidth + ' ' + fxm.offsetHeight +' '+ (fxm.offsetWidth-fxrect) +')';
			}
			fxm.style.top = getPos(fxel,"Top")+"px";
		}
		else
		{
			var xxx=fxel.offsetWidth/2 - fxm.offsetWidth/2;
			fxm.style.left = getPos(fxel,"Left")+xxx+"px";
			fxm.style.clip='rect(' + 0 + ' '+ fxm.offsetWidth + ' ' + fxrect +' '+ 0 +')';
			fxm.style.top = getPos(fxel,"Top")+z1_lm_otstup_menu+fxel.offsetHeight+"px";
		}

	}
	else if( (typ_menu_load==4 && typ_menu==1) || (z1_typ_menu_load==4 && typ_menu==2) )
	{
		if(typ_menu==1)
		{
			if(right_left_menu==1)
			{
				fxm.style.left = getPos(fxel,"Left")+lm_otstup_menu+fxel.offsetWidth+"px";
			}
			else
			{
				fxm.style.left = getPos(fxel,"Left")+lm_otstup_menu-fxm.offsetWidth+"px";
			}

			fxm.style.clip='rect(' + 0 + ' '+ fxm.offsetWidth + ' ' + fxm.offsetHeight +' '+ 0 +')';
			fxm.style.top = getPos(fxel,"Top")+"px";
			fxm.style.filter="alpha(opacity="+(fxrect*2)+")";
			fxm.style.opacity = fxrect/100;
		}
		else
		{
			fxm.style.clip='rect(' + 0 + ' '+ fxm.offsetWidth + ' ' + fxm.offsetHeight +' '+ 0 +')';
			var xxx=fxel.offsetWidth/2 - fxm.offsetWidth/2;
			fxm.style.left = getPos(fxel,"Left")+xxx+"px";
			fxm.style.top = getPos(fxel,"Top")+z1_lm_otstup_menu+fxel.offsetHeight+"px";
			fxm.style.filter="alpha(opacity="+(fxrect*2)+")";
			fxm.style.opacity = fxrect/100;
		}
	}

	if(typ_menu==1)
	{
		if (mstatus) {
			fxrect=fxrect+mstep;
			setTimeout('movefx('+typ_menu+')',1);
		} else {
			fxrect=fxrect-mstep;
			setTimeout('movefx('+typ_menu+')',1);
		}
	}
	else
	{
		if (mstatus) {
			fxrect=fxrect+z1_mstep;
			setTimeout('movefx('+typ_menu+')',1);
		} else {
			fxrect=fxrect-z1_mstep;
			setTimeout('movefx('+typ_menu+')',1);
		}
	}

	return 1;

}

	function z1(id)
	{
		LeftMenuTableShow2(id);
	}

	function z2(id)
	{
		LeftMenuTableHide2(id);
	}

	function z3(id)
	{
		LeftMenuTableShow(id);
	}

	function z4(id)
	{
		LeftMenuTableHide(id);
	}

	function LeftMenuTableShow2(id)
	{
		getobjbyid("x1x2leftmenu"+id).style.color=lm2_pic3_on_color_txt;

		getobjbyid("x3leftmenu"+id).style.background=lm_pic3_2on_color;
		if(typ_menu_load>4)
			getobjbyid("xx3leftmenu"+id).style.background=lm_pic3_2on_color;

		if(lm_pic3_2on)
		getobjbyid("x3leftmenu"+id).style.backgroundImage="url('"+lm_pic3_2on.src+"')";
	}
	
	function LeftMenuTableHide2(id)
	{
		getobjbyid("x1x2leftmenu"+id).style.color=lm2_pic3_off_color_txt;

		getobjbyid("x3leftmenu"+id).style.background=lm_pic3_2off_color;
		if(typ_menu_load>4)
			getobjbyid("xx3leftmenu"+id).style.background=lm_pic3_2off_color;

		if(lm_pic3_2off)
		getobjbyid("x3leftmenu"+id).style.backgroundImage="url('"+lm_pic3_2off.src+"')";
	}


	function LeftMenuTableShow(id)
	{
		getobjbyid("x1leftmenu"+id).style.color=lm_pic3_on_color_txt;

		if(getobjbyid("x2leftmenu"+id)!=null && varlm_pic2_on!="-1")
			getobjbyid("x2leftmenu"+id).src=lm_pic2_on.src;
		getobjbyid("x3leftmenu"+id).style.background=lm_pic3_on_color;
		getobjbyid("x3leftmenu"+id).style.backgroundImage="url('"+lm_pic3_on.src+"')";
		if(getobjbyid("x5leftmenu"+id)!=null && varlm_pic5_on!="-1")
			getobjbyid("x5leftmenu"+id).src=lm_pic5_on.src;
	}

	function LeftMenuTableHide(id)
	{
		getobjbyid("x1leftmenu"+id).style.color=lm_pic3_off_color_txt;

		if(getobjbyid("x2leftmenu"+id)!=null && varlm_pic2_off!="-1")
			getobjbyid("x2leftmenu"+id).src=lm_pic2_off.src;
		getobjbyid("x3leftmenu"+id).style.background=lm_pic3_off_color;
		getobjbyid("x3leftmenu"+id).style.backgroundImage="url('"+lm_pic3_off.src+"')";
		if(getobjbyid("x5leftmenu"+id)!=null && varlm_pic5_off!="-1")
			getobjbyid("x5leftmenu"+id).src=lm_pic5_off.src;
	}




	function z5(id)
	{
		UpMenuTableShow2(id);
	}

	function z6(id)
	{
		UpMenuTableHide2(id);
	}

	function z7(id)
	{
		UpMenuTableShow(id);
	}

	function z8(id)
	{
		UpMenuTableHide(id);
	}


	function UpMenuTableShow2(id)
	{
		getobjbyid("x1x2leftmenu"+id).style.color=z1_lm2_pic3_on_color_txt;

		getobjbyid("x3leftmenu"+id).style.background=z1_lm_pic3_2on_color;

		if(z1_lm_pic3_2on)
		getobjbyid("x3leftmenu"+id).style.backgroundImage="url('"+z1_lm_pic3_2on.src+"')";
	}
	
	function UpMenuTableHide2(id)
	{
		getobjbyid("x1x2leftmenu"+id).style.color=z1_lm2_pic3_off_color_txt;
		getobjbyid("x3leftmenu"+id).style.background=z1_lm_pic3_2off_color;

		if(z1_lm_pic3_2off)
			getobjbyid("x3leftmenu"+id).style.backgroundImage="url('"+z1_lm_pic3_2off.src+"')";
	}


	function UpMenuTableShow(id)
	{
		getobjbyid("x1leftmenu"+id).style.color=z1_lm_pic3_on_color_txt;

		if(getobjbyid("x2leftmenu"+id)!=null && z1_varlm_pic2_on!="-1")
			getobjbyid("x2leftmenu"+id).src=z1_lm_pic2_on.src;
		getobjbyid("x3leftmenu"+id).style.background=z1_lm_pic3_on_color;
		getobjbyid("x3leftmenu"+id).style.backgroundImage="url('"+z1_lm_pic3_on.src+"')";
		if(getobjbyid("x5leftmenu"+id)!=null && z1_varlm_pic5_on!="-1")
			getobjbyid("x5leftmenu"+id).src=z1_lm_pic5_on.src;
	}

	function UpMenuTableHide(id)
	{
		getobjbyid("x1leftmenu"+id).style.color=z1_lm_pic3_off_color_txt;

		if(getobjbyid("x2leftmenu"+id)!=null && z1_varlm_pic2_off!="-1")
			getobjbyid("x2leftmenu"+id).src=z1_lm_pic2_off.src;
		getobjbyid("x3leftmenu"+id).style.background=z1_lm_pic3_off_color;
		getobjbyid("x3leftmenu"+id).style.backgroundImage="url('"+z1_lm_pic3_off.src+"')";
		if(getobjbyid("x5leftmenu"+id)!=null && z1_varlm_pic5_off!="-1")
			getobjbyid("x5leftmenu"+id).src=z1_lm_pic5_off.src;
	}
