var companyHttp;
var companyXML;

function getXmlHttpObject()
{
    var _http=null;
    try
    {
      // Firefox, Opera 8.0+, Safari
      _http=new XMLHttpRequest();
    }
    catch (e)
    {
      // Internet Explorer
      try
      {
		 _http=new ActiveXObject("Microsoft.XMLHTTP");
         
      }
      catch (e)
      {
        _http=new ActiveXObject("Msxml2.XMLHTTP");
      }
    }
    if(_http==null){
        alert("Ajax is Not Supported");
    }
    return _http;
}

function sendSuperRequest(){
	/*currentPageID=pageID
    currentCategoryID=categoryID;
	currentSubCategoryID=subCategoryID;*/
	var url="/processEnquiry.aspx";
	var params = "firstName="+document.getElementById("first_name").value;
	params+="&lastName="+document.getElementById("last_name").value;
	params+="&email="+document.getElementById("email").value;
	params+="&phone="+document.getElementById("phone").value;
	params+="&dob="+document.getElementById("dob_day").value + "/" + document.getElementById("dob_month").value + "/" + document.getElementById("dob_year").value;
	params+="&enquiryType=Super Request";
	params+="&street="+document.getElementById("street").value;
	params+="&suburb="+document.getElementById("suburb").value;
	params+="&city="+document.getElementById("city").value;
	params+="&postcode="+document.getElementById("postcode").value;
	
	companyHttp=getXmlHttpObject();
	try{	
		companyHttp.open("POST",url);
		//companyHttp.open("GET",url+"?search="+searchString+"&pageID="+pageID,true);
		//Send the proper header information along with the request
		companyHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		companyHttp.setRequestHeader("Content-length", params.length);
		companyHttp.setRequestHeader("Connection", "close");
		companyHttp.onreadystatechange=confirmation;
	 }
	 catch(e){
		 alert("HTTP Init error:"+e);
	 }
	 
	// alert("Send");
	if( window.ActiveXObject && /Win/.test(navigator.userAgent) ) { 
	  try{
	      companyHttp.send(params);
	      hideForm();
	  }
	  catch(e){
			alert("SEND ERROR");
	  }
	}else{
		companyHttp.async=true;
		companyHttp.send(params);
		hideForm();
		//document.getElementById("fm_general_enq").innerHTML="<div class=\"contact_msg\"><p>Gidday, cheers for contacting us. We will quickly pass that on to the right people and get back to you as quick as we can.</p></div>";
//		companyHttp.send(document.location.href+"?name=1");
	}
	return false;
}

function hideForm() {
    document.getElementById("form_div").style.display = "none";
    document.getElementById("response_div").style.display = "block";
}

function showForm() {
    document.getElementById("form_div").style.display = "block";
    document.getElementById("response_div").style.display = "none";
}

function confirmation(){
    //var message = "<div id='response_div' style='display:none'><div id='form_response'><div class='contact_success_msg'><p><strong>Thank you, your enquiry has been sent</strong></p><br />&nbsp;<br /><p>Cheers for contacting us - we'll quickly pass that on to the right people and get back to you as quick as we can.</p></div><p class='btn left_btn_back'><a href='/contact-us/'>Back</a></p></div></div>";
	//reg_form_wrap.innerHTML="hey man";
	//alert('chur');
}