// JavaScript Document

$(function() {

    // ------------------------------------------------------------------------------------
    // Zoom
		var options =
		{
					zoomWidth: 250,
					zoomHeight: 571,
					position : 'left',
					yOffset :-250,
					xOffset :100
	
	
		}
		$(".jqzoom").jqzoom(options);
    // Zoom
    // ------------------------------------------------------------------------------------


    // ------------------------------------------------------------------------------------
    // Effet ancres
    if ($("a[href*=#]").length) 
    {
        $('a[href*=#]').click(function() {
        
            var $target = $(this.hash);
            $target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
            $('html,body').animate({ scrollTop: $target.offset().top },1000);
            return false;
        });
    }
    // Effet ancres
    // ------------------------------------------------------------------------------------

    // ------------------------------------------------------------------------------------
	// Effet logo
    $("#logo span").stop().animate({opacity: 0, left:"-250px"}); // Opera Fix
	$("#logo").hover(
    
        function() {
    		$("#logo #accueil").css({display:"block"});
            $(this).stop().animate({left: "40px" }, 400);
    		$(this).find('#accueil').stop().animate({left:"-20px", opacity: 1}, 500);
    	},
        function() {
            $(this).stop().animate({left: "27px"}, 300);
    		$(this).find('#accueil').stop().animate({left:"-250px", opacity: 0}, 400);
        }
    );
    // Effet logo
    // ------------------------------------------------------------------------------------


    // ------------------------------------------------------------------------------------
    // Menu lavaLamp
	$("#mh ul:first").lavaLamp({
		fx: "backout",
		speed: 500,
		click: function(event, menuItem) {
			$("#mh ul:first li").removeClass("current");
			$(this).addClass("current");
		}
	});
	
	$("#mh ul:first").hover(function() {
			$("#mh ul li").addClass("current2");
		},
        function() {				
			$("#mh ul li").removeClass("current2");
	});/**/
    // Menu lavaLamp
    // ------------------------------------------------------------------------------------
	
		
    // ------------------------------------------------------------------------------------
	/* click rubrique */
		$("#mh05 li a").click(function() {
									  	   
			$("#mh05 li").removeClass("current");
			$(this).parent('li').addClass("current");
		});
	/* click rubrique */
    // ------------------------------------------------------------------------------------	


    // ------------------------------------------------------------------------------------
	// Effet éléments  Bandeau home
    // On attend quelques fractions de seconde avant d'afficher le toolTip 
    $("#cnrs, #polytechnique").css({top: "-10em", display:"none"});
	$("#accroche").css({top: "41px", right: "4em", display:"none", opacity: "0"});
	$("body").css({opacity: "0.3"});
		setTimeout(
		function() { 
			$("body").animate({opacity: "1"}, 500);
		},0);
		setTimeout(
		function() { 
			$("#cnrs").css({display:"block"});
			$("#cnrs").animate({top: "37px"}, 300);
		},500);
		setTimeout(
		function() { 
			$("#polytechnique").css({display:"block"});
			$("#polytechnique").animate({top: "37px"}, 300);
		},700);
		setTimeout(
		function() { 
			$("#accroche").css({display:"block"});
			$("#accroche").animate({top: "41px", right: "197px", width: "400", opacity: "1"}, 600);
		},900);
		
		/* hover accroche fabricant */
		/*$("#polytechnique").hover(function() {
			$("#polytechnique").stop().animate({top: "42px"}, 300);
			$("#accroche").stop().animate({top: "41", right: "185px"}, 600);
		},
		function() {
			$("#polytechnique").stop().animate({top: "37px"}, 200);
			$("#accroche").stop().animate({top: "41px", right: "197px", opacity: "1"}, 300);
		});*/
		
		
		/* hover accroche fabricant */
		/*$("#cnrs").hover(function() {
			$("#cnrs").stop().animate({top: "42px"}, 300);
		},
		function() {
			$("#cnrs").stop().animate({top: "37px"}, 200);
		});*/
	// Effet éléments  Bandeau home
    // ------------------------------------------------------------------------------------


    // ------------------------------------------------------------------------------------
	// Anim Visuel Home
    // On attend quelques fractions de seconde avant d'afficher le toolTip 
	$("#visuel102").css({left: "45em", display:"none", opacity: "0"});
   /* $("#visuel").css({height: "0px", overflow: "hidden", display:"block"});
	$("#visuel101").css({left: "-40em", top: "-150px", display:"block", opacity: "0"});
	$("#visuel102").css({left: "45em", display:"none", opacity: "0"});
	$("#visuel103").css({left: "45em", display:"none", opacity: "0"});
	$("#visuel104").css({left: "45em", display:"none", opacity: "0"});
	
		setTimeout(
		function() { 
			$("#visuel").css({display:"block", overflow: "visible"});
			$("#visuel").animate({height: "294px"}, 600);
		},500);

		function vague1()
		{
				//$("#visuel101").css({display:"block"});
				$("#visuel101")
				.animate({left: "780px", top: "0", opacity: "1"}, 3500)
				
				//.animate({left: "780px", opacity: "1"}, 3000)
				.animate({left: "90em", top: "-150px", opacity: "0"}, 3500)
				.animate({left: "-40em", opacity: "0"}, 3000,
				//.animate({left: "780px", top: "0", opacity: "1"}, 1500,

				'', function() { vague1();} );
		}	
		vague1();
		*/
		
		setTimeout(
		function() { 
			$("#visuel102").css({display:"block"});
			$("#visuel102").animate({left: "465px", opacity: "1"}, 600);
		},1300);
		/*
		setTimeout(
		function() { 
			$("#visuel103").css({display:"block"});
			$("#visuel103").animate({left: "465px", opacity: "1"}, 600);
		},1500);
		setTimeout(
		function() { 
			$("#visuel104").css({display:"block"});
			$("#visuel104").animate({left: "465px", opacity: "1"}, 600);
		},1600);*/

		/* hover accroche fabricant */
		/*$("#polytechnique").hover(function() {
			$("#polytechnique").stop().animate({top: "42px"}, 300);
			$("#accroche").stop().animate({top: "41", right: "185px"}, 600);
		},
		function() {
			$("#polytechnique").stop().animate({top: "37px"}, 200);
			$("#accroche").stop().animate({top: "41px", right: "197px", opacity: "1"}, 300);
		});*/
		
		
		/* hover accroche fabricant */
		/*$("#cnrs").hover(function() {
			$("#cnrs").stop().animate({top: "42px"}, 300);
		},
		function() {
			$("#cnrs").stop().animate({top: "37px"}, 200);
		});*/
	// Anim Visuel Home
    // ------------------------------------------------------------------------------------

    // ------------------------------------------------------------------------------------
	// Effet étoile
	/*var $elie = $("#motiffooter");
	rotate(0);
    //var timer_rotate = null;
	function rotate(degree) 
    {        
		$elie.css({ '-webkit-transform': 'rotate(' + degree + 'deg)'});  
		$elie.css({ '-moz-transform': 'rotate(' + degree + 'deg)'}); 
		timer_rotate = setTimeout(function() {
			rotate(++degree);
		},100);
	}*/
    
    /*$('a').click(function() {
    
        clearTimeout(timer_rotate);
        $elie.stop(true, false);
        $('a').unbind('mouseover');
        $('a').unbind('mouseout');
    });*/
	// effet étoile
    // ------------------------------------------------------------------------------------
	
	
    // ------------------------------------------------------------------------------------
    // Motif coté
       /* function motifcote()
        {
            //var ww =  1150;
            if($(window).width() > 1150) 
            {
                //var marg = ($(window).width() - ww) + "px";
                //$('html').css({"background-image" : "../img/fond.g.png"});
				//$('body').css({"background-image" : "../img/fond.d.png"});
				
				$('html').addClass("fg");
				$('body').addClass("fd");
				
				//$('html').css({"background-color" : "#e00"});
            }
            else
            {
                //$('html').css({"background-image" : "../img/fond.d.png"});
				//$('body').css({"background-image" : "../img/fond.g.png"});
				
				$('html').removeClass("fg");
				$('body').removeClass("fd");
				
				//$('html').css({"background-color" : "#f0f"});

            }        
        }
        
		// // Motif coté
        motifcote();
		$(window).resize(motifcote); */
    // Motif coté
    // ------------------------------------------------------------------------------------


	// ------------------------------------------------------------------------------------
	// Changement de page avec animation
	$('a').click(function() {

		var rel = $(this).attr('rel');
		if (rel == 'noanim')  // rel="noanim" desactive l'animation
	       return true;

		if ($(this).hasClass('zoom'))  // class="zoom" desactive l'animation
	       return true;

		if ($(this).hasClass('iframe'))  // class="iframe" desactive l'animation
	       return true;

		if ($(this).hasClass('iframe2'))  // class="iframe" desactive l'animation
	       return true;

	    var lien = $(this).attr('href');
	    if (!lien)
	       return true;
	    if (lien.length < 3)  // lien superieur a 3 caracteres
	       return true;
		if (lien.indexOf('#') == 0)  // ancres
	       return true;
		if (lien.indexOf('mailto:') == 0)  // mailto:
	       return true;
		if (lien.indexOf('zoom.php') >= 0)  // zoom.php
	       return true;

		/*setTimeout(
			function() { 
				$("#visuel").css({height: "29px", overflow: "hidden", display:"block"});
				$("#visuel").animate({height: "0"}, 300);
				//$("#home1, #page1").css({ display:"none" });
			},300);*/
		setTimeout(
			function() { 
				$("body").animate({opacity:"0.7"}, 30, function() {
					document.location.href = lien; 
				});
				//$("#home2, #page2").css({ display:"none" });
			},0);
		setTimeout(
			function() { 
				$("#accroche, #polytechnique, #cnrs").animate({opacity: "0.3"}, 30);
				//$("#home3, #page3").css({ display:"none" });
			},0);

        return false;
	});/**/
    // Changement de page avec animation
    // ------------------------------------------------------------------------------------
	
    // -------------------------------------------------------------------------------------------------
	// ColorBox
	$(".iframe").colorbox({
		width:"95%",
		height:"95%",
		iframe:true,
		opacity: 0.8,
		//slideshow:true,
		//slideshowSpeed:4000,
		//speed:800,

		//previous : "&laquo; précédent",
		//next : "suivant &raquo;",
		//close : "fermer",
		//slideshowStart: "démarrer le diaporama",
		//slideshowStop: "arrêter le diaporama",
		//current : "image {current} sur {total}"
	});
	
	$(".iframe2").colorbox({
		width:"95%",
		height:"95%",
		iframe:true,
		opacity: 0.8,
		//slideshow:true,
		//slideshowSpeed:4000,
		//speed:800,

		previous : "&laquo; précédent",
		next : "suivant &raquo;",
		close : "fermer",
		slideshowStart: "démarrer le diaporama",
		slideshowStop: "arrêter le diaporama",
		current : "image {current} sur {total}"
	});

	$(".zoom2").colorbox({
		opacity: 0.85,
		//slideshow:true,
		transition:"elastic",

		previous : "&laquo; précédent",
		next : "suivant &raquo;",
		close : "fermer",
		slideshowStart: "démarrer le diaporama",
		slideshowStop: "arrêter le diaporama",
		current : "image {current} sur {total}"
	});
	
	$(".zoom").colorbox({
		opacity: 0.6,
		//slideshowSpeed: 4000,
		slideshow:true,
		transition:"elastic",
		preloading:true,
		//speed:800,

		maxWidth:"90%",
		maxHeight:"90%",

		previous : "&laquo; précédent",
		next : "suivant &raquo;",
		close : "fermer",
		slideshowStart: "démarrer le diaporama",
		slideshowStop: "arrêter le diaporama",
		current : "image {current} sur {total}"
	});
    // ColorBox
    // -------------------------------------------------------------------------------------------------


});

