// JavaScript Document
// in this function we are getting the all form elements and values
function buildPOST(textForm) { 
  
   theForm = textForm; 
    var qs = '';
	
    for(e=0;e<theForm.elements.length;e++){ 
	    if (theForm.elements[e].name!='') { 
			var name = theForm.elements[e].name; 
			qs+=(qs=='')?'':'&' 
            qs+= name+'='+escape(theForm.elements[e].value); 
        } 
    } 
    //qs+="\n"; 
    return qs ;
}
// 
function frmclear(textForm) { 
  
   theForm = textForm; 
    var qs = '';
	
    for(e=0;e<theForm.elements.length;e++){ 
	    theForm.elements[e].value=""; 
        } 
      
    //qs+="\n"; 
    return qs ;
}
// Ajax Object creation
function httpObj()
  {
  		return (window.ActiveXObject)?new ActiveXObject("Microsoft.XMLHTTP"): new XMLHttpRequest();
  }
function sendMail(frm)
{
	var xmlqs =buildPOST(frm);
	var xmlHttp = httpObj();
	url  ="sendmail.php";
	xmlHttp.open('POST', url, true); 	 
	xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 
	xmlHttp.send(xmlqs); 
	xmlHttp.onreadystatechange = function()
	{ 
	   if (xmlHttp.readyState == 4) 
	   {
			var rescont=new String(xmlHttp.responseText);
			document.getElementById("thanksid").innerHTML = rescont;
			if(rescont == "Message sent successfully")
				frmclear(frm);
	   }
	}
}

function new_captcha()
{
	var c_currentTime = new Date();
	var c_miliseconds = c_currentTime.getTime();
	document.getElementById('captcha').src = 'captcha/image.php?x='+ c_miliseconds;
}

