function imageLoad(){
document.getElementById("image").style.display="block";
document.getElementById("request_bg").style.display="none";
setTimeout("thankLoad()",3000);
}
function thankLoad(){
document.getElementById("thankyou").style.display="block";
document.getElementById("image").style.display="none";
document.getElementById("request_bg").style.display="none";
setTimeout("formLoad()",4000);
} 

function formLoad(){
document.getElementById("request_bg").style.display="block";
document.getElementById('thankyou').style.display = "none"; 
document.getElementById("image").style.display="none";
document.getElementById('captchaQuickImage').src = 'securimage/securimage_show.php?sid=' + Math.random();
document.frmQuick.quickName.value = "";
document.frmQuick.quickEmail.value = "";
document.frmQuick.quickPhone.value = "";
document.frmQuick.quickCountry.value = "";
document.frmQuick.quickComments.value = "";
document.frmQuick.quickCode.value = "";
}



function quickcontactForm()
{
if(document.frmQuick.quickName.value=="" || document.frmQuick.quickName.value=="Name")
{
alert("Please enter your name");
document.frmQuick.quickName.focus();
return false;
}

if(document.frmQuick.quickEmail.value=="" || document.frmQuick.quickEmail.value=="Email address" )
  {
  alert("Please enter your email address");
  document.frmQuick.quickEmail.focus();
  return false;
  }
  
  
if(validate_email(document.frmQuick.quickEmail,"Invalid email address! Please re-enter!")==false)
  {
  document.frmQuick.quickEmail.select();
  document.frmQuick.quickEmail.focus();
  return false;
  }
  
if(document.frmQuick.quickPhone.value=="" || document.frmQuick.quickPhone.value=="Phone number")
{
alert("Please enter your phone number");
document.frmQuick.quickPhone.focus();
return false;
}
if(IsNumeric(document.frmQuick.quickPhone.value)==false )
{
	alert("Invalid phone number! Please re-enter!");
	document.frmQuick.quickPhone.select();
	document.frmQuick.quickPhone.focus();
	return false;
} 

if(document.frmQuick.quickCountry.value=="" || document.frmQuick.quickCountry.value=="Country")
  {
  alert("Please enter your country");
  document.frmQuick.quickCountry.focus();
  return false;
  }
  


if(document.frmQuick.quickComments.value=="" || document.frmQuick.quickComments.value=="Questions or Comments")
  {
  alert("Please enter your comments");
  document.frmQuick.quickComments.focus();
  return false;
  } 
  
 if(document.frmQuick.quickCode.value=="" || document.frmQuick.quickCode.value=="Code")
 {
  alert("Please enter code");
  document.frmQuick.quickCode.focus();
  return false;
}
  
var name	       =    document.frmQuick.quickName.value;
var email	       =    document.frmQuick.quickEmail.value;
var phone	       = 	document.frmQuick.quickPhone.value;
var country	       = 	document.frmQuick.quickCountry.value;
var comment	       = 	document.frmQuick.quickComments.value;
var comment        = 	comment.replace(/\n/g, "<br />");
var code	       = 	document.frmQuick.quickCode.value;
authenticate_contact(name,email,phone,country,comment,code)
return true;
//document.frmQuick.submit();
}

function getXMLHTTP() { //fuction to return the xml http object
		var xmlhttp=false;	
		try{
			xmlhttp=new XMLHttpRequest();
		}
		catch(e)	{		
			try{			
				xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e){
				try{
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
				}
				catch(e1){
					xmlhttp=false;
				}
			}
		}
		 	
		return xmlhttp;
    }
	
function authenticate_contact(nameVal,emailVal,phoneVal,countryVal,commentVal,codeVal) {		

	var strURL="http://www.apollobuildtec.com/mails/quickmail.php?name="+nameVal+"&email="+emailVal+"&phone="+phoneVal+"&country="+countryVal+"&comment="+commentVal+"&code="+codeVal;

		var req = getXMLHTTP();
		//alert(thisVal1)
			if (req) {
				//document.getElementById('listClientDetails').style.display='block';
				req.onreadystatechange = function() {
					if (req.readyState == 4) {
						//alert(req.readyState);
						// only if "OK"
						if (req.status == 200) {	
						 	if(req.responseText.match(/^OK/) != null) {
        					// alert('Your message has been sent!');  
											
						 // window.location="http://www.apollobuildtec.com/thanks.php";
							imageLoad();
         
        					} else {
          					alert(req.responseText);
							document.frmQuick.quickCode.select();
        					}
														
						} else {
							alert("There was a problem while using XMLHTTP:\n" + req.statusText);
						}
					}				
				}			
				req.open("POST", strURL, true);
				//req.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
				req.send(null);
			}			
		
	}
	 


