$(function() {

	// do something on document ready
	//$(".products").fadeTo(2000,0.4);
	//$(".products").fadeTo("fast", 0.4); // This sets the opacity of the thumbs to fade down to 0% when the page loads
	$('div.fader')
		  .bind('fadeInBaby',function(e) {
		  
			if ($(this).hasClass('type')) {	
					$(this).fadeTo(100,1,function(){ 
						$(this).next().length && $(this).next().trigger("fadeInBaby"); 
					})
			}
			else {	
				$(this).fadeTo('fast',0.7,function(){ 
				$(this).next().length && $(this).next().trigger("fadeInBaby"); 
				})
			}
		  })
		  .eq(0)
			.trigger('fadeInBaby');
			
	$('div.faderInner')
		  .bind('fadeInnerBaby',function(e) {
		  
			if ($(this).hasClass('type')) {	
					$(this).fadeTo(1000,1,function(){ 
						$(this).next().length && $(this).next().trigger("fadeInnerBaby"); 
					})
			}
			else {	
				$(this).fadeTo('fast',0.7,function(){ 
				$(this).next().length && $(this).next().trigger("fadeInnerBaby"); 
				})
			}
		  })
		  .eq(0)
			.trigger('fadeInnerBaby');			
	
	$(".fader").hover(function(){
			$(this).fadeTo("normal", 1.0); // This should set the opacity to 100% on hover
		},function(){
			$(this).fadeTo("slow", 0.7); // This should set the opacity back to 0% on mouseout
		//$(".thumbnail").removeClass("thumbnailbg").show(); // This should make the thumbnail show always
	});
	
	$(".faderInner").hover(function(){
			$(this).fadeTo("normal", 1.0); // This should set the opacity to 100% on hover
		},function(){
			$(this).fadeTo("slow", 0.7); // This should set the opacity back to 0% on mouseout
		//$(".thumbnail").removeClass("thumbnailbg").show(); // This should make the thumbnail show always
	});	
	
	$("div.fader a.fancybox").fancybox({
		'overlayShow': false, 
		'zoomSpeedIn': 800, 
		'zoomSpeedOut' : 800,
		'hideOnContentClick': true
	});

	$("div.fader").each(function(){
        $(this).append("<span>"+ $(this).find('a').attr('title') +"</span>");
    });
	
});