﻿String.prototype.trim = function()
{
	return this.replace(/^\s+|\s+$/g,"");
}

function watermark_focus(textbox, text, css)
{
    if (textbox && textbox.value == text)
    {
        if (css.trim().length > 0 && textbox.className.indexOf(css) > -1)
        {
            var r = new RegExp('\\b' + css + '\\b');
            textbox.className = textbox.className.replace(r, '');
        }
        
        textbox.value = '';
    }
}

function watermark_blur(textbox, text, css)
{
    if (textbox && (textbox.value.trim() == text || textbox.value.trim() == 0))
    {
        if (css.trim().length > 0 && textbox.className.indexOf(css) == -1)
            textbox.className += ' ' + css;
        
        textbox.value = text;
    }
}