$(function() {
$('#tabitem > ul').tabs({ fx: { height: 'toggle', opacity: 'toggle' } });
  $('.error').hide();
  $('input.text-input').css({backgroundColor:"#FFFFFF"});
  $('input.text-input').focus(function(){
    $(this).css({backgroundColor:"#FFDDAA"});
  });
  $('input.text-input').blur(function(){
    $(this).css({backgroundColor:"#FFFFFF"});
  });

  $(".button_feedback").click(function() {
        // validate and process form
        // first hide any error messages
    $('.error').hide();
        
      var name = $("input#name").val();
        if (name == "") {
      $("label#name_error").show();
      $("input#name").focus();
      return false;
    }
        var email = $("input#email").val();
        if (email == "") {
      $("label#email_error").show();
      $("input#email").focus();
      return false;
    }
        var phone = $("input#phone").val();
        if (phone == "") {
      $("label#phone_error").show();
      $("input#phone").focus();
      return false;
    }
    
     var feedback = $("input#feedback").val();
        if (feedback == "") {
      $("label#feedback_error").show();
      $("input#feedback").focus();
      return false;
    }
        
        var dataString = 'name='+ name + '&email=' + email + '&phone=' + phone + '&feedback=' + feedback;
        //alert (dataString);return false;
        
        $.ajax({
      type: "POST",
      url: "bin/process.php",
      data: dataString,
      cache: false,
      success: function() {
        $('#contact_form').html("<div id='message'></div>");
        $('#message').html("<h2>Your Request/Feedback information has been submitted!</h2>")
        .append("<p>We will be in touch soon.</p>")
        .hide()
        .fadeIn(1500, function() {
          $('#message').append("<img id='checkmark' src='images/check.png' />");
        });
      }
     });
    return false;
    });
 
     
 /*---------
 
 Commentig Form processing
   
 ----------*/
 
 
   
$(".button_comment").click(function() {
        // validate and process form
        // first hide any error messages
        
        var itemid = $(":input[name='itemid']").val();
        
      var username = $("input#username").val();
       if (username == "") {
      $("label#username_error").show();
      $("input#username").focus();
      return false;
    }
    
    var comment = $(":input[name='comment']").val();
       if (username == "") {
      $("label#comment_error").show();
      $(":input[name='comment']").focus();
      return false;
    }
    
    var dataString = 'itemid=' + itemid + '&username=' + username + '&comment=' + comment;
        //alert (dataString);return false;
        
        
        $.ajax({
      type: "POST",
      url: "bin/comment.php",
      data: dataString,
      success: function() {
        $('#usercomment').html("<div id='message'></div>");
        $('#message').html("<h3>Your Comment has been submitted for a review!</h3>")
        .hide()
        .fadeIn(1500, function() {
          $('#message').append("<p style='text-align: center'><img id='checkmark' src='images/icons/submitted.png' /></p>");
        });
      }
     });
    return false;
    }); 
/*--------------

$(".button_subscribe").click(function() {
        // validate and process form

        
    var email = $(":input[name='email']").val();
    var filter = /^\ w(\.?[\w-])*@\w(\.?[\w-])*\.[a-z]{2,6}(\.[a-z]{2})?$/i;

   if (!filter.test(email)) {
      alert(“You must enter a valid email address”);
      return false; 
} else {
}
    var subscribe = $(":input[name='subscribe']").val();
      
    
    var dataString = 'email=' + email + '&subscribe=' + subscribe;
       //alert(dataString); return false;
       
        
        
        $.ajax({
      type: "POST",
      url: "bin/subscription.php",
      data: dataString,
      success: function() {
        $('#subscribe').html("<div id='message'></div>");
        $('#message').html("<h3>Your subscription status has been updates!</h3>")
        .hide()
        .fadeIn(1500, function() {
          $('#message').append("<p style='text-align: center'><img id='checkmark' src='images/icons/submitted.png' /></p>");
        });
      }
     });
    return false;
    }); 
    
/*-------------------*/       
    

 });       
    
/*-------------------*/    



