﻿Type.registerNamespace("Controls");
/// <summary>
/// V1.0 Adds hint text to input fields
/// if added in main.js all tags with HintBehavior, the tag needs the attribute hintText if you dont call this plugin explicit with the option hintText
/// Depends:
/// jquery-1.4.js
///	ui.core.js
/// ExtendJquery.js
/// MicrosoftAjax.js
/// </summary>
Controls.Hint = function() 
{
}
Controls.Hint.prototype = 
{
    _init: function()
    {
        this.element.focus($.createEventDelegate(this, this.onFocus));
        this.element.blur($.createEventDelegate(this, this.onBlur));
        if(this.options.hintText==null)
        {
            this.options.hintText=this.element.attr("hintText");
        }
        this.onBlur();
    },
    onFocus: function(element,event)
	{	
    	if (this.element.val()==this.options.hintText)
        {
    		this.element.removeClass(this.options.hintClass);		
    		this.element.val('');
        }
	},
	onBlur: function(element,event)
	{
	    if (this.element.val() == '' || this.element.val()==this.options.hintText)
	    {
    		this.element.addClass(this.options.hintClass);
            this.element.val(this.options.hintText);
        }
	},
	defaults: {
	hintClass: "Hint",
	hintText:  null
   }
}

Controls.Hint.registerClass('Controls.Hint', null, Sys.IDisposable);
$.registerAsWidget(Controls.Hint);







