var img_base = '';

var ie5 = document.all != null && document.getElementsByTagName != null;
var gecko = !ie5;

function getClientWidth() {
	var result = document.documentElement.clientWidth;
	if (result==0)
		result = document.body.clientWidth;
	return result;
}

function getClientHeight() {
	var result = document.documentElement.clientHeight;
	if (result==0)
		result = document.body.clientHeight;
	return result;
}

function FindLeftEdge(img, stopOnAbsolute)
{
	if (!img) return 0;
    xPos = img.offsetLeft;
    tempEl = img.offsetParent;

    while (tempEl!=null && (!stopOnAbsolute || (getStyle(tempEl,"position")!="absolute" && getStyle(tempEl,"position")!="relative")))
    {
        xPos += tempEl.offsetLeft;
        tempEl = tempEl.offsetParent;
    }
    return xPos;
}

function FindTopEdge(img, stopOnAbsolute)
{
	if (!img) return 0;
    yPos = img.offsetTop;
    tempEl = img.offsetParent;
    while (tempEl!=null && (!stopOnAbsolute || (getStyle(tempEl,"position")!="absolute" && getStyle(tempEl,"position")!="relative")))
    {
        yPos += tempEl.offsetTop;
        tempEl = tempEl.offsetParent;
    }
    return yPos;
}

function getLeftPos(el)
{
	var pos = getStyle(el, 'left');
	if (pos=="auto")
		pos = 0;
	return parseInt(pos);
}

function getTopPos(el)
{
	var pos = getStyle(el, 'top');
	if (pos=="auto")
		pos = 0;
	return parseInt(pos);
}

/* Fonctions pour la compatibilité Gecko */

function verticalText(text)
{
	if (ie5)
		return text;

	// Firefox ne sait pas afficher de texte vertical donc on ajoute des saut de lignes
	// Penser a reduire la taille de police pour ces textes avec Firefox
	var result = "";
	for(var i=0; i<text.length; i++)
		result += text.charAt(i)+"<br>";
	return result;
}

function getStyle(el,styleProp)
{
	var x = typeof(el)=="string"?document.getElementById(el):el;
	if (x.currentStyle)
		var y = x.currentStyle[styleProp];
	else if (window.getComputedStyle)
		var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
	else
		var y = x.style[styleProp];
	return y;
}

function popupwindow(URL, PopupName, w, h, resize) 
{
		var available_width = window.screen.availWidth;
		var available_height = window.screen.availHeight;
		var topY = (available_height-h)/2;
		var leftX = (available_width-w)/2;
		var Use_Resize = 'no';
		if (resize != null) Use_Resize = resize
	    PopupName = window.open(URL , PopupName, 'top='+topY+',left='+leftX+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=' + Use_Resize + ',resizable=' + Use_Resize + ',width=' + w +',height=' + h);
        PopupName.focus();
}
