function ChangePic(imgName,imgFile) {
	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+33+'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/map_plus.gif";
			//SignFile="/images/plus_icon.gif";
			 ChangePic(ImgName,ImgFile);
			//ChSign(SignName, SignFile);
		}else{
			elem.style.display="";
			ImgFile="/images/map_minus.gif";
			//SignFile="/images/minus_icon.gif";
			ChangePic(ImgName,ImgFile);
			//ChSign(SignName, SignFile);
		}
}


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('about:blank','','width='+w+',height='+h+',scrollbars=0,resizable=0');
win.document.write(txt);

}

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

function getCookieVal(offset) 
{
	var endstr = document.cookie.indexOf(";", offset);
	if (endstr == -1)
		endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie(name)
{
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen)
	{
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg)
			return getCookieVal (j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0)
			break;
	}
	return null;
}

function SetCookie(name, value)
{
	var argv = SetCookie.arguments;
	var argc = SetCookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	var path = (argc > 3) ? argv[3] : null;
	var domain = (argc > 4) ? argv[4] : null;
	var secure = (argc > 5) ? argv[5] : false;
	document.cookie = name + "=" + escape (value) +
	((expires == null) ? "" : ("; expires=" +
	expires.toGMTString())) +
	((path == null) ? "" : ("; path=" + path)) +
	((domain == null) ? "" : ("; domain=" + domain)) +
	((secure == true) ? "; secure" : "");
}
function choice_month(obj, url)
{
	//document.forms["month"].submit();
	document.location.href = url + obj.options[obj.selectedIndex].value;
}

function OpenPrintVersion() {
	
	var url = ""+document.location;
	var re = /^.+?\/\/[^/]+?\/$/;
	if (url.match(re) != null)
		url+="?forprint=1";
	else
		url+="&forprint=1";
	//document.location.href=url+"&forprint=1";
	window.open(url,"_blank","");

}
function ExpandCollapseMap(status){
	
	
	//alert(MapItems[2]);
	
	for(i=0; i<MapItems.length; i++) if(document.getElementById('tr'+MapItems[i])){
		document.getElementById('tr'+MapItems[i]).style.display=status;
		
		if(status=='none'){
			ChangePic('im'+MapItems[i],'/images/map_plus.gif');
		}else{
			ChangePic('im'+MapItems[i],'/images/map_minus.gif');
		}
			
	}
		
	
	
}
