/**
 * W_SearchSwitch Class
 * @author Marco Troost
 */
var W_SearchSwitch = new Class({
	
	/**
	 * initialize
	 * @param	string	root_node_id
	 * @return	void
	 */
	initialize: function(root_node_id)
	{
		// id's
		this.root_node_id			= root_node_id;
		
		this.root_node				= $(this.root_node_id);
        this.item_node_id           = '.item';

        this.type_prefix            = 'type_';
	},
	
	/**
	 * start
	 * @return	void
	 */
	start: function()
	{		
		if (this.root_node_id)
		{
			this.setEvents();
		}
	},
	
	/**
	 * set events
	 * @return	void
	 */
	setEvents: function()
	{
		// set var as object
		var _this	= this;


        $$(this.item_node_id).addEvent('click', function()
        {
            var type_id     = this.get('id').replace(_this.type_prefix, '');
            if (type_id)
            {
                _this.getForm(type_id);
            }
        })
	},
	
	/**
	 * set object type events
	 * @return	void
	 */
	getForm: function(type_id)
	{
		// set var as object
		var _this	= this;

        if(type_id)
        {
            // make request
            var content_url		= '/http/search/search_form.php?t='+type_id;
            var http_request 	= new Request.HTML(
            {
                url			: content_url,
                update		: this.root_node,
                onRequest	: function()
                {

                },
                onComplete	: function()
                {
                    _this.setEvents();
                }
            });
            http_request.get();
        }
    }
	

});
