// JavaScript Document
// fonctions d'affiche ETC.....


function getLeft(MyObject)
//Fonction permettant de connaître la position d'un objet
//par rapport au bord gauche de la page.
//Cet objet peut être à l'intérieur d'un autre objet.
{
if (MyObject.offsetParent)
	return (MyObject.offsetLeft + getLeft(MyObject.offsetParent));
else
	return (MyObject.offsetLeft);
} 


function getTop(MyObject)
//Fonction permettant de connaître la position d'un objet
//par rapport au bord haut de la page.
//Cet objet peut être à l'intérieur d'un autre objet.
{
if (MyObject.offsetParent)
	return (MyObject.offsetTop + getTop(MyObject.offsetParent));
else
	return (MyObject.offsetTop);
}


function getHeight(element)
{
	return element.offsetHeight;
}


function getWidth(element)
{
	return element.offsetWidth;
}



function inputTextEffect()
{
	var input=document.getElementsByTagName("input");	
	
	
		for(var i = 0; i < input.length; i++) {
			  if(input[i].type=="text")
			  {
			  
				  input[i].style.backgroundColor="#FFFFFF";
				  
				   input[i].onclick=function()
				   {
							
						for(var i = 0; i < input.length; i++) {
						 	if(input[i].type=="text")
			  				input[i].style.backgroundColor="#FFFFFF";
						}
					   
						this.style.backgroundColor="#EAEED7";
			
				   }
				    input[i].onfocus=function()
				   {
							
						for(var i = 0; i < input.length; i++) {
						 	if(input[i].type=="text")
			  				input[i].style.backgroundColor="#FFFFFF";
						}
					   
						this.style.backgroundColor="#EAEED7";
			
				   }
				   input[i].onblur=function()
					{
						for(var i = 0; i < input.length; i++) {
						 if(input[i].type=="text")
						 input[i].style.backgroundColor="#FFFFFF";
						}
					}
			  }
		 }
		 
	
}


function getWindowHeight()
{
 var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
	
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
	
	if(document.body.scrollHeight>myHeight ){
		return (document.body.scrollHeight+30);
	}else{
		return myHeight;
	}
}


function getWindowWidth() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }

return myWidth 

}



function alertSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  window.alert( 'Width = ' + myWidth );
  window.alert( 'Height = ' + myHeight );
}


// affichage d'une alerte
function displayMessage(id_ancre,message,type,AlerteTop,AlerteLeft,AlerteWidth)
{
		// ****** gestion de la creation d'un div dynamique
		if(document.getElementById("message_alerte_123")){
			document.getElementById("message_alerte_123").parentNode.removeChild(document.getElementById("message_alerte_123")); 
		}
		nouveauDiv = document.createElement("div");
		mon_div = document.getElementById("div_phantome");
  		document.body.insertBefore(nouveauDiv, mon_div);
 		
		
   		nouveauDiv.id="message_alerte_123";

		nouveauDiv.style.display='block';
		nouveauDiv.innerHTML=message;	
		nouveauDiv.style.position='absolute';
		
		if(document.getElementById(id_ancre)){
			ancre=document.getElementById(id_ancre);
			
			
			if(AlerteTop)
				nouveauDiv.style.top=getTop(ancre)+parseInt(AlerteTop)+"px";
			else
				nouveauDiv.style.top=getTop(ancre)-5+"px";
			
			if(AlerteLeft)
				nouveauDiv.style.left=getLeft(ancre)+parseInt(AlerteLeft)+"px";
			else
			nouveauDiv.style.left=getLeft(ancre)+"px";
			
			if(AlerteWidth)
				nouveauDiv.style.width=(getWidth(ancre)-34+parseInt(AlerteWidth))+"px";
			else
				nouveauDiv.style.width=(getWidth(ancre)-34)+"px";
		}else{
			
		}

	
		
		
		if(type!="info"){
			nouveauDiv.className="adm-alerte";		
		}else{
			nouveauDiv.className="adm-info";
		}
		dojo.lfx.html.fadeIn(nouveauDiv.id, 400).play();
		alertTimeout = setTimeout("noneAlert('"+nouveauDiv.id+"')",3400);
}


// desaffiche d'une alerte
function noneAlert(id_div)
{
	dojo.lfx.html.fadeOut(id_div, 400).play();
	setTimeout("document.getElementById('"+id_div+"').style.display='none'",400);
}