// remap jQuery to $
$(document).ready(function() {


	// infolettre
	$("#main_nav a.pop_infolettre").click(function(event) {
		 $('#infolettre').stop().animate({ top:-10 }, {duration: 1000,easing: 'easeOutQuint'});
		 $('#promo1').stop().animate({ top:-800 }, {duration: 1000,easing: 'easeOutQuint'});
	});

	$("#close_infolettre").click(function(event) {
		$('#infolettre').stop().animate({ top:-500 }, {duration: 1000,easing: 'easeOutQuint'});
	});
	
	// promo
	$("#main_nav a.pop_promo").click(function(event) {
		$('#infolettre').stop().animate({ top:-500 }, {duration: 1000,easing: 'easeOutQuint'});
		$('#promo1').stop().animate({ top:-10 }, {duration: 1000,easing: 'easeOutQuint'});
	});

	$("#close_promo").click(function(event) {
		$('#promo1').stop().animate({ top:-800 }, {duration: 1000,easing: 'easeOutQuint'});
	});

	
	// videos thumbnails
	$(".video_thumb").click(function(event) {
		theme.playToggle('stop');
		clearInterval(vars.slideshow_interval);
	});

	$(".video_thumb").hover(function(event) {
		 $(this).stop().animate({ opacity: 0.5 }, {duration: 'slow',easing: 'easeOutQuint'});
			},function(){$(this).stop().animate({ opacity: 1 }, {duration: 'slow',easing: 'easeOutQuint'});
			   });

	$("#call_video_frame1").fancybox({
				'width'				: 800,
				'height'			: 450,
				'autoScale'			: false,
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'type'				: 'iframe'
			});

	$("#call_video_frame2").fancybox({
				'width'				: 800,
				'height'			: 450,
				'autoScale'			: false,
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'type'				: 'iframe'
			});

	// Supersized background
	if( $('body').hasClass('home') ) {

	$.supersized({

				// Functionality
					slideshow               :   1,			// Slideshow on/off
					autoplay				:	1,			// Slideshow starts playing automatically
					start_slide             :   1,			// Start slide (0 is random)
					stop_loop				:	0,			// Pauses slideshow on last slide
					random					: 	0,			// Randomize slide order (Ignores start slide)
					slide_interval          :   3000,		// Length between transitions
					transition              :   1, 			// 0-None, 1-Fade, 2-Slide Top, 3-Slide Right, 4-Slide Bottom, 5-Slide Left, 6-Carousel Right, 7-Carousel Left
					transition_speed		:	500,		// Speed of transition
					new_window				:	1,			// Image links open in new window/tab
					pause_hover             :   0,			// Pause slideshow on hover
					keyboard_nav            :   0,			// Keyboard navigation on/off
					performance				:	1,			// 0-Normal, 1-Hybrid speed/quality, 2-Optimizes image quality, 3-Optimizes transition speed // (Only works for Firefox/IE, not Webkit)
					image_protect			:	1,			// Disables image dragging and right click with Javascript

					// Size & Position
					min_width		        :   980,			// Min width allowed (in pixels)
					min_height		        :   560,			// Min height allowed (in pixels)
					vertical_center         :   0,			// Vertically center background
					horizontal_center       :   1,			// Horizontally center background
					fit_always				:	0,			// Image will never exceed browser width or height (Ignores min. dimensions)
					fit_portrait         	:   1,			// Portrait images will not exceed browser height
					fit_landscape			:   0,			// Landscape images will not exceed browser width

					// Components
					slide_links				:	'blank',	// Individual links for each slide (Options: false, 'number', 'name', 'blank')
					thumb_links				:	1,			// Individual thumb links for each slide
					thumbnail_navigation    :   0,			// Thumbnail navigation

					slides 					:  	[			// Slideshow Images
														{image : 'media/images/home_pic1.jpg'},
														{image : 'media/images/home_pic2.jpg'}
												]

				});

	}

	if( $('body').hasClass('collection') ) {

	$.supersized({

				// Functionality
					slideshow               :   1,			// Slideshow on/off
					autoplay				:	0,			// Slideshow starts playing automatically
					start_slide             :   1,			// Start slide (0 is random)
					stop_loop				:	0,			// Pauses slideshow on last slide
					random					: 	0,			// Randomize slide order (Ignores start slide)
					transition              :   6, 			// 0-None, 1-Fade, 2-Slide Top, 3-Slide Right, 4-Slide Bottom, 5-Slide Left, 6-Carousel Right, 7-Carousel Left
					transition_speed		:	600,		// Speed of transition
					keyboard_nav            :   1,			// Keyboard navigation on/off
					performance				:	1,			// 0-Normal, 1-Hybrid speed/quality, 2-Optimizes image quality, 3-Optimizes transition speed // (Only works for Firefox/IE, not Webkit)

					// Size & Position
					min_width		        :   980,			// Min width allowed (in pixels)
					min_height		        :   560,			// Min height allowed (in pixels)
					vertical_center         :   0,			// Vertically center background
					horizontal_center       :   1,			// Horizontally center background
					fit_portrait         	:   1,			// Portrait images will not exceed browser height

					slides 					:  	[			// Slideshow Images
														{image : 'media/images/collection1.jpg'},
														{image : 'media/images/collection2.jpg'},
														{image : 'media/images/collection3.jpg'},
														{image : 'media/images/collection4.jpg'},
														{image : 'media/images/collection5.jpg'},
														{image : 'media/images/collection6.jpg'},
														{image : 'media/images/collection7.jpg'},
														{image : 'media/images/collection8.jpg'},
														{image : 'media/images/collection9.jpg'},
														{image : 'media/images/collection10.jpg'},
														{image : 'media/images/collection11.jpg'},
														{image : 'media/images/collection12.jpg'}
												]

				});


	}

		if( $('body').hasClass('promotions') ) {

	$.supersized({

				// Functionality
					slideshow               :   0,			// Slideshow on/off
					performance				:	1,			// 0-Normal, 1-Hybrid speed/quality, 2-Optimizes image quality, 3-Optimizes transition speed // (Only works for Firefox/IE, not Webkit)

					// Size & Position
					min_width		        :   980,			// Min width allowed (in pixels)
					min_height		        :   560,			// Min height allowed (in pixels)
					vertical_center         :   0,			// Vertically center background
					horizontal_center       :   1,			// Horizontally center background
					fit_portrait         	:   1,			// Portrait images will not exceed browser height

					slides 					:  	[			// Slideshow Images
														{image : 'media/images/promotion1.jpg'}

												]

				});


	}


	if( $('body').hasClass('service_client') ) {

	$.supersized({

				// Functionality
					slideshow               :   0,			// Slideshow on/off
					performance				:	1,			// 0-Normal, 1-Hybrid speed/quality, 2-Optimizes image quality, 3-Optimizes transition speed // (Only works for Firefox/IE, not Webkit)

					// Size & Position
					min_width		        :   980,			// Min width allowed (in pixels)
					min_height		        :   560,			// Min height allowed (in pixels)
					vertical_center         :   0,			// Vertically center background
					horizontal_center       :   1,			// Horizontally center background
					fit_portrait         	:   1,			// Portrait images will not exceed browser height

					slides 					:  	[			// Slideshow Images
														{image : 'media/images/bg_service.jpg'}

												]

				});


	}


	if( $('body').hasClass('apropos') ) {

	$.supersized({

				// Functionality
					slideshow               :   0,			// Slideshow on/off
					performance				:	1,			// 0-Normal, 1-Hybrid speed/quality, 2-Optimizes image quality, 3-Optimizes transition speed // (Only works for Firefox/IE, not Webkit)

					// Size & Position
					min_width		        :   980,			// Min width allowed (in pixels)
					min_height		        :   560,			// Min height allowed (in pixels)
					vertical_center         :   0,			// Vertically center background
					horizontal_center       :   1,			// Horizontally center background
					fit_portrait         	:   1,			// Portrait images will not exceed browser height

					slides 					:  	[			// Slideshow Images
														{image : 'media/images/bg_apropos.jpg'}

												]

				});


	}




});

function check_day() {
	if (document.getElementById('disponibilite_1').checked == true) {
		document.getElementById('div_day_1').style.display = 'block';
		document.getElementById('div_day_2').style.display = 'block';
	} else {
		document.getElementById('div_day_1').style.display = 'none';
		document.getElementById('div_day_2').style.display = 'none';
		document.getElementById('disponibilite_4').checked = false;
		document.getElementById('disponibilite_7').checked = false;
		document.getElementById('disponibilite_1').checked = false;
	}
}

function check_evening() {
	if (document.getElementById('disponibilite_2').checked == true) {
		document.getElementById('div_evening_1').style.display = 'block';
		document.getElementById('div_evening_2').style.display = 'block';
	} else {
		document.getElementById('div_evening_1').style.display = 'none';
		document.getElementById('div_evening_2').style.display = 'none';
		document.getElementById('disponibilite_5').checked = false;
		document.getElementById('disponibilite_8').checked = false;
	}
}

function check_night() {
	if (document.getElementById('disponibilite_3').checked == true) {
		document.getElementById('div_night_1').style.display = 'block';
		document.getElementById('div_night_2').style.display = 'block';
	} else {
		document.getElementById('div_night_1').style.display = 'none';
		document.getElementById('div_night_2').style.display = 'none';
		document.getElementById('disponibilite_6').checked = false;
		document.getElementById('disponibilite_9').checked = false;
	}
}

function newsletter_inscription() {
	var email = $('#email').val();
	var email_filter = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.) {2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);

	if (email == '' || !email_filter.test(email)) {
		$('#email_exists').hide();
		$('#email_success').hide();
		$('#email_error').fadeIn();
	}
	else {
		var data_string = 'email=' + email;
		$.ajax({
			type: 'GET',
			url: 'infolettre_inscription.php',
			data: data_string,

			error: function(XMLHttpRequest, textStatus, errorThrown) {
				alert(errorThrown);
			},

			success: function(msg) {
				//$('#debug').html(msg);
				if (msg != '') {
					if (msg == 'WRONG_EMAIL') {
						$('#email_success').hide();
						$('#email_exists').hide();
						$('#email_error').fadeIn();
					}
					else if (msg == 'EMAIL_EXISTS') {
						$('#email_success').hide();
						$('#email_error').hide();
						$('#email_exists').fadeIn();
					}
					else if (msg == 'OK') {
						$('#email_error').hide();
						$('#email_exists').hide();
						$('#email_success').fadeIn();
					}
				}
			}
		});
	}
}

