function getMapHash(){
	
	var areas = []
	areas[0] = /london-all/i;
	areas[1] = /bexley-riverside/i
	areas[2] = /central-activity-zone/i;
	areas[3] = /change/i;
	areas[4] = /deptford-creek-greenwich-riverside/i;
	areas[5] = /greenwich-peninsula-charlton-riverside/i;
	areas[6] = /isle-of-dogs/i;
	areas[7] = /lewisham-catford-new cross/i;
	areas[8] = /london-riverside/i;
	areas[9] = /london-thames-gateway/i;	
	areas[10] = /lower-lea-valleys/i;
	areas[11] = /movement/i;
	areas[12] = /royal-docks/i;
	areas[13] = /space/i;
	areas[14] = /upper-lea-valley/i;
	areas[15] = /woolwhich-thamesmead/i;
	var wait = window.setInterval(function(){
	if (parent.document.location.hash){ 	
		var hash = parent.document.location.hash;
		var nhash = hash.substr(1);
		for (var i=0; i < areas.length; i++) {
				var subflag = nhash.search(areas[i]);
 		 		if (subflag >= 0){
 		 			nhash = hash.replace(areas[i], "").substr(2);
 		 			var selectCat = $(".cat:eq("+ i +")").children("a").attr("onclick");
 		 			selectCat();
 		 		} 
 		 };
		} else{
			document.location.hash ="london-all";
		}

		var link = "where-we-work/projects/all/" + nhash + "/";
		var elem = (".project");
		var eachFlag = true;
		$(elem).each(function(e){
			if (eachFlag == true){
				var tempHref = $(this).children("a").attr("href");
				if (tempHref == link){
	 				var open = $(this).children("a").attr("onclick");
					open();
					eachFlag = false;
				}
			}
		});
		clearInterval(wait)
		},500);
}


/*** Maps and Categories ***/

var next;
var amount;
window.mapsOnly = 0;
function initCats (){
		amount = $(".cat").length;
		next = -1;
		window.mapsOnly = 1;
}

function toggleCats(){
		if (next < amount-1){next++;}else{next=0;};
		$(".cat > .selected").removeClass("selected");
		$(".cat:eq(" + next + ")" ).children("a").addClass("selected")
		var nextCat = $(".cat:eq(" + next + ")" ).children("a").attr("onclick");
		nextCat();
}

function introSlide(){

		if (next < slides){next++;}else{next=1;};
		var nextSlide = $("#image_selecter_" + next ).children("a").attr("onclick");
		nextSlide();
}

/*** Start 	***/	
			
var slideCats;		
var lightchain = false;		
$(function(){ 
	getMapHash();
	if (lightchain == true){
		$('#mapcontent').css({
			"background-image": "url('fileadmin/templates/img/loading.gif')",
			"background-repeat": "no-repeat",
			"background-position": "50px 50%"
		});
if (!parent.document.location.hash){ 	
	initCats();
	slideCats = window.setInterval(function (){
		toggleCats();
}, 4000);
	$(".cat").children("a").click(function(){clearInterval(slideCats);window.mapsOnly = 0;clicked=false;var evt = $(this).attr("onclick");
	evt();});
	
}
}
});
	
		
