var posX=0;posY=0;

function verifObjAvecNom(nObj){
	if(typeof(nObj)=="object")return nObj;
	else return document.getElementById(nObj);
}
 

function AffBulle(evt,text) {
	var xMouse,yMouse;

	if (navigator.appName!="Microsoft Internet Explorer"){
		xMouse=evt.pageX+15;
		yMouse=evt.pageY+15;
	}else{	
        var de = document.documentElement;
        var b = document.body;
        xMouse = evt.clientX + (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0);
        yMouse = evt.clientY + (de.scrollTop || b.scrollTop) - (de.clientTop || 0);
	}
	var bulle=document.getElementById("div_bulle");
	if (!bulle){
		var bulle=document.createElement("div");
		bulle.setAttribute("id","div_bulle");
		bulle.setAttribute("class","infobulle");
		document.body.appendChild(bulle);

		if (navigator.appName=="Microsoft Internet Explorer"){
			bulle.style.position="absolute";
			bulle.style.background="#FFFFFF";
			bulle.style.padding="10px";
			bulle.style.border="1px solid Black";
			bulle.style.zIndex="50";
			bulle.style.fontSize="76%";
			bulle.style.fontFamily="Arial";
			
		}
	}
	bulle.style.visibility="visible";
	bulle.innerHTML = text;
	bulle.style.left = xMouse + "px"; 
	bulle.style.top = yMouse + "px"; 
}

/****** A tester ******/
function Affiche_Cache(obj) {
	obj=verifObjAvecNom(obj);
	if(!estCache(obj))Cache(obj);			
	else Affiche(obj);
}		

function Affiche_CacheDiv(obj) {
	Affiche_Cache(obj)
}			
/***************************/
function estCache(obj){
	obj=verifObjAvecNom(obj);
	if (obj && obj.style)return (obj.style.display == 'none');		
	else return false;		
}					
		
function estCacheeDiv(obj){
	return estCache(obj);
}					
		
function AfficheDiv(obj){
	Affiche(obj);
}

function CacheDiv(obj){
	Cache(obj);	
}
		
function Cache(obj) {
	obj=verifObjAvecNom(obj);
	if (obj)obj.style.display = 'none';
}

function Affiche(obj) {
	obj=verifObjAvecNom(obj);
	if (obj)obj.style.display = 'block';
}			

function AffBulle_avt(texte,decalX,decalY) {
  	var contenu="<TABLE border=0 cellspacing=0 cellpadding=0><TR "; 
 	contenu+="><TD><TABLE border=0 cellpadding=1 cellspacing=1 bgcolor='white'";
  	contenu+="><TR><TD><FONT size='10px' face='arial' color='#000000'>"+texte+"</FONT></TD></TR></TABLE></TD></TR></TABLE>&nbsp;";

  	contenu+="<div id='div_bulle_contenu' style='border:solid 1px;background:#FFFFFF;color:#808080;font-family:Arial;font-size:76%;'><p style='margin:5px 5px 5px 5px;'>"+texte+"</p></div>";
  
	var finalPosX=parseInt(posX-decalX-10)+'px';
	var finalPosY=parseInt(decalY+posY+10)+'px';
	var bulle=document.getElementById("div_bulle");
	if (!bulle){
 		var body  = document.getElementsByTagName("body").item(0);
		var bulle = document.createElement("DIV");
		bulle.id="div_bulle";
		bulle.style.position="absolute";
		bulle.style.zIndex=500;
		bulle.style.visibility="hidden";
	   	body.appendChild(bulle);
	}
	if (bulle) {
    	bulle.innerHTML=contenu;
    	bulle.style.top=finalPosY;
    	bulle.style.left=finalPosX;
    	bulle.style.visibility="visible";
	}
}
function getMousePos(e) {
	if (document.all) {
		posX=event.x+document.body.scrollLeft+document.documentElement.scrollLeft;
		posY=event.y+document.body.scrollTop+document.documentElement.scrollTop;
	}else {
		posX=e.pageX; 
		posY=e.pageY; 
	}
}
		
function HideBulle() {
	var bulle=document.getElementById("div_bulle");
	if (bulle)bulle.style.visibility="hidden";
}


function copy_DansPressePapier(textACopier){
	  window.clipboardData.setData("Text", textACopier);
}
function findPosX(obj){
	var curleft = 0;
	if (obj.offsetParent){
		while (obj.offsetParent){
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}else if (obj.x)curleft += obj.x;
	return curleft;
}

function findPosY(obj){
	var curtop = 0;
	if (obj.offsetParent){
		while (obj.offsetParent){
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}else if (obj.y)curtop += obj.y;
	return curtop;
}

function AffMenuFly(img,contenu,decalX,decalY) {
	var finalPosX=findPosX(img)+decalX;
	var finalPosY=findPosY(img)+img.height+decalY;

	var menu=document.getElementById('div_menuFly');		
	if (!menu){
		var body  = document.getElementsByTagName("body").item(0);
		var menu = document.createElement("DIV");
		menu.id="div_menuFly";
		menu.style.position="absolute";
		menu.style.zIndex=500;
		menu.style.visibility="hidden";
	   	body.appendChild(menu);
	}
	
	if (menu){
		menu.innerHTML=contenu;
		menu.style.top=finalPosY+'px';
		menu.style.left=finalPosX+'px';				
		menu.style.visibility='visible';
		menu.style.zIndex=5000;		
	}
}

function HideMenuFly() {
	var menu=document.getElementById('div_menuFly');		
	if (menu)menu.style.visibility='hidden';
}

function newImage(arg) {     
	if (document.images) {     
		rslt = new Image();     
		rslt.src = arg;     
		return rslt;     
	}     
}     
     

function changeImages() {     
	if (document.images && (preloadFlag == true)) {     
		for (var i=0; i<changeImages.arguments.length; i+=2) {     
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];     
		}     
	}     
}     
     

var preloadFlag = false;     
function preloadImages(src) {     
	if (document.images) {     
		newImage(src);     
		preloadFlag = true;     
	}     
}     

function basculeImages() {    
	if (document[basculeImages.arguments[0]].src==basculeImages.arguments[1] && (preloadFlag == true)) {       
		document[basculeImages.arguments[0]].src = basculeImages.arguments[2];     
	}
	else {
		document[basculeImages.arguments[0]].src = basculeImages.arguments[1];
	}     
}     

/*
function setCouleurTexte_$prof(tditem,col){                                                                    	
	//tditem.style.color=col;
}
function setCouleurFond_$prof(tditem,col){                                                                    	
	tditem.style.background=col;
}*/

function openPopupBonEchange(html){
	mapopup=window.open("","","toolbar=no,menu=yes,scrollbars,width=400,height=600");
	mapopup.document.write(html);	
	mapopup.document.close();
}
function maPopupFiche(image){
	maPage = window.open(image,"", "width=380,height=200,location=no,menubar=no"); 
	maPage.document.write(image); 
	maPage.document.close();  
}

		