function isValidEmail(email)
{
	re = /^([a-z0-9_\-]+\.)*[a-z0-9_\-]+@([a-z0-9][a-z0-9\-]*[a-z0-9]\.)+[a-z]{2,4}$/i;
	return re.test(email);
}
        

function checkEmpty (val){
	if (val=="" || val.search(/[^\s]+/)==-1) {
		return false;
	}
	return true;
}

function RestoreForm()
	{
		document.form_form.form_name.style.border="1px solid #968E69";
		document.form_form.form_content.style.border="1px solid #968E69";
		document.form_form.form_email.style.border="1px solid #968E69";
	}

function SubmForm()
{
	sm=true;
	if (!checkEmpty(document.form_form.form_name.value)) 
		{
	document.form_form.form_name.style.border="2px solid #ED8F2A";
	sm=false;	
		}
	if (document.form_form.form_name.value=='Ваше имя') 
		{
	document.form_form.form_name.style.border="2px solid #ED8F2A";
	sm=false;	
		}
	if (document.form_form.form_content.value=='Ваше сообщение') 
		{
	document.form_form.form_content.style.border="2px solid #ED8F2A";
	sm=false;	
		}
	if (!isValidEmail(document.form_form.form_email.value)) 
		{
	document.form_form.form_email.style.border="2px solid #ED8F2A";
	
	sm=false;	
		}
	if (!checkEmpty(document.form_form.form_content.value)) 
		{
	document.form_form.form_content.style.border="2px solid #ED8F2A";

	sm=false;	
		}
	if (sm==true) {document.form_form.submit();}		
}

function RestoreFormX()
	{
		document.form_form.form_name.style.border="1px solid #968E69";
		document.form_form.form_city.style.border="1px solid #968E69";
		document.form_form.form_email.style.border="1px solid #968E69";
		document.form_form.form_org.style.border="1px solid #968E69";
		document.form_form.form_phone.style.border="1px solid #968E69";
	}

function SubmFormX()
{
	sm=true;
	if (!checkEmpty(document.form_form.form_name.value)) 
		{
	document.form_form.form_name.style.border="1px solid #ED8F2A";
	sm=false;	
		}
	if (!isValidEmail(document.form_form.form_email.value)) 
		{
	document.form_form.form_email.style.border="1px solid #ED8F2A";	
	sm=false;	
		}
	if (!checkEmpty(document.form_form.form_city.value)) 
		{
			document.form_form.form_city.style.border="1px solid #ED8F2A";
			sm=false;	
		}
	if (!checkEmpty(document.form_form.form_org.value)) 
		{
			document.form_form.form_org.style.border="1px solid #ED8F2A";
			sm=false;	
		}
	if (!checkEmpty(document.form_form.form_phone.value)) 
		{
			document.form_form.form_phone.style.border="1px solid #ED8F2A";
			sm=false;	
		}
	if (sm==true) {document.form_form.submit();}		
}


var httpReq;

function createHttpRequest() {

var httpRequest;
var browser = navigator.appName;

if (browser == "Microsoft Internet Explorer") {
httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
} else {
httpRequest = new XMLHttpRequest();
}

return httpRequest;
} 

function sendRequestZZZ(file)
{
    httpReqZZZ.open('get',file);
    httpReqZZZ.onreadystatechange = InsertDescription;
    httpReqZZZ.send(null);
}

function LoadZZZ(id)
{
	httpReqZZZ=createHttpRequest();
    file = '/desc_ajax.php?p_id='+id;
    sendRequestZZZ(file);		
}

function InsertDescription()
{
	if (httpReqZZZ.readyState==4)
    {
		txt = httpReqZZZ.responseText;
		x = txt.indexOf('+<');
		txt1 = txt.substring(0,x);
		txt2 = txt.substring(x+2);

		document.getElementById('zzz2').innerHTML = txt1;
		document.getElementById('zzz1').innerHTML = txt2;		

	} else
		{
			setTimeout('InsertDescription()',200);
		}
}

