// scripts for storiz.fr
// $$$$$$$$$$$$$$$$$$$$$


var links = jQuery('a').not('no-delay');

window.onunload = function(){}; /* resolves a bug in safari with the back button */


// ONLOAD
jQuery(window).load(function() {

	jQuery('#loading').hide('fast', function() {
		jQuery(this).remove();
		jQuery('#content').fadeTo('500',1);
	});
	
});


// ON READY
jQuery(document).ready(function() {
	
	jQuery('body').addClass('js');
	
	// fade avant redirection
	jQuery(links).click(function(e) {
		e.preventDefault();
		var redirect = jQuery(this).attr('href');
		var clicked = jQuery(this);
		jQuery('#content').fadeTo('100',0, function() {
			return jQuery(location).attr('href',redirect);
		});
	});
	
	// featured / slideshow
	if( jQuery('body').hasClass('home') ) {jQuery('#featured').cycle({pager : '#pager', prev : '#cycle-prev', next : '#cycle-next'});}
	
	jQuery('.box').hover(function() {
		$('.box').not(this).stop().animate({opacity: "0.3"}, 300);
		$(this).find('span').slideDown('fast');
	},function() {
		$('.box').not(this).stop().animate({opacity: "1"}, 300);
		$(this).find('span').slideUp('fast');
	});
	
	
	// video navigation
	
	if ( jQuery('body').hasClass('single-works') ) {
		jQuery('#nav-below').hover(function() {
			jQuery('#entry-header').stop().fadeTo('100',0.3);
		},function() {
			jQuery('#entry-header').stop().fadeTo('100',1);
		});
	}
	
});
