﻿$(document).ready(function() {


$('#faq1q').click(function() {

if ($('#faq1a').is(':visible'))
	{
	$('#faq1a').slideUp('slow', function() {
    // Animation complete.
  });
	}
		else
			{

  			$('#faq1a').slideDown('slow', function() {
  			  // Animation complete.
  								});
  			}
});


$('#faq2q').click(function() {

if ($('#faq2a').is(':visible'))
	{
	$('#faq2a').slideUp('slow', function() {
    // Animation complete.
  });
	}
		else
			{

  			$('#faq2a').slideDown('slow', function() {
  			  // Animation complete.
  								});
  			}
});



var firstText = false;
var lastText = false;
var phoneText = false;
var cityText = false;
var OKtoSend = false;




	$("input#City").focus(function() {
  		if (cityText == false)
  			{
  			$("input#City").css("background-color","white");
  			}
  	});


  $("input#First").focus(function() {
  		if (firstText == false)
  			{
  			$("input#First").css("background-color","white");
  			}
  	});
  			
  $("input#Last").focus(function() {
  		if (lastText == false)
  			{
  			$("input#Last").css("background-color","white");
  			}
 
  }); 
  
 $("input#Phone").focus(function() {
  		if (phoneText == false)
  			{
  			$("input#Phone").css("background-color","white");
  			}
 
  }); 


if(OKtoSend == true)
	jQuery(".quoteDialog").modal({closeClass:"closeDialog"});





$(".quoteClick").click(function() {

var firstText = false;
var lastText = false;
var phoneText = false;
var cityText = false;
OKtoSend = true;


  
 
 var city = $("input#City").val();  
         if (city != "")
         	{ cityText = true; }
         		else
         			{
         			$("input#City").css("background-color","red");
         			OKtoSend = false; 
         			}

 
  
  var first = $("input#First").val();  
         if (first != "")
         	{ firstText = true; }
         		else
         			{
         			$("input#First").css("background-color","red");
         			OKtoSend = false;
         			}
         			
  var phone = $("input#Phone").val();  
         if (phone != "")
         	{ phoneText = true; }
         		else
         			{
         			$("input#Phone").css("background-color","red");
         			OKtoSend = false;
         			}

         			
   var last = $("input#Last").val();  
         if (last != "")
         	{ lastText = true; }
         		else
         			{
         			$("input#Last").css("background-color","red");
         			OKtoSend = false;
         			}

if(OKtoSend == true)
		{
   
   
   var first = $('[name=First]').val();
	 var last = $('[name=Last]').val();
	 var phone = $('[name=Phone]').val();
	 var address = $('[name=Address]').val();
	 var city = $('[name=City]').val();
	 var email = $('[name=Email]').val();

		 	
		 
         var Ran = Math.random()*Math.random();
         
         var dataString = 'First='+first+
		 		'&Last='+last+
				'&Phone='+phone+
				'&Address='+address+
				'&City='+city+
				'&Email='+email+
				'&ran='+Ran;
 $.ajax({
    type: "POST",
	cache: false,
    url: "php/submitQuote.php",
    data: dataString,
    success:function () {jQuery(".quoteDialog").modal({closeClass:"closeDialog"});}
    

            
         });

      	}			
 
		});	

});

