/**
 Javascript which can be used on form fields to manage a textbox.  This uses
 two methods - one onBlur() handler which handles provision of default text,
 and one onSubmit() which removes default text where necessary.

 This is designed to ensure that the default value is never actually sent
 as the value of a text field, allowing it to be used to fill in information.
 
 Behavior:
	- When the user clicks in the text field; remove the default value.
	- If the user leaves it without adding information, re-apply the default.
	- On submit, clear the default.
 
 To use:
 
 1) Set the default value in the value of the form, and call the provided blur and focus handler.
 2) Add the submit handler
  <form onSubmit="textboxSubmitHandler(this.locator); this.submit();">
 <input id="locator" name="formValueName" type="text" value="Default Value" 
 	onBlur="textboxBlurHandler(this)" onFocus="textboxFocusHandler(this)"/>
 </form>
*/

function textboxBlurHandler(element, defaultValue) {
	var val = defaultValue;
	if (val==null || val=="") val = element.defaultValue;
 	if (element.value=="") element.value=val;
 }
 
function textboxFocusHandler(element, defaultValue) {
	var val = defaultValue;
	if (val==null || val=="") val = element.defaultValue;
	if (val==element.value) element.value="";
	else element.select();
 }
 
function textboxSubmitHandler(element, defaultValue) {
	var val = defaultValue;
	if (val==null || val=="") val = element.defaultValue;
	if (val==element.value) element.value="";
 }