/*
//=======================================================================================
// CLASSE : InputDefaultValue(), par William Mcmurray (williammcmurray.com), 14 mai 2011
//=======================================================================================

function InputDefaultValue(objet)
{
	this.obj = objet;
	this.obj.defaultValue;
	this.obj.defaultColor="#bfb2a4";
	this.obj.color="#000";
	
	this.init = function()
	{
		this.obj.defaultValue = (this.obj.defaultValue == this.obj.getAttribute("defaultValue")) ? this.obj.getAttribute("defaultValue") : this.obj.defaultValue ;
		
		if(this.obj.getAttribute("defaultColor")){this.obj.defaultColor = this.obj.getAttribute("defaultColor");}
		this.obj.color = this.obj.style.color;
		
		if(this.obj.defaultValue == this.obj.getAttribute("defaultValue"))
	
			this.obj.addEventListener("focus",this.obj.onFocus,false);
			this.obj.addEventListener("blur",this.obj.onBlur,false);
			this.obj.onBlur();
		
	}
	
	this.obj.onFocus = function(){if(this.value==this.defaultValue){this.value="";this.style.color=this.color;}}
	this.obj.onBlur = function(){if(this.value=="" || this.value==this.defaultValue){this.value=this.defaultValue;this.style.color=this.defaultColor;}}
	this.init();
}

//lie la classe à tout les inputs avec l'attribut "defaultValue"
//ATTENTION ! : addEventListener() n'est pas recunnu par les versions ultérieures d'IE, alors préférez utiliser jQuery 
window.addEventListener("load", function()
{
	var a = window.document.body.getElementsByTagName('input');

	for(i=0;i<a.length;i++)
	{
		if(a[i].type=="text" && a[i].getAttribute("defaultValue"))
		{new InputDefaultValue(a[i]);}
	}
},true);
*/

//-------------------------------------------------------
// CLASSE : InputDescription(objet=[HTMLElementObject])
//-------------------------------------------------------
//Auteur 	: William Mcmurray
//Site Web 	: www.williammcmurray.com
//Version 	: 1.1 (12 juin 2011)
//License 	: Creative Commons Attribution 3.0 Unported
//-------------------------------------------------------

function initInputDescription(){var a = window.document.body.getElementsByTagName('input'); for(i=0;i<a.length;i++){if(a[i].type=="text" && a[i].getAttribute("description")){ new InputDescription(a[i]);}}}
function addEvent(Objet,Event,Function){if(!Objet.addEventListener){Objet.attachEvent("on"+Event, Function);}else{Objet.addEventListener(Event, Function, true);}};
addEvent(window,"load",initInputDescription);

function InputDescription(objet)
{
	this.obj = objet;
	this.obj.description;
	this.obj.descriptionColor="#bfb2a4"; //couleur par défaut de la police lorsque le texte de description est affiché
	this.obj.color="#000"; //couleur par défaut du texte inscrit par l'utilisateur dans le champ
	
	this.init = function()
	{
		this.obj.description = this.obj.getAttribute("description");
		if(this.obj.getAttribute("descriptionColor")){this.obj.descriptionColor = this.obj.getAttribute("descriptionColor");}
		this.obj.color = this.obj.style.color;
		
		var _this = this;
		addEvent(this.obj,"focus",function(){_this.obj.onFocus();});
		addEvent(this.obj,"blur",function(){_this.obj.onBlur();});
		if(document.activeElement==this.obj){this.obj.onFocus();}else{this.obj.onBlur();}
	}
	
	this.obj.onFocus = function(){if(this.value==this.description){this.value="";this.style.color=this.color;}}
	this.obj.onBlur = function(){if(this.value=="" || this.value==this.description){this.value=this.description;this.style.color=this.descriptionColor;}}
	this.init();
}
