// JavaScript Document
var prev_menuClass = '';
var prev_obj = '';
var prev_obj2 = '';
var prev_top = '';
var prev_left = '';
var z = 100 ;

function synchronous_xml(fichier){
	if(window.XMLHttpRequest) // FIREFOX
	xhr_object = new XMLHttpRequest();
	else if(window.ActiveXObject) // IE
	xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	else
	return(false);
	xhr_object.open("GET", fichier, false);
	xhr_object.send(null);
	if(xhr_object.readyState == 4 && xhr_object.status == 200) return(xhr_object.responseXML.documentElement);
	else return(false);
}

function synchronous_html(fichier){
	if(window.XMLHttpRequest) // FIREFOX
	xhr_object = new XMLHttpRequest();
	else if(window.ActiveXObject) // IE
	xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	else
	return(false);
	xhr_object.open("GET", fichier, false);
	xhr_object.send(null);
	if(xhr_object.readyState == 4 && xhr_object.status == 200) return(xhr_object.responseText);
	else return(false);
}

function ouvreMenu(idObj) {
	if ((prev_obj!='') && (prev_obj != idObj)) {
		$('#'+prev_obj).animate({
		marginTop:prev_top,
		marginLeft:prev_left,
		opacity:0.8
		},400 );	
	}
	if (prev_obj != idObj) {
		prev_top = $('#'+idObj).css('margin-top') ;
		prev_left = $('#'+idObj).css('margin-left') ;	
		$('#'+idObj).animate({
			marginTop:"140" ,
			marginLeft:"285" ,
			opacity:1
		},400 );
		prev_obj2 = prev_obj ;
		prev_obj = idObj;
		return true;
	} else return false;
}
function fermeMenu(idObj) {
	if ((idObj!='')) {
		$('#'+idObj).animate({
		marginTop:prev_top,
		marginLeft:prev_left,
		opacity:0.8
		},400 );
		prev_obj = '';	
	}
}

function selMenu(menuClass) {
	if ((prev_menuClass != '') && (prev_menuClass != menuClass)) {
		$('.'+prev_menuClass).animate({
		marginLeft:"0"
		},400 );	
	}

	if (prev_menuClass != menuClass) {
		$('.'+menuClass).animate({
			marginLeft:"-40"
		},400 );
		prev_menuClass = menuClass;
		return true;
	} else return false;
}

function flip( idObj, idObjCible) {
	$('#'+idObj).click(function () {
		$('#'+idObjCible).toggle();
	});
}

function animContenuStandard () {
	$("#contenu").removeClass('carteCL');
	$("#contenu").removeClass('accueil');	
	$("#contenu").animate({
	opacity:.9,
	width:"712px",
	height:"362px"
	},400 , function() {
		$('#wrapper').columnize({ columns: 1 }); 
	});
}

function animCL () {
	$("#carteCL a").each(function() {
	$(this).animate({
		opacity:0
		}, 200);
	});
	$("#carteCL a").each(function() {
		$(this).animate({
			opacity:1,
			marginLeft:"0px" ,
			marginTop:"0px"
			}, 1000);
	});
}
function animCarteCL () {
	$("#contenu").removeClass('carteCL');
	$("#contenu").removeClass('accueil');
	$("#contenu").addClass('carteCL');
   $("#contenu").animate({
   	opacity:1,
   	top: "0px",
		left: "206px",
		width:"500px",
		height:"614px"
	}, 400 , function () {animCL ();} );
   $("#fermeInfoCL").click(function () {
		$("#contenu").animate({
			opacity:0,
			width:"0px",
			height:"0px",
			top:"202px",
			left:"51px"	
			}, 400)
		fermeMenu(prev_obj);
	}, 400 );
}
function animAccueil () {
	$("#contenu").removeClass('carteCL');
	$("#contenu").removeClass('accueil');
	$("#contenu").addClass('accueil');
	$("#contenu").animate({
	opacity:.9,
	width:"710px",
	height:"358px"
	},400 );	
}
function chargeTexteAnimHTML(idObj, fichier ,  type , galerie) {
	var xhr_object = null ;
	$("#contenu").animate({
	opacity:0,
	width:"0px",
	height:"0px",
	top:"202px",
	left:"51px"	
	}, 400 , function () {
		if (fichier!='') {
			document.getElementById(idObj).innerHTML = synchronous_html(fichier) ;
			if (galerie) {
				document.getElementById("galerie_ici").innerHTML = synchronous_html('./lib/affiche_galerie.php?g='+galerie);
			}
/*
		switch (type)
		{
				case 'carteCL' : animCarteCL () ; break;
				//case 'accueil' : animAccueil () ; break;
				default : animContenuStandard () ;
		}
*/
			if (galerie) {
				$("div.ppt").remove();
				$("div.pp_overlay").remove();
				$("div.pp_pic_holder").remove();
				$(".gallery a[rel^='prettyPhoto']").prettyPhoto({theme:'light_rounded'});
			}
		}
		animContenuStandard () ;
	});
}

function afficheMenu () {
	prev_obj2 = '';	
	prev_obj = '';
	prev_top = '';
	prev_left = '';
	var larg=140;
	var haut=60;
	
	var x=0;
	var y=0;
	z=100;
	$('ADN').each(function() { 
   	z++;
      $(this).css('z-index', z);
	});
	x=0;
   $("#menu1").animate({
   	marginLeft: x,
		marginTop: y,
		opacity:.8
	}, 400 );
	x=x+larg;
	$("#menu2").animate({
    	marginLeft: x,
      marginTop: y,
      opacity:.8
	}, 500 );
	x=x+larg;
   $("#menu3").animate({
   	marginLeft: x,
      marginTop: y,
      opacity:.8
	}, 350 );
	x=x+larg;
   $("#menu4").animate({
		marginLeft: x,
      marginTop: y,
      opacity:.8
	}, 300 );
	x=x+larg;
   $("#menu5").animate({
		marginLeft: x,
      marginTop: y,
      opacity:.8
	}, 300 );
	x=0;
	y=y+haut;
   $("#menu6").animate({
   	marginLeft: x,
		marginTop: y,
		opacity:.8
	}, 300 );
	x=x+larg;
   $("#menu7").animate({
   	marginLeft: x,
		marginTop: y,
		opacity:.8
	}, 300 );
	x=x+larg;
   $("#menu8").animate({
   	marginLeft: x,
		marginTop: y,
		opacity:.8
	}, 300 );
	x=x+larg;
   $("#menu9").animate({
   	marginLeft: "170",
		marginTop:y,
		opacity:.8
	}, 300 );
	x=x+larg;
   $("#menu10").animate({
   	marginLeft: x,
		marginTop: y,
		opacity:.8
	}, 300 );
	$("#menu1").mouseover(function(){
		$(this).animate({
			opacity:1}, 400 );
		$(this).css("z-index",z);
	});
	$("#menu1").mouseout(function(){
		$("#menu1").animate({
			opacity:.8 }, 200 );
		$("#menu1").css("z-index",99);	
	});
   
   $("#menu2").mouseover(function(){
		$(this).animate({
			opacity:1 }, 400 );
		$(this).css("z-index",z);
   });
   $("#menu2").mouseout(function(){
		$("#menu2").animate({
			opacity:.8 }, 200 );
		$("#menu2").css("z-index",99);	
   });

	$("#menu3").mouseover(function(){
		$(this).animate({
			opacity:1}, 400 );
		$(this).css("z-index",z);
   });
   $("#menu3").mouseout(function(){
		$("#menu3").animate({
			opacity:.8 }, 200 );
		$("#menu3").css("z-index",99);
   });
   
   $("#menu4").mouseover(function(){
		$(this).animate({
			opacity:1}, 400 );
		$(this).css("z-index",z);
   });
   $("#menu4").mouseout(function(){
		$("#menu4").animate({
			opacity:.8 }, 200 );
		$("#menu4").css("z-index",99);
   });

   $("#menu5").mouseover(function(){
		$(this).animate({
			opacity:1}, 400 );
		$(this).css("z-index",z);
   });
   $("#menu5").mouseout(function(){
		$("#menu5").animate({
			opacity:.8 }, 200 );
		$("#menu5").css("z-index",99);
   });

   $("#menu6").mouseover(function(){
		$(this).animate({
			opacity:1}, 400 );
		$(this).css("z-index",z);
   });
   $("#menu6").mouseout(function(){
		$("#menu6").animate({
			opacity:.8 }, 200 );
		$("#menu6").css("z-index",99);
   });
   
   $("#menu7").mouseover(function(){
		$(this).animate({
			opacity:1}, 400 );
		$(this).css("z-index",z);
   });
   $("#menu7").mouseout(function(){
		$("#menu7").animate({
			opacity:.8 }, 200 );
		$("#menu7").css("z-index",99);
   });
   
   $("#menu8").mouseover(function(){
		$(this).animate({
			opacity:1}, 400 );
		$(this).css("z-index",z);
   });
   $("#menu8").mouseout(function(){
		$("#menu8").animate({
			opacity:.8 }, 200 );
		$("#menu8").css("z-index",99);
   });
   
   $("#menu9").mouseover(function(){
		$(this).animate({
			opacity:1}, 400 );
		$(this).css("z-index",z);
   });
   $("#menu9").mouseout(function(){
		$("#menu9").animate({
			opacity:.8 }, 200 );
		$("#menu9").css("z-index",99);
   });
   
   $("#menu10").mouseover(function(){
		$(this).animate({
			opacity:1}, 400 );
		$(this).css("z-index",z);
   });
   $("#menu10").mouseout(function(){
		$("#menu10").animate({
			opacity:.8 }, 200 );
		$("#menu10").css("z-index",99);
   });
}

function chargeMenuHTML(idObj, fichier) {
	var xhr_object = null ;
     	$('ADN').each(function() { 
		$(this).animate({
        	marginLeft: "700",
        	marginTop:"-20",
        	opacity:"0.4"
      		}, 450 );
     	});	
	document.getElementById(idObj).innerHTML = synchronous_html(fichier);
	afficheMenu();
}

function chargeTexteHTML(idObj, fichier) {
	var xhr_object = null ;
	document.getElementById(idObj).innerHTML = synchronous_html(fichier);
}

function infoCL (fichier) {
	var xhr_object = null ;	
	document.getElementById('infoCL').innerHTML = synchronous_html(fichier);
}