$(function(){
	// Scroll link handler
//	$('a[href*="#"]').click(function(e){
//		e.preventDefault();
//		var $anch = $(this);
//		if ($anch.hasClass('')){
//			var link = $anch.attr('href');
//			var nohash = link.replace(/[?=#]+[a-zA-Z0-9-_.]+/,'');
//			var goal = link.replace(nohash,'');
//			var id = goal.slice(1,5);
//			var fake = '<form method="post" style="display:none" action="'+nohash+'" id="form_'+id+'"><input type="hidden" name="scrollto" value="'+goal+'" /></form>';
//			$anch.after(fake);
//			$('#form_'+id).submit();
//		}
//	});
	
	$pageSlideCont = $('#page_slider_cont');
	$pageNav = $('#page_nav_list');
//	var $to = $('#scrollto').val();
//	console.log($to);
//	if (typeof($to) == 'undefined'){
		if(window.location.hash){
			hash = window.location.hash;
			$(document).scrollTop(0);
			$pageSlideCont.scrollTo(hash); // Reset the slider back to top on reload to avoid container height issues
			$(hash).addClass('visible');
			$('li a[href="'+hash+'"]', $pageNav).parent().addClass('currently_visible');
		} else {
			$pageSlideCont.scrollTo(0); // Reset the slider back to top on reload to avoid container height issues
			$('li:first', $pageSlideCont).addClass('visible');
			$('li:first', $pageNav).addClass('currently_visible');
		}
//	} else {
//		$pageSlideCont.scrollTo($to);
//		$($to, $pageSlideCont).addClass('visible');
//		$('#page_nav_list li a[href='+$to+']').parent().addClass('currently_visible');	
//	}
	
	var initial_height = $('li.visible', $pageSlideCont).outerHeight(true);
	$pageSlideCont.animate({height:initial_height+'px'}, 0);
});
