// JavaScript Document

function validate_test(){
  valid=true;
  var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

var name=document.testform.name;


var telephone=document.testform.telephone;


var email=document.testform.email;


	if ( name.value == "" ){alert ( "Моля попълнете полето \"Име\"!" ); name.focus(); valid = false;}
	else if ( telephone.value == "" ){alert ( "Моля попълнете полето \"Телефон\"!"); telephone.focus(); valid = false;}
	else if ( email.value == "" ){alert ( "Моля попълнете полето \"Е-мейл\"!" ); email.focus(); valid = false;}
	else if ( !filter.test(email.value)) {alert( "Моля въведете валиден E-мейл!"); email.focus(); valid = false;}

return valid;
}
function test(ans)
{ 
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }

var url="js/test.php";
var params="ans="+ans+"&sid="+Math.random();
xmlHttp.open("POST",url, true); //get for get and url+"?"+params
xmlHttp.onreadystatechange=state_ans;

//Send the proper header information along with the request (whitout these for get)
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-length", params.length);
xmlHttp.setRequestHeader("Connection", "close");

//xmlHttp.setRequestHeader("Content-Type", "charset=utf-8");

xmlHttp.send(params); //null for get
}

function state_ans()
{ 
//document.getElementById('writing').innerHTML = '<img src="include/im/writing.gif" /> Операторът пише...';
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 {
 document.getElementById("test").innerHTML=xmlHttp.responseText;
 } 
}
