
function GetXmlHttpObject()
        {
        var xmlHttp=null;
        try
        {
        // Firefox, Opera 8.0+, Safari
        xmlHttp=new XMLHttpRequest();
        }
        catch (e)
                {
                // Internet Explorer
                try
                {
                xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
                }
                        catch (e)
                        {
                        try
                                {
                                xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
                                }
                                catch (e)
                                {
                                alert("Your browser does not support AJAX!");
                                return false;
                                }
                        }
                }
        return xmlHttp;
        }

var xmlhttp;

function checkEmail()
{
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	}
	var url="../ajax/checkemail.php";
	url=url+"?q="+document.getElementById("email").value;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=checkEmailChanged;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
	document.getElementById("email").value='';

}


function checkEmailChanged()
{
	if (xmlhttp.readyState==4){
		document.getElementById("corect").innerHTML='';
		document.getElementById("incorect").innerHTML=xmlhttp.responseText;
		
	}
	
}


function serchCity(str)
{
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	}
	var url="../ajax/showcity.php";
	url=url+"?q="+str;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=showCity;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);


}

function showCity()
{
	if (xmlhttp.readyState==4){
		document.getElementById("showcity").innerHTML=xmlhttp.responseText;
		
	}
	
}

function checkNull(str)
{
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	}
	var url="../ajax/checknull.php";
	url=url+"?q="+str;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=checkNullChanged;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);


}

function checkNullChanged()
{
	if (xmlhttp.readyState==4){
		document.getElementById("corectname").innerHTML='';
		document.getElementById("incorectname").innerHTML=xmlhttp.responseText;
		
	}
	
}

function mail (str) { return /^[a-z0-9_\.]+@[a-z0-9_\.]+.[a-z]{2,3}$/.test(str); }

function numeric (str) { return /^[0-9-\+\(\)\s]+z/.test(str + "z"); }

function checkPhone()
{
	
	elem1 = document.getElementById("phone_1").value;
	elem = document.getElementById("phone").value;
	
	if (!numeric(elem1)) {
		document.getElementById("corectphone").innerHTML='<input id="phone_1" maxlength="3" style="width:35px"  class="podpiska_inpyt_incorect" type=" text" name="phone_1" onchange="checkPhone()" value="'+elem1+'"/> <input maxlength="7" value="'+elem+'"id="phone" class="podpiska_inpyt" type=" text" name="phone" onchange="checkPhone()" />';
	}
	else if (!numeric(elem)) {
		document.getElementById("corectphone").innerHTML='<input id="phone_1" maxlength="3" style="width:35px"  class="podpiska_inpyt" type=" text" name="phone_1" onchange="checkPhone()" value="'+elem1+'"/> <input maxlength="7" value="'+elem+'"id="phone" class="podpiska_inpyt_incorect" type=" text" name="phone" onchange="checkPhone()" />';
	}
	else {
		document.getElementById("corectphone").innerHTML='<input id="phone_1" value="'+elem1+'" maxlength="3" style="width:35px"  class="podpiska_inpyt" type=" text" name="phone_1" onchange="checkPhone()" /> <input maxlength="7" value="'+elem+'"id="phone" class="podpiska_inpyt" type=" text" name="phone" onchange="checkPhone()" />';
	}

}

function submitAllMYFORM() {
	email=document.getElementById("email").value;
	
	name = document.getElementById("name").value;

	
	if (mail(email) && name!='') {
		document.getElementById("form22").submit();
	}
	else {
		document.getElementById("eror").innerHTML='Правильно заполните форму';
	}
}

function submitAllMYFORM1() {
	
	phone=document.getElementById("phone").value;
	phone_1=document.getElementById("phone_1").value;
	name = document.getElementById("name").value;
	

	if (numeric(phone) && numeric(phone_1) && name!='') {
		document.getElementById("form22").submit();
	}else {
		document.getElementById("eror").innerHTML='Правильно заполните форму';
	}
}

function submitAllMYFORM3() {
	
	phone=document.getElementById("phone").value;
	phone_1=document.getElementById("phone_1").value;
	name = document.getElementById("name").value;
	email=document.getElementById("email").value;

	if (mail(email) && numeric(phone) && numeric(phone_1) && name!='') {
		document.getElementById("form22").submit();
	}else {
		document.getElementById("eror").innerHTML='Правильно заполните форму';
	}
}



function searchSan(str)
{
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	}
	var url="/ajax/searchsan.php";
	url=url+"?q="+str;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=searchSanChanged;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
	

}

function searchSan1(str,order,this_value)
{
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	}
	var url="/ajax/searchsan.php";
	url=url+"?q="+str+"&order="+order+"&this_value="+this_value;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=searchSanChanged;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
	

}


function searchSanChanged()
{
	if (xmlhttp.readyState==4){
		
		document.getElementById("showsan").innerHTML=xmlhttp.responseText;
		
	}else {
		document.getElementById("showsan").innerHTML='<img src="http://meditation.in.ua/images/loader.gif"/> Loading ...'
	}
	
}
