var $gridModules;
function fadeInGridModules() {
	$gridModules.fadeTo(500,1.0); 
}; 

$(document).ready(function() {

	// make it so that clicking anywhere in a scholar row makes it go to the scholar
	$("table.list_scholars tbody tr").click(function() {
		var $a = $(this).find("td.list_scholars_name a"); 
		window.location = $a.attr('href'); 
	}); 

	// setup scholar grids
	$gridModules = $(".list_scholars_grid li"); 
	var gridTimeout; 

	$gridModules.children("a")
		.qtip({
			show: {
				delay: 250
			},
			content: { text: false },
			position: {
				corner: {
					target: 'rightTop',
					tooltip: 'topLeft'
				},
				adjust: {
				}
			},
			style: {
				name: 'dark',
				width: {
					max: 700
				},
				border: 0
			}
		})
		.hover(function() {
			clearTimeout(gridTimeout); 
			$gridModules.fadeTo(0,0.4); 
			$(this).parent('li').fadeTo(0,1.0); 
		}, function() {
			gridTimeout = setTimeout("fadeInGridModules()", 750); 
		});


	// setup scholar sort select
	$("#scholar_sort").change(function() {

		var q = $.query;
		$.each(q.keys, function(key) {
			if(this.toString() == 'true') {
				$.query.REMOVE(key); 
				return;
			}
		});

		q.SET('sort', $(this).val()); 
		window.location = "./" + q.toString();
	}); 

	var $email = $("#scholar_email"); 
	if($email.size() > 0) {
		var address = $.rotate13($email.attr('title')) + '@' + $email.text();
		$email.attr('href', 'mailto:' + address).text(address).attr('title', ''); 
	}


}); 

