// NC: JavaScript fuctions for KC3.Web.Controls.TextBox

function initWatermark(element)
{
	if (element != null)
	{
		element.onfocus = removeWatermark;
		element.onblur = addWatermark;
		
		if (!element.value)
		{
			element.value = element.title;
		}

		if (watermarkCssClass != "" && element.value == element.title)
		{
			element.className += element.className ? ' ' + watermarkCssClass : watermarkCssClass;
		}
	}
}

function addWatermark()
{
	if (this.value == "")
	{
		this.value = this.title;
		if (watermarkCssClass)
		{
			this.className += this.className ? ' ' + watermarkCssClass : watermarkCssClass;
		}
	}
}

function removeWatermark()
{
	if (this.value == this.title)
	{
		this.value = "";
		if (watermarkCssClass)
		{
			var replaceString = this.className.match(' ' + watermarkCssClass) ? ' ' + watermarkCssClass : watermarkCssClass;
			this.className = this.className.replace(replaceString, '');
		}
	}
}
