var onFocusColor='#F8A74E';
//var onFocusColor='#EAD5D6';
var IB=new Object;
var posX=0;posY=0;
var xOffset=-20;yOffset=10;

function focusColor(obj) {
	obj.style.backgroundColor=onFocusColor;
}
function blurColor(obj) {
	obj.style.backgroundColor='';
}


fDomOffset = function( oObj, sProp )
{ 
 // oObj : [Object] - Objet dont on désire le positionnement 
 // sProp : [String] - Propriété désirée : offsetLeft - offsetTop 
 var iVal = 0; 
 // On boucle tant que l'on n'est pas à la racine du document 
 while (oObj && oObj.tagName != 'BODY') { 
  eval('iVal += oObj.' + sProp + ';');
  oObj = oObj.offsetParent; 
 } 
 return iVal; 
}  

fSwapSelect = function( sId ) 
{ 
 oObj = document.getElementById(sId); 

 Top_Element  = fDomOffset(oObj, 'offsetTop'); 
 Left_Element  = fDomOffset(oObj, 'offsetLeft'); 
 Largeur_Element  = oObj.offsetWidth; 
 Hauteur_Element  = oObj.offsetHeight; 
 oSelects = document.getElementsByTagName('SELECT'); 
 if (oSelects.length > 0) { 
  for (i = 0; i < oSelects.length; i++) { 
   oSlt = oSelects[i]; 
   Top_Select = fDomOffset(oSlt, 'offsetTop'); 
   Left_Select = fDomOffset(oSlt, 'offsetLeft'); 
   Largeur_Select = oSlt.offsetWidth; 
   Hauteur_Select = oSlt.offsetHeight; 
   isLeft = false; 
   if ((Left_Element > (Left_Select - Largeur_Element)) && (Left_Element < (Left_Select + Largeur_Select))) { 
    isLeft = true; 
   } 
   isTop = false; 
   if ((Top_Element > (Top_Select - Hauteur_Element)) && (Top_Element < (Top_Select + Hauteur_Select))) { 
    isTop = true; 
   } 
   if (isLeft && isTop) { 
    sVis = (oObj.style.visibility == 'hidden') ? 'visible' : 'hidden'; 
    if (oSlt.style.visibility != sVis) {oSlt.style.visibility = sVis;} 
   } else { 
    if (oSlt.style.visibility != 'visible') {oSlt.style.visibility = 'visible';} 
   } 
  } 
 } 
} 

function AffBulle(texte) 
{
	contenu=		  "<table border='0' cellpadding='0' cellspacing='0' class='infoBulle'>";
	contenu=contenu +  "<tr>";
	contenu=contenu +   "<th scope='col'><img src='/admin/images/con_info.png' width='16' height='16' border='0' class='cadreImage' /> Information </th>";
	contenu=contenu +    "</tr>";
	contenu=contenu +     "<tr>";
	contenu=contenu +      "<td><p>" + texte + "</p></td>";
	contenu=contenu +     "</tr>";
	contenu=contenu +   "</table>";

	var finalPosX=posX-xOffset;
	if (finalPosX<0) finalPosX=0;
	if (document.layers) 
	{
		document.layers["bulle"].document.write(contenu);
		document.layers["bulle"].document.close();
		document.layers["bulle"].top=posY+yOffset;
		document.layers["bulle"].left=finalPosX;
		document.layers["bulle"].visibility="show";
	}

	if (document.all) 
	{
		bulle.innerHTML=contenu;
		document.all["bulle"].style.top=posY+yOffset;
		document.all["bulle"].style.left=finalPosX;
		document.all["bulle"].style.visibility="visible";
	}
	else if (document.getElementById) {
		document.getElementById("bulle").innerHTML=contenu;
		document.getElementById("bulle").style.top=posY+yOffset;
		document.getElementById("bulle").style.left=finalPosX;
		document.getElementById("bulle").style.visibility="visible";
	}

	fSwapSelect('bulle')	
}

function getMousePos(e) 
{
	if (document.all) 
	{
		posX=event.x+document.body.scrollLeft; 
		posY=event.y+document.body.scrollTop;
	}
	else 
	{
		posX=e.pageX; 
		posY=e.pageY; 
	}
}


function HideBulle() 
{
	if (document.layers) 
	{
		document.layers["bulle"].visibility="hide";
	}

	if (document.all) 
	{
		document.all["bulle"].style.visibility="hidden";
	}
	else if (document.getElementById)
	{
		document.getElementById("bulle").style.visibility="hidden";
	}
	fSwapSelect('bulle')	
}

function InitBulle(ColTexte,ColFond,ColContour,NbPixel) 
{
	IB.ColTexte=ColTexte;IB.ColFond=ColFond;IB.ColContour=ColContour;IB.NbPixel=NbPixel;
	if (document.layers) 
	{
		window.captureEvents(Event.MOUSEMOVE);window.onMouseMove=getMousePos;
		document.write("<LAYER name='bulle' top=0 left=0 visibility='hide'></LAYER>");
	}
	
	if (document.all) 
	{
		document.write("<DIV id='bulle' style='position:absolute;top:0;left:0;visibility:hidden;z-index:10'></DIV>");
		document.onmousemove=getMousePos;
	}
	else if (document.getElementById) 
	{
		document.onmousemove=getMousePos;
		document.write("<DIV id='bulle' style='position:absolute;top:0;left:0;visibility:hidden'></DIV>");
	}
}

function AffMenu(texte) 
{
	// Variables locales
	var menu = ""
	var i = 1
	var strClass=""
	var strLib=""
	var strLien=""
	var ColTexte = IB.ColTexte
	var ColFond = IB.ColFond
	var ColContour = IB.ColContour
	var NbPixel = IB.NbPixel

	//***********
			
	// Construction du tableau
	contenu='	     <TABLE border=0 cellspacing=0 cellpadding=0 style="border:1.5pt outset">'
	contenu=contenu + '		<TR bgcolor="#7F97AF">'
	contenu=contenu + '			<TD>'	
	contenu=contenu + '				<TABLE border="0" bgcolor="#7F97AF">'

	menu = GetCol(texte, i, "¤")

	while (menu != "")
	{
		contenu=contenu + '				<TR>'
		contenu=contenu + '					<TD'
		if (GetCol(texte, i+1, "¤")!="")
		{
			contenu=contenu + '					 style="border-bottom:1.5pt groove" '
		}	

		contenu=contenu + '						 onmouseover="this.style.background=\'#4F607F\'" onmouseout="this.style.background=\'#7F97AF\'">'

		strLib=GetCol(menu, 1, "")
		strLien=GetCol(menu, 2, "")

		contenu=contenu + '						<a id="menu'+i+'" name="menu'+i+'" href="' + strLien + '" style="text-decoration:none;color:#000000;font-family:arial">' + strLib + '</a>'

		contenu=contenu + '					</TD>'
		contenu=contenu + '				</TR>'

		i=i+1
		menu = GetCol(texte, i, "¤")
	}
	contenu=contenu + '				</TABLE>'
	contenu=contenu + '			</TD>'
	contenu=contenu + '		</TR>'
	contenu=contenu + ' </TABLE>'

	IB.ColTexte=""
	IB.ColFond=""
	IB.ColContour=""
	IB.NbPixel=0

	if (document.layers) 
	{
		document.layers["bulle"].document.write(contenu);
		document.layers["bulle"].document.close();
		document.layers["bulle"].top=posY;
		document.layers["bulle"].left=posX;
		document.layers["bulle"].visibility="show";
	}

	if (document.all) 
	{
		bulle.innerHTML=contenu;
		document.all["bulle"].style.top=posY;
		document.all["bulle"].style.left=posX;
		document.all["bulle"].style.visibility="visible";
	}
	else if (document.getElementById) {
		document.getElementById("bulle").innerHTML=contenu;
		document.getElementById("bulle").style.top=posY;
		document.getElementById("bulle").style.left=posX;
		document.getElementById("bulle").style.visibility="visible";
	}
	IB.ColTexte=ColTexte;
	IB.ColFond=ColFond;
	IB.ColContour=ColContour;
	IB.NbPixel=NbPixel;

}

function GetCol(strChaine, iCol, strSep)
{
	var j=1;	
	var strRetour=""

	if (strSep == "")
	{
		strSep = "#";
	}
	
	while (j<=iCol)
	{
		strRetour = strChaine.substring(0, strChaine.indexOf(strSep,0));
		if (strRetour=="" && strChaine!="")
		{
			if 	(j==iCol)
			{
				strRetour=strChaine;
			}
			else if (strChaine.indexOf(strSep,0)!=0)
			{
				strRetour=""
				j=iCol
				}	
		}

		if (j==iCol && strChaine.indexOf(strSep,0)==0)
		{
               // Le caractére suivant étant le séparateur, on a donc une chaîne vide à renvoyer
			strRetour="";
		}

		strChaine = strChaine.substring(strChaine.indexOf(strSep,0)+1,strChaine.length);

		j=j+1;
	}

	return strRetour;
}
function redimImage(inImg, inMW, inMH)
{
  // Cette function recoit 3 parametres
  // inImg : Chemin relatif de l'image
  // inMW  : Largeur maximale
  // inMH   : Hauteur maximale
  var maxWidth = inMW;
  var maxHeight = inMH;
  // Declarations des variables "Nouvelle Taille"
  var dW = 0;
  var dH = 0;
  // Declaration d'un objet Image
  var oImg = new Image();
  // Affectation du chemin de l'image a l'objet
  oImg.src = inImg;
  // On recupere les tailles reelles
  var h = dH = oImg.height;
  var w = dW = oImg.width;
  // Si la largeur ou la hauteur depasse la taille maximale
  if ((h >= maxHeight) || (w >= maxWidth)) {
    // Si la largeur et la hauteur depasse la taille maximale
    if ((h >= maxHeight) && (w >= maxWidth)) {
      // On cherche la plus grande valeur
      if (h > w) {
        dH = maxHeight;
        // On recalcule la taille proportionnellement
        dW = parseInt((w * dH) / h, 10);
      } else {
        dW = maxWidth;
        // On recalcule la taille proportionnellement
        dH = parseInt((h * dW) / w, 10);
      }
    } else if ((h > maxHeight) && (w < maxWidth)) {
      dH = maxHeight;
        // On recalcule la taille proportionnellement
      dW = parseInt((w * dH) / h, 10);
    } else if ((h < maxHeight) && (w > maxWidth)) {
      dW = maxWidth;
        // On recalcule la taille proportionnellement
      dH = parseInt((h * dW) / w, 10);
    }
  }
  // On ecrit l'image dans le document
  document.writeln("<img src=\"" + inImg + "\" width=\"" + dW + "\" height=\"" + dH + "\" border=\"0\">");
 return "<img src=\"" + inImg + "\" width=\"" + dW + "\" height=\"" + dH + "\" border=\"0\">";
};

function getWidth(inImg)
{
  var oImg = new Image();
  oImg.src = inImg;
 return oImg.width;
};

function getHeight(inImg)
{
  var oImg = new Image();
  oImg.src = inImg;
 return oImg.height;
};

function fileInfo(folder, entry) 
{
contenu=		  "<table  border='0' cellpadding='0' cellspacing='0'  class='infoBulle'><tr>";
//contenu=contenu +  "<th scope='col'><img src='images/con_info.png' width='16' height='16' border='0' class='cadreImage' /> Information </th>";
contenu=contenu +  "<th scope='col'>" + entry + "</th>";
contenu=contenu +   "</tr>";
contenu=contenu +   "<tr><td><p>";
//contenu=contenu + 	 entry + " <br /> ";
contenu=contenu + 	 "largeur : " + getWidth(folder+entry) + "<br />";
contenu=contenu + 	 "hauteur : " + getHeight(folder+entry) + "<br />";
contenu=contenu + 	"</p></td></tr>";
contenu=contenu + "</table>";


	var finalPosX=posX-xOffset;
	if (finalPosX<0) finalPosX=0;
	if (document.layers) 
	{
		document.layers["bulle"].document.write(contenu);
		document.layers["bulle"].document.close();
		document.layers["bulle"].top=posY+yOffset;
		document.layers["bulle"].left=finalPosX;
		document.layers["bulle"].visibility="show";
	}

	if (document.all) 
	{
		bulle.innerHTML=contenu;
		document.all["bulle"].style.top=posY+yOffset;
		document.all["bulle"].style.left=finalPosX;
		document.all["bulle"].style.visibility="visible";
	}
	else if (document.getElementById) {
		document.getElementById("bulle").innerHTML=contenu;
		document.getElementById("bulle").style.top=posY+yOffset;
		document.getElementById("bulle").style.left=finalPosX;
		document.getElementById("bulle").style.visibility="visible";
	}

	fSwapSelect('bulle')	
}

function OpenWindow(param,w,h) {
	title='Admin';
	//w=500;
	//h=300;
	newwin=window.open(param,title,'width='+w+',height='+h+',directories=no,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=no');
	newwin.window.focus();
}

function validateForm(obj){
	alert(obj);
}