/*$(function () {
       $('img').hide();//hide all the images on the page
});

var i = 0;//initialize
var int=0;//Internet Explorer Fix
$(window).bind("load", function() {//The load event will only fire if the entire page or document is fully loaded
       var int = setInterval("doThis(i)",500);//500 is the fade in speed in milliseconds
});

function doThis() {
       var imgs = $('img').length;//count the number of images on the page
       if (i >= imgs) {// Loop the images
              clearInterval(int);//When it reaches the last image the loop ends
       }
       $('img:hidden').eq(0).fadeIn(500);//fades in the hidden images one by one
       i++;//add 1 to the count
}*/

function load_content(url){$("#content_left").fadeOut('fast').load(url).fadeIn('fast');}

function process_form() {

    // validate and process form here

    $('.error').hide();
      var full_name = $("input#full_name").val();
        if (full_name == "") {
      $("label#full_name_error").show();
      $("input#full_name").focus();
      return false;
    }
        var biz_name = $("input#biz_name").val();
        if (biz_name == "") {
      $("label#biz_name_error").show();
      $("input#biz_name").focus();
      return false;
    }
        var email_address = $("input#email_address").val();
        if (email_address == "") {
      $("label#email_address_error").show();
      $("input#email_address").focus();
      return false;
    }
        var phone_number = $("input#phone_number").val();
        if (phone_number == "") {
      $("label#phone_number_error").show();
      $("input#phone_number").focus();
      return false;
    }
        var textarea = $("#textarea").val();
        if (textarea == "") {
      $("label#textarea_error").show();
      $("#textarea").focus();
      return false;
    }

        var dataString = 'full_name='+ full_name + '&biz_name=' + biz_name + '&email_address=' + email_address + '&phone_number=' + phone_number + '&comments=' + textarea;
        //alert (dataString);

        $.ajax({
          type: "POST",
          url: "http://www.aandnpainting.com/cgi-bin/send.cgi",
          data: dataString,
          success: function(msg) {
                  if (msg == "0"){
                  $('#contact_form').html("<div id='message'></div>");
                  $('#message').html("<h2>Contact Form Submitted!</h2>")
                  .append("<p>We will be in touch soon.</p>")
                  .hide()
                  .fadeIn(1000, function() {
                  $('#message').append("<img id='checkmark' src='../static/images/check.png' />");
                 });
                } else {
                  $('#contact_form').html("<div id='message'></div>");
                  $('#message').html("<h2>An Error Occurred!</h2>")
                  .append("<p>There was a problem with the email address you provided. Please <a href=\"javascript:load_content('/includes/contact.html');\">click here</a> to retry.</p>")
                  .hide()
                  .fadeIn(1000, function() {
                  $('#message').append("<img id='checkmark' src='../static/images/x_icon.png' />");
                 });
                }
         }
        });
   return false;
}

