/**
 * @class	OnClickInputbox
 * @author	Marco Troost
 */
var OnClickInputbox = new Class({

	/**
	 * initialize
	 * @param	string	handler_id
	 * @param	string	input_value
	 * @return	void
	 */
	initialize: function(handler_id, input_value, type)
	{
		// nodes
		this.type			= !type ? 1 : type.toInt(); // default is 1

		switch(this.type) {
			case 2:
			  this.handler_node	= $$('#'+handler_id+' input'); break; // use the first inputbox find in the div
			default:
			  this.handler_node	= $(handler_id);
		}

		// strings
		this.input_value		= input_value;
	},

	/**
	 * start
	 * @return	void
	 */
	start: function()
	{
		if (this.handler_node)
		{
			// set events
			this.setEvents();
		}
	},

	/**
	 * set events
	 * @return	void
	 */
	setEvents: function()
	{
		// set vars
		var _this = this;

		if (!this.handler_node)
		{
			alert(1);
			this.handler_node = this.handler_node_input;
		}

		if (this.handler_node)
		{
			this.handler_node.removeEvents();
			this.handler_node.set('value', this.input_value);

			this.handler_node.addEvent('click',function()
			{
				var get_value = _this.handler_node.get('value');
				if (get_value == _this.input_value)
				{
					_this.handler_node.set('value', '');
					_this.handler_node.toggleClass('input_selected');
				}
			});

			this.handler_node.addEvent('blur',function()
			{
				var get_value = _this.handler_node.get('value');
				if (get_value == '')
				{
					_this.handler_node.set('value', _this.input_value);
					_this.handler_node.toggleClass('input_selected');
				}
			});
		}
	}

});
