/**
 * NOTE: all methods below return the state of the input field.
 * The state values are:
 * other than '' (empty string) - label displayed, not modified by user
 * '' (empty string) - label not displayed, modified by user
 */

/**
 * 
 * @param field - the HTML object of type INPUT
 * @param label - label text
 * @return state of the field
 */
function innerLabelInit (field, label, state)
{
	if (field == null)
	{
		throw "[" + field + "] is not an INPUT HTML element";
		return;
	}
	/*
	 * The input has to have some original color, so if it has none, we apply black
	 */
	if (field.style.color == '')
	{
		field.style.color = 'black';
	}
	
	field.value = label;
	state = field.style.color;
	field.style.color = '#aaaaaa';
	return state;
}

function innerLabelOnFocus (field, state)
{
	if (field == null)
	{
		throw "[" + field + "] is not an INPUT HTML element";
		return;
	}
	if (state != '')
	{
		field.value = '';
		field.style.color = state;
		state = '';
	}
	return state;
}

function innerLabelOnBlur (field, label, state)
{
	if (field == null)
	{
		throw "[" + field + "] is not an INPUT HTML element";
		return;
	}
	if (field.value == '')
	{
		return innerLabelInit (field, label, state);
	}
	else
	{
		return '';
	}
}