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 (update[i]=="no") Hidden("wrongnum", "inline");
				else if (update[i]=="yes")
				{
					document.Form.reset();
					Hidden("sent", "inline");
					Hidden("wrongnum", "none");
				}
				if (document.getElementById(update[i])) document.getElementById(update[i]).innerHTML = update[i+1];
			}
			Hidden("overlay", "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;
		}
	}
}

/*
window.addEvent("domready", function()
{
	$$("img.voidSave").each(function(inElem)
	{
		var vPos = inElem.getPosition();
		var vDim = inElem.getStyles("width", "height");
		var vPar = inElem.getParent();
		var vFix = vPar ? vPar.getProperty("href") : false;
		var vIeW = window.ie && vFix ? 4 : 0;
		var vIeH = window.ie && vFix ? 4 : 0;
		var vDiv = new Element("div", {"styles": {"position": "absolute", "width": vDim.width.toInt() + vIeW, "height": vDim.height.toInt() + vIeH}});
		var vImg = new Element("img", {"src": "http://vsekolesa.kiev.ua/img/ru/t.gif", "styles": {"width": vDim.width.toInt() + vIeW, "height": vDim.height.toInt() + vIeH}});
		if (vFix)
		{
			var vArea = new Element("a", {"href": vFix, "title": vPar.getProperty("title")});
			vImg.inject(vArea);
			vArea.inject(vDiv);
		}
		else
		{
			vImg.inject(vDiv);
		}
		vDiv.inject(vPar, "top"); 
	});
});*/

function InnerHtml(id, str)
{
	if (document.getElementById(id)) document.getElementById(id).innerHTML=str;
}

function numeric (str){return /^[0-9-\+\(\)\s]+z/.test(str+"z");}
