var mapBase = '/tmaps.nsf/';function b_doMap(){	var capi = window.location.toString(); 	capi = capi.substring(capi.indexOf('&x=')+3, 	capi.indexOf('&', capi.indexOf('x=')));	var f = $('box'+capi);	if(!f) f = $('boxgoogle');	if(f) f.className='b_db l_wh lf';	window.q = new qs();	window.pan = new mapPanel();	pan.init('map');	var wl = window.location.toString();	q.init($('map_search'), mapBase+'(MapSearch)', 10, null,wl.substring(0, wl.indexOf('&loc=')+5),3);	log(wl);}function mapPanel(){	this.mow;	this.moh;	this.panel;	this.par;	this.id;	this.cat;	this.name;	this.url;	this.las;	this.vis = false;}mapPanel.prototype = {		init : function(i){		this.par = $(i);		this.drawPanel();	},		drawPanel : function(){		var a = document.createElement('div');		a.id = 'b_map_selector';		this.mow = (this.par.offsetWidth - 10);		this.moh = (this.par.offsetHeight - 20);		a.style.left = (findPosX(this.par) + 5) + 'px';		a.style.top = (findPosY(this.par) + 5) + 'px';		a.style.width = this.mow + 'px';		a.style.height = this.moh + 'px';		a.style.display = 'none';		a.innerHTML = this.innerPanel('', 'Loading ...', '');					this.panel = document.body.appendChild(a);	},		update : function(c, t, s){		this.panel.innerHTML = this.innerPanel(c, t, s);	},		innerPanel : function (c, t, s){		return '<div>'+				'<div class="lf b_qs_hlp b_lb png" id="b_qs_tlb"></div>'+				'<div class="lf b_lb b_qs_mid" style="width:' + (this.mow-24) + 'px"></div>'+				'<div class="rf b_qs_hlp png" id="b_qs_trb"></div>'+				'<div class="cb"></div>'+			'</div>'+			'<div class="b_lb f4 la">'+				'<div id="b_ms_title"><div class="lf" id="bmh">' + t + '</div><div class="b_qs_cl mo rf" style="margin-right:5px;" onmouseover="this.className=\'b_qs_cl b_qs_clo mo\';" onmouseout="this.className=\'b_qs_cl mo\';" onclick="pan.hide();"></div><div class="rf" id="bms"><img src="'+iconbase+'bspin.gif" /></div><div class="cb"></div></div>'+				'<div id="b_ms_subtitle" class="f0">'+s+'</div>'+				'<div class="ip2" id="b_ms_panel_content" style="height:' + (this.moh-64) + 'px;">' + c + '</div>'+			'</div>'+			'<div>'+				'<div class="lf b_qs_hlp png" id="b_qs_blb"></div>'+				'<div class="lf b_lb b_qs_mid" style="width:' + (this.mow-24) + 'px"></div>'+				'<div class="rf b_qs_hlp png" id="b_qs_brb"></div>'+				'<div class="cb"></div>'+			'</div>'+		'</div>';	},		get : function(u, mcat, bread, etext, li, func, mlx){		$('bms').style.display='block';		var a = new ax(mapBase+u, function(op, stat, ops){			if(stat==200){				var xml = cx(op);				var cats = $t(xml, ops[1]);				var uz;				if(ops[6]==2){					name=$t(xml,'name', true);					cat=$t(xml,'category', true);				}				var cc =''; var boroughs; var id; var mt; var name; var cat;				for(x=0;x<cats.length;x++) {					if(ops[6]==1){						boroughs = $t(cats[x], 'la');						id = $t(cats[x], 'id', true);						mt = $t(cats[x], 'name', true);					}					ux = $t(cats[x], 'url');					ux = !ux[0]?cats[x].firstChild.nodeValue:ux[0].firstChild.nodeValue;					if(ops[1]=='la'){						uz = $t(xml, 'url');						uz = !uz[0]?cats[x].firstChild.nodeValue:uz[0].firstChild.nodeValue;					}										mty = $t(cats[x], 'type');									mty = !mty[0]?'tMap':mty[0].firstChild.nodeValue;					cc+='<div class="h_lb c_db mo ip2" onclick="'+ops[5] + '(\''+ux+'\', event'+(uz?', \''+uz+'\'':'')+', \''+mty+'\');'+'" onmouseover="this.className=\'h_lb ip2 b_lg c_db mo ip\';" onmouseout="this.className=\'h_lb c_db ip2 mo ip\';"><div class="lf"><ul class="m_bullet"><li class="f f_'+(mty=='GIS'?'GIS':ops[4])+' f">'+(mt?mt:cats[x].firstChild.nodeValue)+(id?(id==ops[0].id?'</li><li class="f0 c_bl">You are currently viewing this map':''):'') +'</li></ul></div>'						+ (boroughs?(boroughs.length>1?'<div class="rf" style="margin-top:5px;"><a href="javascript:b_getLAs(\''+cats[x].getElementsByTagName('url')[0].firstChild.nodeValue+'\');" class="rb f1"><span>See this map in another borough</span></a></div>':''):'')						+'<div class="cb"></div></div>';				}						var bc = '';				for(b=0;b<ops[2].length;b++) bc += '<div class="lf">'+(b==0?ops[2][b] :'<ul class="b_bullet"><li style="margin-top:-2px;padding-right:0px;">' + (ops[6]==2&&b==1?cat:(ops[6]==2&&b==2?name:ops[2][b])) + '</li></ul>') + '</div>';				if(ops[6]==1||ops[6]==2)					ops[0].update('<div id="b_mapBlockT">'						+'<div class="h_lb b_lr ip2 c_bl b">'							+'<div class="lf"><ul class="b_bullet"><li>'+(ops[6]==2?'See '+name + ' in ...':ops[2][1])+'</li></ul></div>'							+'<div class="rf"><a class="rb f1" onclick="' +  (ops[6]==2?'b_getMaps(\'' + cat + '\')':'b_maps(true)') + ';"><span>' + (ops[6]==2?'See maps in '+cat:'See all map categories') + '</span></a></div>'							+'<div class="cb"></div>'						+'</div>'					+'</div>'					+'<div id="b_mapBlockM" style="height:' + (ops[0].moh-105) + 'px;">' + cc + '</div>', bc+'<div class="cb"></div>', ops[3]);									else					ops[0].update('<div id="b_mapBlock" style="height:' + (ops[0].moh-61) + 'px;">' + cc + '</div>', bc+'<div class="cb"></div>', ops[3]);													$('bms').style.display='none';			}		}, [this, mcat, bread, etext, li, func, mlx]);		a.dG();	},		cell : function(oc, v, li){		return '<div class="h_lb c_db mo ip" onclick="'+oc+'" onmouseover="this.className=\'h_lb b_lg c_db mo ip\';" onmouseout="this.className=\'h_lb c_db mo ip\';"><div class="ip"><ul class="m_bullet"><li class="f f_'+li+'">'+v+'</li></ul></div></div>';	},		visible : function(){		this.vis = true;		this.panel.style.display='block';		this.panel.style.left = (findPosX(this.par) + 5) + 'px';		this.panel.style.top = (findPosY(this.par) + 5) + 'px';	},		hide : function(){		this.vis = false;		$('b_ms_panel_content').innerHTML = '';		this.panel.style.display='none';	}		}function b_maps(force, help){	if(!pan.vis||force){		pan.visible();		var cc = '';									if(!help){				// Matching category?			var gU = getSelMap();			var c = new SJAX(mapBase+'MU?ReadForm&u=' + gU[0].substring(0, gU[0].indexOf('?')) + (gU[1]?gU[1]:''));			var xml = cx(c.doGet());			var sel = xml.getElementsByTagName('map');			c = null;			if(sel[0]&&!force){				pan.id = $t(sel[0], 'id', true);				pan.cat = $t(sel[0], 'category', true);				pan.name = $t(sel[0], 'name', true);				pan.url = $t(sel[0], 'url', true);				pan.las = $t(sel[0], 'la');				b_getMaps(pan.cat);					}else{				pan.get('(MapCategories)?OpenView&Count=1000', 'category', ['Our maps'], 'Please click a category to see the available maps', 'fld', 'b_getMaps');			}		}else{			pan.get('xh', 'title', ['Our maps', 'Help'], 'Please choose a help topic from the list below', 'que', 'b_getHelp');			var wlo = window.location.toString();			wlo = wlo.substring(wlo.indexOf('loc=')+4).replace('#top', '');			if(wlo.indexOf('la=')>-1) wlo = wlo.substring(0, wlo.indexOf('&la='));			aj('/tmaps.nsf/mwk?OpenView&u=' + wlo, 'mashup');		}	}else{		pan.hide();		if($('kmlbutton')) $('kmlbutton').style.display='none';	}					function getSelMap(){		var loc = window.location.toString();		selurl = loc.substring(loc.indexOf('loc=')+4);		var selty = '';		loc = selurl.substring(0, selurl.indexOf('?', selurl.indexOf('loc=')));		if(selurl.indexOf('LA=') > -1){			sella = selurl.substring(selurl.indexOf('LA=')+3);			selurl = selurl.substring(0, selurl.indexOf('LA=')+3);		}		if(selurl.indexOf('type=') > -1) selty = selurl.substring(selurl.indexOf('type=')+5).replace(/ /g, '+');		return [selurl, selty];	}}function b_getMaps(cat){	pan.get('MC?ReadForm&c=' + cat.replace(/ /g, '+'), 'map', ['Our maps', cat], 'Please select from the maps listed below', 'fin', 'b_getMap', 1);}function b_getLAs(m){	pan.get('MU?ReadForm&u=' + m.substring(0, m.indexOf('?')), 'la', ['Our maps', '', '', 'Select a borough'], 'Please select a borough to open their map', 'bor', 'b_getMapLA', 2);}function b_getHelp(help){	$('bms').style.display='block';	var a = new ax(mapBase + 'xhs?OpenPage&title=' +help.replace(/ /g, '+'), function(op, stat){		if(stat==200){			var xml = cx(op);			var title = $t(xml, 'title', true);			var body = $t(xml,'body',true);			var cc = body;			pan.update('<div id="b_mapBlockM"><div class="h_lb mo b_lr ip c_bl" onmouseover="this.className=\'h_lb b_dr c_wh b_dr mo ip\';" onmouseout="this.className=\'h_lb ip c_bl b_lr mo\';" onclick="b_maps(true, true);"><ul class="b_bullet"><li class="wh">See all help topics</li></ul></div></div><div id="b_mapBlockM" class="ip" style="height:' + (pan.moh-105) + 'px;">' + cc + '</div>', '<div class="lf">Our maps </div><div class="lf"><ul class="b_bullet"><li style="margin-top:-2px;padding-right:0px;">Help</li></ul></div><div class="lf"><ul class="b_bullet"><li style="margin-top:-2px;">'+title+'</li></ul></div>', '');				$('bms').style.display='none';		}	}, this);	a.dG();}function b_getMap(u, e, t){	var tgt = e.target || e.srcElement;	if(tgt.nodeName!='SPAN'){		var wl = window.location.toString();		wl = wl.substring(0, wl.indexOf('&loc=')+5);		if(t == 'GIS'){			if(confirm('You are about to leave tMaps and enter Brent\'s GIS system.\n\nIf you wish to continue, please select "Ok". Once you are inside GIS, you can return to tMaps at any time by selecting the "alternative map formats" link from underneath the map.\n\nAlternatively, please select "Cancel" to stay in tMaps.')) location.replace(u);		}else			location.replace(wl + u);	}}function b_getfMapLA(u, e, z){	var tgt = e.target || e.srcElement;	var wl = window.location.toString();	if(wl.indexOf('&loc=')>-1){		wl = wl.substring(0, wl.indexOf('&loc=')+5);		window.location = wl + z + '&la=' + u;	}else{		wl = wl.substring(0, wl.indexOf('.uk/')+4);		window.location = wl + 'tmaps.nsf/Map?ReadForm&x=google&loc=' + z + '&la=' + u;	}}    function changeApi(a){	var w = window.location.toString();	var ca = w.substring(w.indexOf('&x='), w.indexOf('&', w.indexOf('&x=')+1));	window.location = w.replace(ca, '&x='+a);}function correctPoint(t, i, l1,l2){	uback = window.location.toString();	uback = uback.substring(uback.indexOf('&loc=')+5);	location.replace('/tmaps.nsf/Map?ReadForm&x=google&loc=tmaps.nsf/correction.xml?ReadForm&t=' + t+ '&item=' + i + '&correct=' + l1 + ',' + l2  + '&uback=' + uback);}var mashed;function mashup(xmldoc){	var mash = xmldoc.getElementsByTagName('kml');	if(mash.length > 0){		kmlb = $('kmlbutton');		kmlb.style.display = 'inline';		mashed = 'http://www.brent.gov.uk'+ mash[0].firstChild.nodeValue + 'Brent';	}}function getMashup(){	location.replace(mashed);}/*fav*/function addMapMB(){    var wl = window.location.toString();    d = wl.substring(wl.indexOf('tmaps.nsf'), wl.indexOf('loc=')+4);    p = wl.substring(wl.indexOf('loc=')+4);    t = document.getElementsByTagName('h1');    t = t[0].innerHTML.replace(/\r\n|\n|\r(?!\n)|\u0085/g,'');    if(t.substring(1,1)==' ') t = t.substring(1, t.length-2);	var faves = readCookie('FV');	var gol = d+'~'+p+'~'+t.replace("'", "\'") + ' (Map)'; 			if(faves){		if(faves.indexOf(gol) > -1){			alert('This page is already in your My Brent favourites ...');			return;		}else{			createCookie('FV', faves + '(@)' + gol, 365);		}	}else{		createCookie('FV', gol, 365);	}	var flink = document.getElementById('b_mbfl');     flink.href = "/mybrent#favourites";	flink.innerHTML = 'Added to your favourites';	}function log(xloc){ var a = new ax('http://www.brent.gov.uk/icsat.nsf/mc?createdocument&u='+xloc.replace(/&/g, '%A*').replace(/=/g, '%E*'), function(){}); a.dG();}/*===============================================standard brent*//*glb*/var iconbase = '/brent25.nsf/';function findPosX(obj){	var curleft = 0;	if (obj.offsetParent)		while (obj.offsetParent)		{			curleft += obj.offsetLeft;			obj = obj.offsetParent;		}	else if (obj.x)		curleft += obj.x;	return curleft;}function findPosY(obj){	var curtop = 0;	if (obj.offsetParent)		while (obj.offsetParent)		{			curtop += obj.offsetTop;			obj = obj.offsetParent;		}	else if (obj.y)		curtop += obj.y;	return curtop;}bind = function(obj,fn){	return function(e){		fn.call(obj,e);	}}function $t(o,t,f){	if(f)		return o.getElementsByTagName(t)[0].firstChild.nodeValue;	else		return o.getElementsByTagName(t);}/*qs*/function qs(){	this.box;	this.url;	this.co;	this.panel;	this.prepend;	this.addc;}qs.prototype = {	init : function(b, u, c, l, p, a){		this.box = b;		this.url = u;		this.co = c;		this.addc = a;		this.prepend = p;		if(window.addEventListener){			this.box.addEventListener('keyup',bind(this,function(){ this.qs_search() }),false); 			window.addEventListener('click',bind(this,function(){ this.check() }),false); 		}else{			this.box.attachEvent ('onkeyup',bind(this,function(){ this.qs_search()}));			window.attachEvent ('onclick',bind(this,function(){ this.check() }));		}		this.qs_create();	},	qs_create : function(l){		var a = document.createElement("div");		a.id = 'b_qs_panel';		a.innerHTML = 			'<div>'+				'<div class="lf b_qs_hlp b_db"></div>'+				'<div class="lf b_db b_qs_mid"></div>'+				'<div class="rf b_qs_hlp" id="b_qs_tr"></div>'+				'<div class="cb"></div>'+			'</div>'+			'<div class="b_db f4">'+				'<div class="ip c_wh b" id="b_qs_panel_upper"></div>'+				'<div class="ip c_wh" id="b_qs_panel_content"></div>'+			'</div>'+			'<div>'+				'<div class="lf b_qs_hlp" id="b_qs_bl"></div>'+				'<div class="lf b_db b_qs_mid"></div>'+				'<div class="rf b_qs_hlp" id="b_qs_br"></div>'+				'<div class="cb"></div>'+			'</div>'+		'</div>';		this.panel = document.body.appendChild(a);	},	qs_search : function(){		if(this.box.value!=''){			this.panel.style.display = 'block';			$('b_qs_panel_upper').innerHTML = '<div class="lf ip">Searching ...</div><div class="b_qs_cl rf mo" onclick="q.panel.style.display = \'none\';" onmouseover="this.className=\'b_qs_cl rf b_qs_clo mo\';" onmouseout="this.className=\'b_qs_cl rf mo\';">&nbsp;</div><div class="rf ip"><img src="' + iconbase + '/b_qs_spin.gif" />&nbsp;</div><div class="cb"></div>';			$('b_qs_panel').style.left = findPosX(this.box) + 'px';			$('b_qs_panel').style.top = (findPosY(this.box) + this.box.offsetHeight) + 'px';			$('b_qs_panel').style.display = 'block';			var a = new ax(this.url + '?ReadViewEntries&Count=' + this.co + '&StartKey=' + this.box.value, function(op, stat, con){				if(stat==200){					var xd = cx(op);					if(xd){						var ve = xd.getElementsByTagName('viewentry');						var cc = '';						var m = con.box.value;						m = m.replace(/ /g, '&nbsp;');						var rx = new RegExp(m, 'gi');						for(var x=0;x<ve.length;x++){								cc += '<div class="qs_m l_wh mo h_cb"  onmouseover="this.className=\'qs_mo b_lb c_bl mo h_cb\';" onmouseout="this.className=\'qs_m l_wh mo h_cb\';" onclick="window.location = \'' +  (con.prepend&&(con.qs_gc(ve[x], 2).indexOf('http')==-1)?con.prepend:'')  + con.qs_gc(ve[x], 2)  + '\';"><div class="ip">' + con.qs_gc(ve[x], 1).replace(rx, '<span>' + m + '</span>') +  (con.addc?'<div class="f0">'+con.qs_gc(ve[x], con.addc)+'</div>':'')  +'</div></div>';					}					$('b_qs_panel_content').innerHTML = cc;					$('b_qs_panel_upper').innerHTML = '<div class="lf ip">Please choose a result</div><div class="b_qs_cl rf mo" onclick="q.panel.style.display = \'none\';" onmouseover="this.className=\'b_qs_cl rf b_qs_clo mo\';" onmouseout="this.className=\'b_qs_cl rf mo\';">&nbsp;</div><div class="cb"></div>';				}else					$('b_qs_panel_content').innerHTML = 'Sorry, the search function is unavailable at this time ...';				}			}, this);			a.dG();		}else			this.panel.style.display = 'none';	},	qs_gc : function(e, c){		var ed = e.getElementsByTagName('entrydata');		var t = ed[c].getElementsByTagName('text');		if(t[0].firstChild)			if(t[0].firstChild.nodeValue)				return t[0].firstChild.nodeValue;			else				return '';		},	check : function(e){		this.panel.style.display = 'none';	}}function ms_clear(o, b, t){	if(!b) if(o.value==t)	o.value = '';	if(b) if(o.value=='')	o.value = t;}