xmlHttp = new createXMLHttpRequest();
host="http://"+document.domain+"/";

function menushka()
{
	alert(document.domain);
//if (document.domain=="")
}

function createXMLHttpRequest()
{
	var xmlHttp;
	try
	{
		xmlHttp = new XMLHttpRequest();
	}
	catch (e)
	{
		try
		{
			var XmlHttpVersions  = new Array ('MSXML2.XMLHTTP.6.0',
											'MSXML2.XMLHTTP.5.0',
											'MSXML2.XMLHTTP.4.0',
											'MSXML2.XMLHTTP.3.0',
											'MSXML2.XMLHTTP'
											,'Microsoft.XMLHTTP');
			for (var i=0;i<XmlHttpVersions.length && !xmlHttp;i++)
			{
				try 
				{
					xmlHttp = new ActiveXObject(XmlHttpVersions[i]);
				}
				catch(e) 
				{}
			
			}
			//xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			//xmlHttp = new ActiveXObject("Microsoft.XMLHttp");
		}
		catch (e)
		{
		}
		
	}
	if (!xmlHttp)
	{
		alert ("Error: XMLHttpRequest is not creat.");
		return false;
	}
	else return xmlHttp;
}

function send_post(script,str,func_response)
{
	if (xmlHttp.readyState == 4 || xmlHttp.readyState ==0)
	{
		xmlHttp.open('POST',script,true);
		xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8');
		xmlHttp.onreadystatechange = func_response;
		xmlHttp.send(str);

	}
	else
		setTimeout('send_post(script,str,func_response)',500);
}

function mess(ad,ser)
{ 
	location='mailto:'+ad+'@'+ser;
	return true;
}

function mailvalid(mail) 
{
	if(mail.match(/^[A-Za-z0-9\.\_]{1,32}\@[A-Za-z0-9\.\_]{1,32}\.[a-zA-Z]{2,6}$/))
		return true;
	else
		return false;
}

function check_empty()
{

	var name=document.getElementById("name").value;
	var adress=document.getElementById("adress").value;
	var phone=document.getElementById("phone").value;
	var email=document.getElementById("email").value;
	var text1=document.getElementById("text1").value;
	var error_message='';
	var error_message1='';
	if (name=='First name, Last name' || name=='')
		error_message+=' Name';
	
	if (email=='')
	{
		if(error_message!='')
			error_message+=', ';
		error_message+=' E-mail';
	}
	else
	{
		if (!mailvalid(email))
			error_message1=' Your E-mail not correct';
	}

	if (text1=='' || text1==' ')
	{
		if(error_message!='')
			error_message+=',';
		error_message+=' Message';
	}
	if(error_message!='')
		error_message='<center><strong><span style="color:#ff0000;font-color:#ff0000;">You have not filled fields '+error_message+'.'+error_message1+'</span></strong></center>';
	if(error_message1!='')
		error_message=error_message1;
	if(error_message!='' )	
		document.getElementById("error").innerHTML=error_message;
	else
	{
		str='name='+name+'&email='+email+'&adress='+adress+'&phone='+phone+'&text1='+text1;
		send_post(host+'send.php',str,resp);
	}	
}

function resp()
{
	if (xmlHttp.readyState ==4)
	{
		if (xmlHttp.status==200)
		{
			xmlResponse = ' '+xmlHttp.responseText;
			str = '<center><strong><span style="color:#0000ff;font-color:#0000ff;">'+xmlResponse+'</span></strong></center>';
		document.getElementById("error").innerHTML=str;
name=document.getElementById("name").value='';
adress=document.getElementById("adress").value='';
 phone=document.getElementById("phone").value='';
email=document.getElementById("email").value='';
text1=document.getElementById("text1").value='';
		}
		else
		{
			alert ("There is a problem with connection to the server.");
		}
	}
}

function hv(tn, text_)
{
    if (keyword_value==text_)
        tn.value='';
}
