/* -------------------------------------------------------------------------------------------
	File : jscript/include_form.js
	Abstract : ensemble de fonctions générales

	Fonctions définies :
	Author : Emmanuel PODVIN 
	Modifications :
		- 30/09/04 - Emmanuel PODVIN - emmanuel.podvin@intersel.org	
		- 07/06/05 - EPO - evol de TrouveStyle qui ne protégeait pas lorsque les input étaient vides

Commentaires à l'usage des RECOPIEURS ET/OU CURIEUX :
----------------------------------
	Ce code peut être réutilisé comme bon vous semble et à vos risques et périls...
    En vous remerciant de me faire éventuellement bénéficier de vos améliorations.
   ------------------------------------------------------------------------------------------- */

/* //--------------------------------------------------------------------
//	Function name :
//	Description		: 
//	input 			:
//  return value 	: 
//  global variables:
//--------------------------------------------------------------------
*/

//--DEBUT CODE INTERDIRE SELECTION TEXTE-->
function disableselect(e){
return false;
}
function reEnable(){
return true	;
}        	  
						
// Désactivation de la sélection du texte
//if IE4+
/*document.onselectstart=new Function ("return false");
//if NS6
if (window.sidebar){
document.onmousedown=disableselect;
document.onclick=reEnable;
} 
*/
//-- Fin CODE Interdire Selection texte                                                      
 
// Affichage d'un texte sur la barre de statut	 
function DisplayStatusTitle(aTitle)
{
	window.status=aTitle;
    return true;
}

// décryptage simple d'une adresse mail (anti-spam)
var a, s, n;
function Decrypt(s) 
{
	r='';
    for(i=0;i<s.length;i++)
    {
    	n=s.charCodeAt(i); 
        if (n>=8364) 
        {
    	    n = 128;
	    } 
	    r += String.fromCharCode( n - 3 ); 
    }
    return r;
}           
// affichage d'une adresse mail perturbante pour les moteurs spamm
// input:
//	- name : partie login d'une adresse mail
//	- domain : partie domaine d'une adresse mail (name@domain)
//	- args : argument de mailto (permet d'ajouter un CC, etc...
//	- Text : texte à afficher pour le lien
// Output :
//		sortie html : <a href='mailto:name@domain args> Text </a>
// où name, domain args Text sont les variables d'input
function print_mail(name,domain,args,Text)
{
	a ="pdlowr=";
	m='@';d=unescape(m);
	var nom = name;
	var domaine = domain;
	var aro = nom + d + domaine;
	document.write('<a href=');
    document.write(Decrypt(a));
    document.write(aro);
    document.write(args);
    document.write('>');  
	document.write(Text + '</a>');    
}                 

/* //--------------------------------------------------------------------
//	Function name : TrouveObjet
//	Description		:  permet de retrouver un objet depuis son ID
//		La syntaxe d'appel de cette fonction est
//   var objet = trouveobjet(idf);
//	input 			:  idf est l'identificateur (ID) d'un élément. 
//  return value 	:  objet associé à idf
//  global variables:
//--------------------------------------------------------------------
*/
 function TrouveObjet(idf) { 
 
 doc=document;
 
    if (doc.getElementById && doc.getElementById(idf)) 	//IE
	{
	  	return doc.getElementById(idf);
    } 
	else if (doc.all && doc.all[idf]) //Mozilla
	{
      return doc.all[idf];
    } 
	else if (doc.layers) 
	{
      return doc.layers[idf];
    } 
	else 
	{ 
		return null; 
	}
  }
  
/* //--------------------------------------------------------------------
//	Function name : TrouveStyle
//	Description		:  permet de retrouver le style d'un objet depuis son ID
//		La syntaxe d'appel de cette fonction est
//   var objet_style = trouvestyle(idf);
//	input 			:  idf est l'identificateur (ID) d'un élément. 
//  return value 	:  objet de style associé à idf
//  global variables:
//--------------------------------------------------------------------
*/
 function TrouveStyle(idf) { 
 
 doc=document;
 
    if (doc.getElementById && doc.getElementById(idf)) 	//IE
	{
	  	return doc.getElementById(idf).style;
    } 
	else if (doc.all && doc.all[idf]) //Mozilla
	{
      return doc.all[idf].style;
    } 
	else if (doc.layers) 
	{
      return doc.layers[idf];
    } 
	else 
	{ 
		return null; 
	}

  }
		
  
  
/* //--------------------------------------------------------------------
//	Function name : ChangeStyle
//	Description		: Permet de modifier le style d'un objet
//	input 			:
//		idf : Id d'un objet
//		prop : nom d'une propriété
//	Dans le cas des noms composés comme background-image, la règle est de
     — mettre en majuscule la lettre après un tiret,
     — et de supprimer le(s) tiret(s).
//  return value 	:
//		aucune
//  global variables:       
//	exemple :
//		ChangeStyle("aaa","visibility","hidden");
//		ChangeStyle("aaa","border","5px ridge green"); 
//      ChangeStyle("aaa","backgroundImage","url(image_bis.jpg)") 
//--------------------------------------------------------------------
*/
  function ChangeStyle(idf,prop,value) 
  {
     var objet_style= TrouveStyle(idf);	   

	 if(objet_style) 					  
	 {			  
        eval( 'objet_style.' + prop + '="' + value+ '"' );
	 }
	 //DisplayImgText(idf);
  }
/* //--------------------------------------------------------------------
//	Function name : GetStyle
//	Description		: Permet de récupérer la valeur d'un style d'un objet
//	input 			:
//		idf : Id d'un objet
//		prop : nom d'une propriété
//	Dans le cas des noms composés comme background-image, la règle est de
     — mettre en majuscule la lettre après un tiret,
     — et de supprimer le(s) tiret(s).
//  return value 	:
//		aucune
//  global variables:       
//	exemple :
//		val=GetStyle("aaa","visibility");
//--------------------------------------------------------------------
*/
  function GetStyle(idf,prop) 
  {
	 var result=null;
     var objet= TrouveObjet(idf);	
	 if (objet)
	 {
		 if (objet.currentStyle) 
		 { 
			result= objet.currentStyle[prop];	
	     } 
		 else if (window.getComputedStyle) 
		 { 
	        var compStyle = window.getComputedStyle(objet, ""); 
	        result = compStyle[prop]; 
	     }      
	}
	 return result;
  }

/* //--------------------------------------------------------------------
//	Function name : ChangeInnerHtml
//	Description		: Permet de remplacer le texte html intérieur d'un objet
//	input 			:
//		idf : Id d'un objet
//		text : texte à remplacer
//  return value 	:
//		aucune
//  global variables:       
//	exemple :
//      ChangeInnerHtml("aaa","<a href='#'>coucou</a>") 
//--------------------------------------------------------------------
*/
  function ChangeInnerHtml(idf,text) 
  {
     var objet= TrouveObjet(idf);
     if(objet) 
        eval( 'objet.innerHTML="' + text+ '"' );
  }
/* //--------------------------------------------------------------------
//	Function name : AppendInnerHtml
//	Description		: Permet d'ajouter du texte html intérieur d'un objet
//	input 			:
//		idf : Id d'un objet
//		text : texte à remplacer
//  return value 	:
//		aucune
//  global variables:       
//	exemple :
//      ChangeInnerHtml("aaa","<a href='#'>coucou</a>") 
//--------------------------------------------------------------------
*/
  function AppendInnerHtml(idf,text) 
  {
     var objet= TrouveObjet(idf);
     if(objet) 
        eval( 'objet.innerHTML.="' + text+ '"' );
  }

  /* //--------------------------------------------------------------------
//	Function name : ChangeClass
//	Description		: Permet de modifier la classe d'un objet
//	input 			:
//		idf : Id d'un objet
//		aclass : nom d'une classe
//  return value 	:
//		aucune
//  global variables:       
//	exemple :
//		ChangeClass("aaa","mynewclass");
//--------------------------------------------------------------------
*/
  function ChangeClass(idf,aclass) 
  {
     var objet= TrouveObjet(idf);
     if(objet)
	 	objet.className = aclass;
  }

  
var Tableau_Images = new Array();	
  
function CreateImage(imageid,imageoff,imageon)
{
	Tableau_Images[imageid+'on']=new Image();
	Tableau_Images[imageid+'off']=new Image();
	Tableau_Images[imageid+'on'].src=imageon;
	Tableau_Images[imageid+'off'].src=imageoff;	  
}

function  SetImageOn(imageid)
{	
	img=TrouveObjet(imageid);
	if (img) img.src=Tableau_Images[imageid+'on'].src;
} 
function  SetImageOff(imageid)
{
	img=TrouveObjet(imageid);
	if (img) img.src=Tableau_Images[imageid+'off'].src;
}
/* //--------------------------------------------------------------------
//	Function name : Auth_Verification
//	Description		: Vérifie l'authentification
//	input 			:
//  return value 	:
//  global variables:       
//	exemple :
//--------------------------------------------------------------------
*/
 //verification avant envoi pour authentification
function Auth_Verification()
{
	var msg="";
	var verif=true;
	var user_login=document.authen.user_login.value;
	var mdp=document.authen.mdp.value;
	if (user_login=="")
	{
		msg=msg +('Votre compte utilisateur est manquant\n');
		verif=false;
	}
	
	if ( (mdp==null) || (mdp=="") )
	{
		msg=msg +('Votre mot de passe est manquant\n');	 
		document.authen.mdp.focus();
		verif=false;
	}
	else 
	{							  
		document.authen.mdp.value='';
		document.authen.mdphidden.value=hex_md5(mdp);// on encode le password avant envoi...   
	}
		

	
	if (verif==false)
	{
		alert(msg);
	}
	if (verif==true) return true; else return false;
}

/* //--------------------------------------------------------------------
//	Function name : SetChecked
//	Description		: permet de cocher un ensemble de cases à cocher contenu dans un formulaire
//	input 			:
		- val [0|1]:  si == 1, case cochée (checked)
		- chkName : nom des cases à cocher (leur donner toutes le même nom comme name="id[]"
		- aForm : nom id d'un formulaire
//  return value 	: none
//  global variables:       
//	exemple :						
		
//--------------------------------------------------------------------
*/
function SetChecked(val,chkName,aForm) 
{
	dml=document.forms[aForm];
	len = dml.elements.length; 
	var i=0;
	for( i=0 ; i<len ; i++) 
	{				 
		//alert(dml.elements[i].name);
		if (dml.elements[i].name==chkName) 
		{
			dml.elements[i].checked=val;
		}
	}
} 

/* //--------------------------------------------------------------------
//	Function name : SelectAllOpt
//	Description		: permet de cocher/décocher un ensemble de cases à cocher contenu dans un formulaire
						piloté par une case à cocher
//	input 			:
		- selId:  nom Id d'une case à cocher qui pilote les autres cases
		- chkName : nom des cases à cocher (leur donner toutes le même nom comme name="id[]"
		- aForm : nom id d'un formulaire
//  return value 	: none
//  global variables:       
//	exemple :						
	<input type="checkbox" id="CheckSelected" onclick="SelectAllOpt('CheckSelected','id[]','SendingForm')" checked>

	<input type="checkbox" name="id[]" id="" checked>	
//--------------------------------------------------------------------
*/
function SelectAllOpt(selId,chkName,aForm) 
{        
	var sel = document.getElementById(selId); 
	SetChecked(sel.checked,chkName,aForm);
} 
/* //--------------------------------------------------------------------
//	Function name : activate_XMLHttpRequest
//	Description		: initialise a XMLHttpRequest object
//	input 			: 
//  return value 	: void
//  global variables:	xhrcont: a global XMLHttpRequest object
//--------------------------------------------------------------------
*/							
var xhrcont = null;
function getXhrcont()
{				  
	
	if (window.XMLHttpRequest) xhrcont = new XMLHttpRequest();
	else if(window.ActiveXObject)
	{
		try
		{
			xhrcont = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e)
		{
			xhrcont = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	else
	{
		alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
		xhrcont = false;
	}	 
	return xhrcont;
}
/* //--------------------------------------------------------------------
//	Function name : activate_dynamic_results
//	Description		: allows to make requests through XMLHttpRequest
//	input 			: 
//		aValueObjectId : the object whose value should be used for the request and where it will be updated
//		WhereToDisplay_ObjectId : a 'div' object where should be given back the results
// 		PosX, PosY	: position X/Y from initial position of WhereToDisplay_ObjectId (generally should be 0,0)  
//		aServerFile : http file managing the httpRequest
//						should be formatted as for example : myfile.php?myvariable=	 
//		encoding []: if == 'base64', encoding between server and ajax client should be encoded in base 64
//		variables : a string to pass through			
//		aTrigger : a function name to call with the returned values
// 
//    	the call of aServerFile function file is done as:
//			<aServerFile><aValue>::<aValueObjectId>::<WhereToDisplay_ObjectId>::<variables>
//		Example : myfile.php?myvariable=activi::objid1::myobjid2::12-4555-qdqs
//  return value 	: void
//  global variables:	  
//	call example : activate_dynamic_results('NLId','pourcent_fait',0,0,'send_mails.php?request=','','10') ;
//--------------------------------------------------------------------
*/							
function activate_dynamic_results(aValueObjectId,WhereToDisplay_ObjectId,PosX,PosY,aServerFile,Encoding,variables,aTrigger)
{
	WhereToDisplay_Object = TrouveObjet(WhereToDisplay_ObjectId,'');	  
	aValueObject = TrouveObjet(aValueObjectId,'');	  

	getXhrcont();
	xhrcont.onreadystatechange = function()
	{
//				alert('coucou:'+xhrcont.readyState+'-'+xhrcont.status);
		//document.getElementById('affich_mess').innerHTML=("<table width=\"350\" height=\"50\" bgcolor=\"#F4F4F4\"><tr><td align=\"center\">envoi en cours... <image src='loading.gif' border=0></td></tr></table>");
		if(xhrcont.readyState == 4 && xhrcont.status == 200)
		{
			if (xhrcont.responseText!="")
			{
				WhereToDisplay_Object.style.visibility="visible";
				if (Encoding=='base64')
					aReturnedValue=Base64.decode(xhrcont.responseText);
				else
					aReturnedValue=xhrcont.responseText;
				WhereToDisplay_Object.innerHTML=aReturnedValue;
				if (aTrigger) eval('aTrigger(aReturnedValue)');
			}
			else
			{
				WhereToDisplay_Object.style.visibility="hidden";
			}
		}
	}	   

	DivLeft = getLeft(aValueObject);
	DivTop = getTop(aValueObject);
	WhereToDisplay_Object.style.left = DivLeft+PosX-5;
	WhereToDisplay_Object.style.top = DivTop+PosY-12;

//	aValueObject=TrouveObjet(aValueObjectId,''); bis repetita?
	aValue=aValueObject.value;																			   
//	alert(aServerFile+aValue+"::"+aValueObjectId+"::"+WhereToDisplay_ObjectId+'::'+variables);
	xhrcont.open("GET",(aServerFile+aValue+"::"+aValueObjectId+"::"+WhereToDisplay_ObjectId+'::'+variables),true);
	xhrcont.send(null);
}

/* //--------------------------------------------------------------------
//	Function name : transfer_results
//	Description		: attached to an object, transfer its value to another object...
//	input 			: 
//		aValue : a value to set
//		WhereToDisplay_ObjectId : the object whose value should change
//  return value 	: void
//  global variables:
//--------------------------------------------------------------------
*/							
function transfer_results(aValue,WhereToDisplay_ObjectId)
{						
	WhereToDisplay_Object = TrouveObjet(WhereToDisplay_ObjectId,'');	  
	WhereToDisplay_Object.value=aValue;

}

/* //--------------------------------------------------------------------
//	Function name : activate_dynamic_options
//	Description		: allows to update an option list from a request
//	input 			: 
//		aValueObjectId : the object whose value should be used for the request
//		WhereToDisplay_ObjectId : a 'div' object where should be installed the news select/option list
//		aServerFile : http file managing the httpRequest
//						should be formatted as for example : myfile.php?myvariable=	 
//		encoding []: if == 'base64', encoding between server and ajax client should be encoded in base 64
//		variables : a string to pass through
// 
//    	the call of aServerFile function file is done as:
//			<aServerFile><aValue>::<aValueObjectId>::<WhereToDisplay_ObjectId>::<variables>
//		Example : myfile.php?myvariable=activi::objid1::myobjid2::12-4555-qdqs
//  return value 	: void
//  global variables:
//--------------------------------------------------------------------
*/							
function activate_dynamic_options(aValueObjectId,WhereToDisplay_ObjectId,aServerFile,Encoding,variables)
{
	WhereToDisplay_Object = TrouveObjet(WhereToDisplay_ObjectId,'');	  
	aValueObject = TrouveObjet(aValueObjectId,'');	  
	getXhrcont();
	xhrcont.onreadystatechange = function()
	{
		//alert('coucou:'+xhrcont.readyState+'-'+xhrcont.status);
		//document.getElementById('affich_mess').innerHTML=("<table width=\"350\" height=\"50\" bgcolor=\"#F4F4F4\"><tr><td align=\"center\">envoi en cours... <image src='loading.gif' border=0></td></tr></table>");
		if(xhrcont.readyState == 4 && xhrcont.status == 200)
		{
			if (xhrcont.responseText!="")
			{
				if (Encoding=='base64')
					WhereToDisplay_Object.innerHTML=Base64.decode(xhrcont.responseText);
				else
					WhereToDisplay_Object.innerHTML=xhrcont.responseText;
			}
		}
	}	   

	aValueObject=TrouveObjet(aValueObjectId,'');
	aValue=aValueObject.value;																			  
//	alert(aServerFile+aValue+"::"+aValueObjectId+"::"+WhereToDisplay_ObjectId+'::'+Encoding+'::'+variables);
	xhrcont.open("GET",(aServerFile+aValue+"::"+aValueObjectId+"::"+WhereToDisplay_ObjectId+'::'+Encoding+'::'+variables),true);
	xhrcont.send(null);
}


/* //--------------------------------------------------------------------
//	Function name : PlaceObject
//	Description		: Position an object with {position:absolute} settings to a specific position according to another object
//	input 			: 																										 
		aObjectToPlace : a DOM Object to position
		aRefObject : a Dom object used to position aObjectToPlace
		PosX, PosY : position (x,y) from corner upper-left of aRefObject
//  return value 	: void
//  global variables:
//--------------------------------------------------------------------
*/							
function PlaceObject(aObjectToPlace,aRefObject,PosX, PosY)
{				
	DivLeft = getLeft(aRefObject);
	DivTop = getTop(aRefObject);
	aObjectToPlace.style.left = DivLeft+PosX+'px';
	aObjectToPlace.style.top = DivTop+PosY+'px';

}
/* //--------------------------------------------------------------------
//	Function name : getLeft
//	Description		: gets absolute left position of an object in the general document
//	input 			: 
//		a DOM Object
//  return value 	: void
//  global variables:
//--------------------------------------------------------------------
*/							
function getLeft(MyObject)
{
	if (MyObject.offsetParent)
	    return (MyObject.offsetLeft + getLeft(MyObject.offsetParent));
	else 
	    return (MyObject.offsetLeft);
} 
/* //--------------------------------------------------------------------
//	Function name : getTop
//	Description		: gets absolute top position of an object in the general document
//	input 			: 
//		a DOM Object
//  return value 	: void
//  global variables:
//--------------------------------------------------------------------
*/							
function getTop(MyObject)
{
	if (MyObject.offsetParent)
	   return (MyObject.offsetTop + getTop(MyObject.offsetParent));
	else
	   return (MyObject.offsetTop);
}

/* //--------------------------------------------------------------------	
utilisé pour datepicker...
//--------------------------------------------------------------------
*/
function SetFormatYear(aDate)
{		  	  
	atabdate=aDate.split("/"); 
	if (!IsNumeric(atabdate[0])) 
	{
		atabdate[0]='01'; 
		atabdate[1]='01'; 
		atabdate[2]='2001'; 
	}
	if (parseInt(atabdate[0],10)<10) atabdate[0]='0'+parseInt(atabdate[0],10); 
	else if (parseInt(atabdate[0],10)>31) atabdate[0]='31'; 
	if (parseInt(atabdate[1],10)<10) atabdate[1]='0'+parseInt(atabdate[1],10);
	else if (parseInt(atabdate[1],10)>12) atabdate[1]='12';
	if (parseInt(atabdate[2],10)<100) atabdate[2]=parseInt(atabdate[2],10)+2000;
	aNewDate=atabdate[0]+'/'+atabdate[1]+'/'+atabdate[2];
	return(aNewDate);
}	  

//
// correctly handle PNG transparency in Win IE 5.5 & 6.
// example of call : if (window.attachEvent) window.attachEvent("onload", correctPNG);
function correctPNG()
{
   var arVersion = navigator.appVersion.split("MSIE")
   var version = parseFloat(arVersion[1])
   if ((version >= 5.5) && (document.body.filters)) 
   {
      for(var i=0; i<document.images.length; i++)
      {
         var img = document.images[i]
         var imgName = img.src.toUpperCase()
         if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
         {
            var imgID = (img.id) ? "id='" + img.id + "' " : ""
            var imgClass = (img.className) ? "class='" + img.className + "' " : ""
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
            var imgStyle = "display:inline-block;" + img.style.cssText 
            if (img.align == "left") imgStyle = "float:left;" + imgStyle
            if (img.align == "right") imgStyle = "float:right;" + imgStyle
            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
            var strNewHTML = "<span " + imgID + imgClass + imgTitle
            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
            img.outerHTML = strNewHTML
            i = i-1
         }
      }
   }    
}
/* //--------------------------------------------------------------------
//	Function name : escape_plus
//	Description		: seems that the escape javascript function does not escape enough...
//					  so I hope this one does!
//	input 			: 
//		aString
//  return value&#12208;&#1025;: &#17980;ž&#4848;&#350;&#0;&#0;ped string
//  global variables:
//--------------------------------------------------------------------
*/							
    function escape_plus(aString) 
    {					   
		aString = escape(aString);  
//		aString = encodeURIComponent(aString);
		aString= aString.replace(new RegExp('\\+','g'),'%2B');
	    aString= aString.replace(new RegExp('%20','g'),'+');
		return aString;
	}			 
	
/* //--------------------------------------------------------------------
//	Function name : escape_quote
//	Description		: escape quote in string
//	input 			: 
//		aString
//  return value 	: a escaped string
//  global variables:
//--------------------------------------------------------------------
*/							
	function escape_quote(jscript)
	{
        jscript=Replace(jscript,'\\', '\\\\');//'
        jscript=Replace(jscript,"'", "\\'");
        jscript=Replace(jscript,'"', '\\"');
        jscript=Replace(jscript,'\n', '');
        jscript=Replace(jscript,'\t', '');
		return jscript;
	}
 /* //--------------------------------------------------------------------
//	Function name : Replace
//	Description		: effectue le remplacement des occurences d'une chaine de caractères par une autre
//	input 			: 										  
//		-str : une string
//		- find : une chaine à rechercher
//		- rep : la chaine de remplacement
//  return value 	: 					 
//		la chaine résultante après remplacement
//  global variables:						   
//	exemple : myString = Replace("coucou les amis et coucou les copains", "coucou", "Salut");
//		myString == "Salut les amis et Salut les copains"
//--------------------------------------------------------------------
*/							
function Replace(str, find, rep)
{
    var res = str;
    var i = 0;	   
    while(true)
    {				
        i = res.indexOf(find, i);
        if (i == -1) break;
        res = res.substr(0, i) + rep + res.substr(i + find.length);
        i += rep.length;
    }		   		
    return res;
}	
 /*
//--------------------------------------------------------------------
//	Function name : IsInternetExplorer
//	Description		: vérifie si le navigateur courant est Internet Explorer ou non
//--------------------------------------------------------------------
*/
function IsInternetExplorer()
{	
	smallcap_navigator=navigator.appName.toLowerCase();
	
	if (smallcap_navigator.indexOf("explorer") != -1)
		return true;
	else return false;
}


//--------------------------------------------------------------------
//  Affichage de sous-menus avec latence
//--------------------------------------------------------------------
var CurrentMenuTime=0; 
var ClearDelay=500; //milliseconds	  latency 
var last_displayed=null;

/* 
//--------------------------------------------------------------------
//	Function name : DisplayObject
//	Description		: Display an object with {position:absolute} settings to a specific position according to the current object
//	input 			: 																										 
		aObjectToPlaceId : a Object Id to position
		PosX, PosY : position (x,y) from corner upper-left of the current object doing the call
//  return value 	: void
//  global variables:
//--------------------------------------------------------------------
*/							
function DisplayObjectFromMe(Me,aObjectToPlaceId,PosX, PosY)
{						
	// delete any previous waiting actions on menus...
	if (aObjectToPlaceId == last_displayed) ClearCountToHideMenu();	//if we display the same submenu, stop any action to erase it
	else HideMenu(last_displayed); //if we display another sub menu, hide the previous one
	last_displayed=aObjectToPlaceId;			   
	
	aObjectToPlace=TrouveObjet(aObjectToPlaceId,'');
	DivLeft = getLeft(Me);
	DivTop = getTop(Me);	 
	aObjectToPlace.style.left = DivLeft+PosX+'px';	  //ne pas oublier le 'px' à la fin sinon ne marche pas sur FF!
	aObjectToPlace.style.top = DivTop+PosY+'px';
	aObjectToPlace.style.position = 'absolute';
	aObjectToPlace.style.visibility = 'visible';
//	alert(DivLeft+'-'+aObjectToPlace.style.left);

}

/* 
//--------------------------------------------------------------------
//	Function name : StartCountToHideMenu - ClearCountToHideMenu	- HideMenu
//	Description		: Management of display/clear display of an object (~ submenu for instance)
//						through the visibility style parameter
//	input 			: 																										 
		aObjectToPlaceId : a Object Id to clear with a delay
//  return value 	: void
//  global variables:
//--------------------------------------------------------------------
*/							

function StartCountToHideMenu(aObjectToPlaceId)
{
	CurrentMenuTime=window.setTimeout(	function()
										{
											HideMenu(aObjectToPlaceId)
										}, 
										ClearDelay);
} 
function ClearCountToHideMenu()
{
	clearTimeout(CurrentMenuTime);	
	CurrentMenuTime=0;
}

function HideMenu(aObjectToPlaceId)
{
	if (CurrentMenuTime != 0) ChangeStyle(aObjectToPlaceId,'visibility','hidden');
	ClearCountToHideMenu();
}
