// cross navigator functions
	
var isIE =  ((navigator.userAgent.indexOf("MSIE") > -1) ? true : false);
var isMac =  ((navigator.userAgent.indexOf("Mac") > -1) ? true : false);
var isGecko = ((navigator.userAgent.indexOf("Gecko") > -1) ? true : false);

var isDOM = (document.getElementById ? true : false); 
var isIE4 = ((document.all && !isDOM) ? true : false);
var isNS4 = (document.layers ? true : false);
var isDyn = (isDOM || isIE4 || isNS4);

function getTag(id){
 if (isDOM) return document.getElementById(id);
 if (isIE4) return document.all[id];
 if (isNS4) return document.layers[id];
}

function getTagStyle(id){
 return (isNS4 ? getTag(id) : getTag(id).style);
} 

//*************************************************************	
// pour allumer
//*************************************************************

  function allumer(e, value) {
        $(e).css('opacity',value);
		$(e).css('z-index',+10);
  }
  
  function eteindre(e, value) {
        $(e).css('opacity',value);
		$(e).css('z-index',1);
		
		
  }

//***********************************************
// fade in
//********************************************


var timer = 0;
      var iFade = 1;
      var iOpacity = 0;
      var idFade = "";
      
      function FadeById(id) {
        idFade = id;
        timer = setInterval("FadeIn()", 50);
		loop();
      }
      
      function CancelFadeById() {
        if (timer == 0) return;
        clearInterval(timer);
        timer = 0;
      }
      
      function FadeIn() {
        var elem = document.getElementById(idFade + iFade);
        if (iOpacity >= 0.6) {
          iFade++;
          elem = document.getElementById(idFade + iFade);
          if (! elem) {
            CancelFadeById();
            return;
          }
          iOpacity = 0;
        }
        iOpacity += 0.1;
        elem.style.opacity = iOpacity;
        elem.style.MozOpacity = iOpacity;
        elem.style.KhtmlOpacity = iOpacity;
        elem.style.filter = "alpha(opacity=" + iOpacity * 100 + ")";
      }
//*******************************************************************************

/*
	Réalisé par oli.
	http://blog.oli-web.com
*/

var isDragging = false;
var objectToDrag;
var obj;
var ecartX;
var ecartY;
var curX;
var curY;

function positionne(p_id, p_posX, p_pos_Y){
	document.getElementById(p_id).style.left = p_posX;
	document.getElementById(p_id).style.top = p_pos_Y;
}

function getPositionCurseur(e){
	//ie
	if(document.all){
		curX = event.clientX;
		curY = event.clientY;
	}
	
	//netscape 4
	if(document.layers){
		curX = e.pageX;
		curY = e.pageY;
	}
	
	//mozilla
	if(document.getElementById){
		curX = e.clientX;
		curY = e.clientY;
	}
}

function beginDrag(p_obj,e){
	isDragging = true;
	objectToDrag = p_obj;
	getPositionCurseur(e);
	ecartX = curX - parseInt(objectToDrag.style.left);
	ecartY = curY - parseInt(objectToDrag.style.top);
}

function drag(e){
	var newPosX;
	var newPosY;
	if(isDragging == true){
		
		getPositionCurseur(e);
		newPosX = curX - ecartX;
		newPosY = curY - ecartY;

		objectToDrag.style.left = newPosX + 'px';
		objectToDrag.style.top = newPosY + 'px';
		
	}
	
}

function endDrag(){
	isDragging = false;
}

//*****************************************************


//*************************************************************	
// pour afficher les keywords
//*************************************************************

var actuellement = '';

function efface() {
	// actuellement = mot-clé actuellement visible
	if (actuellement != '') {
		getTagStyle(actuellement).visibility = "hidden";
	}
	
}

function affiche(keywords) {
  
  	if (getTagStyle(keywords).visibility != "visible") {
		//alert("actuellement="+actuellement);
		// efface le mot-clé actuellement selectionné
		efface();
		
    	getTagStyle(keywords).visibility = "visible";
		
		// Définit le mot-clé actuellement sélectionné (celui que l'on vient d'activer devient "actuellement")
		actuellement = keywords;
		//alert("actuellement="+actuellement);
		return;
  	}
	
}	

//*****************************************************************
// pop up
//*****************************************************************

function openNewWindow(URLtoOpen, windowName, windowFeatures) {
	if (windowFeatures.search(/scrollbars/) == -1) {
		windowFeatures = windowFeatures + ",scrollbars=1";
	}
	if (windowFeatures.search(/toolbar/) == -1) {
		windowFeatures = windowFeatures + ",toolbar=0";
	}
	if (windowFeatures.search(/titlebar/) == -1) {
		windowFeatures = windowFeatures + ",titlebar=0";
	}
	if (windowFeatures.search(/status/) == -1) {
		windowFeatures = windowFeatures + ",status=0";
	}
	if (windowFeatures.search(/resizable/) == -1) {
		windowFeatures = windowFeatures + ",resizable=1";
	}
	if (windowFeatures.search(/location/) == -1) {
		windowFeatures = windowFeatures + ",location=0";
	}
	if (windowFeatures.search(/left/) == -1) {
		windowFeatures = windowFeatures + ",left=30";
	}
	if (windowFeatures.search(/top/) == -1) {
		windowFeatures = windowFeatures + ",top=50";
	}
	window.open(URLtoOpen, windowName, windowFeatures); 
}
//*************************************************************

//*************************************************************	
// pour afficher les définitions et les clients
//*************************************************************

//var now = 0;

//function hide() {
	
//    if (now == 1) {
//		getTagStyle("edito-content").display = "none";
	//}
	
//    if (now == 2) {
//		getTagStyle("bulle").display = "none";
	//}
	//now == 0;

//}

//function show(contenu) {
  
//  	if (contenu == 1 && getTagStyle("edito-content").display != "block") {
//	    hide();
 //   	getTagStyle("edito-content").display = "block";
   // 	now = 1;
//		return;
//  	}
  
//  	if (contenu == 2 && getTagStyle("bulle").display != "block") {
//	    hide();
//    	getTagStyle("bulle").display = "block";
//    	now = 2;
//		return;
//  	}
	
//  return;
//}
