function getCookie(name) {
        var prefix = name + "="
        var cookieStartIndex = document.cookie.indexOf(prefix)
        if (cookieStartIndex == -1)
                return null
        var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length)
        if (cookieEndIndex == -1)
                cookieEndIndex = document.cookie.length
        return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex))
}

function CloseBigImage() {
    document.getElementById('bimg').style.top='-1000px';
    document.getElementById('bimg').style.left='0px';
    document.getElementById('bimg').style.display='none';
    document.getElementById('bimgc').innerHTML='';
}

function DS(ex,ey,nid,url,ox,oy,wd) {
    if (document.getElementById('bimg').style.display=='block') return;
    if (url)
    {	
			if (url != '')
			{
		    document.getElementById('bimg').style.top=(ey + oy)+'px';
		    document.getElementById('bimg').style.left=(ex + ox)+'px';
		    document.getElementById('bimg').style.width = wd+'px';
		    document.getElementById('bimg').style.display='block';
				theDate = new Date();
		    jsAjaxUtil.InsertDataToNode(url + '?dummy=' + theDate.getTime().toString(10), 'bimgc',  true);
			}
    } 
    else 
    {
    	document.getElementById('bimg').style.top=(ey + ox)+'px';
    	document.getElementById('bimg').style.left=(ex + ox)+'px';
    	document.getElementById('bimg').style.width = wd+'px';
    	document.getElementById('bimg').style.display='block';
    	document.getElementById('bimgc').innerHTML = '<center><img src="'+nid+'"></center>';
    }
}

function DelayShow(e,nid,url,ox,oy,wd) {
    theSBTimer = setTimeout('DS('+e.clientX+','+(e.clientY+document.body.scrollTop)+',"'+ nid +'","'+url+'",'+ox+','+oy+','+wd+')', 700);
}

function CancelDelayShow() {
    clearTimeout(theSBTimer);
}

function reloadImage()
{
    if (document.getElementById("CamImg"))
    {
        theDate = new Date()
        urlstr = "http://admmegion.ru/images/cam/viewbuf.php"
        urlstr += '?dummy=' + theDate.getTime().toString(10);
        document.getElementById("CamImg").src = urlstr;
    }
    theTimer = setTimeout('reloadImage()', 10000);
}

function ShowTab(Tab, Tabs)
{
if(Tabs)
		{
			for(t in Tabs)	
			{
				var div = Tabs[t];
				var style = document.getElementById(div).style;
				if (style)	style.display = "none";
				var s_link = document.getElementById(div+"_link").parentNode.style;
				var style_link = document.getElementById(div+"_link").style;
				if (style_link)		
				{
					style_link.fontWeight = "";	
					s_link.backgroundColor = "#FFF";
					s_link.border = "0px";
					s_link.borderBottom = "1px solid #aaa";
					s_link.borderRight = "1px solid #ddd";
					s_link.padding = "4px";
					s_link.paddingLeft = "10px";
					s_link.paddingRight = "10px";
					
				}
			}
		}
	if (Tab)
	{
		for(t in Tab)	
		{
		var div = Tab[t];
		var style = document.getElementById(div).style;
		if (style)	style.display = "block";	
		var s_link = document.getElementById(div+"_link").parentNode.style;
		var style_link = document.getElementById(div+"_link").style;
		if (style_link)	{
			style_link.fontWeight = "bold";	
			s_link.backgroundColor = "#DEF";
			s_link.border = "1px solid #aaa";
			s_link.borderBottom = "0px solid #aaa";
			s_link.padding = "4px";
			s_link.paddingLeft = "10px";
			s_link.paddingRight = "10px";
		}
		}
	}
}
	    										  
function ShowKotirovki()
{
	ShowTab(['mz1'],['mz2','mz3','mz4']);
	document.cookie = "MZ=mz1; expires=Fri, 31 Dec 2030 23:59:59 GMT;";
	void(0);
}

function ShowKonkurs()
{
	ShowTab(['mz2'],['mz1','mz3','mz4']);
	document.cookie = "MZ=mz2; expires=Fri, 31 Dec 2030 23:59:59 GMT;";	
	void(0);
}

function ShowAuctions()
{
	ShowTab(['mz3'],['mz1','mz2','mz4']);
	document.cookie = "MZ=mz3; expires=Fri, 31 Dec 2030 23:59:59 GMT;";	
	void(0);
}

function ShowMzAll()
{
	ShowTab(['mz1','mz2','mz3'],['mz4']);
	document.cookie = "MZ=mz4; expires=Fri, 31 Dec 2030 23:59:59 GMT;";	
	void(0);
}



function ShowPgdMegion()
{
	ShowTab(['pgd_megion'],['pgd_visoki']);
	document.cookie = "PGD=megion; expires=Fri, 31 Dec 2030 23:59:59 GMT;";	
	void(0);
}

function ShowPgdVisoki()
{
	ShowTab(['pgd_visoki'],['pgd_megion']);
	document.cookie = "PGD=visoki; expires=Fri, 31 Dec 2030 23:59:59 GMT;";	
	void(0);
}

function SetPgdDef()
{
	var pgd_ck = getCookie('PGD');
	switch (pgd_ck) {
		case "megion":
			ShowPgdMegion();
			break;
		case "visoki":
			ShowPgdVisoki();
			break;
		default:
			ShowPgdMegion();
			break;
		}
		void(0);
}

function SetMzDef()
{
	var mz_ck = getCookie('MZ');
	switch (mz_ck) {
		case "mz1":
			ShowKotirovki();
			break;
		case "mz2":
			ShowKonkurs();
			break;
		case "mz3":
			ShowAuctions();
			break;
		case "mz4":
			ShowMzAll();
			break;
		default:
			ShowKotirovki();
			break;
		}
		void(0);
}