// JavaScript Document

$(function () {
$('.error').hide();
$(".button").click(function() {  
$('.error').hide();
 var name = $("input#name").val();
 var email = $("input#email").val();  
 var phone = $("input#phone").val(); 
 var comments = $("textarea#comments").val(); 
 if (name == "" || isNaN(phone)|| phone==" ` ( )  \\ ~ ! @ ^ & * + \" | : =  , < > "  || email == "" || comments.length>255){
 	if(comments.length>255){
	$("label#comments_error").html("Comments should not exceed 255 chars. <br/><br/>You entered <b>"+comments.length+"</b> chars!");
	$("label#comments_error").show();  
      $("textarea#comments").focus();  
	}
  	if (email == "") {  
      $("label#email_error").show();  
      $("input#email").focus();  
    }
	if (isNaN(phone)||(phone==" ` ( )  \\ ~ ! @ ^ & * + \" | : =  , < > ") ) {  
      $("label#phone_error").show();  
      $("input#phone").focus();
    }   
	if (name == "") {  
      $("label#name_error").show();  
      $("input#name").focus();  
	}  
return false; 
}
else
{
var dataString = 'name='+ name + '&email=' + email + '&phone=' + phone + '&comments=' + comments;
$.ajax({
type: "POST",
url: "submitmail.php",
data: dataString,
success: function(){
alert("We will contact you soon.");
document.forms['contactdetails'].reset();
}
});
}
return false;
});
});

$(function () {
$(".updateemail").click(function() {
var uemail = $("input#uemail").val();
if (uemail=="" || uemail== "Enter Email Address for Updates") {
alert("Please Enter Correct Email Address");
return false;
}
else
{
var dataString = 'uemail='+ uemail;
$.ajax({
type: "POST",
url: "submitmail.php",
data: dataString,
success: function(){
alert("Thank you for signing up to get updates.");
document.forms['submituemail'].reset();
}
});
}
return false;
});
});
