$(function() {
	$("#submit-button").click(function() {
		var email = $("input#email").val();
		$(".email-error").html('');
		$(".name-error").html('');
		var name = $("input#name").val();  
        if (name == "" || name == 'Name') {
			$(".name-error").html('<span class="red">*</span>');  			
			$("input#name").focus();  
			return false;  
		}
        if (email == "") {
			$(".email-error").html('<span class="red">*</span>');  
			$("input#email").focus();  
			return false;  
		}else if(!isValidEmailAddress(email)){
			$(".email-error").html('<span class="red">*</span>');  
			$("input#email").focus();  
			return false;  
		}		
		var dataString = 'name='+ name + '&email=' + email;  
		$.ajax({  
			  type: "POST",  
			  url: "bin/process.php",  
			  data: dataString,  
			  success: function() {  
				$('#news-form').html("<div id='message-success'></div>");  
				$('#message-success').html('<p style="padding-top:10px;" class="red"><span style="font-size:14px;font-weight:bold;">Thank You!</span><br/>We will be in touch soon.</p>');  
			  }  
		});  
		return false;  
	});  
	
});
function clickclear(thisfield, defaulttext) {
	if (thisfield.value == defaulttext) { thisfield.value = ""; }
}
function clickrecall(thisfield, defaulttext) {
	if (thisfield.value == "") { thisfield.value = defaulttext; }
}
function isValidEmailAddress(emailAddress) {
	var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
	return pattern.test(emailAddress);
};
