//Jquery fonctions
$(document).ready(function() {
	///// MENUS
	
	//Newsletter
	$('#newsletter').click(function() {
		$("#haut-newsletter").slideToggle();
		return false;
	});
	$('#haut-newsletter-fermer').click(function() {
		$("#haut-newsletter").slideUp();
		return false;
	});
	
	
	//Menu espace client
	var espace_check='';
	$("#haut-espace-client-nom").hover(
  		function () {
    		$("#haut-espace-client-detail").slideDown(600,"easeOutExpo");
			$("#navigation-panier-detail").hide();
			$("#menu-location").hide();
			$("#menu-vente").hide();
			espace_check='ok';
  		}, 
  		function () {
			espace_check='';
			setTimeout(function(){
				if (espace_check!='ok')
				{
					$("#haut-espace-client-detail").fadeOut("fast");
				}
   			}, 1000);
  		}
	);
	
	$("#haut-espace-client-detail").hover(
  		function () {
			espace_check='ok';
  		}, 
  		function () {
    		$("#haut-espace-client-detail").fadeOut("fast");
			espace_check='';
  		}
	);
	
	
	//Panier détail
	var panier_check='';
	$("#navigation-panier").hover(
  		function () {
    		$("#navigation-panier-detail").slideDown(500,"easeOutExpo");
			$("#haut-espace-client-detail").hide();
			$("#menu-location").hide();
			$("#menu-vente").hide();
			panier_check='ok';
  		}, 
  		function () {
			panier_check='';
			setTimeout(function(){
				if (panier_check!='ok')
				{
					$("#navigation-panier-detail").fadeOut("fast");
				}
   			}, 1000);
  		}
	);
	
	$("#navigation-panier").click(function() {
		MM_goToURL('parent','panier.htm');
		return false;
	});
	
	$("#navigation-panier-detail").hover(
  		function () {
			panier_check='ok';
  		}, 
  		function () {
    		$("#navigation-panier-detail").fadeOut("fast");
			panier_check='';
  		}
	);
	
	$('#panier-fidelites-tableau-lien').click(function() {
		$("#panier-fidelites-tableau").slideToggle();
		return false;
	});
	
	
	
	//Vente
	var vente_check='';
	$("#navigation-menu-vente").hover(
  		function () {
    		//$("#menu-vente").show();
			$("#menu-vente").fadeIn(350);
			$("#menu-location").hide();
			$("#haut-espace-client-detail").fadeOut();
			$("#navigation-panier-detail").fadeOut("fast");
			vente_check='ok';
  		}, 
  		function () {
    		vente_check='';
			setTimeout(function(){
				if (vente_check!='ok')
				{
					$("#menu-vente").hide();
				}
   			}, 1000);
  		}
	);
	
	$("#menu-vente").hover(
  		function () {
			vente_check='ok';
  		}, 
  		function () {
    		$("#menu-vente").hide();
			vente_check='';
  		}
	);
	
	
	//Location
	var location_check='';
	$("#navigation-menu-location").hover(
  		function () {
    		//$("#menu-location").show();
			$("#menu-location").fadeIn(350);
			$("#menu-vente").hide();
			$("#haut-espace-client-detail").fadeOut();
			$("#navigation-panier-detail").fadeOut("fast");
			location_check='ok';
  		}, 
  		function () {
			location_check='';
			setTimeout(function(){
				if (location_check!='ok')
				{
					$("#menu-location").hide();
				}
   			}, 500);
  		}
	);
	
	$("#menu-location").hover(
  		function () {
			location_check='ok';
  		}, 
  		function () {
    		$("#menu-location").hide();
			location_check='';
  		}
	);
	
	
	//Forfaits
	$("#navigation-menu-forfaits").mouseover(function() {
		$("#menu-vente").hide();
		$("#menu-location").hide();
		$("#haut-espace-client-detail").fadeOut();
		$("#navigation-panier-detail").fadeOut("fast");
		return false;
	});
	
	
	
	///// QTIP
	
	//Qtip
	$('.tooltip-qtip').qtip({
	position:
	{
		target: 'mouse',
		corner:
		{
			target: 'topMiddle',
			tooltip: 'bottomLeft'
		},
		adjust:
		{
			x: -3,
			y: 3
		}
	},
	style:
	{
		padding: '2px 8px',
		color: '#FFFFFF',
		background: '#3A3D43',
		border:
		{
			color: '#3A3D43'
			},
		tip:
		{
			corner: 'bottomLeft',
			size:
			{
				x: 5,
				y : 5
			}
		},
		name: 'dark' // Inherit the rest of the attributes from the preset dark style
	},
	show:
	{
		effect: function()
		{
			$(this).slideDown(50);
		}
		//effect: 'slide'
	}
	});
   
   //Photos
   $('.qtip-photo325').qtip({
	position:
	{
		target: 'mouse',
		corner:
		{
			target: 'topMiddle',
			tooltip: 'bottomLeft'
		},
		adjust:
		{
			x: -3,
			y: 3
		}
	},
	style:
	{
		padding: 1,
		color: '#000000',
		background: '#E6E6E6',
		border:
		{
			width: 3,
			color: '#E6E6E6'
		},
		width: 335.5,
		tip:
		{
			corner: 'bottomLeft',
			size:
			{
				x: 10,
				y : 10
			}
		},
		name: 'dark' // Inherit the rest of the attributes from the preset dark style
	}
	});
   
   $('.qtip-photo462').qtip({
	position:
	{
		target: 'mouse',
		corner:
		{
			target: 'topMiddle',
			tooltip: 'bottomLeft'
		},
		adjust:
		{
			x: -3,
			y: 3
		}
	},
	style:
	{
		padding: 1,
		color: '#000000',
		background: '#E6E6E6',
		border:
		{
			width: 3,
			color: '#E6E6E6'
		},
		width: 472.5,
		tip:
		{
			corner: 'bottomLeft',
			size:
			{
				x: 10,
				y : 10
			}
		},
		name: 'dark' // Inherit the rest of the attributes from the preset dark style
	}
	});
	
	
	
	///// COLORBOX
	
	//Identification
	$(".identification").click(function() {
		$.fn.colorbox({href:"identification.htm", iframe:true, innerWidth:530, innerHeight:300, overlayClose:false});
	});
	
	//Test configuration
	$(".test-configuration").click(function() {
		$.fn.colorbox({href:"test-configuration.htm", iframe:true, innerWidth:625, innerHeight:690});
	});
	
	
	
	///// SLIDE TO
   //Top page
	$('.top-page').click(function() {
		$.scrollTo( 0, 1000);
		return false;
	});
	
	
	///// VIDEO
	$(".video-liste-photo").hover(
  		function () {
			//$('.video').children().show();
			$(this).children().find('img.video').show();
  		}, 
  		function () {
    		$(this).children().find('img.video').hide();
  		}
	);
});

function MenuRubrique(id)
{	
	$('#specialite'+id).slideToggle();
	$('#rubriques-fleche'+id).toggleClass('menu-gauche-specialites-fleche menu-gauche-specialites-fleche2');
}

function HistoriqueToggle()
{
	$('#menu-gauche-videos-historique-plus').slideToggle();
}

function ColorboxVod(format,url)
{
	if (format == '400x300')
	{
		$.fn.colorbox({href:url, iframe:true, innerWidth:750, innerHeight:420, overlayClose:false});
	}
	else if (format == '600x450')
	{
		$.fn.colorbox({href:url, iframe:true, innerWidth:970, innerHeight:560, overlayClose:false});
	}
}

function ColorboxIdentification()
{
	$.fn.colorbox({href:"identification.htm", iframe:true, innerWidth:530, innerHeight:300, overlayClose:false});
}

function ColorboxRecommandation(id)
{
	$.fn.colorbox({href:"recommandation.htm?id="+id, iframe:true, innerWidth:530, innerHeight:350, overlayClose:false});
}

function HighlightFaq(id)
{
	$("#"+id).css('outline', '#B90E53 solid thin');
	$("#"+id).stop().animate( {outlineColor: '#FFFFFF'}, 2000)
	$("#"+id).css('background-color', '#FBCEE0');
	$("#"+id).animate( {backgroundColor: '#FFFFFF'}, {queue: false, duration: 2500})
	/*
	$("#question1").animate( { backgroundColor: '#FBCEE0' }, 2000)
    .animate( { backgroundColor: '#FFFFFF' }, 1000);
	*/
}

function HomeCarousel(id)
{
	for (i=1; i!=11; i++)
	{
		$("#nouveaute-detail"+i).hide();
	}
	
	var x = $("#nouveaute"+id).offset().left;
	var y = $("#nouveaute"+id).offset().top;
	$("#nouveaute-detail"+id).show();
	document.getElementById("nouveaute-detail"+id).style.left = (x-150)+"px";
	document.getElementById("nouveaute-detail"+id).style.top = (y-95)+"px";
	
	$("#nouveaute-detail"+id).mouseleave(function() {
		$("#nouveaute-detail"+id).hide();
		return false;
	});
}


