var isMSIE = /*@cc_on!@*/false;

$(document).ready(function(){

	// INITIALIATION
	var $menu = $("#menu");
	var $menuLinks = $("#menu a");
	var $content = $("#content");
	var $contentContainer = $("#contentContainer");
	var $sep = $(".septest");
	var $menuSup=$("#lesIrisAbout a");
	var $backToTop=$(".backToTop");
	
	$menuLinks.click(scrollPage);
	$menuSup.click(scrollPage);
	$backToTop.click(scrollTop);


	function scrollPage(e) {
		e.preventDefault(e); 
	
		var whereTo = $(this).attr("href");
		var targetLink = whereTo.substring(1); //remove hash
		var offset = parseInt($("#header").css("height"));
		
		//correction car le parseInt renvoie NaN sous IE
		if(isMSIE==true){
			offset=202;
		}
	
		//if there is a div on this page where id = whereTo, then scroll to it
		if($("#"+targetLink).text() != ''){
			$.scrollTo( $("#"+targetLink), 500, {offset: {top:-offset+1, left:0}});

		} else{
	
			window.location = rootPath + whereTo;
	
		}

	};
	
	function scrollTop(e) {
		e.preventDefault(e); 
	
		var whereTo = $(this).attr("href");
		var targetLink = whereTo.substring(1); //remove hash
		var offset = parseInt($("#header").css("height")) + 60;
		
		//correction car le parseInt renvoie NaN sous IE
		if(isMSIE==true){
			offset=202;
		}
	
		//if there is a div on this page where id = whereTo, then scroll to it
		if($("#"+targetLink).text() != ''){
			$.scrollTo( $("#"+targetLink), 500, {offset: {top:-offset+1, left:0}});

		} else{
	
			window.location = rootPath + whereTo;
	
		}

	};
	
    $('a.lightbox').lightBox(); // Select all links with lightbox class

	$("#slider").easySlider({
		auto: false,
		continuous: true,
		numeric: true
	});

    $("#commentForm").validate();
    

	//OPACITE    
//    var menuTimeout;
//    menuTimeout = setTimeout(collapseMenu, 10000);
//
//	$('#header').hover(function() {
//
//	    clearTimeout(menuTimeout);
//	    menuTimeout = setTimeout(expandMenu, 100);
//	}, collapseMenu);
//
//	
//	function expandMenu(){
//		$menu.stop();
//
//	    $menu.animate({opacity:1}, 200);
//	    $sep.animate({opacity:1}, 200);
//	}
//
//	function collapseMenu(){
//
//		clearTimeout(menuTimeout);
//		$menu.stop();
//		menuTimeout = setTimeout(collapseMenuReal, 5000);
//	}
//	
//	function collapseMenuReal() {
//	
//		$menu.animate({opacity:0.5}, 200);
//		$sep.animate({opacity:0.3}, 200);
//
//	}




});

