function show(ID) {
	if(document.getElementById(ID))
		document.getElementById(ID).style.display = "block";
}

function mask(ID) {
	if(document.getElementById(ID))
		document.getElementById(ID).style.display = "none";
}

function toggle_view(ID) {
	if(document.getElementById(ID)) {
		if(document.getElementById(ID).style.display == "none")
			document.getElementById(ID).style.display = "block";
		else
			document.getElementById(ID).style.display = "none";
	}
}





function placeMenu(IDmenu, elementToPlace) {
	if(document.getElementById(elementToPlace) && document.getElementById(IDmenu)) {
		args = placeMenu.arguments;

		//var align	= (args[2]!=null ? args[2] : "left");
		var offsetX	= (args[2]!=null ? args[2] : 0);
		var offsetY	= (args[3]!=null ? args[3] : 0);
		var a = new Object();
		a = getPosition(document.getElementById(elementToPlace));
		document.getElementById(IDmenu).style.left = eval(a.x) + offsetX;
		document.getElementById(IDmenu).style.top = eval(a.y) + offsetY;
	}
}


function getPosition(element)
{
	var elem=element, tagname="", x=0, y=0;
  
	while ((typeof(elem)=="object")&&(typeof(elem.tagName)!="undefined"))
	{
		y+=elem.offsetTop;
		x+=elem.offsetLeft;
		tagname=elem.tagName.toUpperCase();

		if(tagname=="BODY")
			elem=0;

		if(typeof(elem)=="object")
			if (typeof(elem.offsetParent)=="object")
				elem=elem.offsetParent;
	}

	position = new Object();
	position.x = x;
	position.y = y;
	return position;
}


function getSize(element)
{
	var elem=element, tagname="", h=0, w=0;
	while ((typeof(elem)=="object")&&(typeof(elem.tagName)!="undefined"))
	{
		if(elem.height!=undefined)
			h+=elem.height+1-1;
		if(elem.width!=undefined)
			w+=elem.width+1-1;
		tagname=elem.tagName.toUpperCase();

		if(tagname=="BODY")
			elem=0;

		if(typeof(elem)=="object")
			if (typeof(elem.offsetParent)=="object")
				elem=elem.offsetParent;
	}

	position = new Object();
	position.w = w;
	position.h = h;
	return position;
}








/* FONCTIONS STRING */

function setDocumentFromFile(val, ctlDest) {
	// récupère le basename et supprime l'extension de val, et le place dans ctlDest
	if(val.lastIndexOf('\\') != 0)
		val = val.substring(val.lastIndexOf('\\')+1);
	if(val.lastIndexOf('/') != 0)
		val = val.substring(val.lastIndexOf('/')+1);
	
	if(val.lastIndexOf('.') != 0)
		val = val.substring(0, val.lastIndexOf('.'));
	
	document.getElementById(ctlDest).value = val;
}















/*
function textareaSize(zoneTexte) { 
 if (zoneTexte) { 
  nbrLignes=2;longueurDeLigne=2; // Taille minimal de la zone de texte. 
  nbrLignesMax=24;longueurDeLigneMax=24; // Taille maximale de la zone de texte. 
  lesLignes=escape(zoneTexte.value).split("%0D%0A"); 
  if (lesLignes) {nbrLignes=lesLignes.length;} 
  if (nbrLignes>document.body.clientHeight/nbrLignesMax) {nbrLignes=document.body.clientHeight/nbrLignesMax;} 
  
  if (lesLignes) { 
   for(n=0; n<(lesLignes.length); n++) { 
    if (longueurDeLigne<unescape(lesLignes[n]).length) {longueurDeLigne=unescape(lesLignes[n]).length;} 
    if (longueurDeLigne>document.body.clientWidth/longueurDeLigneMax) 
     { 
     longueurDeLigne=document.body.clientWidth/longueurDeLigneMax; 
     nbrLignes+=unescape(lesLignes[n]).length/(document.body.clientWidth/longueurDeLigneMax); 
     } 
   } 
  } 
  else {longueurDeLigne=zoneTexte.value.length} 
  
  zoneTexte.cols=(longueurDeLigne+1); // Charge le nombre de colonnes utile, plus une colonne pour la clarté 
  zoneTexte.rows=(nbrLignes+1); // Charge le nombre de lignes utile, plus une ligne pour la clarté 
 } 
} 
  
  
function textareaSizeLimites(zoneTexte,colMin,colMax,rowMin,rowMax) { 
 if (zoneTexte) { 
  nbrLignesMin=rowMin;longueurDeLigneMin=colMin; // Taille minimal de la zone de texte. 
  nbrLignesMax=rowMax;longueurDeLigneMax=colMax; // Taille maximale de la zone de texte. 
  nbrLignes=nbrLignesMin; 
  longueurDeLigne=longueurDeLigneMin; 
  lesLignes=escape(zoneTexte.value).split("%0D%0A"); 
  if (lesLignes) {nbrLignes=lesLignes.length;} 
  if (nbrLignes>nbrLignesMax) {nbrLignes=nbrLignesMax;} 
  else if (nbrLignes<nbrLignesMin) {nbrLignes=nbrLignesMin;} 
  
  if (lesLignes) { 
   for(n=0; n<(lesLignes.length); n++) { 
    if (longueurDeLigneMin<unescape(lesLignes[n]).length) {longueurDeLigne=unescape(lesLignes[n]).length;} 
    if (longueurDeLigne>longueurDeLigneMax) 
     { 
     longueurDeLigne=longueurDeLigneMax; 
     nbrLignes+=unescape(lesLignes[n]).length/longueurDeLigneMax; 
     } 
   } 
  } 
  else {longueurDeLigne=zoneTexte.value.length} 
  
  zoneTexte.cols=(longueurDeLigne+1); // Charge le nombre de colonnes utile, plus une colonne pour la clarté 
  zoneTexte.rows=(nbrLignes+1); // Charge le nombre de lignes utile, plus une ligne pour la clarté 
 } 
}
*/


function textareaSize(zoneTexte) {
	num_of_chars_per_line = 40;

	if(zoneTexte) {
		lesLignes = escape(zoneTexte.value).split("%0D%0A");
		nbrLignes = lesLignes.length;

		for(n = 0; n < nbrLignes; n++) { 
			longueurDeLigne = unescape(lesLignes[n]).length;
			if( longueurDeLigne > num_of_chars_per_line ) {
				nbrLignes += unescape(lesLignes[n]).length / num_of_chars_per_line;
			}
		}

		zoneTexte.rows = nbrLignes + 1;

	}
}