function bbg_table(table) {
		var bbg_classtable;

		bbg_classtable = $('#'+table).dataTable( {
			"sDom": '<"tablecontrol"f>t<"bottom">lipr',
			"bFilter": true,
			"bPaginate": false,
			"bLengthChange": true,
			"bFilter": true,
			"bSort": true,
			"bInfo": false,
			"aaSorting": [[4,'asc']],
			"aoColumns": [
							{ "sType": 'html' },
							{ "sType": 'html' },
							{ "sType": 'html' },
							{ "sType": 'html' },
							{ "sType": 'date' }
						]
		});
		
		//Add the dropdown here, because the dataTable plugin 
		//is injecting the search box, so need to wait till 
		//it's injected then add to the same div.
/*
<option value ="">All</option>
<optgroup label="Certificate Courses">
<option value ="Certificate in Horticulture">Certificate in Horticulture</option>
<option value ="Horticulture Electives">Horticulture Electives</option>
<option value ="Certificate in Floral Design">Certificate in Floral Design</option>
<option value ="Floral Electives">Floral Electives</option>
</optgroup>
<optgroup label="Non-certificate Courses">
<option value ="Gardening and Landscaping">Gardening and Landscaping</option>
<option value ="Nature and Critters">Nature and Critters</option>
<option value ="Herbs, Health, and Cooking">Herbs, Health, and Cooking</option>
<option value ="Botanical Crafts">Botanical Crafts</option>
<option value ="The Arts">The Arts</option>
<option value ="Trips and Tours">Trips and Tours</option>
<option value ="Lectures">Lectures</option>
</optgroup>
*/		
		//HACK: extra floatleft-div for ie :-/
		$('#'+table+'_filter').parent().prepend('<!--[if IE]><div style="float: left; margin-top:16px;"><![endif]--><div style="float: left; margin-right: 10px;"><span style="float: left; margin-top: 2px;">View: </span><select id="'+table+'_selectsort" style="margin-left: 3px;"><option value ="">All</option><optgroup label="Certificate Courses"><option value ="certificate in horticulture">Certificate in Horticulture</option><option value ="horticulture electives">Horticulture Electives</option><option value ="certificate in floral design">Certificate in Floral Design</option><option value ="floral electives">Floral Electives</option></optgroup><optgroup label="Non-certificate Courses"><option value ="gardening and landscaping">Gardening and Landscaping</option><option value ="nature and critters">Nature and Critters</option><option value ="herbs, health, and cooking">Herbs, Health, and Cooking</option><option value ="botanical crafts">Botanical Crafts</option><option value ="the arts">The Arts</option><option value ="trips and tours">Trips and Tours</option><option value ="lectures">Lectures</option></optgroup></select></div><!--[if IE]></div><![endif]-->');

		//Event Handlers
		$('#'+table+'_selectsort').change( function() {
			bbg_classtable.fnFilter($(this).val(), 2);
	  });

	  //Remove this event, since we are sorting from the drop down.
	  $(".classtable thead th").unbind('click');
	  
	  if(window.location.hash) {
	  	//Check if the url has a hash.
	  	
	  	//If yes find the link with this name, 
	  	//then trigger the click event to the row that contains it.

	  	//remove the hash char.
	  	var hash_name = window.location.hash.toString().replace(/#/, "");
	  	
	  	$('a[name="'+hash_name+'"]').parent().parent().trigger('click');

	  	//Go to this hash, in case the table was sorted and the scroll location is inaccurate.
	  	window.location = window.location.hash;
	  } else if (window.location.search) {
	  	//Check if the url has a catagory to filter by.
	  	//Remove dashes.
	  	var cat_name = window.location.search.toString().replace(/\?type=/, "").replace(/[-]/g," ");

			//Filter table.
	  	bbg_classtable.fnFilter(cat_name, 2);

	  	//Show selected option.
			$('#'+table+'selectsort option').removeAttr('selected');
			$('#'+table+'selectsort option[value='+cat_name+']').attr('selected', 'true');
	  }
}


function set_event() {
		$('.classtable tbody tr').unbind('click');
	  $('.classtable tbody tr').click(function(e) {	
	  	var exp = /expand_btn/;
	  	var expc = /collapse_btn/;
	  	
	  	if(e.target.href != undefined) {
	  		//If link is clicked, go to that link and don't exapnd row.
	  		if(! exp.test(e.target.href) && ! expc.test(e.target.href)) {
	  			//IE thinks that the src of the expand btn is a target
	  			//If not the expand btn or collpase btn, just go to that link, and cancel this function.
	  			return;
	  		}
	  	}
	  
	  	var img = $(this).children("td:first").children("img:first");
		  var src = img.attr("src");
		  
		  if(exp.test(src)) { //If need to expand the row:
		  	  	
		  	$(this).css("cursur", "none");
		  	var new_src = img.attr("src").replace(/expand_btn.png/i, "collapse_btn.png");
		  	img.attr("src", new_src);
		  	img.parent().addClass("selectedEntry").siblings().addClass("selectedEntry");
		  	var class_desc = img.parent().siblings('td:first').children("div").children("div.classdescription").html();
		  	var class_meta = img.parent().siblings('td:first').children("div").children("div.classmeta").html();
		  	img.parent().parent().after('<tr><td class="selectedEntry desccell"></td><td class="selectedEntry desccell" style="padding-right: 8px;" colspan="2" width="325px">'+class_desc+'<br /></td><td class="selectedEntry desccell" colspan="2">'+class_meta+'</tr>').next().hide().fadeIn(700);
		  } else { //Else, collpase the row:
				
		  	$(this).css("cursur", "pointer");
		  	img.parent().parent().next().remove();
		  	var new_src = img.attr("src").replace(/collapse_btn.png/i, "expand_btn.png");
		  	img.attr("src", new_src);
		  	img.parent().removeClass("selectedEntry").siblings().removeClass("selectedEntry");
		  }
		});
}