var over=true;
function killOver(){
	over=false;
}

$(document).ready(function(){
	
	// MENU
	var base=document.getElementsByTagName('base')[0].href;
	
	$(".menu a").mouseenter(function(){
		if(over && !$(this).find("h2").hasClass("active")){
			//window.location = base+$(this).attr("href");
		}
	});

	// MENU PORTFOLIO
	
	$(".navTop a").mouseenter(function(){
		if(over && !$(this).find("h2").hasClass("active")){
		//	effaceTab();
			//effaceRub();
			//window.location = base+$(this).attr("href");
		}
    });
	
	// BOX
	
	$(".navLeft li").mouseenter(function(){
		if(over && !$(this).hasClass("active")){
			effaceBox();
			
			var value=$(this).attr("name");
			$(this).addClass("active");
			$(".navRight ."+value.toString()).css("display","block").addClass("active");
			afficheImage(value+1);
			//window.location = base+$(this).find("a").attr("href");
		}
    });
	
	// RUB IMAGE
	
	$(".rub img").mouseenter(function(){
		if(over)afficheImage($(this).attr("value"));
	});
	
	$(".rub h5").mouseenter(function(){
		if(over && $(this).attr("value") && $("#iframe").attr('src')!==$(this).attr("value")){
			$("#image").css("display","none").attr("title","");
			$("#iframe").css("display","block").attr('src',$(this).attr("value"));
		}
	});
	
	$("#iframe").mouseover(function() {
 		$(".nav").css("opacity",.6);
		$(".header").css("opacity",.6);
		killOver();
	});
	
	// FONCTIONS
	
	function afficheImage(lien){
		if($("#image").attr("title")!==lien){
			$("#iframe").css("display","none").attr('src','');
			$("#image").attr('src','links/image/'+lien+'.jpg').load(function(){
				$("#image").css("display","block").attr("title",lien);
			})
		}
	}
	function effaceTab(){
		$(".tab[value=active]").css({display:"none"}).removeAttr("value");
		$(".nav li .active").removeClass("active").stop().animate({borderBottomWidth:"2px",opacity:.6,marginBottom:"2px"},200);
	}
	function effaceRub(){
		$(".rub[value=active]").css("display","none").removeAttr("value");
	}
	function effaceBox(){
		$(".tab .active").removeClass("active");
		$(".navRight .active").css("display","none").removeClass("active");
	//	$(".tab .active").removeClass("active").stop().animate({borderRightWidth:"0px"},200).find(".in").stop().animate({marginLeft:"0px"},200);
	}
	function effaceRubTab(){
		$(".rubTab[value=active]").removeAttr("value").css("display","none");
	}
	/*
	function slideTous(balise,vitesse){
		balise.hide();
		var childNumber = 0;
		function afficheElement() {
			balise.eq(childNumber).stop().slideDown(vitesse, afficheElement);
			++childNumber;
		}
		afficheElement();
	};
	slideTous($(".actu li"),200);
	slideTous($(".contact li"),200);
	
	if($(".navLeft").attr("value")=="slide"){
	//	$(".navLeft").css("display","none").slideDown(300);
	}

	var rub=$(".navRight");
	var _boxTop=$(".tab .active").offset().top-$(".nav").offset().top;
	var _marginTop=_boxTop-$(".navRight").height()/2;
	if(_marginTop+rub.height()>400)_marginTop-=(_marginTop+rub.height()-400);
	if(_marginTop<0)_marginTop=0;
	
	//rub.css({marginTop:_marginTop+"px"});
	*/

});
