// JavaScript Document
var controltwo;
var controlthree;

$(document).ready(function() {
	controltwo = setInterval("$('#nextSlide').fadeTo(1000, 0.2);$('#nextSlide').fadeTo(1000, 1);",2000);
	controlthree = setInterval("$('#prevSlide').fadeTo(1000, 0.2);$('#prevSlide').fadeTo(1000, 1);",2000);
	
	
	
	$('#imgGal').crossSlide({
		fade: 1
	}, [
		{
		src:  '_kenburns/IMG_8280.jpg',
		from: 'bottom left 1x',
		to:   'top right 1x',
		time: 16
	}, {
		src:  '_kenburns/IMG_8302.jpg',
		from: 'top left',
		to:   'bottom right 1.2x',
		time: 17
	}, {
		src:  '_kenburns/IMG_8305.jpg',
		from: '100% 80% 1.5x',
		to:   '80% 0% 1.1x',
		time: 16
	}, {
		src:  '_kenburns/IMG_8299.jpg',
		from: 'bottom left 1x',
		to:   'top right 1.3x',
		time: 17
	}
	]);
	
	
	// affichage mot du chef
	$('#motChef').fadeIn(1500);
	
	// bouton midi
	$('#midiBT').click(function() {
		
		$('#galerie').hide();
		$('#topPan').fadeTo(10,1);
		$('#hoverAll').fadeTo(400, 0);
		
		$.ajax({
			type: "POST",
			url: "midiSlide.php",
			data: "ident=1",
			beforeSend: function(msg) {
				$("#loading").fadeIn("fast");
			},
			success: function(msg){
				$('#bigscreen').html(msg);			
				setTimeout(function() {
					$("#loading").fadeOut("fast");
					$('#sections').trigger('goto',[1]);
				}, 1500);
			}
		});
		
	});
	
	// bouton midi
	/*
	$('#newMenuSoir').click(function() {
		
		$('#galerie').hide();
		$('#topPan').fadeTo(10,1);
		$('#hoverAll').fadeTo(400, 0);
		
		$.ajax({
			type: "POST",
			url: "newMenuSoir.php",
			data: "ident=1",
			beforeSend: function(msg) {
				$("#loading").fadeIn("fast");
			},
			success: function(msg){
				$('#bigscreen').html(msg);			
				setTimeout(function() {
					$("#loading").fadeOut("fast");
					$('#sections').trigger('goto',[1]);
				}, 1500);
			}
		});
		
	});
	*/
	
	// bouton midi
	$('#newMenuSoir').click(function() {
		
		$('#galerie').hide();
		$('#topPan').fadeTo(10,1);
		$('#hoverAll').fadeTo(400, 0);
		
		$.ajax({
			type: "POST",
			url: "stValentin.php",
			data: "ident=1",
			beforeSend: function(msg) {
				$("#loading").fadeIn("fast");
			},
			success: function(msg){
				$('#bigscreen').html(msg);			
				setTimeout(function() {
					$("#loading").fadeOut("fast");
					$('#sections').trigger('goto',[1]);
				}, 1500);
			}
		});
		
	});
	
	// bouton soir
	$('#soirBT').click(function() {
		
		$('#galerie').hide();
		$('#topPan').fadeTo(10,1);
		$('#hoverAll').fadeTo(400, 0);
		
		$.ajax({
			type: "POST",
			url: "soirSlide.php",
			data: "ident=1",
			beforeSend: function(msg) {
				$("#loading").fadeIn("fast");
			},
			success: function(msg){
				$('#bigscreen').html(msg);			
				setTimeout(function() {
					$("#loading").fadeOut("fast");
					$('#sections').trigger('goto',[1]);
				}, 1500);
			}
		});
	});
	
	
	// bouton evénements
	$('#evntBT').click(function() {
		
		$('#galerie').hide();
		$('#topPan').fadeTo(10,1);
		$('#hoverAll').fadeTo(400, 0);
		
		$.ajax({
			type: "POST",
			url: "menuRev.php",
			data: "ident=1",
			beforeSend: function(msg) {
				$("#loading").fadeIn("fast");
			},
			success: function(msg){
				$('#bigscreen').html(msg);			
				setTimeout(function() {
					$("#loading").fadeOut("fast");
					$('#sections').trigger('goto',[1]);
				}, 1500);
			}
		});
	});
	
	/*
	$('#fakeMenu').click(function() {
		
		$('#galerie').hide();
		$('#topPan').fadeTo(10,1);
		$('#hoverAll').fadeTo(400, 0);
		
		$.ajax({
			type: "POST",
			url: "feuxMenu.php",
			data: "ident=1",
			beforeSend: function(msg) {
				$("#loading").fadeIn("fast");
			},
			success: function(msg){
				$('#bigscreen').html(msg);			
				setTimeout(function() {
					$("#loading").fadeOut("fast");
					$('#sections').trigger('goto',[1]);
				}, 1500);
			}
		});
	});
	*/
	
	
	// bouton cours
	$('#coursBT').click(function() {
	});
	
	// bouton cours
	$('#newsletterBT').toggle(function() {
		$('#leVraiMot').hide();
		$('#newsInsc').fadeIn();
	}, function() {
		$('#newsInsc').hide();
		$('#leVraiMot').fadeIn();		
	});
	
	// focus sur le champs d'email
	$('#myEmail').focus(function() {
		$('#myEmail').val("");
	});
	
	// perd le focus sur le champs d'email
	$('#myEmail').blur(function() {
		if($('#myEmail').val() == "") $('#myEmail').val("Entrez votre adresse email ici");
	});
	
	$('#valid').live('click',function() {
		// équivalent du submit
		$.ajax({
			type: "POST",
			url: "addEmail.php",
			data: "email="+$('#myEmail').val(),
			success: function(msg){
				$('#myEmail').blur();
				$('#myEmail').val("Merci !");
				$('#valid:visible').fadeOut("fast");
			}
		});
	});
	
	// control de l'adresse mail
	$('#myEmail').keyup(function(e) {
		var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
		var maValeur = $(this).val();
		if(reg.test(maValeur) == false) {
			$('#valid:visible').fadeOut("fast");
		}
		else {
			// c'est ok le mail est valid
			$('#valid:hidden').fadeIn("fast");
			
		}
	});
	
	// bouton 
	$('#galleryBT').click(function() {
		$('#galerie').fadeIn("fast");
		$('#motChef').hide();
		$('#hoverAll').fadeTo(400, 0.7);
		$('#bigscreen').empty();
		
		$('#slideshow').cycle({
			fx:     'fade',
			speed:  700,
			timeout: 4000
		});
		
		$('#slideMin').cycle({
			fx:     'scrollHorz',
			speed:  700,
			timeout: 0,
			pager:  '#navCont'
		});
		
		// calcul de la taille pour centrer les points
		var nbPage = $('.page').size() * 19;
		$('#navCont').css("width",nbPage);
		
		$("a[rel=example_group1]").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 : '') + ' - <a href="http://www.planat-guillaume.tk/" target="_blank">© Planat Guillaume</a></span>';
			}
		});
		
		$("a[rel=example_group2]").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 : '') + ' - <a href="http://www.planat-guillaume.tk/" target="_blank">© Planat Guillaume</a></span>';
			}
		});
		
		
	});
	
	
	
});
