$(document).ready(function() {
/*   $('#slideshow').cycle({ 
      fx:     'fade', 
      speed:  'slow', 
      timeout: 3000,
      pause: 'true',
      pager: '#slideshow-nav',
      activePagerClass: 'active',
      pagerAnchorBuilder: function(idx, slide) {
        return '<a href="#"></a>'
      }
  });
  
  $('.go-to-top a').click(function(){
    if ( $.browser.webkit ) {$("body").animate({scrollTop:0}, 1000);}
    else{$("html").animate({scrollTop:0}, 1000);}
    return false;    
  });
 
  if ($('#subnav').length > 0) {
    var offset = $("#subnav").offset();
    var topPadding = 15;
    $(window).scroll(function() {
      if ($(window).scrollTop() > offset.top) {
        $("#subnav").stop().animate({
          marginTop: $(window).scrollTop() - offset.top + topPadding
        });
      } else {
        $("#subnav").stop().animate({
          marginTop: 0
        });
      };
    });
  }*/
  
/*  $('#headnav li div').mouseout(function(){
    $('#headnav li div').hide();
    $("#headnav li a").removeClass();
  });
  $("#headnav li a").hover(function(){
    $("#headnav li a").removeClass();  
    $('#headnav li div').hide();
    $(this).addClass('active');
    $(this).parent().children("div").toggle();    
  });  */
  
    function addMega() {
      $(this).addClass("hover");$/*(this).find('.drop').animate({opacity: 1.0 }, { duration: 75 });*/
    }
    function removeMega() {
      var extended = this;$(extended).removeClass("hover");
      /*$(this).find('.drop').animate({opacity: 0.0 }, { duration: 75, complete: function(){ $(extended).removeClass("hover"); }});*/
    }

    var megaConfig = {
         interval: 0,
//         sensitivity: 10,
         over: addMega,
         timeout: 0,
         out: removeMega
    };

    $("#headnav li.extended").hoverIntent(megaConfig)

/*FIND - pushtabs*/
  $(".prd-content").hide();
  $(".prd-content:first").show();  
  $("#prd-tabs li:first a.tab").addClass("active").show()

  $("#prd-tabs li a.tab").click(function() {
    $("#prd-tabs li a.tab").removeClass("active"); 
    $(this).addClass("active"); 
    $(".prd-content").hide();
    var activeTab = $(this).attr("href");
    $(activeTab).fadeIn('slow');
    return false;
  });

  $('#gallery-slideshow').cycle({ 
    fx:     'fade', 
    speed:  'fast', 
    timeout: 5000,
    pause: 1,
    activePagerClass: 'active',
    slideResize: 0,
    pager:  '#gallery-pager',
     
    // callback fn that creates a thumbnail to use as pager anchor 
    pagerAnchorBuilder: function(idx, slide) { 
      var src = slide.src.split('&')[0];
      return '<a href="#"><img src="' + src + '&amp;height=50" /></a>'; // &amp;height=50
    }
  });

  $('div#filter ul li input').click(function() {
    if($(this).is(':checked')) {
      //$('#prdlist ul:not([class*=' + $(this).attr('class') + '])').addClass('fade');
      $('#prdlist ul:not([class*=' + $(this).attr('class') + '])').animate({opacity: 0.25});
    }
    else {
      var currentClass = $(this).attr('class');
      var checkedClasses = []
      $('div#filter ul li input:checked').each(function() {
        checkedClasses = checkedClasses.concat($(this).attr('class').split(/\s+/));
      });
    
      $('#prdlist ul:not([class*=' + currentClass  + '])').each(function() {
        var currentProductClasses = $(this).attr('class').split(/\s+/);
        if(checkedClasses.length > 0) {
          var t = checkedClasses.filter(function(element, index, array) {
            return ($.inArray(element, currentProductClasses) == -1);
          });
          if(t.length > 0) {
            $(this).animate({opacity: 0.25});
          }
          else {
            $(this).animate({opacity: 1.0});
          }
        }
        else {
          $(this).animate({opacity: 1.0});
        }
      });
    }
  })
    
  $('#prdlist ul').click(function(event) { 
    if($(this).attr('class').match(/fade/) != null) {
      event.stopPropagation(); 
      return false; 
    }
  });

});

//Cufon.replace('.push-quote h2, .profile h2, .profile small');
