$(function() {

/** slideshow **/
	$('.slideshow').cycle({
		fx: 'fade'
	});
	
/** Fancybox **/
	$("a[rel=accueil]").fancybox({
		'titleShow'			: false,
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'cyclic' 			: 'true',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-over">' + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
	});
	$("a[rel=planquette]").fancybox({
		'titleShow'			: false,
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'cyclic' 			: 'true',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-over">' + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
	});
	$("a[rel=ternoise]").fancybox({
		'titleShow'			: false,
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'cyclic' 			: 'true',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-over">' + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
	});
	$("a[rel=crequoise]").fancybox({
		'titleShow'			: false,
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'cyclic' 			: 'true',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-over">' + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
	});
	
/** contact : slidingLabels **/
	$('form#form_contact .slider label').each(function(){
		var labelColor = '#393f2b';
		var restingPosition = '5px';
		
		$(this).css({
			fontSize	: '12px',
			fontStyle	: 'italic',
			color 		: labelColor,
			position	: 'absolute',
			top			: '5px',
			left		: restingPosition,
			display		: 'inline',
			'z-index'	: '99'
		});	
		
		var inputval = $(this).next().val();
		
		var labelwidth = $(this).width();
		var labelmove = labelwidth + 5 +'px';
		
		if(inputval !== '') {
			$(this).stop().animate({ 'left':'-'+labelmove }, 1);
		}    	
		
		$('input, textarea').focus(function() {
			var label = $(this).prev('label');
			var width = $(label).width();
			var adjust = width + 5 + 'px';
			var value = $(this).val();
			
			if(value == '') {
				label.stop().animate({ 'left':'-'+adjust }, 'fast');
			}
			else {
				label.css({ 'left':'-'+adjust });
			}
		}).blur(function(){
			var label = $(this).prev('label');
			var value = $(this).val();
			
			if(value == '') {
				label.stop().animate({ 'left':restingPosition }, 'fast');
			}
		});	
	});
});
