
/**
 *  Function to set the default value of a text field.
 *  This will ensure that:
 *   - The value of the text field is set to the default string on page load (as long as there isn't already a value in place)
 *   - When the user clicks in the text field, if the value is the default string, the text field is emptied
 *   - When the user clicks out of the text field, if the field is empty it's set back to the default again
 */
function textfield_setDefaultValue(id, text)
{
	/** grab the specified field */
	var txt = document.getElementById(id);
	
	/** make sure the field exists */
	if(txt)
	{
		/** if the field is empty, set it to the default text */
		if(txt.value == "") txt.value = text;
		
		/** store the default text in the DOM of the field so we can retrieve it later */
		txt.defaulttext = text;
		
		/** when the user clicks in the field */
		txt.onfocus = function()
		{
			/** if the value is the default string, empty the field for imput */
			if(this.value == this.defaulttext)
			{
				this.value = "";
			}
		}
		
		/** when the user clicks out of the field */
		txt.onblur = function()
		{
			/** if the field is empty, put the default value back */
			if(this.value == "")
			{
				this.value = this.defaulttext;
			}
		}
	}
}