var auto_testi;
// MENU DEROULANT

function findPosX(obj) {
	var curleft = 0;
	if(obj.offsetParent)
	while(1) {
		curleft += obj.offsetLeft;
		if(!obj.offsetParent)
		break;
		obj = obj.offsetParent;
	}
	else if(obj.x)
		curleft += obj.x;
		return curleft;
}

function findPosY(obj) {
	var curtop = 0;
	if(obj.offsetParent)
	while(1) {
		curtop += obj.offsetTop;
		if(!obj.offsetParent)
		break;
		obj = obj.offsetParent;
	}
	else if(obj.y)
		curtop += obj.y;
		return curtop;
}


function ouvre(quoi) {
	document.getElementById("btn_"+quoi).className = "menu_on";
	document.getElementById(quoi).style.top = (findPosY(document.getElementById("btn_"+quoi))+16)+"px";
	document.getElementById(quoi).style.left = (findPosX(document.getElementById("btn_"+quoi))-4)+"px";
	document.getElementById(quoi).style.display = "block";	
}

function ferme(quoi) {
	document.getElementById("btn_"+quoi).className = "";
	document.getElementById(quoi).style.display = "none";	
}

$(document).ready(function() {
	$(".description_page_1 IMG").css("cursor","pointer");
	$(".description_page_1 IMG").click(function() {
		var limage = $(this).attr("src");
		limage = limage.replace("images","imagesG");

		$.facebox({image : limage});
	});
	slide_testi();
});

function slide_testi() {
	var nb = Math.floor(Math.random() * 4);
	if(nb == 4) {
		nb = 3;
	}
	if(nb == 0) {
		nb = 1;
	}
	$(".testi").fadeIn();
	$(".testi").html($("#testi_"+nb).html());					
	
	auto_testi = setInterval(function(){
		auto_play_testi(nb+1);
	}, 15000);
//	auto_play_testi(nb);
}
function auto_play_testi(nb) {
	if(nb == 4) {
		nb = 1;
	}
	$(".testi").fadeOut(function() {
		$(".testi").fadeIn();
		$(".testi").html($("#testi_"+nb).html());
		clearInterval(auto_testi);
		auto_testi = setInterval(function(){
			auto_play_testi(nb+1);
		}, 15000);
	});
}