// ::::: JQuery to handle awards directory data :::::

$(document).ready(function(){
		
	// Select the first directory list item
	//	$("#awardcategorylist").children(":first").attr("class", "current");
	$("#awardcategorylist li:first").attr("class", "current");
	$("#awardcategorylist li:first a").attr("class", "current");

	// Show the first info block
	$("#awardcategorycontainer").children(":first").show();

	// Show the prev/next pagination links
	$("#dir_navInfo_nav a").hide();

	// If not last element then get next
	if( $("#awardcategorylist li:first a").attr("id") != $("#awardcategorylist li:last a").attr("id") ) {
		var nextElement = $("#awardcategorylist li:eq(1) a");
		var nextElementID = nextElement.attr("id").substring( nextElement.attr("id").indexOf("_"), nextElement.attr("id").length );
		$("#dir_navInfo_nav a:last").attr("id", "next" + nextElementID);
		$("#dir_navInfo_nav a:last").show();
	}
			
	
	// ::::: Do this when a AWARD DIRECTORY LINK is clicked on ::::::
	$("#awardcategorylist a").click(function(e){
									  		
			// stop normal link click
			e.preventDefault();
	
			// Reset all directory links
			$("#awardcategorylist > li").attr("class", "");
			$("#awardcategorylist > li a").attr("class", "");

			// hide all directory details
			$("#awardcategorycontainer> div[id]").hide();
				
			// Set/highlight current link to current
			$(this).parent().parent().attr("class", "current");
			$(this).attr("class", "current" );
			
	
			var showinfo = "#awardcategoryinfo" + getID( $(this) );
			// Show directory info 		
			$(showinfo).show();
	
		
	});
	
	function getID( element ) {
		return element.attr("id").substring( element.attr("id").indexOf("_"), element.attr("id").length );	
	}
	


});
