$(document).ready(function ( ) {
	
	$("#jobOpeningsList").tablesorter( ).bind("sortEnd",function() { 
		$("#jobOpeningsList").find(".first").removeClass("first");
		$("#jobOpeningsList tbody tr:first-child").addClass("first");
	});
	
	$("#jobOpeningsList thead th:nth-child(4n)").trigger("click").trigger("click");
	$("#jobOpeningsList tbody tr:first-child").trigger("click");
	
	$("#jobOpeningsList tr").click(function( ) {
		
		var id = $(this).attr("id").split("jobListing")[1];
		
		$("#jobOpeningsList .current").removeClass("current");
		$(this).addClass("current");
		
		$(".jobDescription.current").fadeOut("fast", function( ) {
			$(this).removeClass("current");
			$("#jobDescription" + id).fadeIn("fast", function( ) {
				$(this).addClass("current");
			});
		});
		
	});
	
	$("#introJobOpenings ul li").click(function( ) {
		
		var id = $(this).attr("id").split("jobOpening")[1];
		
		$("#jobOpeningsList .current").removeClass("current");
		$("#jobListing" + id).addClass("current");
		
		$(".jobDescription.current").fadeOut("fast", function( ) {
			$(this).removeClass("current");
			$("#jobDescription" + id).fadeIn("fast", function( ) {
				$(this).addClass("current");
			});
		});
		
		scrollToSection("#jobOpenings");
		
	});
	
	$("#news tr").click(function( ) {
		
		var id = $(this).attr("id").split("newsListing")[1];
		
		$("#news table .current").removeClass("current");
		$(this).addClass("current");
		
		$(".newsContent.current").fadeOut("fast", function( ) {
			$(this).removeClass("current");
			$("#news" + id).fadeIn("fast", function( ) {
				$(this).addClass("current");
			});
		});
		
	});
	
	$("input.init").focus(function( ) {
		$(this).val("").removeClass("init");
	});
	
});
