$(function() {
	$("#submit").click(function() {
		// validate
		$(".error").hide();
		var hasError = false;
		
		var nameVal = $("#name").val();
		if(nameVal == '') {
			hasError = true;
		}
		
		var jobVal = $("#job").val();
		if(jobVal == '') {
			hasError = true;
		}
		
		var companyVal = $("#company").val();
		if(companyVal == '') {
			hasError = true;
		}
		
		var industryVal = $("#industry").val();
		
		var emailToVal = $("#emailTo").val();
		if(emailToVal == '') {
			hasError = true;
		} 
		
		var telephoneVal = $("#telephone").val();
		if(telephoneVal == '') {
			hasError = true;
		}
		
		var messageVal = $("#message").val();
		
		var subscribeVal = $("#subscribe").attr('checked')?"Yes":"No";
		
		if(hasError == true) {
			$("#errorMessage").after('<div class="error">Please enter the required fields below, they are marked with a *<br /><br /></div>');	
		} 
		
		
		var rnd = String((new Date()).getTime()).replace(/\D/gi,'');
		
		if(hasError == false) {
			$.post("send.php?"+rnd , { emailName: nameVal, emailJob: jobVal, emailCompany: companyVal, emailAddress: emailToVal, emailPhone: telephoneVal, emailIndustry: industryVal, emailMessage: messageVal, emailSub: subscribeVal },
				function(data){
					$('#contact_area').html('<p style="text-align:center; margin-top:120px;"><strong>' + data);			
			});
		}
				
		return false;
		
	});
});