if (window.navigator.userAgent.indexOf ("MSIE") > 0) ie4=true;
else ie4=false;
var http = createRequestObject();
re = /^\s*$/;
re2 = /^\d+$/;
re3= /([^<)\s]+@\S+\.[^>(\s]+)/;
re4 = /^[\d \-\+\(\)]+$/;
function createRequestObject()
{
    var ro;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer") ro = new ActiveXObject("Microsoft.XMLHTTP");
    else ro = new XMLHttpRequest();
    return ro;
}
function handleResponse()
{
    if(http.readyState == 4)
	{
        var response = http.responseText;
        var update = new Array();
        if(response.indexOf('|' != -1))
		{
            update = response.split('|');
			length_=update.length;
			for (i=0; i<length_; i=i+2)
			{
//				alert(update[i]+"---"+update[i+1]);
				if (document.getElementById(update[i])) document.getElementById(update[i]).innerHTML = update[i+1];
			}
			Hidden("indicator", "none");
        }
    }
}

function goAjax(url)
{
//	alert(url);
    http.open("get", url);
   	http.onreadystatechange = handleResponse;
    http.send(null);
}

function Hidden(id, style)
{
	if (document.getElementById(id))
	{
		if (style == "table-row")
		{
				if (ie4) document.getElementById(id).style.display="inline";
				else document.getElementById(id).style.display=style;
		}
		else
		document.getElementById(id).style.display=style;
	}
}

function getPageSize()
{
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY)
	{
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	}
	else if (document.body.scrollHeight > document.body.offsetHeight) // all but Explorer Mac
	{
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	}
	else // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
	{
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight)// all except Explorer
	{
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight) // Explorer 6 Strict Mode
	{
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	}
	else if (document.body) // other Explorers
	{
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight) pageHeight = windowHeight;
	else pageHeight = yScroll;

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth) pageWidth = windowWidth;
	else pageWidth = xScroll;

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
	return arrayPageSize;
}

function OnFocus(always, object, mode)
{
	if (mode==1)
	{
		if (object.value==always) object.value="";
	}
	else
	{
		if (object.value=="")
		{
			object.value=always;
		}
	}
}

function InnerHtml(id, str)
{
	if (document.getElementById(id)) document.getElementById(id).innerHTML=str;
}

var curtainStep = 15; //шаг - количество пикселей на которое будет сворачивать слой за один раз
var curtainTimeout = 15; //задержка перед последующей итерацией для эффекта плавности

var curtainTop = 0;
var curtainBottom = 0;
var curtainHeight = 750;

function curtainOpen()
{
	if (curtainBottom<curtainHeight)
	{
		curtainBottom += curtainStep;
		curtainTop -= curtainStep;
		if (ie4)StartX=33;
		else	StartX=286
		var rect = "rect("+ curtainTop +"px, auto, "+ curtainBottom +"px, auto)";
		document.getElementById(glob_ID).style.clip = rect;
		if (glob_ID=="search2") 
		{
			tops=StartX+curtainBottom;
			document.getElementById("search1").style.top=tops+"px";
		}
		timeout_id=setTimeout(curtainOpen, curtainTimeout); //вызываем эту же функцию повторно через curtainTimeout миллисекунд
	}
}

function curtainClose()
{
	if (curtainBottom>=0) 
	{
		curtainBottom -= curtainStep;
//		curtainTop += curtainStep;
		
		if (ie4)StartX=25;
		else	StartX=279
		var rect = "rect("+ curtainTop +"px, auto, "+ curtainBottom +"px, auto)";
		document.getElementById(glob_ID).style.clip = rect;
		if (glob_ID=="search2") 
		{
			tops=StartX+curtainBottom;
			if (tops>StartX)
			document.getElementById("search1").style.top=tops+"px";
		}
		timeout_id=setTimeout(curtainClose, curtainTimeout); //вызываем эту же функцию повторно через curtainTimeout миллисекунд
	}
}

function Selects(id, num)
{
	select=document.getElementById(id);
	document.getElementById("sel_div"+num).innerHTML=select.options[select.selectedIndex].text;
}


level1=0;
level2=0;
var pr=0;

function OVER(num, level)
{
	clearTimeout(pr);
	if (level==1)
	{
		level1=num;
		level2=0;
	}
	else 
	if (level==2)
	{
		level2=num;
	}
	
	for (i=0; i<b.length; i++)
	{
		if ((b[i]!=level1) && (b[i]!=level2))
		if (document.getElementById("m"+b[i])) document.getElementById("m"+b[i]).style.visibility="hidden";
	}
	if (document.getElementById("m"+num)) document.getElementById("m"+num).style.visibility="visible";
}

function OUT()
{
	for (i=0; i<b.length; i++)
	document.getElementById("m"+b[i]).style.visibility="hidden";
	clearTimeout(pr);
}
function DELAYS()
{
	pr=setTimeout("OUT()", 1000);
}
