var url2 = "/php/mailto.php"; // The server-side script
function handleHttpResponse2() {
  if (http2.readyState == 4) {
    results = http2.responseText;
	if(results=="success")
	{
	//document.register.reset();
	document.getElementById('reponse_text2').innerHTML = "<p class='success'>Your Details have been submitted.</p>";
	}
	else
		{
		
		document.getElementById('reponse_text2').innerHTML = "<p class='failed'>The Form Not able to Successfully Send due to server Problem, Please Try Later</p>";
		}
  }
}
var http2; // We create the HTTP Object

function SendEmailData2(email_form2) {
	http2 = getHTTPObject2();
	var form_var2="fo=1" ;
	for(i=0;i<email_form2.elements.length; i++)
	{
		//code by anirban
		String.prototype.replaceAll=function(s5, s6) {return this.split(s5).join(s6)}
		if (email_form2.elements[i].type == 'radio' || email_form2.elements[i].type == 'checkbox') {
			if (email_form2.elements[i].checked == false) {
				continue;
			}
		}
		var str_value2 = email_form2.elements[i].value;
		str_value12 = str_value2.toString();
		//str_value1 = str_value1.replace(" ","_");
		//str_value1 = str_value.replaceAll(" ","_");
		email_form2.elements[i].value = str_value2;
		//code by anirban
		form_var2 = form_var2 + "&" + email_form2.elements[i].name + "=" + email_form2.elements[i].value ;
	}
	http2.onreadystatechange = handleHttpResponse2;
	http2.open("POST", url2, true);
	http2.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	http2.send(form_var2);
	document.getElementById('reponse_text2').style.display='';
	document.getElementById('reponse_text2').innerHTML="<p class='sending'>Sending The Data.. Wait Please!</p>" ;
 }
function getHTTPObject2() {
  var xmlhttp;
  /*@cc_on
  @if (@_jscript_version >= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlhttp = false;
      }
    }
  @else
  xmlhttp = false;
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
    } catch (e) {
      xmlhttp = false;
    }
  }
  return xmlhttp;
}



function checkform2(contact2)
{
	/*alert ('Hi');	 
	//NAME VALIDATION
	if(contact2.name.value=="")
	{
		contact2.name.className = 'errorbox';
		contact2.name.focus() ;
		contact2.name.parentNode.style.background = 'url(images/cross-ico.gif) no-repeat 88% 0' ;
		contact2.name.parentNode.getElementsByTagName('span')[1].style.display = 'block';
		contact2.name.parentNode.getElementsByTagName('span')[1].innerHTML = 'Please Enter Your Name.';
		return false;
	}
	else {
		contact2.name.className = '';
		contact2.name.parentNode.style.background = 'url(images/right-ico.gif) no-repeat 89% 0' ;
		contact2.name.parentNode.getElementsByTagName('span')[1].style.display = '';
	}
	
	// EMAIL VALIDATION
	if(contact2.email.value=="")
	{
		contact2.email.className = 'errorbox';
		contact2.email.focus() ;
		contact2.email.parentNode.style.background = 'url(images/cross-ico.gif) no-repeat 88% 0' ;
		contact2.email.parentNode.getElementsByTagName('span')[1].style.display = 'block';
		contact2.email.parentNode.getElementsByTagName('span')[1].innerHTML = 'Please Enter Your Email Id.';
		return false;
	}

	if (!contact2.email.value.match(/^[\w\.-]+@(?:[A-Za-z0-9-]+\.)*[A-Za-z0-9-]{1,}\.[a-z]{2,9}$/))
	{
		contact2.email.focus();
		contact2.email.value="";
		contact2.email.parentNode.getElementsByTagName('span')[1].innerHTML = 'Please Enter Valid Email Id.';
		return false;
	}
	else {
		contact2.email.className = '';
		contact2.email.parentNode.style.background = 'url(images/right-ico.gif) no-repeat 89% 0' ;
		contact2.email.parentNode.getElementsByTagName('span')[1].style.display = '';
	}


	//PHONE NUMBER AND FORMAT VALIDATION
	if(contact2.phone.value!="" && isNaN(contact.phone.value))
	{
		contact2.phone.className = 'errorbox';
		contact2.phone.focus() ;
		contact2.phone.parentNode.style.background = 'url(images/cross-ico.gif) no-repeat 88% 0' ;
		contact2.phone.parentNode.getElementsByTagName('span')[1].style.display = 'block';
		contact2.phone.parentNode.getElementsByTagName('span')[1].innerHTML = 'Phone Number must be Numeric.';
		return false;
	}
	if(contact2.phone.value.match(/^[0-9]+$/) && contact.phone.value.length<"5")
	{
		contact2.phone.focus() ;
		contact2.phone.parentNode.getElementsByTagName('span')[1].innerHTML = 'Phone Number must be 5 Digit.';
		return false;
	}
	else {
		contact2.phone.className = '';
		contact2.phone.parentNode.style.background = 'url(images/right-ico.gif) no-repeat 89% 0' ;
		contact2.phone.parentNode.getElementsByTagName('span')[1].style.display = '';
	}
	
		
	if(contact2.phone.value=="")
	{
		contact2.phone.className = '';
		contact2.phone.parentNode.style.background = 'none' ;
		contact2.phone.parentNode.getElementsByTagName('span')[1].style.display = '';
	}*/

	SendEmailData2(contact2); 
	return false ;
}

