
function ArtPopup_displayPopupPanel(isVisible, clientID, popupFix)
{
	// On définit l'affchage de nos divs en none/block suivant la valeur de isVisible
	var visible = "none";
	if(isVisible)
		visible = "block";
	// Récupération de l'overlay
	var overlay = clientID + "_overlay";
	
	// Si on désactive la page
	if(document.getElementById(overlay) != null)
	{
		// Récupération de notre frame d'erreur pour IE6
		var framePopup = clientID + "_framePopup";
	
		// Affichage des divs
		document.getElementById(overlay).style.display = visible;
		document.getElementById(framePopup).style.display = visible;
	}
	
	// Récupération et affichage de notre div contenant la popup
	var panelPopup = clientID + "_panelPopup";
	document.getElementById(panelPopup).style.display = visible;

	// On initialise les positions
	ArtPopup_initPosition(clientID, popupFix);

	// En cas de redimensionnement, on recalcul les positions
	window.onresize = function() {
		ArtPopup_initPosition(clientID, popupFix);
	}
}

// Récupération de la taille de la fenêtre
// Retourne : [x,y]
function ArtPopup_getWindowSize()
{
	var x,y;
	// Pour tous les navigateurs sauf IE
	if (self.innerHeight)
	{
		x = self.innerWidth;
		y = self.innerHeight;
	}
	// Pour IE
	else if (document.documentElement && document.documentElement.clientHeight)
	{
		x = document.documentElement.clientWidth;
		y = document.documentElement.clientHeight;
	}
	// Autres
	else if (document.body)
	{
		x = document.body.clientWidth;
		y = document.body.clientHeight;
	}

	return [ x, y ];
}

// Récupére la taille du corp de la page
// Retourne : [x,y]
function ArtPopup_getBodySize()
{
	var x,y;
	
	var test1 = document.body.scrollHeight;
	var test2 = document.body.offsetHeight
	// Tous sauf les navigateurs MAC
	if (test1 > test2)
	{
		x = document.body.scrollWidth;
		y = document.body.scrollHeight;
	}
	else
	{
		x = document.body.offsetWidth;
		y = document.body.offsetHeight;
	}
	return [ x, y ];

}

// Récupére la taille du scroll
// Retourne : [x,y]
function ArtPopup_getScrollSize()
{
	var x,y;
	
	// Récupération x
	if (navigator.appName == 'Microsoft Internet Explorer')
		x = Math.max(document.documentElement.offsetWidth, document.documentElement.scrollWidth);
	else if (document.childNodes && !document.all && !navigator.taintEnabled) 
		x = document.body.scrollWidth;
	else 
		x= document.documentElement.scrollWidth;
	
	// Récupération y
	if (navigator.appName == 'Microsoft Internet Explorer') 
		y= Math.max(document.documentElement.offsetHeight, document.documentElement.scrollHeight);
	else if (document.childNodes && !document.all && !navigator.taintEnabled) 
		y= document.body.scrollHeight;
	else 
		y= document.documentElement.scrollHeight;
		
	return [ x, y ];
}

// Récupére la plus grande valeur
// Retourne : int
function ArtPopup_highestValue(intArray)
{
	var max = intArray[0];
	
	// On passe dans toutes les données
	for(i=1; i < intArray.length; i++)
	{
		if(intArray[i] > max)
			max = intArray[i];
	}
	
	return max;
}

// Initialisation de la position
function ArtPopup_initPosition(clientID, popupFix)
{
	// Positionnement de la popup
	var panelPopup = clientID + "_panelPopup";
	var panelPopupElement = document.getElementById(panelPopup);
	
	// Taille de la fenêtre
	var windowSize = ArtPopup_getWindowSize();
	var windowX = windowSize[0];
	var windowY = windowSize[1];

	// Taille de l'iframe
	var bodySize = ArtPopup_getBodySize();

	// Taille de l'iframe
	var scrollSize = ArtPopup_getScrollSize();

	var x = ArtPopup_highestValue(new Array(bodySize[0], windowX, scrollSize[0]));
	var y = ArtPopup_highestValue(new Array(bodySize[1], windowY, scrollSize[1]));
	
	// Si la popup doit être centré
	if(!popupFix && panelPopupElement != null && panelPopupElement.style.display == "block")
	{	
		var top = (windowY-panelPopupElement.offsetHeight)/2;
		
		// Si le top est négatif on le fixe à 0
		if(top < 0)
			top = 0;
		
		// On positionne la popup
		panelPopupElement.style.left = (windowX-panelPopupElement.offsetWidth)/2 + "px";
		panelPopupElement.style.top = top + "px";		
	}
	
	// Récupération de la frame d'erreur
	var framePopup = clientID + "_framePopup";
	var iframeElement = document.getElementById(framePopup);
	
	// Si l'iframe est affichée
	if(iframeElement != null && iframeElement.style.display == "block")
	{
		var overlay = clientID + "_overlay";
		var overlayElement = document.getElementById(overlay);

		// Taille de l'overlay
		overlayElement.style.width = x+"px";
		overlayElement.style.height = y+"px";
		overlayElement.style.top = "0px";
		overlayElement.style.left = "0px";
		
		// Taille de l'iframe
		iframeElement.style.width = x+"px";
		iframeElement.style.height = y+"px";
		iframeElement.style.top = "0px";
		iframeElement.style.left = "0px";
	}
}