$(document).ready(function() {

  // add first and last classes to all lists, table rows, table heads and table cells in the DOM
  $('ul li:first-child,table tr:first-child,tr td:first-child, tr th:first-child').addClass('first');
  $('ul li:last-child,table tr:last-child,tr td:last-child, tr th:last-child').addClass('last');

  $('#feature ul') 
  .after('<div id="pager">') 
  .cycle({ 
      fx:     'scrollLeft', 
      speed:  'slow', 
      timeout: 8000, 
      delay: -4000, 
      pager:  '#pager' 
  });

  $('#gallery ul') 
  .cycle({ 
      fx:     'scrollLeft', 
      speed:  'slow', 
      timeout: 8000, 
      delay: -4000 
  });

  $('#page-body p:first-child').addClass("intro");
  
  $('#quotation blockquote p').prepend('<span class="quote66">&ldquo;</span>');
  $('#quotation blockquote p').append('<span class="quote99">&rdquo;</span>');

  // validation of form submissions
  $('.validate-form, .validate-form form').validate({
		messages: {
			password2: {
				password_confirm: " ",
				equalTo: "Please enter the same password as above."	
			}
	  }
	});

  $('#shipping_info').slideUp('fast');

  $('#billing_for_shipping').click(function() {
   if ($('#billing_for_shipping').is(':checked')) {
     $('#shipping_info').slideUp('fast',function(){
      $('#shipping_first_name').removeClass('required');
      $('#shipping_last_name').removeClass('required');
      $('#shipping_address').removeClass('required');
      $('#shipping_city').removeClass('required');
      $('#shipping_state').removeClass('required');
      $('#shipping_zip').removeClass('required');
     });
   } else {
     $('#shipping_info').slideDown('fast',function(){
      $('#shipping_first_name').addClass('required');
      $('#shipping_last_name').addClass('required');
      $('#shipping_address').addClass('required');
      $('#shipping_city').addClass('required');
      $('#shipping_state').addClass('required');
      $('#shipping_zip').addClass('required');
     });
   }
  });

  $(".preview-link").tooltip({ effect: 'slide', position: 'center right', offset:	[9, 5], relative: true });

  $("a[rel^='prettyPhoto']").prettyPhoto({
      animationSpeed: 'normal', /* fast/slow/normal */
      padding: 40, /* padding for each side of the picture */
      opacity: 0.35, /* Value betwee 0 and 1 */
      showTitle: true, /* true/false */
      allowresize: true, /* true/false */
      counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
      theme: 'light_square', /* light_rounded / dark_rounded / light_square / dark_square */
      callback: function(){}
  });

});
