//******************************************
//				autolabel.js				
//			by Cameron Gaut, 2006			
//				www.modcam.com				
//
//******************************************/	

/*
Description: Automatically searches for all text boxes with values and converts their values into grayed
text that disappears when the input receives focus. If the user has not typed anything and switches the
focus to another input, the default value will re-appear. To use this script, upload to your web site
and link to it in the <head>
  <meta name="verify-v1" content="YJg+lyFzZmnlZTDR5CvbU3K4S9lR2ksqQ1R6y59cRbE=" />
  <meta name="Identifier-URL" content="http://www.nbs-system.com" />
  <meta name="Author" content="NBS System" />
  <meta name="Reply-to" content="contact@nbs-system.com" />
  <meta name="Copyright" content="NBS System 2007" />
  <meta name="Description" content="NBS-System est une entreprise spécialisée dans la sécurité informatique, avec des prestations telles que le test d'intrusion ou l'audit de sécurité." />
  <meta http-equiv="Content-Language" content="fr" />
  <meta name="Keywords" content="sécurité informatique, formation informatique, test de sécurité, audit informatique, hebergement sécurisé, " />
  <meta name="category" content="document" />
  <meta name="revisit-after" content="15 days" />
  <meta name="Expires" content="never" />
  <meta name="date-creation-yyyymmdd" content="20060401" />
  <meta name="date-revision-yyyymmdd" content="20071019" />
  <meta name="robots" content="All" /> area.

if the auto-label feature does not work, change your body tag to <body onload="labelFields()">

<script language="JavaScript" type="text/javascript" src="autolabel.js"></script>

If you have dynamically generated fields, convert them to labeled fields with "initField(FIELD_NAME)"
Enjoy!

*/
function labelFields() {
	if (!document.getElementsByTagName){ return; }
	var allfields = document.getElementsByTagName("input");	
	for (var i=0; i<allfields.length; i++){ 	// loop through all input tags and add events
		initField(allfields[i]);
	}
	var allfields2 = document.getElementsByTagName("textarea");	
	for (var i=0; i<allfields2.length; i++){ 	// loop through all textarea tags and add events
		initField(allfields2[i]);
	}
}
function initField(field) {
	if (field) { //prevent misfire
		var graycolor = "#888";
		if ((field.type == "text" || field.type == "textarea" || field.type == "password") && (field.value != null)) {	// include text boxes, exclude empty ones
			field.style.color = graycolor;
			field.graytext = field.value;
			field.onfocus = function () {
				if (this.value==this.graytext){
					this.style.color="#000";
					this.value="";
				} else {
					this.select();
				}
			}
			field.onblur = function () {
				if (this.value=="") {
					this.style.color=graycolor;
					this.value=this.graytext;
				}
			}
		}
	}
}
window.onload = function() {
	labelFields();
}

