/* Doctor Table Init for DataTables */
var oTable;
var asInitVals = new Array();

// this runs as the page is being built for display
$(function() {
	oTable = $('#doctortable').dataTable( { 

		"oLanguage": { "sSearch": "Search all columns:" },
//		"bStateSave": true,
		"bPaginate": false,
//		"sPaginationType": "full_numbers",
		"iDisplayLength": "100",

		"bAutoWidth": false,
//		"bJQueryUI ": false,
//		"bFilter": true,
		"aoColumns": [
					  { "sWidth": "310px", "sType": "html"},
					  { "sWidth": "40px"},
					  { "sWidth": "240px"},
					  { "sWidth": "90px", "bSortable": false}
					  ]
	
	});
	
	// added by DFF
	//$('#departments button').click(function() {
	//		filter_dept($(this).attr("id"));
 	//  });
	$('#departments a').click(function() { filter_dept($(this).attr("id")) } );
	$('#departments button').click(function() { filter_dept($(this).attr("id")) } )
	.hover(function() { $(this).addClass("buttonOver"); },
				  function() { $(this).removeClass("buttonOver"); }
				  );
	
	$('#gender button').click(function() { filter_gender($(this).attr("id")) } )
	.hover(function() { $(this).addClass("buttonOver"); },
				  function() { $(this).removeClass("buttonOver"); }
				  );

	$("tfoot input").keyup( function () {
		/* Filter on the column (the index) of this element */
		oTable.fnFilter( this.value, $("tfoot input").index(this) );
	} );
	/*
	 * Support functions to provide a little bit of 'user friendlyness' to the textboxes in 
	 * the footer
	 */
	$("tfoot input").each( function (i) {
		asInitVals[i] = this.value;
	} );
	
	$("tfoot input").focus( function () {
		if ( this.className == "search_init" )
		{
			this.className = "";
			this.value = "";
		}
	} );
	
	$("tfoot input").blur( function (i) {
		if ( this.value == "" )
		{
			this.className = "search_init";
			this.value = asInitVals[$("tfoot input").index(this)];
		}
	} );
} );

function dff_reset () {
	//alert('Calling RESET!');
	oTable.fnFilter('.*',1,false);
	oTable.fnFilter('.*',2,false);
}

function filter_dept (filstr) {
	//alert('Calling DEPT = ', filstr);
	oTable.fnFilter('.*',1,false);
	oTable.fnFilter('',2);
	oTable.fnFilter(filstr,2);
}

function filter_gender (filstr) {
	oTable.fnFilter('.*',2,false);
	oTable.fnFilter('',1);
	oTable.fnFilter(filstr,1);
}
