$(document).ready(function() {
    //allow back and forward history to work with the map
//    if (!$.browser.msie || $.browser.version >=8) {
//        $.address.externalChange(function(info) { loadMap(info.path); });
//
//        function loadMap(mapName) {
//            var main_map_raw = $("#main_map").get(0);
//
//            if (mapName=="/") {
//                main_map_raw.scrollTop = 0;
//                main_map_raw.scrollLeft = 0;
//            }
//
//            if (!mapName.match(/^map-district-.*/)) return;
//
//            main_map_raw.scrollTop = 0;
//            main_map_raw.scrollLeft = 0;
//
//            var activeMap = $("#" + mapName);
//
//            //emulate the default behaviour
//            main_map_raw.scrollTop = activeMap.position().top;
//            main_map_raw.scrollLeft = activeMap.position().left;
//        }
//    }
	
	$("#enlarge-map").fancybox();
	
	//the map is so awesome i feel bad in using javascript

	// $('#main_navigation ul li a').bind('click', function(){
		// var href = $(this).attr('href');
		// var bookmark = href.replace(/town_/, 'district-');
		
		// alert(bookmark);
		// $('a[href$="'+bookmark+'"]').click();
	// });
	
	//$('#main_navigation ul li a').last().click();
	
	// $('.map-district a').bind('click', function(){
		// var href = $(this).attr('href');
		// var bookmark = href.replace(/district-/, 'town_');
		
		// alert(bookmark);
		// $('a[href$="'+bookmark+'"]').click();
	// });
	
	
	// $("#main_navigation ul li a").click(function() {
		// location.hash="#district-" + $(this).val();
	// });
	
	// $('.map-district a').bind("contextmenu", function(event) {
		// event.preventDefault();
		
		// var href = $(this).attr('href');
		// var bookmark = href.replace(/district-/, 'town_');

		// location.hash = bookmark;
		
	// });
	
	// $('.map-district:first-child a').each(function(i, e){
		// var href = $(e).attr('href');
		// if(href.match(/district-/)){
			// $(e).bind("click", function(event) {
				// event.preventDefault();
				// var bookmark = href.replace(/district-/, 'town_');
				// location.hash = bookmark;
				// location.hash = href;
			// });
		// }

	// });
	


	
	
	// $('.map-back_button').bind("click", function(){
		// location.hash = "#town_yorkshire";
	// });
});

