$(document).ready(function() {
	$('.slider-hide-all').hide();
	$('#slider1').show();

	$('.del').live('click',function(){
		var lien = $(this).attr("title");
		$.post(lien, function(data) {
			$('#result').empty();
			$('#result').append(data);
		})
	});
	
	$("#various3").fancybox({
		'showCloseButton'		:	true,
		'hideOnOverlayClick'	:	0,
		'width'					: 	400,
		'height'				:	100,
		'autoScale'				:	false,
		'transitionIn'			:	'none',
		'transitionOut'			:	'none',
		'type'					:	'iframe'
	});
	
			$("a[rel=example_group]").fancybox({
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'titlePosition' 	: 'over',
				'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
					return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
				},
				'onComplete' :  function() { 
				    if ($('.up').css("display") != "none") {
				    $('.up').toggle(); }
				    } ,	
				'onClosed': function() { 
				    $('.up').toggle();
				    } 
			});

	var position = 1;
	setInterval(function() {
		if(position == 3) {
			position = 1;
		} else {
			position++;
		}
		if($('#slider').hasClass('play')) {
			changeSlider(position);
		}
	}, 5000);

	$('#mail').focusin(function() {
		var value = $('#mail').val();
		if(value == 'monemail@adresse.fr') {
			$('#mail').val('');
		}
	});
});

// Fonction du slider
function changeSlider(position) {
	$('.slider-hide-all').hide();
	$('#slider'+position).show();
	$(".news").removeClass('up');
	$(".news").addClass('down');
	$("#sliderPosition"+position).removeClass('down');
	$("#sliderPosition"+position).addClass('up');
}

function change() {
	$('#slider').removeClass('play');
}
