if (!window.events)
	events = false;

search_tool_html_str = "";
search_tool_html_str += '<span class="rgt-link no-bg"><input type="radio" name="search-switch" id="search-switch-channel" checked="checked" /> <label for="search-switch-channel">' + channel_name + "</label></span>\n";

if (events == true)
	search_tool_html_str += '<span class="rgt-link no-bg"><input type="radio" name="search-switch" id="search-switch-index" /> <label for="search-switch-    index">All Industries</label>' + "</span>\n";
else
	search_tool_html_str += '<span class="rgt-link no-bg"><input type="radio" name="search-switch" id="search-switch-index" /> <label for="search-switch-index">Entire Site</label>' + "</span>\n";

document.write(search_tool_html_str);


var search_tools = {
	'action_old' : '',
	'index' : function()
	{
		if (events == true)
			this.label().innerHTML = "SEARCH ALL INDUSTRY EVENTS";		
		else
			this.label().innerHTML = "SEARCH ALL PUBLICATIONS";

		this.action_old = this.form().getAttribute('action');

		var action_path = '/search/results.html';

		if (events == true)
			action_path = '/industry_events/results.html';

		this.form().setAttribute('action', action_path);
	},
	'channel' : function()
	{
		this.label().innerHTML = "SEARCH <em>" + channel_name.toUpperCase() + "</em>";
		this.form().setAttribute('action', this.action_old);
	},
	'form' : function()
	{
		return document.getElementById('search-form-main');
	},
	'label' : function()
	{
		return document.getElementById('search-input-label');
	}

};


var search_tool_rules = {
	'input#search-switch-channel' : function(element)
	{
		element.onclick = function()
		{
			if(this.checked == true && search_tools.action_old != '')
			{
				search_tools.channel();
			}
		}
	},
	'input#search-switch-index' : function(element)
	{
		element.onclick = function()
		{
			if(this.checked == true)
			{
				search_tools.index();
			}
		}
	}
};

Behaviour.register(search_tool_rules);
