$(document).ready(function() {
  
  $("a.fb").attr('rel', 'gallery').fancybox({
    'padding' : 20
  });
  
  $('.ad-image').css('cursor', 'pointer');
  
	$('.ad-image').live('click', function(){		 
     var index = $(this).find('img').attr('title');
     $('#hiddenSlides').find('a.'+index).trigger('click');
	});
	
	$('#archiveSelect').change(function() {
	  $('#filterForm').submit();
	});


   /*
$("#subscribe").validate({
			debug: false,
			rules: {
				email: {
					required: true,
					email: true
				}
			},
			submitHandler: function(form) {
				// do other stuff for a valid form      
				$.post('subscribe.php', $("#subscribe").serialize(), function(data) {
					$('#thankyou').lightbox_me({
              centered: true
              });
				});
				
				
				
			}
		});
		
*/
		
		
		 $("#contactForm2").validate();
		 $("#webuyInquiry").validate();
		 $("#purchaseForm2").validate();
		 
		  		   
   
   $('#footernavbar li:last-child').addClass('last');
   $('#products li:last-child').addClass('last');
   $('.ad-gallery .ad-thumbs li:last-child').addClass('thumblast');
   $('.slideWrapper li:not(:first)').addClass('inactive');
   
  $('.ad-gallery').adGallery();
   
   
   
    
 
   $('#slideshow img:not(:first)').hide();
    
    setInterval(function(){
      $('#slideshow :first-child').fadeOut()
         .next('img').fadeIn()
         .end().appendTo('#slideshow');}, 
      5000);
      

    $('#purchaseBttn').click(function(e) {
    $('#purchasePage').lightbox_me({
        centered: true, 
        onLoad: function() { 
            $('#purchasePage').find('input:first').focus()
            }
        });
    e.preventDefault();
    });
    
    $('#close').click(function (){
        $('#purchasePage').trigger('close');
    });
    
    $('.willusethislaterbutton').click(function(e) {
      $('#purchasePage').trigger('close');
         $('#thankyou').lightbox_me({
              centered: true
              });
          });
          
     $('#button').click(function(e) {
      $("#contactForm").validate();
          });
          
    $('#navbar li').hover(function(){
      $(this).addClass('hover');
    },
      function(){
      $(this).removeClass('hover');
    });
    
     $('#footernavbar li').hover(function(){
      $(this).addClass('hover');
    },
      function(){
      $(this).removeClass('hover');
    });
    
   
          
          
});







