// JavaScript Document// JavaScript Document

// JavaScript Document

//Gets the browser specific XmlHttpRequest Object 

function getXmlHttpRequestObject3() {

 if (window.XMLHttpRequest) {

    return new XMLHttpRequest(); //Mozilla, Safari ...

 } else if (window.ActiveXObject) {

    return new ActiveXObject("Microsoft.XMLHTTP"); //IE

 } else {

    //Display our error message

    alert("Your browser doesn't support the XmlHttpRequest object.");

 }

}



//Our XmlHttpRequest object

var receiveReq3 = getXmlHttpRequestObject3();



//Initiate the AJAX request

function makeRequest3(url, param) {



//If our readystate is either not started or finished, initiate a new request

 if (receiveReq3.readyState == 4 || receiveReq3.readyState == 0) {

   //Set up the connection to captcha_test.html. True sets the request to asyncronous(default) 

   receiveReq3.open("POST", url, true);



   //Set the function that will be called when the XmlHttpRequest objects state changes

  

   receiveReq3.onreadystatechange = updatePage3; 



   //Add HTTP headers to the request

   receiveReq3.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

   receiveReq3.setRequestHeader("Content-length", param.length);

   receiveReq3.setRequestHeader("Connection", "close");



   //Make the request

   receiveReq3.send(param);

 }   

}



//Called every time our XmlHttpRequest objects state changes

function updatePage3() {

	

 //Check if our response is ready

 if (receiveReq3.readyState == 4) {



   //Set the content of the DIV element with the response text

   document.getElementById('resulttex').innerHTML = receiveReq3.responseText;
	document.getElementById('noshow').style.visibility="hidden";
	//Get a reference to CAPTCHA image

   	img = document.getElementById('imgCaptcha'); 

   	img.src = 'Inc/generate_image.php';

	

   

 }

}





//Called every time when form is perfomed

function getParam3(theForm) {

 //Set the URL



 var url = 'comments/texcomment.php';

 //Set up the parameters of our AJAX call

 var postStr;

 postStr  = theForm.scode.name + "=" + encodeURIComponent( theForm.scode.value );

 var uname = theForm.name.value;

 if(uname=="")
	{
		 alert('یرجي التأکد من حقل الاسم');
      	 return false;
	}
 postStr +="," + theForm.name.name + "=" + encodeURIComponent( theForm.name.value );
 
 var email = theForm.email.value;

	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;

	if(email=="")
	{
		 alert('یرجي التأکد من حقل البرید الالکتروني');
      	 return false;
	}

    if(reg.test(email) == false) {

      alert('البرید المدخل غیر صحیح');
      return false;



   }

    

 postStr +="," + theForm.email.name + "=" + encodeURIComponent( theForm.email.value );

 postStr +="," + theForm.comment.name + "=" + encodeURIComponent( theForm.comment.value );

 postStr +="," + theForm.tid.name + "=" + encodeURIComponent( theForm.tid.value );

 //Call the function that initiate the AJAX request



 makeRequest3(url, postStr);

}



//Called every time when form is perfomed


