function FormHighLighter()
{
	
	// privées
	this._items = new Array();
	
	// public
	this.backgroundColor 			= null;
	this.borderColor 				= null;
	this.borderWidth				= 1;
	this.borderStyle 				= "solid";
	this.Color 						= null;
	
	this.messageHeight				= null;
	this.messageLeftImage 			= null;
	this.messageLineHeight 			= null;
	this.messagerightImage 			= null;
	this.messageBackgroundColor 	= null;
	this.messageBorderColor 		= null;
	this.messageBorderWidth			= null;
	this.messageBorderStyle 		= null;
	this.messageColor 				= null;
	this.messagePadding				= null;
	
	// public
	this.ajouter = function( element, message )
	{
		if( element != null )
		{
			this._items.push(new HightLightedElement(element, message));
		}
	}
	
	this.hightlight = function()
	{
		this.appliquerStyles();
		
		for( var i=0; i < this._items.length; i++ )
		{
			this._items[i].hightlight();
		}
	}
	
	// privées
	this.appliquerStyles = function()
	{
		for( var i=0; i < this._items.length; i++ )
		{
			if( this.backgroundColor != null )	this._items[i].backgroundColor 	= this.backgroundColor;
			if( this.borderWidth != null )		this._items[i].borderWidth 		= this.borderWidth;
			if( this.borderStyle != null )		this._items[i].borderStyle 		= this.borderStyle;
			if( this.borderColor != null )		this._items[i].borderColor 		= this.borderColor;
			if( this.Color != null )			this._items[i].Color 			= this.Color;
			
			if( this.messageHeight != null )			this._items[i].messageHeight		 	= this.messageHeight;
			if( this.messageLineHeight != null )		this._items[i].messageLineHeight		= this.messageLineHeight;
			if( this.messageLeftImage != null )			this._items[i].messageLeftImage		 	= this.messageLeftImage;
			if( this.messagerightImage != null )		this._items[i].messagerightImage 		= this.messagerightImage;
			if( this.messageBackgroundColor != null )	this._items[i].messageBackgroundColor 	= this.messageBackgroundColor;
			if( this.messageBorderColor != null )		this._items[i].messageBorderColor 		= this.messageBorderColor;
			if( this.messageBorderWidth != null )		this._items[i].messageBorderWidth 		= this.messageBorderWidth;
			if( this.messageBorderStyle != null )		this._items[i].messageBorderStyle 		= this.messageBorderStyle;
			if( this.messageColor != null )				this._items[i].messageColor 			= this.messageColor;
			if( this.messagePadding != null )			this._items[i].messagePadding 			= this.messagePadding;
		}
	}
}

function HightLightedElement( element, message)
{
	// privées
	this.element 				= element;
	this.element.controleur 	= this;
	this.message 				= message;
	this.divElement 			= null;
	this.leftImgElement 		= null;
	this.rightImgElement 		= null;
	this.textElement 			= null;
	
	// public
	this.backgroundColor 			= null;
	this.borderColor 				= null;
	this.borderWidth				= null;
	this.borderStyle 				= null;
	this.Color 						= null;
	
	this.messageLineHeight 			= null;
	this.messageHeight	 			= null;
	this.messageLeftImage 			= null;
	this.messagerightImage 			= null;
	this.messageBackgroundColor 	= null;
	this.messageBorderColor 		= null;
	this.messageBorderWidth			= null;
	this.messageBorderStyle 		= null;
	this.messageColor 				= null;
	this.messagePadding				= null;
	
	
	// public
	this.hightlight = function ()
	{
		this.appliquerStyles( this.getType() );
		
		this.appliquerEvenements();
		
		this.creerDiv();
		
		switch( this.getType() )
		{
			case "input":
			break;
			case "textarea":
			break;
			case "select":
			break;
			case "radio":
				// --
			break;
			case "checkbox":
				// --
			break;
			default:
				// --
			break;
		}
	}
	
	this.afficherMessage = function ()
	{
		if( navigateur.estIE6 && !this.done )
		{
			var t = "seert"+Math.random();
			window.t = this;
			window.setTimeout("window.t.pourIE6()",510);
		}
		
		$(this.divElement.id).appear({ duration: 0.5 });
		//this.divElement.style.display 	= "block";
	}
	
	this.done = false;
	this.pourIE6 = function()
	{
		this.rightImgElement.style.width = this.textElement.clientWidth*95/100;
		this.leftImgElement.style.width = this.textElement.clientWidth*95/100;
		this.done = true;
	}
	
	this.masquerMessage = function ()
	{
		$(this.divElement.id).hide();
		//this.divElement.style.display 	= "none";
	}
	
	// privées
	this.appliquerStyles = function( type )
	{
		if( type == "radio" || type == "checkbox" )
		{
			// ne rien faire
		}
		else
		{
			if( this.backgroundColor != null )			this.element.style.backgroundColor 	= this.backgroundColor;
			if( this.borderWidth != null )				this.element.style.borderWidth 		= this.borderWidth+"px";
			if( this.borderStyle != null )				this.element.style.borderStyle 		= this.borderStyle;
			if( this.borderColor != null )				this.element.style.borderColor 		= this.borderColor;
			if( this.Color != null )					this.element.style.color 			= this.Color;
		}
	}
	
	this.appliquerEvenements = function( )
	{
		if( this.message != "" )
		{
			YAHOO.util.Event.addListener(this.element, "mouseover", this.afficherMessage, this, true  );
			YAHOO.util.Event.addListener(this.element, "mouseout", this.masquerMessage, this, true  );
		}
	}
	
	this.creerDiv = function()
	{
		if( this.divElement != null )
			return false;
		
		this.divElement 		= document.createElement("div");
		this.leftImgElement 	= document.createElement("div");
		this.rightImgElement 	= document.createElement("div");
		this.textElement 		= document.createElement("div");
		
		if( this.messageBackgroundColor != null ) 	this.divElement.style.backgroundColor 	= this.messageBackgroundColor;
		if( this.messageBorderColor != null ) 		this.divElement.style.borderColor 		= this.messageBorderColor;
		if( this.messageBorderWidth != null ) 		this.divElement.style.borderWidth 		= this.messageBorderWidth+"px";
		if( this.messageBorderStyle != null ) 		this.divElement.style.borderStyle 		= this.messageBorderStyle;
		
		
		this.leftImgElement.style.position 				= "absolute";
		this.leftImgElement.style.top 					= "0px";
		this.leftImgElement.style.left 					= "0px";
		this.leftImgElement.style.height				= this.messageHeight+"px";
		this.leftImgElement.style.width					= "95%";
		this.leftImgElement.style.backgroundImage		= "url("+this.messageLeftImage+")";
		this.leftImgElement.style.backgroundPosition	= "top left";
		this.leftImgElement.style.backgroundRepeat		= "no-repeat";
		
		this.textElement.style.position 				= "relative";
		this.textElement.style.styleFloat 				= "left";
		this.textElement.style.top 						= "0px";
		this.textElement.style.left 					= "0px";
		//this.textElement.style.height					= this.messageHeight+"px";
		this.textElement.style.width					= "auto";
		//this.textElement.style.lineHeight				= (this.messageHeight-this.messagePadding*2)+"px";
		if( this.messageColor != null ) 				this.textElement.style.color 			= this.messageColor;
		if( this.messagePadding != null ) 				this.textElement.style.padding 			= this.messagePadding+"px";
		
		this.textElement.innerHTML = this.message;
		
		this.rightImgElement.style.position 			= "absolute";
		this.rightImgElement.style.top 					= "0px";
		this.rightImgElement.style.right 				= "0px";
		this.rightImgElement.style.height				= this.messageHeight+"px";
		this.rightImgElement.style.width				= "95%";
		this.rightImgElement.style.backgroundImage		= "url("+this.messagerightImage+")";
		this.rightImgElement.style.backgroundPosition	= "top right";
		this.rightImgElement.style.backgroundRepeat		= "no-repeat";
		
		
		
		this.divElement.appendChild( this.rightImgElement );
		this.divElement.appendChild( this.leftImgElement );
		this.divElement.appendChild( this.textElement );
		
		this.divElement.style.display 		= "none";
		this.divElement.style.textAlign 	= "left";
		this.divElement.style.position 		= "absolute";
		this.divElement.style.zIndex 		= 900;
		this.divElement.style.lineHeight 	= (this.messageLineHeight)+"px";
		this.divElement.style.top 			= (YAHOO.util.Dom.getY(this.element)-this.messageHeight-2)+"px";
		this.divElement.style.left	 		= (YAHOO.util.Dom.getX(this.element)+20)+"px";

		
		id = Math.random();
		while( document.getElementById("my"+id) != null )
			id = Math.random();
		this.divElement.id = "my"+id;
		
		document.body.appendChild( this.divElement );
	}
	
	this.getType = function ()
	{
		if( this.element == null )
			return "";
			
		if( this.element.nodeName == null )
		{
			// Reception d'une liste d'elements (cas des radio qui porte tous le même nom par exemple....)
			for( var e=0; e < element.length; e++ )
			{
				if( this.element[e].nodeName.toLowerCase() == "input" &&  this.element[e].type.toLowerCase() == "radio" )
					return "radio";
				else if( this.element[e].nodeName.toLowerCase() == "input" &&  this.element[e].type.toLowerCase() == "checkbox" )
					return "checkbox";
			}
		}
		else if( this.element.nodeName.toLowerCase() == "input" )
		{
			return "input";
		}
		else if( this.element.nodeName.toLowerCase() == "textarea" )
		{
			return "textarea";
		}
		else if( this.element.nodeName.toLowerCase() == "select" )
		{
			return "select";
		}
	}
}
