
// form-handling functions


function init_NameValuedFields()
{
	var aInp = oGetAll("NameValuedField");
	
	for (var i = 0; i < aInp.length; i++)
	{
		aInp[i].name_value = aInp[i].value;         // save the "name-value"
		aInp[i].onfocus = NVF_focus;                // set the input element's onfocus
		aInp[i].onblur = NVF_blur;                  //     and onblur events
		
		// add input element to its form's NVF-list
		
		var oForm = aInp[i].form;
		
		if (oForm)
		{
			if (!oForm.NVF_list)
				oForm.NVF_list = new Array();
			
			oForm.NVF_list[oForm.NVF_list.length] = aInp[i];
			
			if (!oForm.onsubmit)                    // if the form does not have an onsubmit handler,
			{
				oForm.onsubmit = NVF_submit;               // then install ours
			}
		}
		
		// add input element to the document's NVF-list
		
		if (!document.NVF_list)
			document.NVF_list = new Array();
		
		document.NVF_list[document.NVF_list.length] = aInp[i];
		
		// save the alternate CSS classes in expando-properties
		
		var sVC = AGet(aInp[i], "class2");
		
		if (sVC || (sVC == ""))
		{
			aInp[i].name_class = aInp[i].className;
			aInp[i].value_class = sVC;
		}
	}
}


function clear_NameValuedFields(oForm)
{
	if (!oForm)
		var aInp = document.NVF_list
	else
		var aInp = oForm.NVF_list;
	
	if (aInp && aInp.length)
	{
		for (var i = 0; i < aInp.length; i++)
		{
			if (aInp[i].value == aInp[i].name_value)
				aInp[i].value = "";
		}
	}
}


function NVF_submit()
{
	clear_NameValuedFields(this);
}


function NVF_focus()
{
	if (this.value == this.name_value)
	{
		this.value = "";
		
		if (this.name_class)
			this.className = this.value_class;
	}
}


function NVF_blur()
{
	if (this.value == "")
	{
		this.value = this.name_value;
		
		if (this.name_class)
			this.className = this.name_class;
	}
}




