$(document).ready(function(){ 
	$("ul.sf-menu").superfish({
		autoArrows:  false,
		delay:       0,
		speed: 0
	}); 

	$('.quoteLink').click(function (e) {
		e.preventDefault();
		$.get("/quote.html", function(data){
			$.modal(data, {
				opacity : '75'
			});
		});
	});
	
	$('.privacyLink').click(function (e) {
		e.preventDefault();
		$.get("/privacy.html", function(data){
			$.modal(data, {
				opacity : '75'
			});
		});
	});


}); 



function submitQuote() {

	if (!document.quoteForm.name.value)
		{
			alert('Please enter your Name.');
			document.quoteForm.name.focus();
			return false;
		}	

	if (!document.quoteForm.email_real.value)
		{
			alert('Please enter your Email.');
			document.quoteForm.email_real.focus();
			return false;
		}	

	if (!document.quoteForm.phone.value)
		{
			alert('Please enter your Phone Number.');
			document.quoteForm.phone.focus();
			return false;
		}
		
	if (!document.quoteForm.message.value)
		{
			alert('Please enter your Insurance Needs.');
			document.quoteForm.message.focus();
			return false;
		}
		
		
		
	 var params = $("#quoteForm").serialize();
	$.post("/cgi-bin/quote.cgi", params,
	   	function(data){
			if (data == 'ok') {
				$("#quoteForm .submitButton").fadeOut('slow', function(){
					$("#quoteComplete").fadeIn('slow');
				});

				setTimeout(function(){
					$.modal.close();
				}, 10000);

			}
	});
	
	return false;
}


function submitContact() {

	if (!document.contactForm.name.value)
		{
			alert('Please enter your Name.');
			document.contactForm.name.focus();
			return false;
		}	

	if (!document.contactForm.email_real.value)
		{
			alert('Please enter your Email.');
			document.contactForm.email_real.focus();
			return false;
		}	
		
	if (!document.contactForm.message.value)
		{
			alert('Please enter your Message.');
			document.contactForm.message.focus();
			return false;
		}
		
		
		
	 var params = $("#contactForm").serialize();
	$.post("/cgi-bin/contact.cgi", params,
	   	function(data){
			if (data == 'ok') {
				$("#contactForm .submitButton").fadeOut('slow', function(){
					$("#contactComplete").fadeIn('slow');
				});

				setTimeout(function(){
					document.contactForm.reset()
					$("#contactComplete").fadeOut('slow', function(){
						$("#contactForm .submitButton").fadeIn('slow');
					});
				}, 10000);

			}
	});
	
	return false;
}


function submitEmail() {


	if (!document.emailForm.email_real.value)
		{
			alert('Please enter your Email.');
			document.emailForm.email_real.focus();
			return false;
		}	
		
	
		
		
	 var params = $("#emailForm").serialize();
	$.post("/cgi-bin/email.cgi", params,
	   	function(data){
			if (data == 'ok') {
				$("#emailFields").fadeOut('slow', function(){
					$("#emailComplete").fadeIn('slow');
				});

				setTimeout(function(){
					document.emailForm.reset()
					$("#emailComplete").fadeOut('slow', function(){
						$("#emailFields").fadeIn('slow');
					});
				}, 5000);

			}
	});
	
	return false;
}
