var t = 0;

//sfHover__ = function() {
//	if(!document.getElementById("nav")==null) {
//		var sfEls = document.getElementById("nav").getElementsByTagName("LI");
//		for (var i=0; i<sfEls.length; i++) {
//			sfEls[i].onmouseover=function() {
//				this.className+=" sfhover";
//			}
//			sfEls[i].onmouseout=function() {
//				this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
//			}
//		}
//	}
//}
//if (window.attachEvent) window.attachEvent("onload", sfHover);

//sfHover = function() {
//var sfEls = document.getElementById("nav2").getElementsByTagName("LI");
//	for (var i=0; i<sfEls.length; i++) {
//		sfEls[i].onmouseover=function() {
//			this.className+=" sfhover";
//		}
//		sfEls[i].onmouseout=function() {
//			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
//		}
//	}
//}
//if (window.attachEvent) window.attachEvent("onload", sfHover);

function _visibilite(thingId)
{
	var arrayPageSize = sfhGetPageSize();
	var arrayPageScroll = sfhGetPageScroll();
	var L = arrayPageSize[0];
	var H = arrayPageSize[1];
	var posX = (L-555)/2;
	var S=arrayPageScroll[1];
	var posY=(H-448)/2+S;
	var targetElement;
	
	targetElement = document.getElementById(thingId) ;
	/*
	targetElement.style.left=posX;
	targetElement.style.top=posY;
	*/
	visibilite(thingId);
}

function visibilite(thingId)
{
	var targetElement;
	targetElement = document.getElementById(thingId) ;
	if (targetElement.style.display == "none") {
		targetElement.style.display = "" ;
		sfhHideSelect();	//cacher les select (bug ie6)
	} else {
		targetElement.style.display = "none" ;
		sfhUnhideSelect();
		clearTimeout(t);
	}
}

function getElementsByClassName_(className, tag, elm){
	var testClass = new RegExp("(^|s)" + className + "(s|$)");
	var tag = tag || "*";
	var elm = elm || document;
	var elements = (tag == "*" && elm.all)? elm.all : elm.getElementsByTagName(tag);
	var returnElements = [];
	var current;
	var length = elements.length;
	for(var i=0; i<length; i++){
		current = elements[i ];
		if(testClass.test(current.className)){
			returnElements.push(current);
		}
	}
	return returnElements;
}

function affimg(thingId)
{
	var parent=document.getElementById('parent');
	var targetElement;
	targetElement = getElementsByClassName_(thingId,'div',parent);
	//alert(targetElement[0]);
	if (targetElement[0].style.display == "none") {
		targetElement[0].style.display = "" ;
		//sfhHideSelect();	cacher les select (bug ie6)
	} else {
		targetElement[0].style.display = "none" ;
		//sfhUnhideSelect();
		clearTimeout(t);
	}

}		





function sfhHideSelect() {
	for (j=0; j<document.forms.length; j++) {
		var theForm = document.forms[j]
		if(theForm.name=="choixliv1") {
			for(i=0; i<theForm.elements.length; i++){
				if(theForm.elements[i].type == "select-one") {
					theForm.elements[i].style.visibility = "hidden";
				}
			}
		} else {
			for(i=0; i<theForm.elements.length; i++){
				if(theForm.elements[i].type == "select-one") {
					theForm.elements[i].style.visibility = "hidden";
				}
			}
		}
	}
} 

function sfhUnhideSelect() {
	for (j=0; j<document.forms.length; j++) {
		var theForm = document.forms[j]
		if(theForm.name=="choixliv1") {
			for(i=0; i<theForm.elements.length; i++){
				if(theForm.elements[i].type == "select-one") {
					theForm.elements[i].style.visibility = "visible";
				}
			}
		} else {
			for(i=0; i<theForm.elements.length; i++){
				if(theForm.elements[i].type == "select-one") {
					theForm.elements[i].style.visibility = "visible";
				}
			}
		}
	}
} 

//
// sfhGetPageScroll()
//
function sfhGetPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// Tout autres qu'Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}

//
// sfhGetPageSize()
//
function sfhGetPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // Tous sauf Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...marchera également avec Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// tous excepté Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // autres qu'Explorer
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function ShowSommBox(thingID)
{
	var arrayPageSize = sfhGetPageSize();
	var arrayPageScroll = sfhGetPageScroll();
	var objBox = document.getElementById('pagecenter');
	
	objBox.style.left=(((arrayPageSize[0] - 20 - 1100) / 2) + 'px');

	visibilite(thingID);
}

//pere_bulle
function aff_flash(thingID)
{
	var arrayPageSize = sfhGetPageSize();
	var arrayPageScroll = sfhGetPageScroll();
	var objBox = document.getElementById('pagecenter2');
	
	objBox.style.left=(((arrayPageSize[0] - 20 - 550) / 2) + 'px');

	visibilite(thingID);
	
	t = setTimeout('visibilite(\'pagecenter2\')',14000);
	//t = clearTimeout(t);
	
}

interrupteur_afficheSousMenu=false;
clicBloc="rien";

function afficheSousMenu(bloc){
	if(clicBloc!=bloc && interrupteur_afficheSousMenu==true){
		document.getElementById(clicBloc).style.display="none";
	   	clicBloc=bloc;
		interrupteur_afficheSousMenu=false;
	}
	if(interrupteur_afficheSousMenu==false){
		document.getElementById(bloc).style.display="block";
		interrupteur_afficheSousMenu=true;
		clicBloc=bloc;
	}else{
		document.getElementById(bloc).style.display="none";
		interrupteur_afficheSousMenu=false;
	}
}

function afficheSousMenu2(bloc){
	if(clicBloc!=bloc && interrupteur_afficheSousMenu==true){
		document.getElementById(clicBloc).style.display="none";
	   	clicBloc=bloc;
		interrupteur_afficheSousMenu=false;
	}
	if(interrupteur_afficheSousMenu==false){
		document.getElementById(bloc).style.display="block";
		interrupteur_afficheSousMenu=true;
		clicBloc=bloc;
	}else{
		document.getElementById(bloc).style.display="none";
		interrupteur_afficheSousMenu=false;
	}
}

//POP UP centrer avec en param les tailles + url de la page à affiché
function ouvrir(l,h,url) {
hauteur=Math.round((screen.availHeight-h)/2);
largeur=Math.round((screen.availWidth-l)/2);
window.open(url, "site", "toolbar=0,location=0,directories=0,status=0, scrollbars=1,resizable=0,menubar=0,top="+hauteur+",left="+largeur+",width="+l+",height="+h);
}

/* INFOS BULLE rollover sur imag affiche ces dernière en grande taille */
var xOffset=6
var yOffset=5

var affiche = false; // La variable i nous dit si le bloc est visible ou non
var w3c=document.getElementById && !document.all;
var ie=document.all;
var ope=window.opera;


var ua = navigator.userAgent.toLowerCase();
if ( ua.indexOf( "opera" ) != -1 ) {
    browserName = "opera";
	var navi = 4;
} else if ( ua.indexOf( "msie" ) != -1 ) {
    browserName = "msie";
	var navi = 1 ;
} else if ( ua.indexOf( "safari" ) != -1 ) {
    browserName = "safari";
	var navi = 5;
} else if ( ua.indexOf( "mozilla" ) != -1 ) {
    if ( ua.indexOf( "firefox" ) != -1 ) {
        browserName = "firefox";
		var navi = 2;
    } else {
        browserName = "mozilla";
		var navi = 6;
    }
}

if (ie||w3c) {
	var laBulle
}

function ietruebody(){ // retourne le bon corps...
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function deplacer(e) {
	
	if(affiche){
		
		//var curX = (w3c) ? e.pageX - window.innerWidth/2 + 263 : event.x + ietruebody().scrollLeft; // opéra et chrome
		//var curX = (w3c) ? e.pageX : event.x + ietruebody().scrollLeft; //ie et mozilla
		
		//var curY = (w3c) ? e.pageY - 325 : event.y; // pour opéra 
		//var curY = (w3c) ? e.pageY - 375 : event.y; // pour chrome 
		//var curY = (w3c) ? e.pageY : event.y; //ie et mozilla
		
		var curX = 0;
		var curY = 0;
		
		switch (navi) {
			case 1 : 
			curX = event.x + ietruebody().scrollLeft;
			curY = event.y;
				break;
			case 2 : 
			curX = e.pageX;
			curY = e.pageY;
				break;
			case 4 : 
			curX = e.pageY - 325;
			curY = e.pageX - window.innerWidth/2 + 263;
				break;
			default : 
			curX = e.pageX - window.innerWidth/2 + 263;
			curY = e.pageY - 375;
				break;
			}
			
		
		/*var debeugId = document.getElementById("debeug");
		debeugId.innerHTML = curX + ' - ' + curY;*/
		
		var winwidth = ie && !window.opera ? ietruebody().clientWidth : window.innerWidth - 20;
		var winheight = ie && !window.opera ? ietruebody().clientHeight : window.innerHeight - 20;
		
		var rightedge = ie && !window.opera ? winwidth - event.clientX - xOffset : winwidth - e.clientX - xOffset;
		var bottomedge = ie && !window.opera ? winheight - event.clientY - yOffset : winheight - e.clientY - yOffset;
		
		var leftedge = (xOffset < 0) ? xOffset*(-1) : -1000
	
	// modifier la largeur de l'objet s'il est trop grand...
	if(laBulle.offsetWidth > winwidth / 3){
		laBulle.style.width = winwidth / 3
	}

// si la largeur horizontale n'est pas assez grande pour l'info bulle
	if(rightedge < laBulle.offsetWidth){
		// bouge la position horizontale de sa largeur à gauche
		laBulle.style.left = curX - laBulle.offsetWidth + "px"
	} else {
		if(curX < leftedge){
		laBulle.style.left = "5px"
	} else{
		// la position horizontale de la souris
		laBulle.style.left = curX + xOffset + "px"
	}
}

// même chose avec la verticale
if(bottomedge < laBulle.offsetHeight){
laBulle.style.top = curY - laBulle.offsetHeight - yOffset + "px"
} else {
laBulle.style.top = curY + yOffset + "px"
}
}
}
function showTooltip(text) {
if (w3c||ie){
laBulle = document.all ? document.all["bulle"] : document.getElementById ? document.getElementById("bulle") : ""
laBulle.innerHTML = text; // fixe le texte dans l'infobulle
// *** Initialise avec des valeurs X, Y hors écran pour ne pas voir l'image avant mouvement.
laBulle.style.left=-999;
laBulle.style.top=-999;
laBulle.style.visibility = "visible"; // Si il est cachée (la verif n'est qu'une securité) on le rend visible.
affiche = true;
}
}
function hideTooltip() {
if (w3c||ie){
affiche = false
laBulle.style.visibility="hidden" // avoid the IE6 cache optimisation with hidden blocks
laBulle.style.top = '-100000px'
laBulle.style.backgroundColor = ''
laBulle.style.width = ''
}
}

document.onmousemove = deplacer; // des que la souris bouge, on appelle la fonction move pour mettre a jour la position de la bulle.