function isEmail( strValue) {
 var objRegExp = /^[a-z]\w*([.\-]\w+)*@[a-z]\w*([.\-]\w+)*\.[a-z]{2,3}$/i;
 return objRegExp.test(strValue);
}
function CheckPhoneNumber(TheNumber) {
 var valid = 1
 var GoodChars = "0123456789()-+.$ "
 var i = 0
 if (TheNumber=="") {
 // Return false if number is empty
 valid = 0
 }
 for (i =0; i <= TheNumber.length -1; i++) {
 if (GoodChars.indexOf(TheNumber.charAt(i)) == -1) {
// Note: Remove the comments from the following line to see this
// for loop in action.
// alert(TheNumber.charAt(i) + " is no good.")
 valid = 0
 } // End if statement
 } // End for loop
 return valid
}
	
function ContactSubmit(){
var why = "";

if(document.contactForm.email_addressed.value == "" ||  document.contactForm.email_addressed.value == "Please Select" ){
 why+="Please Select Email Addressed To<br />";
}

if(document.contactForm.first_name.value == ""){
 why+="Please enter First Name<br />";
}

if(document.contactForm.email.value == ""){
 why+="Please enter Email<br />";
}
else
{
	if(isEmail(document.contactForm.email.value) == false){
	 why+="Please enter a Valid Email<br />";
	}
}
if(document.contactForm.comments.value == ""){
 why+="Please enter your Enquires and comments<br />";
}

 if(why!="")
	{
	showDialog('Contact Form',why,'warning');
	return false;
	   
	}
	else
	{
	CheckLogin();
	}
return false;
	
}


function CheckLogin(){
	var email_addressed = document.contactForm.email_addressed.value;
	var first_name = document.contactForm.first_name.value;
	var surname = document.contactForm.surname.value;
	var email = document.contactForm.email.value;
	var company = document.contactForm.company.value;
	var mobile = document.contactForm.mobile.value;
	var business = document.contactForm.business.value;
	var address = document.contactForm.address.value;
	var city = document.contactForm.city.value;
	var state = document.contactForm.state.value;
	var postcode = document.contactForm.postcode.value;
	var comments = document.contactForm.comments.value;
	
		var html= $.ajax({
			 type: "POST",
			url: '/media/server-scripts/contactus.php?',
			 async: false,		
			data: "email_addressed="+encodeURIComponent(email_addressed)+"&first_name="+encodeURIComponent(first_name)+"&surname="+encodeURIComponent(surname)+"&email="+encodeURIComponent(email)+"&company="+encodeURIComponent(company)+"&mobile="+encodeURIComponent(mobile)+"&business="+encodeURIComponent(business)+"&address="+encodeURIComponent(address)+"&city="+encodeURIComponent(city)+"&state="+encodeURIComponent(state)+"&postcode="+encodeURIComponent(postcode)+"&comments="+encodeURIComponent(comments)
		 }).responseText;
				if(html==1)
				{
				showDialog('Contact Form','Email Sent Successfully','warning');
				document.contactForm.reset();
				}
				if(html==0)
				{
				showDialog('Contact Form','Error - While sending email','warning');				
				return false;
				}	
	
		
	}		