var index_table = {
	load: function () {
		this.table = $('events_table');
		this.table_rows = this.table.select("tbody tr");

		$$('#events_nav a').each(function(t) { 
			t.observe('click',function(event) {
				this.toggleClassName("on"); 
				index_table[this.name](this);
				Event.stop(event);
			}); 
		});

		$$('#events_table a.details').each(function(t) { 
			t.observe('click',function(event) {
				var row = this.up("tr");
				index_table.addDescription(row,"toggle");
				Event.stop(event);
			}); 
		});
	},

	/* TABLE CHECKBOXES */
	descriptions: function(node) {
		var box_switch = ($(node).hasClassName("on")) ? true : false;
		
		this.table_rows.each(function(t) {
			index_table.addDescription(t,box_switch);
		});
	},
	onsite: function(node) {
		var box_switch = ($(node).hasClassName("on")) ? true : false;
		
		this.table_rows.each(function(t) {
			if (t.hasClassName("onsite")) {
				t.style.display = (box_switch) ? "table-row" : "none";
			}
		});
	},
	online: function(node) {
		var box_switch = ($(node).hasClassName("on")) ? true : false;

		this.table_rows.each(function(t) {
			if (t.hasClassName("online")) {
				t.style.display = (box_switch) ? "table-row" : "none";
			}
		});
	},
	addDescription:function(row,state) {
		var description = row.select("div.description")[0];

		if (state == "toggle") {
			description.toggle();
		} else {
			description.style.display = (state) ? "block" : "none";
		}
		
		if (!row.done) { 
			var height = description.select("span")[0].getHeight();
			description.style.height = height-11 + "px";
		}
		
		row.done = true;
	}
	/* END TABLE CHECKBOXES */


};