jQuery(document).ready(function($)
{
	// bindings
	$('.topicselect select, .pagesort select').bind('change', selectRedirectHandler);

	//handlers
	function selectRedirectHandler( )
	{
		var url = $(this).children('option:selected').val();

		if ( url != '' )
		{
			window.location.replace( url );
		}
	}

	function treesSaved()
	{
		if ( $('#env_stats span').length > 0 )
		{
			var d	  = new Date()									//today's date
			var mill  = new Date(2007, 12, 17, 00, 00, 00)			// start date
			var diff  = d-mill										//difference in milliseconds
			var mtg	  = new String(11117+diff/24/60/60/1000*5.6)    //calculate days and convert to string
			var point = mtg.indexOf(".")							//find the decimal point
			var trees = mtg.substring(0,point)						//get just the whole days

			$('#env_stats span').html(trees);
		}
	}
	treesSaved();

});
