// JavaScript Document

   $(function () {
$('.error').hide();
$(".button").click(function() {  
$('.error').hide();
 var name = $("input#name").val();
 var surname = $("input#surname").val();
 var email = $("input#email").val();  
 var phone = $("input#phone").val(); 
 var address1 = $("textarea#address1").val(); 
 var postcode = $("input#postcode").val();
 var datef = $("input#datef").val(); 
 var taccident = $("input#taccident").val();
 var tellus = $("textarea#tellus").val();
 if (name == "" || surname == "" || email == "" || isNaN(phone)|| phone==" ` ( )  \\ ~ ! @ ^ & * + \" | : =  , < > " || address1 == "" || postcode == "" || datef == "" || taccident == "" || tellus =="" ){
 	
	if (surname == "") {  
      $("label#surname_error").show();  
      $("input#surname").focus(); 
	}
	
	if (email == "") {  
      $("label#email_error").show();  
      $("input#email").focus();  
    }
	
	if (isNaN(phone)||(phone==" ` ( )  \\ ~ ! @ ^ & * + \" | : =  , < > ") ) {
      $("label#phone_error").show();  
      $("input#phone").focus();  
    } 
	
	if (address1 == "") {  
      $("label#address1_error").show();  
      $("textarea#address1").focus();  
	}
		
	if (postcode == "") {  
      $("label#postcode_error").show();  
      $("input#postcode").focus();  
	}
	
	if (datef == "") {  
      $("label#datef_error").show();  
      $("input#datef").focus();  
	}
	
	if (taccident == "") {  
      $("label#taccident_error").show();  
      $("input#taccident").focus();  
	}
	
	if (tellus == "") {  
      $("label#tellus_error").show();  
      $("input#tellus").focus();  
	}
	
	if (name == "") {  
      $("label#name_error").show();  
      $("input#name").focus();  
	}
	  
return false; 
}
else
{document.claimfor.submit();
	//alert("OK");
	//document.forms['claimfor'].reset();
}
  });  
});

$(function () {
$('.error').hide();
$(".button1").click(function() {  
$('.error').hide();
 var cname = $("input#cname").val();
 var cnumber = $("input#cnumber").val();
 var accidenttype = $("select#accidenttype").val();
 var cmbday = $("select#cmbday").val();
 var cmbtime = $("select#cmbtime").val();
 
 if (cname == "" || isNaN(cnumber)|| cnumber==" ` ( )  \\ ~ ! @ ^ & * + \" | : =  , < > " || cnumber == ""){
 	
	if (isNaN(cnumber) || cnumber == "" ||(cnumber==" ` ( )  \\ ~ ! @ ^ & * + \" | : =  , < > ") ) {
      $("label#cnumber_error").show();  
      $("input#cnumber").focus();  
    } 
	
	if (cname == "") {  
      $("label#cname_error").show();  
      $("input#cname").focus();  
	}
	  
return false; 
}
else
{

var dataString = 'cname='+ cname + '&cnumber=' + cnumber + '&accidenttype=' + accidenttype + '&cmbday=' + cmbday + '&cmbtime=' + cmbtime;
$.ajax({
type: "POST",
url: "startclaim.php",
data: dataString,
success: function() {
alert("We will contact you soon.");
document.forms['cmbf'].reset();
}
});
}
return false; 
}); 
});



