// JavaScript Document
	
	// SLIDE DE HEADER
	
	$(function(){
	$('#movies').panelGallery({
		viewDuration: 3000,
		transitionDuration: 3000,
		boxSize: 45,
		boxFadeDuration: 500,
		boxTransitionDuration: 50,
		FX: new Array('panelSouthLeftRightReveal')
	});
	$('select').change(function(){ $('form').submit(); });
	});
	$(function() {

	$("#products").tabs("div.description", {event:'mouseover'});
	});

	
	
	
	// SLIDE AVEC COMMENTAIRE
	
	$(document).ready(function() {

	//Vitesse du slide
	var speed = 5000;
	
	//Une fois les largeurs et hauteurs spécifiées dans le s propriétés css de #slider
	//ce script les ajustera automatiquement
	$('#masque-galerie, #galerie li').width($('#slider').width());	
	$('#galerie').width($('#slider').width() * $('#galerie li').length);
	$('#masque-galerie, #galerie li, #masque-commentaires, #commentaires li').height($('#slider').height());
	
	var run = setInterval('newsscoller(0)', 8000);	
	
	$('#galerie li:first, #commentaires li:first').addClass('selected');
	$(function () {
		run = setInterval('newsscoller(0)',8000);	
		return false;
	});	
});


function newsscoller(prev) {

	// Sélectionne Get the current selected item (with selected class), if none was found, get the first item
	var current_image = $('#galerie li.selected').length ? $('#galerie li.selected') : $('#galerie li:first');
	var current_commentaires = $('#commentaires li.selected').length ? $('#commentaires li.selected') : $('#commentaires li:first');

	//if prev is set to 1 (previous item)
	if (prev) {
		
		//Get previous sibling
		var next_image = (current_image.prev().length) ? current_image.prev() : $('#galerie li:last');
		var next_commentaires = (current_commentaires.prev().length) ? current_commentaires.prev() : $('#commentaires li:last');
	
	//if prev is set to 0 (next item)
	} else {
		
		//Get next sibling
		var next_image = (current_image.next().length) ? current_image.next() : $('#galerie li:first');
		var next_commentaires = (current_commentaires.next().length) ? current_commentaires.next() : $('#commentaires li:first');
	}

	//clear the selected class
	$('#commentaires li, #galerie li').removeClass('selected');
	
	//reassign the selected class to current items
	next_image.addClass('selected');
	next_commentaires.addClass('selected');

	//Scroll the items
	$('#masque-galerie').scrollTo(next_image, 8000);		
	$('#masque-commentaires').scrollTo(next_commentaires, 8000);					
	
}


// +++++++ FANCY BOX +++++++++

//About FancyBox & NewsLetter Fancybox
		$("a#nl-inline,a#about-inline").fancybox({
			'transitionIn'		:'elastic',
			'overlayShow'		:false,
			'speedIn'			:600,
			'padding'			:0,
			'titleShow':false
		});
		
		//ContactForm FancyBox
		$("a#c-inline").fancybox({
			'transitionIn'		:'elastic',
			'overlayShow'		:false,
			'speedIn'			:600,
			'titleShow':false
		});
		
		//Screenshots FancyBox
		$("a[rel=s-thumbs]").fancybox({
			'transitionIn'	:	'elastic',
			'transitionOut'	:	'elastic',
			'titlePosition' 	: 'over',
			'speedIn'		:	600, 
			'speedOut'		:	200, 
			'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
				return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
			}
		});

		//Screenshots Fade Effect on hover
		$(function() {
			$(".s-thumbs").css("opacity","0.6");
			$(".s-thumbs").hover(function () {
			$(this).stop().animate({
			opacity: 1.0
			}, "medium");
			},
			function () {
			$(this).stop().animate({
			opacity: 0.6
			}, "medium");
			});
		});
