$(function() {

	$('.error').hide();

	var page = $("input#page").val();

	var page5 = $("input#page5").val();

//E-mail Sign up contact form



if (page == "Email Signup") {

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

		// validate and process form

		// first hide any error messages

    $('.error').hide();



	var email = $("input#email").val();
		if (email == "") {

      $("input#email").focus();

      return false;

    }
	
    if (email.indexOf("@") == "-1" || email.indexOf(".") == "-1") {
      alert("Please enter a valid email address.");		
      $("input#email").focus();

      return false;
    }


	

	if (email == "Sign up for Special Offers!") {

      $("input#email").focus();

      return false;

    }





	var dataString = 'email='+ email + '&page=' + page;

		//alert (dataString);return false;



		$.ajax({

      type: "POST",

      url: "http://www.columbiapoolandspa.com/bin/process.php",

      data: dataString,

      success: function() {

		_gaq.push(['_trackPageview', '/thank-you1.php']);	  

        $('#email_form').html("<div id='message2' style='padding-right:20px; padding-top:8px;'></div>");

        $('#message2').html("<span align='center' style='color:#434444'><strong>Thank You!</strong> Watch for future e-mails.  </span>")

        .hide()

        .fadeIn(500, function() {

        });

      }

     });

    return false;

	});

   }

   

   

//Contact Page contact form



if (page5 == "Contact Us Page"){

  $(".button-contact").click(function() {

		// validate and process form

		// first hide any error messages

 		// validate and process form

		// first hide any error messages

    $('.error').hide();

	$('input.contact-form').css({borderColor:"#434444"});

  	$('textarea.contact-form').css({borderColor:"#434444"}); 

 

 	var phone = $("input#phone").val();	

 	var subject = $("input#subject").val();	

 	var name = $("input#name").val();

    if (name == "") {

      $("label#name_error").show();

	  document.contact_form.name.style.borderColor="red "; 

      $("input#name").focus();

      return false;

   }

	

	    var email2 = $("input#email2").val();

		if (email2 == "") {

      $("label#email2_error").show();

	  document.contact_form.email2.style.borderColor="red ";

      $("input#email2").focus();

      return false;

    }

	



     var comments = $("textarea#comments").val();

	 		if (comments == "") {

      $("label#comments_error").show();

	  document.contact_form.comments.style.borderColor="red ";

      $("input#comments").focus();

      return false;

    }



	var dataString = 'name='+ name + '&email2=' + email2 + '&phone=' + phone + '&subject=' + subject + '&comments=' + comments + '&page5=' + page5;

		//alert (dataString);return false;

		$.ajax({

      type: "POST",

      url: "http://www.columbiapoolandspa.com/bin/process.php",

      data: dataString,

      success: function() {

		_gaq.push(['_trackPageview', '/thank-you2.php']);	  

        $('#contact_form').html("<div id='message' style='padding-right:20px; padding-top:8px;'></div>");

        $('#message').html("<span align='center' style='color:#434444'><strong>Thank you for contacting us!</strong> <p>Your information has been sent and we should be in touch with you soon.</p><p>You should expect a personal reply within the day or even sooner - as we answer most request within a few hours.</p><p>Feel free to contact us at 573-874-6972 if you have any questions.</p>  </span>")

        .hide()

        .fadeIn(500, function() {

        });

      }

     });

    return false;

	});

   }

      

   

//Service Page contact form



if (page5 == "Request For Service"){

  $(".button-contact").click(function() {

		// validate and process form

		// first hide any error messages

 		// validate and process form

		// first hide any error messages

    $('.error').hide();

	$('input.contact-form').css({borderColor:"#434444"});

  	$('textarea.contact-form').css({borderColor:"#434444"}); 

 
 	var service = $("select#service").val();	

 	var name = $("input#name").val();

    if (name == "") {

      $("label#name_error").show();

	  document.contact_form.name.style.borderColor="red "; 

      $("input#name").focus();

      return false;

   }

	

	    var email2 = $("input#email2").val();

		if (email2 == "") {

      $("label#email2_error").show();

	  document.contact_form.email2.style.borderColor="red ";

      $("input#email2").focus();

      return false;

    }

	
 	var phone = $("input#phone").val();	
	    if (phone == "") {

      $("label#phone_error").show();

	  document.contact_form.phone.style.borderColor="red "; 

      $("input#phone").focus();

      return false;

   }


     var comments = $("textarea#comments").val();



	var dataString = 'name='+ name + '&email2=' + email2 + '&phone=' + phone + '&service=' + service + '&comments=' + comments + '&page5=' + page5;

		//alert (dataString);return false;

		$.ajax({

      type: "POST",

      url: "http://www.columbiapoolandspa.com/bin/process.php",

      data: dataString,

      success: function() {

		_gaq.push(['_trackPageview', '/thank-you3.php']);	  

        $('#contact_form').html("<div id='message' style='padding-right:20px; padding-top:8px;'></div>");

        $('#message').html("<span align='center' style='color:#434444'><strong>Thank you for contacting us!</strong> <p>Your request has been sent and we should be in touch with you soon.</p><p>You should expect a personal reply within the day or even sooner - as we answer most request within a few hours.</p><p>Feel free to contact us at 573-874-6972 if you have any questions.</p>  </span>")

        .hide()

        .fadeIn(500, function() {

        });

      }

     });

    return false;

	});

   }

         

   

   

//Side Form page contact form



if (page5 == "Side Form") {

  $(".button-interior").click(function() {

		// validate and process form

		// first hide any error messages

    $('.error').hide();

	$('input.side-form').css({borderColor:"#434444"});

  	$('textarea.side-form').css({borderColor:"#434444"}); 

 

 	var phone = $("input#phone").val();	

 	var product = $("input#product").val()



 	var name = $("input#name").val();

    if (name == "") {

      $("label#name_error").show();

	  document.side_form.name.style.borderColor="red "; 

      $("input#name").focus();

      return false;

   }



	

	    var address = $("input#address").val();

		if (address == "") {

      $("label#address_error").show();

	  document.side_form.address.style.borderColor="red ";

      $("input#address").focus();

      return false;

    }



	    var city = $("input#city").val();

		if (city == "") {

      $("label#city_error").show();

	  document.side_form.city.style.borderColor="red ";

      $("input#city").focus();

      return false;

    }

	

	    var state = $("input#state").val();

		if (state == "") {

      $("label#state_error").show();

	  document.side_form.state.style.borderColor="red ";

      $("input#state").focus();

      return false;

    }	



	    var zip = $("input#zip").val();

		if (zip == "") {

      $("label#zip_error").show();

	  document.side_form.zip.style.borderColor="red ";

      $("input#zip").focus();

      return false;

    }	

	    var email2 = $("input#email2").val();

		if (email2 == "") {

      $("label#email2_error").show();

	  document.side_form.email2.style.borderColor="red ";

      $("input#email2").focus();

      return false;

    }

	

	

	

     var comments = $("textarea#comments").val();



	var dataString = 'name='+ name + '&address=' + address + '&city=' + city + '&state=' + state + '&zip=' + zip + '&email2=' + email2 + '&phone=' + phone + '&comments=' + comments + '&page5=' + page5 + '&product=' + product;

		//alert (dataString);return false;

		$.ajax({

      type: "POST",

      url: "http://www.columbiapoolandspa.com/bin/process.php",

      data: dataString,

      success: function() {

		_gaq.push(['_trackPageview', '/thank-you4.php']);	  

        $('#side_form').html("<div id='message' style='padding-right:20px; padding-top:8px;'></div>");

        $('#message').html("<span align='center' style='color:#434444'><strong>Thank you for contacting us!</strong> <p>Your information has been sent and we should be in touch with you soon.</p><p>You should expect a personal reply within the day or even sooner - as we answer most request within a few hours.</p><p>Feel free to contact us at 573-874-6972 if you have any questions.</p> </span>")

        .hide()

        .fadeIn(500, function() {

        });

      }

     });

    return false;

	});



   }

   

   

});
