$(document).ready(function()						   
{
	
	    $("#search_options > ul").tabs();   //tabs this is not part of validation
	
										
				$("#quote_form").submit(function()
				{
						
					
						if ($('#nameinsured').val() == "" ||
								$('#streetaddress').val() == "" ||
								$('#city').val() == "" ||
								$('#state').val() == "" ||
								$('#zip').val() == "" ||
								$('#phone').val() == "" ||
								$('#email').val() == "") 
						 {
							
							
							$("#msgbox").removeClass().addClass('messagebox').html('<img src=/images/spinner.gif />').fadeIn(3000);
							$("#msgbox").fadeTo(900,0.1,function() //start fading the messagebox
							{ 
							  //add message and change the class of the box and start fading
							  $(this).html('Please make sure all the required fields have values.').addClass('messageboxerror').fadeTo(900,1);
							  //$("#invoicenumber").text("Some thing missing");
							  //$('invoicenumber, :text').val("Some thing missing"); 
							});
							return false;
						
						
						
							
						}else{
						
							//remove all the class add the messagebox classes and start fading
							$("#msgbox").removeClass().addClass('messagebox').html('<img src=/images/spinner.gif />').fadeIn(2000);
							//check the username exists or not from ajax
							$.post("/get-a-quote/quote-act.php",{
								   FindQuote:$('#FindQuote').val(),
								   nameinsured:$('#nameinsured').val(),
								   bmonth:$('#bmonth').val(),
								   bday:$('#bday').val(),
								   byear:$('#byear').val(),
								   streetaddress:$('#streetaddress').val(),
								   city:$('#city').val(),
								   state:$('#state').val(),
								   zip:$('#zip').val(),
								   phone:$('#phone').val(),
								   email:$('#email').val(),
								   year:$('#year').val(),
								   make:$('#make').val(),
								   length:$('#length').val(),
								   engines:$('#engines').val(),
								   rebuilt:$('#rebuilt').val(),
								   experience:$('#experience').val(),
								   insurance:$('#insurance').val(),
								   rbmonth:$('#rbmonth').val(),
								   rbday:$('#rbday').val(),
								   rbyear:$('#rbyear').val(),
								   hull:$('#hull').val(),
								   deductible:$('#deductible').val(),
								   liability:$('#liability').val(),
								   crew:$('#crew').val(),
								   charter:$("input[@name='charter']:checked").val(),
								   additional:$('#additional').val()
							   },function(data)
							 {
								 
								 //alert(data);
							 
							 // $("#invoicenumber").removeClass('msgerror');
							 
							 
							 
							  if(data=='yes') //if correct login detail
							  {
									$("#msgbox").fadeTo(200,0.1,function()  //start fading the messagebox
									{ 
									  
									  //add message and change the class of the box and start fading
									  $(this).html('Processing your quote, please wait...').addClass('messageboxok').fadeTo(900,1,function(){ 
										 //redirect to secure page
										 document.location='/get-a-quote/thankyou.php';
									   });
									  
									});
									
							  }else if(data=='noemail') {
									$("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
									{ 
									  
									  //add message and change the class of the box and start fading
									  $(this).html('The email address provided is invalid.').addClass('messageboxerror').fadeTo(900,1);
									});	
							  
							  }else {
									$("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
									{ 
									  
									  //add message and change the class of the box and start fading
									  $(this).html('Please make sure all the required fields have values.').addClass('messageboxerror').fadeTo(900,1);
									});		
							  }
									
							});
							return false; //not to post the  form physically
					
					   } //end of if 
				
			  }); // end of submit
				
       			
	   
			   /* This is report claim form validation section  2009*/
			 
				$("#claim_form").submit(function()
				{
					
					
						 if ($('#name').val() == "" ||
								$('#address').val() == "" ||
								$('#city').val() == "" ||
								$('#state').val() == "" ||
								$('#zip').val() == "" ||
								$('#phone').val() == "" ||
								$('#email').val() == "" ||
								$('#policy').val() == "" ||
								$('#describe').val() == "" 
								) 
						 {
							
							
							$("#msgbox").removeClass().addClass('messagebox').html('<img src=/images/spinner.gif />').fadeIn(3000);
							$("#msgbox").fadeTo(900,0.1,function() //start fading the messagebox
							{ 
							  //add message and change the class of the box and start fading
							  $(this).html('Please make sure all the required fields have values.').addClass('messageboxerror').fadeTo(900,1);
							  //$("#invoicenumber").text("Some thing missing");
							  //$('invoicenumber, :text').val("Some thing missing"); 
							});
							return false;
						
						
						
							
						}else{
							
							
						
							//remove all the class add the messagebox classes and start fading
							$("#msgbox").removeClass().addClass('messagebox').html('<img src=/images/spinner.gif />').fadeIn(2000);
							//check the username exists or not from ajax
							$.post("/customer-service/claim-act.php",{
								   Claim:$('#Claim').val(),
								   name:$('#name').val(),
								   Amonth:$('#Amonth').val(),
								   Aday:$('#Aday').val(),
								   Ayear:$('#Ayear').val(),
								   address:$('#address').val(),
								   city:$('#city').val(),
								   state:$('#state').val(),
								   zip:$('#zip').val(),
								   phone:$('#phone').val(),
								   email:$('#email').val(),
								   policy:$('#policy').val(),
								   describe:$('#describe').val()
								   
							   },function(data)
							 {
								 
								 //alert(data);
							 
							 // $("#invoicenumber").removeClass('msgerror');
							 
							 
							 
							  if(data=='yes') //if correct login detail
							  {
									$("#msgbox").fadeTo(200,0.1,function()  //start fading the messagebox
									{ 
									  
									  //add message and change the class of the box and start fading
									  $(this).html('Processing your claim, please wait...').addClass('messageboxok').fadeTo(900,1,function(){ 
										 //redirect to secure page
										 document.location='/customer-service/thankyou.php';
									   });
									  
									});
									
									
									
							  }else if(data=='noemail') {
									$("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
									{ 
									  
									  //add message and change the class of the box and start fading
									  $(this).html('The email address provided is invalid.').addClass('messageboxerror').fadeTo(900,1);
									});	
							  
							  }else {
									$("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
									{ 
									  
									  //add message and change the class of the box and start fading
									  $(this).html('Please make sure all the required fields have values.').addClass('messageboxerror').fadeTo(900,1);
									});		
							  }
									
							});
							return false; //not to post the  form physically
					
					   } //end of if 
				
			     }); // end of submit
				
				
				
				
				 /* This is contact form validation section  2009*/
			 
				$("#contact_form").submit(function()
				{
					
					
						 if ($('#name').val() == "" ||
								$('#phone').val() == "" ||
								$('#email').val() == "" ||
								$('#describe').val() == "" 
								) 
						 {
							
							
							$("#msgbox").removeClass().addClass('messagebox').html('<img src=/images/spinner.gif />').fadeIn(3000);
							$("#msgbox").fadeTo(900,0.1,function() //start fading the messagebox
							{ 
							  //add message and change the class of the box and start fading
							  $(this).html('Please make sure all the required fields have values.').addClass('messageboxerror').fadeTo(900,1);
							  //$("#invoicenumber").text("Some thing missing");
							  //$('invoicenumber, :text').val("Some thing missing"); 
							});
							return false;
						
						
						
							
						}else{
							
							
						
							//remove all the class add the messagebox classes and start fading
							$("#msgbox").removeClass().addClass('messagebox').html('<img src=/images/spinner.gif />').fadeIn(2000);
							//check the username exists or not from ajax
							$.post("contact-act.php",{
								   Contact:$('#Contact').val(),
								   name:$('#name').val(),
								   phone:$('#phone').val(),
								   email:$('#email').val(),
								   describe:$('#describe').val()
								   
							   },function(data)
							 {
								 
								 //alert(data);
							 
							 // $("#invoicenumber").removeClass('msgerror');
							 
							 
							 
							  if(data=='yes') //if correct login detail
							  {
									$("#msgbox").fadeTo(200,0.1,function()  //start fading the messagebox
									{ 
									  
									  //add message and change the class of the box and start fading
									  $(this).html('Processing your request, please wait...').addClass('messageboxok').fadeTo(900,1,function(){ 
										 //redirect to secure page
										 document.location='thankyou.php';
									   });
									  
									});
									
							  }else if(data=='noemail') {
									$("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
									{ 
									  
									  //add message and change the class of the box and start fading
									  $(this).html('Invalid email address.').addClass('messageboxerror').fadeTo(900,1);
									});	
							  
							  }else {
									$("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
									{ 
									  
									  //add message and change the class of the box and start fading
									  $(this).html('Please make sure all the required fields have values.').addClass('messageboxerror').fadeTo(900,1);
									});		
							  }
									
							});
							return false; //not to post the  form physically
					
					   } //end of if 
				
			     }); // end of submit
			
	
	 
		
		
		
				
}); // end of ready