var newsSliderThumbs = [];

jQuery(document).ready(function($) {
	$("ul#teamImgList li").hover(
		function() {
			$(this).find(".pinkOverlay").css({opacity:0.0}).animate({"opacity":0.45},300);
		},
		function() {
			$(this).find(".pinkOverlay").stop().animate({"opacity":0},200);
		}
	);
	$('#homeRotator').cycle({ 
		fx:    'fade', 
		timeout:'3000',
		pause:  false 
	});
	$('#accoladeRotator').cycle({ 
		fx:    'fade', 
		timeout:'7000',
		pause:  false 
	});
	
	  // bind selectbox in the form
	  var $filterType = $('form#filter option[name="type"]');

	  // get the previous and current client collections
	  var $currentClient = $('ul#currentClients');
	  var $previousClient = $('ul#previousClients');
	  //console.log($currentClient); console.log($previousClient);
	  	  
	  // clone first and second client collections
	  var $currentClientData = $currentClient.clone();
	  var $previousClientData = $previousClient.clone();
	  
	  // attempt to call Quicksand on every form change
	  $("form#filter").change(function(e) {
		if ($($filterType+':selected').val() == 'all') {
		  var $filteredCurrentData = $currentClientData.find('li');
		  var $filteredPreviousData = $previousClientData.find('li');
		} else {
		  var $filteredCurrentData = $currentClientData.find('li[data-type=' + $($filterType+":selected").val() + ']');
		  var $filteredPreviousData = $previousClientData.find('li[data-type=' + $($filterType+":selected").val() + ']');
		}

		$currentClient.quicksand($filteredCurrentData, {
		  duration: 800,
		  easing: 'easeInOutQuad'
		});
		$previousClient.quicksand($filteredPreviousData, {
		  duration: 800,
		  easing: 'easeInOutQuad'
		});
	
	  });
	  
	$("div#clientsGrid a.clientLink, div.newsStand a.newsstandLink").live("mouseover mouseout", function(event) {
		if ( event.type == "mouseover" ) {
			$(this).find(".pinkOverlay").css({opacity:0.0}).animate({"opacity":0.45},300);
		} else {
			$(this).find(".pinkOverlay").stop().animate({"opacity":0},200);
		}
	});
});

jQuery(window).load(function() {
    //Newsstand Asset view
    jQuery("#newsstand-slider").anythingSlider({
        autoPlay: false,
        vertical: true,
        buildArrows: false,
        buildNavigation: true,
        buildStartStop: false,
        resizeContents: false,
        delay: 5000,
        animationTime : 700,
        hashTags: false,
        easing : "easeInOutExpo",
        onInitialized: function(e, slider) { $(slider.$el).css({opacity: 0.0, visibility: "visible"}).animate({opacity: 1.0},100); },
        navigationFormatter : function(i, panel){
              return '<img class="tooltip-img" src="'+newsSliderThumbs[i-1]+'" /><span class="pink-overlay"></span></span>';
        }
    });
});
