//********************************************************************************************************************************************//
//***********************************************************Variables globales***************************************************************//
//********************************************************************************************************************************************//
var ie = /MSIE/.test(navigator.userAgent);
var moz = !ie && navigator.product == "Gecko";

var DocRef;
var running ;

var oImage;
var oImageLoading;
//#############################################################################################################################################//

//********************************************************************************************************************************************//
//*********************************Gestion de la position de la souris (fonctionne sous IE et FireFox*****************************************//
//********************************************************************************************************************************************//
/*document.onmousemove = position;
function position(evt)
{    
    if (!evt) 
    {
        evt = window.event;
    }
    
    if( document.documentElement && document.documentElement.clientWidth)
    {
        DocRef = document.documentElement;
    }
    else
    {
        DocRef = document.body;
    }
    mouseposx = evt.clientX + DocRef.scrollLeft;
    mouseposy = evt.clientY + DocRef.scrollTop;     
}
*/
//#############################################################################################################################################//

//********************************************************************************************************************************************//
//**********************************************Affiche la bubble Image***********************************************************************//
//********************************************************************************************************************************************//
function affiche(text, sens, e)
{
	try
    {
        var nValeurDeCorrection = 14
        oImage = new Image();
        oImage.src= text;
        
        oImageLoading = new Image();
        oImageLoading.src= "Image/WEB/loadingTous.gif";
        
        bubble = document.getElementById("infobulle");
                       
        //if ((ie) || (moz))
        //{
            bubble.style.visibility = "visible";
		    bubble.style.display = "block";
        //}                     
        bubble.innerHTML = '<img src=' + oImageLoading.src + ' class="loadingBulle">'; 
        bubble.style.left = mouseposx + nValeurDeCorrection +'px';
        bubble.style.top = mouseposy + nValeurDeCorrection +'px';	        
            
        if (oImage.complete==false)
        {
            running = setInterval(function() { iscomplete(sens)},200);
        }
        else
        {
            document.getElementById("infobulle").innerHTML = '<img src="' + oImage.src + '">'; 
            PositionneBubble(sens);
        }
    }
    catch (ex)
    {         
        window.status = "Erreur affiche : " + ex.Message;
    }
}
//#############################################################################################################################################//

//********************************************************************************************************************************************//
//**********************************************Positionne la bubble Image***********************************************************************//
//********************************************************************************************************************************************//
function PositionneBubble(sens) {

    try
    {
        var imageposy;
        var imageposx;
        
        var bDebordementBas = false;
        var bDebordementDroit = false;
        var nValeurDeCorrection = 14
        
        bubble = document.getElementById("infobulle");
              
        imageposy = mouseposy;
        imageposx = mouseposx;
         
        //DEBORDE EN BAS                               
        
        //if ((mouseposy + oImage.height + nValeurDeCorrection) >= (screen.availHeight - 50 + DocRef.scrollTop) * 0.9)
        if ((mouseposy + oImage.height + nValeurDeCorrection) >= (screen.availHeight - 50 + 0000) * 0.85)
        {   
            //window.status="debord bas";
            bDebordementBas = true;
            //imageposy = mouseposy - oImage.height;
        }
        
        
        //DEBORDE A DROITE = voir a gauche ;)
        if (((mouseposx + oImage.width)>(screen.availWidth -50) * 0.9) || (sens = "gauche"))
        {           
            bDebordementDroit = true;
            //imageposx = mouseposx - oImage.width;
        }
        
        //selon cas        
        if ((bDebordementDroit) && (bDebordementBas))
        {
            bubble.style.left = (mouseposx - oImage.width - nValeurDeCorrection) + 'px';
            bubble.style.top = (mouseposy - oImage.height + nValeurDeCorrection) + 'px';	        
	    }
        else if (bDebordementDroit) 
        {
            bubble.style.left = (mouseposx - oImage.width - nValeurDeCorrection) + 'px';
            bubble.style.top = (imageposy + nValeurDeCorrection) +'px';
        }
        else if (bDebordementBas) 
        {            
            bubble.style.left = (imageposx + nValeurDeCorrection) +'px';
            bubble.style.top = (mouseposy - oImage.height - nValeurDeCorrection) + 'px';	        
        }
        else
        {         
            bubble.style.left = (imageposx + nValeurDeCorrection) +'px';
            bubble.style.top = (imageposy + nValeurDeCorrection) +'px';	        
        }
    }
    catch (ex)
    {    
        window.status = "Erreur PositionneBubble : " + ex.Message;
    }
}
//#############################################################################################################################################//


//********************************************************************************************************************************************//
//*********************************************Cache la bubble********************************************************************************//
//*******************************************************************************************************************************************//
function cache()
{
	bubble = document.getElementById("infobulle");
	bubble.style.visibility = "hidden";
	bubble.style.display = "none";
}



function iscomplete(sens)
{        
    if (oImage.complete)
    {
        clearInterval(running);
        document.getElementById("infobulle").innerHTML = '<img src="' + oImage.src + '">'; 
        PositionneBubble(sens);
    }
}




function showDrop(element) {
    document.getElementById(element).style.display = 'block';
	if($('CATALOGUE_CONNU')){$('CATALOGUE_CONNU').style.visibility='hidden'}
	if(typeof(a)!='undefined')
	{
		clearTimeout(a);
	}
}
function hideDrop(element) {
	document.getElementById(element).style.display = 'none';
	if($('CATALOGUE_CONNU')){$('CATALOGUE_CONNU').style.visibility='visible'}
	clearTimeout(a);
}
function temporiz(element,tempo) {
	string="hideDrop('" + element + "');";
	a = setTimeout(string,tempo);
}			




function popUp(url, width, height, bCenter, bScrollBar)
    {

	var popUp ;

	//---------la popUp ne doit pas etre centrée
	if (!bCenter)
	{
		var calcLeft = 50;
		var calcTop = 50;		
	}
	//---------la popUp doit etre centrée
	else
	{
		var calcLeft = 400;
		var calcTop = 300;		
		
		//---------si la version du navigateur > 4 alors on peut centrer la popUp
		if (parseInt(navigator.appVersion) >= 4)
		{
			calcTop = screen.availHeight /2 - height ;
			calcLeft = screen.availWidth / 2 - width / 2 ;
		}
	}
	
	//------------si la version du navigateur est > 3
	if (parseInt(navigator.appVersion) > 3)
	{
		var sb = (bScrollBar) ?',scrollbars' :'' ;
		popUp = window.open('' + url + '', null,'top=' + calcTop + ',left=' + calcLeft + ',height=' + height + ',width=' + width + ',resizable' + sb) ;
		popUp.focus() ;						
    }
    else alert("Vous avez besoin d'un browser dont la version est supérieure à 3.");
}