$(document).ready(function() {

  //***************************
  // superfluous hover effects
  //***************************
    $('table#shopping-cart tr tr.item-row').hover(function() {
      $(this).addClass('hover');
    }, function() {
      $(this).removeClass('hover');
    });
    
    $('div#steps ol li').hover(function() {
      $(this).addClass('hover');
    }, function() {
      $(this).removeClass('hover');
    });

  //***************************
  // contact validation rules
  //***************************
  $('form#contact-form').validate({
    
    // tell the validation plugin to check the following inputs
		// documentation: http://docs.jquery.com/Plugins/Validation
    rules: {
      Name: "required",
			Animal_Type: "required",
      Phone: {required: true, digits: true},
		  Email_From: {required: true, email: true},
		  Comments_Enquiry: "required"
    },
    messages: {
      Phone: {digits: "Please enter numbers only"}
    },
    success: function(label) { 
      // inform user their input is valid
      label.html(" ").addClass("correct"); 
    }
    
  });
  
  
  //***************************
  // disables delivery info
  // inputs if user checks
  // "same as billing"
  //***************************
  $('a#delivery-same').toggle(function() {
      $('ol#delivery input:text').val("");
      $('ol#delivery input:text').attr("disabled", true);
      $('ol#delivery select').attr("disabled", true);
      $('ol#delivery input:text').addClass('disabled');      
    }, function() {
      $('ol#delivery input:text').removeAttr("disabled");
      $('ol#delivery select').removeAttr("disabled");
      $('ol#delivery input:text').removeClass('disabled');
  });
    
  $('form #form-reset').click(function() {
    $('form.baseform').clearForm();
    $('ol#delivery input:text').removeAttr("disabled");
    $('ol#delivery select').removeAttr("disabled");
    $('ol#delivery input:text').removeClass('disabled');
  });
  
  
  
  //***************************
  // Clear form with reset
  // Do not delete!
  //***************************    
  $.fn.clearForm = function() {
    return this.each(function() {
  	var type = this.type, tag = this.tagName.toLowerCase();
  	if (tag == 'form')
  	  return $(':input',this).clearForm();
  	if (type == 'text' || type == 'password' || tag == 'textarea')
  	  this.value = '';
  	else if (type == 'checkbox' || type == 'radio')
  	  this.checked = false;
  	else if (tag == 'select')
  	  this.selectedIndex = 0;
    });
  };
    
});