$(document).ready(function() 
    { 
        $("#tblreglisting").tablesorter({sortList: [[0,0]]});
		
		$("#sort-regname").click(function() { 			
			var sorting = [[0,0]]; 
			$("table").trigger("sorton",[sorting]); 
			$("#sort-regname").addClass("active");
			$("#sort-country").removeClass("active");
			$("#sort-sun").removeClass("active");
			$("#sort-land").removeClass("active");
			$(".nosunrise").show();
			$(".nolandrush").show();
			$(".sunriseelements").show();
			$(".landrushelements").show();
			//make rows alternate in bg colour
			$('table tr:even').addClass("alt");
			$('table tr:odd').removeClass("alt");
			return false; 
		}); 

		$("#sort-country").click(function() { 
			var sorting = [[1,0]]; 
			$("table").trigger("sorton",[sorting]); 
			$("#sort-regname").removeClass("active");
			$("#sort-country").addClass("active");
			$("#sort-sun").removeClass("active");
			$("#sort-land").removeClass("active");
			$(".nosunrise").show();
			$(".nolandrush").show();
			$(".sunriseelements").show();
			$(".landrushelements").show();
			//make rows alternate in bg colour
			$('table tr:even').addClass("alt");
			$('table tr:odd').removeClass("alt");
			return false; 
		}); 

		$("#sort-sun").click(function() { 
			var sorting = [[2,0]]; 
			$("table").trigger("sorton",[sorting]); 
			//make rows alternate in bg colour
			$('table tr:even').addClass("alt");
			$('table tr:odd').removeClass("alt");
			$("#sort-regname").removeClass("active");
			$("#sort-country").removeClass("active");
			$("#sort-sun").addClass("active");
			$("#sort-land").removeClass("active");
			$(".nosunrise").hide();
			$(".nolandrush").hide();
			$(".sunriseelements").show();
			$(".landrushelements").hide();
			return false; 
		}); 

		$("#sort-land").click(function() { 
			var sorting = [[3,0]]; 
			$("table").trigger("sorton",[sorting]); 
			$("#sort-regname").removeClass("active");
			$("#sort-country").removeClass("active");
			$("#sort-sun").removeClass("active");
			$("#sort-land").addClass("active");
			$(".nosunrise").show();
			$(".nolandrush").hide();
			$(".sunriseelements").hide();
			$(".landrushelements").show();
			//make rows alternate in bg colour
			$('table tr:even').addClass("alt");
			$('table tr:odd').removeClass("alt");
			return false; 
		}); 

		$("#helpclose").click(function() {
			$("#helparea").hide("slow");
		});

		$(".help").click(function() {
			$("#helparea").show("slow");
		});

		// Set initial state
		$("#sort-regname").addClass("active");
		$('table tr:even').addClass("alt");
		$('table tr:odd').removeClass("alt");

	} 
); 
