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 Restore()
	{
		document.send_form.send_name.style.background="url('/img/gr2.gif') 100% 0 no-repeat transparent";	
		document.send_form.send_name.style.color="#000000";	
		document.send_form.send_content.style.background="url('/img/gr2.gif') 100% 0 no-repeat transparent";	
		document.send_form.send_content.style.color="#000000";	
		document.send_form.send_email.style.background="url('/img/gr2.gif') 100% 0 no-repeat transparent";	
		document.send_form.send_email.style.color="#000000";	
	}

function Subm()
{
	sm=true;
	if (!checkEmpty(document.send_form.send_name.value)) 
		{
	document.send_form.send_name.style.background="#AE0F0D";
	document.send_form.send_name.style.color="#FFFFFF";
	sm=false;	
		}
	if (document.send_form.send_name.value=='Ваше имя') 
		{
	document.send_form.send_name.style.background="#AE0F0D";
	document.send_form.send_name.style.color="#FFFFFF";
	sm=false;	
		}
	if (document.send_form.send_content.value=='Ваше сообщение') 
		{
	document.send_form.send_content.style.background="#AE0F0D";
	document.send_form.send_content.style.color="#FFFFFF";
	sm=false;	
		}
	if (!isValidEmail(document.send_form.send_email.value)) 
		{
	document.send_form.send_email.style.background="#AE0F0D";
	document.send_form.send_email.style.color="#FFFFFF";
	
	sm=false;	
		}
	if (!checkEmpty(document.send_form.send_content.value)) 
		{
	document.send_form.send_content.style.background="#AE0F0D";
		document.send_form.send_content.style.color="#FFFFFF";

	sm=false;	
		}
	if (sm==true) {document.send_form.submit();}		
}
function RestoreX()
	{
		document.send_form.send_name.style.background="url('/img/gr2.gif') 100% 0 no-repeat transparent";	
		document.send_form.send_name.style.color="#000000";	
		document.send_form.send_city.style.background="url('/img/gr2.gif') 100% 0 no-repeat transparent";	
		document.send_form.send_city.style.color="#000000";	
		document.send_form.send_email.style.background="url('/img/gr2.gif') 100% 0 no-repeat transparent";	
		document.send_form.send_email.style.color="#000000";	
		document.send_form.send_phone.style.background="url('/img/gr2.gif') 100% 0 no-repeat transparent";	
		document.send_form.send_phone.style.color="#000000";	
		document.send_form.send_org.style.background="url('/img/gr2.gif') 100% 0 no-repeat transparent";	
		document.send_form.send_org.style.color="#000000";	
	}

function SubmX()
{
	sm=true;
	if (!checkEmpty(document.send_form.send_name.value) || document.send_form.send_name.value=='Ваше имя') 
		{
	document.send_form.send_name.style.background="#AE0F0D";
	document.send_form.send_name.style.color="#FFFFFF";
	sm=false;	
		}
	if (!isValidEmail(document.send_form.send_email.value)) 
		{
	document.send_form.send_email.style.background="#AE0F0D";
	document.send_form.send_email.style.color="#FFFFFF";
	
	sm=false;	
		}
	if (!checkEmpty(document.send_form.send_phone.value) || document.send_form.send_phone.value=='Телефон') 
		{
	document.send_form.send_phone.style.background="#AE0F0D";
		document.send_form.send_phone.style.color="#FFFFFF";

	sm=false;	
		}
	if (!checkEmpty(document.send_form.send_city.value) || document.send_form.send_city.value=='Город') 
		{
	document.send_form.send_city.style.background="#AE0F0D";
		document.send_form.send_city.style.color="#FFFFFF";

	sm=false;	
		}
	if (!checkEmpty(document.send_form.send_org.value) || document.send_form.send_org.value=='Организация') 
		{
	document.send_form.send_org.style.background="#AE0F0D";
		document.send_form.send_org.style.color="#FFFFFF";

	sm=false;	
		}
	if (sm==true) {document.send_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 sendRequestDesc(file)
{
    httpReqDesc.open('get',file);
    httpReqDesc.onreadystatechange = InsertDescription;
    httpReqDesc.send(null);
}

function LoadAll(id)
{
	httpReqDesc=createHttpRequest();
    file = '/desc_ajax.php?p_id='+id;
    sendRequestDesc(file);		
}

function InsertDescription()
{
	if (httpReqDesc.readyState==4)
    {
		txt = httpReqDesc.responseText;
		x = txt.indexOf('+<');
		txt1 = txt.substring(0,x);
		txt2 = txt.substring(x+2);

		document.getElementById('db').innerHTML = txt1;
		document.getElementById('pt').innerHTML = txt2;		

	} else
		{
			setTimeout('InsertDescription()',200);
		}
}

