var searchOption = new Class({
  initialize: function(formaction, formmethod, inputname, hiddenfields, formtarget){
		this.formaction = formaction;
		this.formmethod = formmethod;
		this.inputname = inputname;
		this.hiddenfields = hiddenfields;
		this.formtarget = formtarget;
  },
  setSettings: function() {
  	$('the_searchform').setProperty('action', this.formaction);
  	$('the_searchform').setProperty('method', this.formmethod);
  	$('queryfield').setProperty('name', this.inputname);
  	$('hiddenfields').setHTML(this.hiddenfields);  	
  	$('the_searchform').setProperty('target', this.formtarget);
  }
});
var Search = new Array();
Search["theBubbler"] = new searchOption('http://www.thebubbler.com/index.php', 'get', 'q', '<input type="hidden" name="client" value="pub-3426796819612790" /><input type="hidden" name="forid" value="1" /><input type="hidden" name="channel" value="3666815593" /><input type="hidden" name="ie" value="ISO-8859-1" /><input type="hidden" name="oe" value="ISO-8859-1" /><input type="hidden" name="safe" value="active" /><input type="hidden" name="flav" value="0001" /><input type="hidden" name="sig" value="KPn2W-Sj_OohUmJs" /><input type="hidden" name="cof" value="GALT:#008000;GL:1;DIV:#336699;VLC:663399;AH:center;BGC:FFFFFF;LBGC:336699;ALC:0000FF;LC:0000FF;T:000000;GFNT:0000FF;GIMP:0000FF;FORID:11" /><input type="hidden" name="hl" value="en" /><input type="hidden" name="pageid" value="search" /><input type="hidden" name="domains" value="www.theBubbler.com" /><input type="hidden" name="sitesearch" value="www.theBubbler.com" />', '_top');
Search["Members"] = new searchOption('http://www.thebubbler.com/forums/members/list/', 'post', 'ausername', '', '_top');
Search["Classifieds"] = new searchOption('http://www.thebubbler.com/forums/vbclassified.php', 'post', 'searchfor', '<input type="hidden" name="do" value="search">', '_top');
Search["Directory"] = new searchOption('http://www.thebubbler.com/links/search.php', 'post', 'string', '<input name="fields[]" type="hidden" value="name" /><input name="fields[]" type="hidden" value="description" /><input name="fields[]" type="hidden" value="field1" /><input name="fields[]" type="hidden" value="field2" /><input type="hidden" name="catids[]" value="0" /><input name="do" type="hidden" value="searchresults" />', '_top');
Search["Events"] = new searchOption('http://www.WisEvents.com/search.php', 'post', 'q', '', '_blank');
Search["Forums"] = new searchOption('http://www.thebubbler.com/forums/search.php?do=process', 'post', 'query', '<input type="hidden" name="do" value="process" /><input type="hidden" name="quicksearch" value="1" /><input type="hidden" name="childforums" value="1" /><input type="hidden" name="exactname" value="1" /><input type="hidden" name="s" value="" />', '_top');
Search["Videos"] = new searchOption('http://www.wistube.com/modules/OYMVideos/index.php', 'get', 'q', '', '_blank');
Search["Music"] = new searchOption('http://www.WisMusic.com/forums/search.php?do=process', 'post', 'query', '<input type="hidden" name="do" value="process" /><input type="hidden" name="quicksearch" value="1" /><input type="hidden" name="childforums" value="1" /><input type="hidden" name="exactname" value="1" /><input type="hidden" name="s" value="" />', '_blank');
Search["Store"] = new searchOption('http://www.thebubbler.com/index.php?pageid=store', 'get', 'keywords', '<input type="hidden" name="pageid" value="store" />', '_top');
Search["Employment"] = new searchOption('https://wisemployment.com/job_search.php', 'post', 'keyword', '<input type="hidden" name="action" value="search"><input type="hidden" name="county" value=""><input type="hidden" name="Industry_Sector[]" value="0">', '_blank');
Search["Web"] = new searchOption('http://www.thebubbler.com/index.php', 'get', 'q', '<input type="hidden" name="cx" value="partner-pub-3426796819612790:jpdp6mlbr9p" /><input type="hidden" name="cof" value="FORID:10" /><input type="hidden" name="ie" value="ISO-8859-1" /><input type="hidden" name="pageid" value="search" />', '_top');

var searchElements = $('the_search_options').getElements('td');

var stage1Elements = $('the_search_options').getElements('td[id^=stage1_]');
var stage2Elements = $('the_search_options').getElements('td[id^=stage2_]');

searchElements.each(function(element){ 
	element.addEvent('click', function(e){
		new Event(e).stop();
		if(element.getProperty('id') == 'search_gt') {
			// Show other items
			stage1Elements.each(function(others){ others.setStyle('display', 'none'); });
			stage2Elements.each(function(others){ others.setStyle('display', 'table-cell'); });
			$('search_gt').setStyle('display', 'none');
			$('search_lt').setStyle('display', 'table-cell');
		} else if(element.getProperty('id') == 'search_lt') {
			stage2Elements.each(function(others){ others.setStyle('display', 'none'); });
			stage1Elements.each(function(others){ others.setStyle('display', 'table-cell'); });
			$('search_lt').setStyle('display', 'none');
			$('search_gt').setStyle('display', 'table-cell');
		} else {
			var testing = new Array();
			searchElements.each(function(others){ others.className = ''; });
			element.className = 'selected';
			Search[element.getText()].setSettings();
		}
	});
});
