function ChangePic(imgName,imgFile) {
	if(document.images[imgName])
		document.images[imgName].src=imgFile;
	}
	
	
function getForIeX(El) {
	  var X = 0;
	  
	  do { 
		X += El.offsetLeft;
		
		} while ((El = El.offsetParent) != null);
	  return X;
	}
	
function getForIeY(El) {
	  var Y = 0;
	  do { Y += El.offsetTop } while ((El = El.offsetParent) != null);
	  return Y;
	}
var parentMenuY;
var HideTimeOuts=Array();
//var parentEl;
function ShowMenu(div_id, el, frompopup, level){

divid='vmenu'+div_id;
	//window.status=el;
		if (document.getElementById(divid)){
			if(el){
			   
				
				if (frompopup){
					var MenuX=0;
					var MenuY=0;
					//window.status=el;
					if (document.getElementById('vsubmenu'+div_id)){
						MenuX = getForIeX(document.getElementById('vsubmenu'+div_id));
						MenuY = getForIeY(document.getElementById('vsubmenu'+div_id));
					}
				//alert(frompopup);
					//window.status="элемент:"+el+" позиция:"+MenuY;
					//MenuY+=el.offsetHeight-20;
					document.getElementById(divid).style.left = 190+'px';				
					document.getElementById(divid).style.top=MenuY-parentMenuY+'px';
					//ChBgcolorOverTest(parentEl);
					
					parentTdId[parentTdId.length]=div_id;
					
					if (parentTdId.length>0){
						ChBgcolorOverV(parentTdId[0], level);
					}
					
					
				}else{
					var MenuX=0;
					var MenuY=0;
				
					MenuX = getForIeX(el);
					MenuY = getForIeY(el);
				//window.status="элемент:"+el+" позиция:"+MenuY;
				
				    
					//MenuY+=el.offsetHeight-8;
					parentMenuY=MenuY;
					
					document.getElementById(divid).style.left = MenuX+225+'px';				
					document.getElementById(divid).style.top = MenuY+'px';
					
				}
		
				document.getElementById(divid).style.visibility = "visible";
			}
							
		}
	}
	
	function HideMenuH(div_id, level){
		if (!HideTimeOuts[div_id]) HideTimeOuts[div_id]=setTimeout("HideMenuH_act("+div_id+", "+level+")",100);
		
		
	}
	function HideMenuH_act(div_id, level){
		HideTimeOuts[div_id]=false;
	divid='hmenu'+div_id;
	
		if (document.getElementById(divid)){
			document.getElementById(divid).style.visibility="hidden";
			parentTdId = new Array();
			ChBgcolorOut(div_id, level);
			
		}
		
	}
	function HideMenu(div_id, level){
	divid='vmenu'+div_id;
	
		if (document.getElementById(divid)){
			document.getElementById(divid).style.visibility="hidden";
			parentTdId = new Array();
			ChBgcolorOutV(div_id, level);
			
		}
		
	}
	var parentMenuHY;
	var parentMenuHX;
	var parentTdId = new Array();
	
	function ShowMenuH (div_id, el, frompopup, level){
	
		if (HideTimeOuts[div_id])
		{
			clearTimeout(HideTimeOuts[div_id]);
			HideTimeOuts[div_id]=false;
		}
	divid='hmenu'+div_id;
	
		if (document.getElementById(divid) && !frompopup){
			if(el){
			   
				
				if (frompopup){
					MenuX=0;
					MenuY=0;
					if (document.getElementById('hsubmenu'+div_id)){
						MenuX = getForIeX(document.getElementById('hsubmenu'+div_id));
						MenuY = getForIeY(document.getElementById('hsubmenu'+div_id));
					}
					//window.status=el;
					
					windowCenter=WindowWidth()/2;
					//window.status=parentTdId;
				
					if(parentMenuHX<windowCenter+80){
						document.getElementById(divid).style.left = 169+'px';	
					}else{
						document.getElementById(divid).style.left = -169+'px';
					}
					
					
					document.getElementById(divid).style.top=MenuY-parentMenuHY-32+'px';
					
					
					
					parentTdId[parentTdId.length]=div_id;
					
					if (parentTdId.length>0){
						ChBgcolorOver(parentTdId[0],level);
					}
					
				
				}else{
					MenuX=0;
					MenuY=0;
				
					MenuX = getForIeX(el);
					MenuY = getForIeY(el);
					
				//window.status="элемент:"+el+" позиция:"+MenuY;
				
				    
					//MenuY+=el.offsetHeight-8;
					parentMenuHY=MenuY;
					parentMenuHX=MenuX;
					
					
					document.getElementById(divid).style.left = MenuX+'px';				
					document.getElementById(divid).style.top = MenuY+21+'px';
					
				}
		
				document.getElementById(divid).style.visibility = "visible";
				
			}
							
		}
	}
//window.onload=WindowWidth;
//window.onresize=WindowWidth;

function WindowWidth(){
	if (document.all){
		return document.body.offsetWidth + document.body.scrollLeft -4;
	}else{
		return window.pageXOffset + window.innerWidth;
	}

}

function ChBgcolorM(El) {
document.getElementById(El).style.backgroundColor="#FFFFFF";
}
function ChBgcolor(El) {
document.getElementById(El).style.backgroundColor="#F0EEEF";
}






function ChBgcolorOver(id_num, level) {

if(level<3){
	bcolor="#444C58";
	imgFile='/images/p_way_arrow_i.gif';
}else{
    bcolor="#767F8E";
	imgFile='/images/p_way_arrow_ii.gif';
}
imgName='smh'+id_num;
El='hsubmenu'+id_num;
	if(document.getElementById(El)){
		document.getElementById(El).className='texta';
		document.getElementById(El).style.backgroundColor=bcolor;
		document.images[imgName].src=imgFile;
	}
}


function ChBgcolorOut(id_num,level) {

if(level<3){
	bcolor="#F3F5F8";
	imgFile='/images/empty.gif';
}else{
    bcolor="#D9DDE6";
	imgFile='/images/empty.gif';
}

//imgFile='/images/p_way_arrow_b.gif';
imgName='smh'+id_num;
El='hsubmenu'+id_num;
	if(document.getElementById(El)){
		document.getElementById(El).className='text';
		document.getElementById(El).style.backgroundColor=bcolor;
		document.images[imgName].src=imgFile;
	}
}



function ChBgcolorOverV(id_num, level) {

if(level<3){
	bcolor="#444C58";
	
}else{
    bcolor="#767F8E";
	
}
imgFile='/images/p_way_arrow_b.gif';
imgName='smv'+id_num;
El='vsubmenu'+id_num;


	if(document.getElementById(El)){
		document.getElementById(El).className='vtexta';
		document.getElementById(El).style.backgroundColor=bcolor;
		document.images[imgName].src=imgFile;
	}
}

function ChBgcolorOutV(id_num, level) {

if(level<3){
	bcolor="#F3F5F8";
	
}else{
    bcolor="#D9DDE6";
	
}

imgFile='/images/empty.gif';
imgName='smv'+id_num;
El='vsubmenu'+id_num;

	if(document.getElementById(El)){
		document.getElementById(El).className='vtext';
		document.getElementById(El).style.backgroundColor=bcolor;
		document.images[imgName].src=imgFile;
	}
}






function ShowHideMap(trid){
	//alert("iii");
	ImgName="im"+trid;
	//SignName="sign"+trid;
	elem=document.getElementById("tr"+trid);
	state=elem.style.display;
	//alert(state);
		if(!state){
			elem.style.display="none";
			ImgFile="/images/sitemap_folder_plus.gif";
			//SignFile="/images/plus_icon.gif";
			 ChangePic(ImgName,ImgFile);
			 ChangeMapLinkColor(trid,1);
			//ChSign(SignName, SignFile);
		}else{
			elem.style.display="";
			ImgFile="/images/sitemap_folder_minus.gif";
			//SignFile="/images/minus_icon.gif";
			ChangePic(ImgName,ImgFile);
			ChangeMapLinkColor(trid,0);
			//ChSign(SignName, SignFile);
		}
}


function ShowEl(El,CLink){
obj=document.getElementById(El);
	x=getForIeX(document.getElementById(CLink));
	y=getForIeY(document.getElementById(CLink));
//window.status=x+":"+y;
obj.style.left=x;
obj.style.top=y;
if (obj)
	obj.style.display='';
}
function HideEl(El){
obj=document.getElementById(El);
if (obj)
	obj.style.display='none';
}

function ShowHideCatalogMenu(trid){
	//alert("iii");
	ImgName="cim"+trid;
	//SignName="sign"+trid;
	elem=document.getElementById("ctr"+trid);
	state=elem.style.display;
	//alert(state);
		if(!state){
			elem.style.display="none";
			ImgFile="/images/plus.gif";
			//SignFile="/images/plus_icon.gif";
			 ChangePic(ImgName,ImgFile);
			 //ChangeMapLinkColor(trid,1);
			//ChSign(SignName, SignFile);
		}else{
			elem.style.display="";
			ImgFile="/images/minus.gif";
			//SignFile="/images/minus_icon.gif";
			ChangePic(ImgName,ImgFile);
			//ChangeMapLinkColor(trid,0);
			//ChSign(SignName, SignFile);
		}
}


function ChangeMapLinkColor(linkid, stat){
	elem=document.getElementById("link"+linkid);
	
	if(stat)
		elem.className="mapsection";
	else
		elem.className="mapsectionactive";
}
	
function OpenBigPic(w,h,pic,tit){
txt="<html><head><title>"+tit+"</title></head><body leftmargin='0' topmargin='0' rightmargin='0' bottommargin='0' marginwidth='0' marginheight='0'><img src='"+pic+"' alt='' border='0'></body></html>";
win=window.open('','win','width='+w+',height='+h+',scrollbars=0,resizable=0');
win.document.write(txt);
win.document.close(txt);
}
function OpenBigPatent(w,h,pic,tit,descr){
txt="<html><head><title>"+tit+"</title><link rel=stylesheet type='text/css' href='/style.css' title='style'></head><body leftmargin='30' topmargin='30' rightmargin='30' bottommargin='30' marginwidth='30' marginheight='30' bgcolor='#ffffff'><table cellpadding='0' cellspacing='0' border='0'><tr><td class='greyfontbig'>"+tit+"</td><td align='right'><a href='javascript:window.close();'><img src='/images/win_close.gif' border='0' width='20' height='20'  alt='закрыть окно'></a></td></tr><tr><td colspan='2'><img src='"+pic+"' alt='' border='0' width='"+w+"' height='"+h+"' vspace='10'></td></tr><tr><td colspan='2'>"+descr+"</td></tr></table></body></html>";
w=w+80;
h=h+60;
win=window.open('','win','width='+w+',height='+h+',scrollbars=1,resizable=0');
win.document.write(txt);
win.document.close(txt);
}

function submit(form)
{
	document.forms[form].submit();
}

function choice_month(obj, url)
{
	//document.forms["month"].submit();
	document.location.href = url + obj.options[obj.selectedIndex].value;
}

function InsertMessage(){
		var messObj = document.getElementById('messdiv');
		
		if (messObj){
			var max_random = messages.length-1;
			
			var message=messages[GetRandom(0, max_random)];
			//alert(messObj);
			messObj.innerHTML = message;
			InitialPositioning(messObj);
			ChangeOpacity(0,100,1);
		}
	}
	function GetRandom(min_random, max_random) { 

		max_random++;

		var range = max_random - min_random;
		var n=Math.floor(Math.random()*range) + min_random;

		return n;
	}
	var timerId;
	
	function ChangeOpacity(currentOpacity, finishlevel, step){
			//alert("!!!!");
			document.getElementById('messdiv').filters.alpha.opacity=currentOpacity;
			currentOpacity=currentOpacity+step;
			if (currentOpacity<finishlevel)
				timerID=setTimeout("ChangeOpacity("+currentOpacity+", "+finishlevel+", "+step+")",20);
			else clearTimeout(timerID);
	}
	function InitialPositioning(messObj){
		messObj.style.top=getForIeX(messObj)+65;
		messObj.style.left=getForIeY(messObj)-35;
	}
