﻿var busMapApplication = function () {
	function e(a) { dc && GLog.write(a) } function O(a) { a = a.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); a = RegExp("[\\?&]" + a + "=([^&#]*)").exec(window.location.href); return a === null ? "" : decodeURIComponent(a[1]) } function ub() { if (P != null) { g.addOverlay(P); GEvent.addListener(P, "click", function () { P.openInfoWindowHtml(vb) }) } } function D(a) {
		switch (G) { case "SingleLine": $("#" + l + "show-all-routes").text("Back to route list") } switch (a) {
			case "active": if (!K) {
					Q = true; $("#" + l + "show-all-routes").show().bind("click",
function () { switch (G) { case "SingleLine": if ($("#show-all-stops-link_" + f[h].Index).hasClass("stops-active")) { e("! A"); $("#show-all-stops-link_" + f[h].Index).trigger("click") } break; case "multi": showAllRoutes() } }).attr("class", "showAllRoutesActive")
				} break; case "inactive": Q = false; $("#" + l + "show-all-routes").attr("class", "").unbind("click"); break; case "hidden": $("#" + l + "show-all-routes").hide(); break; default: Q = false; $("#" + l + "show-all-routes").attr("class", "").unbind("click")
		} 
	} function Ta(a) {
		if (u = a) {
			$(".IsDay_0").hide();
			$(".IsDay_1").show(); $("#img_buttom_day").attr("class", "").addClass("dN_day_active"); $("#img_buttom_night").attr("class", "").addClass("dN_night"); $("#busesLeftCol_Routes").removeClass("night")
		} else { $(".IsDay_1").hide(); $(".IsDay_0").show(); $("#img_buttom_day").attr("class", "").addClass("dN_day"); $("#img_buttom_night").attr("class", "").addClass("dN_night_active"); $("#busesLeftCol_Routes").addClass("night") } 
	} function R(a) {
		try {
			e("f action_SwitchDayNight :: IsDay = " + a); ga(); Ta(a); Ua(); L({ showHide: false,
				HideAll: true
			}); try { wb(f[0].Id) } catch (b) { e("ERROR - f ScrollToTop") } $("." + H).removeClass(H).removeClass(ha); $("." + I).removeClass(I); $(".mm-bus-routes-item-SwapRun").removeClass("active"); xb(); h = null; Q && D("inactive"); $("." + I).removeClass(I); u = a; switch (G) { case "SingleLine": $.each(f, function (d, j) { if (j.IsDay == a) { if (Va) { e("@1"); Ca(j.Route); e("@1.1") } else Va = true; return false } }) } if (K) {
				D("hidden"); $.each(f, function (d, j) {
					if (j.IsDay == a) {
						$("#mm-search-result h3").text("Showing route " + j.Route); $(".trigger_show-all-stops-link_" +
j.Id).trigger("click")
					} 
				})
			} 
		} catch (c) { e("3: " + c); e("ERROR - f action_SwitchDayNight") } 
	} function S() { $("#" + l + "LHP-loading").hide() } function yb() { $("#" + l + "LHP-ServerErrorMsg").hide(); $("#" + l + "LHP-content").hide(); $("#" + l + "LHP-NoResults").hide(); $("#busesLeftCol_inner").hide(); $("#busesLeftCol_inner").hide(); D("hidden"); $("#busesLeftCol_Routes").removeClass("night"); o.setMapSize(o.MapSizeSmall); o.ResizeMap(); T.html("") } function Da() { $("#" + l + "PopUpBoxMsg").fadeOut("fast") } function ec(a) {
		$("#" + l + "LHP-ValidationErrorMsg").show();
		$("." + l + "searchValidationMsg").html(a); S()
	} function fc() { $("#" + l + "WorkingMsg").ajaxStart(function () { e("AJAX START"); U = false; $(this).show(); zb = setTimeout(function () { U = true; $(this).hide() }, 1E4) }); $("#" + l + "WorkingMsg").ajaxStop(function () { e("AJAX stop"); U = true; $(this).hide(); clearTimeout(zb) }) } function Ab() { try { $.each(f, function (b, c) { c.oPolyline_1 !== null && g.removeOverlay(c.oPolyline_1); c.oPolyline_2 !== null && g.removeOverlay(c.oPolyline_2) }) } catch (a) { e("ERROR - f removePolyLineAll") } } function Bb() {
		try {
			if (M !=
null) { M.clearMarkers(); M = null } 
		} catch (a) { e("ERROR - f removeMarkersCluster") } 
	} function Cb() {
		if (!Ea) { $(".overlay").hide(); g.enableContinuousZoom(); g.enableDoubleClickZoom(); g.enableScrollWheelZoom(); g.addControl(new GLargeMapControl3D); g.addControl(new GMenuMapTypeControl); $("#busesRightCol_TopSearchBar").fadeIn("fast"); Ea = true; $("#busesHolder").css("padding", "0") } $("#overlayMsg").hide(); yb(); V = W = X = 0; P = null; $("#img_buttom_night").show(); $("#img_buttom_day").show(); Fa = u; g.enableDragging(); g.removeOverlay(Ga);
		$.each(f, function (a, b) { if (null != b.endPoint.div) b.endPoint.div.id = "RemoveStartEnd"; $("#RemoveStartEnd").remove(); if (null != b.startPoint.div) b.startPoint.div.id = "RemoveStartEnd2"; $("#RemoveStartEnd2").remove() }); Ua(); Wa = null; J = new GLatLngBounds; ia = false; Da(); ja = ""; Ta(1); K = false; f = []; p = []; Xa = []; Y = 0; ka = 1; Ya = []; la = ma = ""; searchWas_RouteOnly_FirstOpen = true; $("#" + l + "LHP-ValidationErrorMsg").hide(); $("#SearchResultsTextHTML").empty(); $("#" + l + "search-result").empty(); D("active"); D("inactive")
	} function Za(a) {
		return a.replace(/Greater London /,
"").replace(/, UK/, "").replace(/, London/, "").replace(/, City of London/, "").replace(/, Greater London/, "").replace(/Piccadilly/, "Picadilly").replace(/piccadilly/, "picadilly").replace(/Flats to rent in Canary Wharf, Horseferry Rd, Westminster SW1P/, "Canary Wharf")
	} function gc(a) {
		var b = []; b.push(RegExp("^([abcdefghijklmnoprstuwyz]{1}[abcdefghklmnopqrstuvwxy]?[0-9]{1,2})(\\s*)([0-9]{1}[abdefghjlnpqrstuwxyz]{2})$", "i")); b.push(/^([abcdefghijklmnoprstuwyz]{1}[0-9]{1}[abcdefghjkstuw]{1})(\s*)([0-9]{1}[abdefghjlnpqrstuwxyz]{2})$/i);
		b.push(RegExp("^([abcdefghijklmnoprstuwyz]{1}[abcdefghklmnopqrstuvwxy]?[0-9]{1}[abehmnprvwxy]{1})(\\s*)([0-9]{1}[abdefghjlnpqrstuwxyz]{2})$", "i")); b.push(/^(GIR)(\s*)(0AA)$/i); b.push(/^(bfpo)(\s*)([0-9]{1,4})$/i); b.push(/^(bfpo)(\s*)(c\/o\s*[0-9]{1,3})$/i); b.push(/^([A-Z]{4})(\s*)(1ZZ)$/i); a = a; for (var c = false, d = 0; d < b.length; d++) if (b[d].test(a)) { b[d].exec(a); a = RegExp.$1.toUpperCase() + " " + RegExp.$3.toUpperCase(); a = a.replace(/C\/O\s* /, "c/o "); c = true; break } return c ? a.toUpperCase() : false
	} function hc() { R(1) }
	function ic() { R(0) } function jc() {
		T = $("#" + l + "bus-routes-holder"); $("#SearchButton_Top").bind("click", function () { g.enableDragging(); if ($a) return false; else { $a = true; yb(); kc(); Db = setTimeout(function () { $a = false; clearTimeout(Db) }, 3E3) } }); $("#searchbutton_overlay").bind("click", function () { $("#SearchBox_Top").val($("#SearchBox_Overlay").val()); $("#SearchButton_Top").trigger("click"); return false }); $("#SearchBox_Top").keypress(function (a) { if (a.which == 13) { $("#SearchButton_Top").trigger("click"); return false } });
		$("#SearchBox_Overlay").keypress(function (a) { if (a.which == 13) { $("#SearchBox_Top").val($("#SearchBox_Overlay").val()); $("#SearchButton_Top").trigger("click"); return false } }); $("#" + l + "but_showLHP").bind("click", function () { o.setMapSize(o.MapSizeSmall); o.ResizeMap() }); $("#" + l + "but_hideLHP").bind("click", function () { o.setMapSize(o.MapSizeLarge); o.ResizeMap() }); $(window).resize(function () { o.ResizeMap() }); $("#" + l + "but_showLHP").hide(); GEvent.addListener(g, "infowindowclose", function () {
			$(".stop-item-active").removeClass("stop-item-active");
			na = true; oa = q = Ha = null; $("#InfoWindowPrimary").empty(); L({ showHide: true }); ia = true
		}); $("#img_buttom_night").bind("click", ic); $("#img_buttom_day").bind("click", hc); GEvent.addListener(g.getInfoWindow(), "restoreend", function () { na = true; g.getInfoWindow().disableMaximize(); $("#planJourneyFromHere").html("") }); GEvent.addListener(g.getInfoWindow(), "maximizeclick", function () { infoWindowMaximizedWithClick = true }); GEvent.addListener(g.getInfoWindow(), "maximizeend", function () {
			if (na) {
				var a = $("#maxContentDiv"); a.empty();
				q = $(".NonMapInfoWindowHolder"); q.clone(true).prependTo(a); a.find(".NonMapInfoWindowHolder").removeClass("NonMapInfoWindowHolder").show(); a.find(".tabsL").addClass("tabs").removeClass("tabsL"); na = false
			} Eb({ RouteID: ab, StopCode: Ha, Towards: $(".TowardsLocation_" + h).text(), From: $(".FromLocation_" + h).text(), SkiID: bb, RouteInSearchResults: Fb })
		}); GEvent.addListener(g, "move", function () {
			e("f checkBounds"); var a = g.getBounds().toSpan(), b = a.lng() / 2; a = a.lat() / 2; var c = g.getCenter(), d = c.lng(); c = c.lat(); var j = new GLatLng(c -
a, d - b), k = new GLatLng(c + a, d + b); if (!(y.containsLatLng(j) && y.containsLatLng(k))) { j = y.getNorthEast().lng(); k = y.getNorthEast().lat(); var m = y.getSouthWest().lng(), n = y.getSouthWest().lat(); if (d < m + b) d = m + b; if (d > j - b) d = j - b; if (c < n + a) c = n + a; if (c > k - a) c = k - a; g.setCenter(new GLatLng(c, d)) } 
		}); lc()
	} function Ia(a, b) { return Math.round(a * Math.pow(10, b)) / Math.pow(10, b) } function mc(a) {
		if (a.Routes) p = a.Routes; if (a.Stops) r = a.Stops; if (a.CoOrds) E = a.CoOrds; a = $("#SearchBox_Top").val(); $(".Nav_listPoint a").attr("href", "tfl-bus-map/text/?q=" +
a); if (p[0] == "" || p == "" || p.length <= nc) { e("SearchTryCount:" + Z); Z++; e("SearchTryCountsss:" + Z); if (Z <= 1) { U = true; aa({ Lat: cb, Lng: db, ZoomOveride: "15", q: Gb }) } else { Z = 0; A(cb, db) } } else {
			e("DO THE PLOTTING OF THE SEARCH"); if (p[0].encodedLevels == "") { a = 16; if (E.Zoom != "") a = E.Zoom; g.setCenter(new GLatLng(E.Latitude, E.Longitude), a) } else { w = Hb(p[0].encodedPoints, p[0].encodedLevels, "#" + p[0].Color, "FullRoute", p[0].Route); g.addOverlay(w) } eb(p); if (p[0].encodedLevels != "") {
				h = 0; CurrentActiveRun = 1; D("inactive"); Ib(w); Jb(B); Q = true;
				Ja(); a = g.getBounds(); MapBounds_OldSW = a.getSouthWest().toUrlValue(); MapBounds_OldNE = a.getNorthEast().toUrlValue()
			} T.show(); $("#busesLeftCol_inner").show(); $("#" + l + "search-result").show(); setTimeout(function () { ba() }, 2E3); S(); $("#" + l + "LHP-content").show(); switch (G) { case "SingleLine": e("! b"); e("@2"); a: { for (i = 0; i < f.length; i++) if (f[i].IsDay == 1) { a = f[i]; break a } a = void 0 } Ca(a.Route); e("@2.1") } if (Fa != u) { Fa === 0 && W > 0 && R(0); Fa === 1 && X > 0 && R(1) } 
		} 
	} function ca(a) {
		e("function aJackLoad"); if (typeof a.url === "string") url =
a.url; e("url:" + url); $.ajax({ type: "GET", contentType: "application/json; charset=utf-8", url: url, dataType: "json", timeout: 2E4, tryCount: 0, data: {}, retryLimit: 3, success: function (b) { if (typeof a.CallFunction === "function") { e("CALL FUNCTION"); a.CallFunction(b) } else return b }, error: function (b, c) {
	if (c === "timeout") { e("TRY AGAIN"); this.tryCount++; this.tryCount <= this.retryLimit ? $.ajax(this) : ShowServerErrorMsg("Error loading data: code AJ2 ") } else if (b.status === 500) {
		e("Error " + b.status + " on " + url + " called from function aJackLoad");
		ShowServerErrorMsg("Error loading data: code AJ3 ")
	} else e("Error " + b.status + " on " + url + " called from function aJackLoad   2")
} 
})
	} function aa(a) {
		Cb(); e("function: userSearchServer"); var b = a.Lat, c = a.Lng, d = a.q, j = 16; if (typeof a.ZoomOveride === "string") j = a.ZoomOveride; if (b === "51.5001524" && c === "-0.1262362" && d.toUpperCase().indexOf("WESTMINSTER") == -1) A("", ""); else if (b === "51.5052437" && c == "-0.0188475" && d.toUpperCase().indexOf("CANADA") == -1) A("", ""); else {
			if (typeof a.qInput === "string") d = a.qInput; t = d; Da(); cb =
b; db = c; Gb = d; var k = ""; if (b !== null) { k = "&Lat=" + Ia(b, 3) + "&Lng=" + Ia(c, 3); d = Za(d); $("#" + l + "search-result").empty(); $("." + l + "inputTxt-SearchBox").val(d); $("#textVersionLink").attr("href", "tfl-bus-map/text/?q=" + d); h = null } typeof a.LHP === "object" ? N(a.LHP) : N({ Heading: "Showing routes near " + d }); a = d; e("f placeSearchLocationMarker"); var m = new GLatLng(b, c); vb = "<strong>Location:</strong> " + a; P = new GMarker(m, { icon: pa }); e("CALL search.aspx"); ca({ url: "tfl-bus-map/dotnet/Search.aspx?searchStr=" + d + "&width=" + $("#" + l + "map").width() +
"&height=" + $("#" + l + "map").height() + "&zoom=" + j + k, CallFunction: mc
}); b = b; c = c; try { e("lat:" + b); e("lng:" + c); if (b === "" || b === "") { b = "51.515232"; c = "-0.141792" } c = "http://adsyndication.yelldirect.com/synd/synd.aspx?ass=2030&url=www.tfl.gov.uk/busmap&tc=3497D5&dc=565656&lc=565656&styl=mrb&subid=maps&linknew=1&lat=" + b + "&long=" + c; $("#yell_Iframe").attr("src", c) } catch (n) { e("ERROR : F updateYellIFrame:" + n) } 
		} 
	} function qa(a) {
		e("resetStartEndPoints - - - - -  - - - -CalledFrom:" + a); y.getSouthWest(); y.getNorthEast();
		$.each(f, function (b, c) { if (!c.startPoint.latlng) return true; y.containsLatLng(c.startPoint.latlng) || y.extend(c.startPoint.latlng); y.containsLatLng(c.endPoint.latlng) || y.extend(c.endPoint.latlng); var d = g.fromLatLngToDivPixel(c.startPoint.latlng); d.x -= parseInt(Ka / 2, 10); d.y -= parseInt(ra / 2, 10); var j = c.startPoint.div; j.style.top = d.y + "px"; j.style.left = d.x + "px"; d = g.fromLatLngToDivPixel(c.endPoint.latlng); d.x -= parseInt(Ka / 2, 10); d.y -= parseInt(ra / 2, 10); j = c.endPoint.div; j.style.top = d.y + "px"; j.style.left = d.x + "px" })
	}
	function Ua() { try { e("f: mm_clearOverlays"); g.clearOverlays(); Ab(); Bb(); ub() } catch (a) { e("ERROR - f mm_clearOverlays") } } function Kb() { for (var a = g.getMapTypes(), b = 0; b < a.length; b++) { a[b].getMinimumResolution = function () { return 10 }; a[b].getMaximumResolution = function () { return 20 } } } function oc() {
		e("function:makeMap"); var a = O("q"); if (a == "") { var b = O("r"); if (b != "") a = "route:" + b; else { b = O("s"); if (b != "") a = "stop:" + b } } fb = $("#" + l + "map"); g = new GMap2(document.getElementById(l + "map"), { mapTypes: [G_NORMAL_MAP, G_PHYSICAL_MAP,
G_SATELLITE_MAP, G_HYBRID_MAP]
		}); g.setCenter(new GLatLng(51.515232, -0.141792), 13); (new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(130, 20))).apply(document.getElementById("overlayMsg")); g.getContainer().appendChild(document.getElementById("overlayMsg")); (new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(80, 5))).apply(document.getElementById(l + "WorkingMsg")); g.getContainer().appendChild(document.getElementById(l + "WorkingMsg")); (new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(80, 5))).apply(document.getElementById(l +
"WorkingMsg2")); g.getContainer().appendChild(document.getElementById(l + "WorkingMsg2")); b = new GTileLayer(new GCopyrightCollection, 0, 17); b.getTileUrl = function () { return "tfl-bus-map/img/white_map_tile.gif" }; b.getOpacity = function () { return 0.5 }; Ga = new GTileLayerOverlay(b); g.addOverlay(Ga); g.disablePinchToZoom(); GEvent.addListener(g, "maptypechanged", function () { Kb() }); GEvent.addListener(g, "infowindowclose", function () { $(".NonMapInfoWindowHolder").empty() }); g.disableDragging(); Kb(); fc(); pc(); g.openInfoWindowHtml(new GLatLng(51.515232,
-0.141792), "Loading..."); GEvent.addListener(g, "moveend", function () { qa("moveend"); if (Ea) x.style.visibility = "hidden" }); T = $("#" + l + "bus-routes-holder"); o.setMapSize(o.MapSizeLarge); o.ResizeMap(); qc(); sa.image = "tfl-bus-map/img/stop.png"; sa.iconSize = new GSize(32, 32); sa.iconAnchor = new GPoint(17, 17); sa.infoWindowAnchor = new GPoint(24, 12); pa.image = "tfl-bus-map/img/your_location.png"; pa.iconSize = new GSize(32, 32); pa.iconAnchor = new GPoint(17, 17); pa.infoWindowAnchor = new GPoint(24, 12); La.image = "tfl-bus-map/img/StreetViewIcon.png";
		La.iconSize = new GSize(32, 32); La.iconAnchor = new GPoint(17, 17); La.infoWindowAnchor = new GPoint(24, 12); if (a != "") { e("==================================qString:" + a); $(".mm-inputTxt-SearchBox").val(a); setTimeout(function () { $("#SearchButton_Top").trigger("click") }, 1500) } else {
			(new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(0, 72))).apply(document.getElementById(l + "PopUpBoxMsg")); g.getContainer().appendChild(document.getElementById(l + "PopUpBoxMsg")); $("#overlayMsg").show(); $("#" + l + "PopUpBoxMsg_close").bind("click",
function () { Da() }); $(".overlay").show(); $("#SearchBox_Overlay").focus()
		} 
	} function Lb(a) { var b = false; $.each(Mb, function (c, d) { if (d === a) { b = true; return false } }); return b } function qc() { ca({ url: "tfl-bus-map/dotnet/AllRoutes.aspx?session=" + rc, CallFunction: function (a) { Mb = a.AllRoutes } }) } function N(a) {
		var b = $("#" + l + "search-result"), c = a.Heading.replace(/POSTCODE /, ""); b.empty(); b.html("<h3>" + c + "</h3>"); if (typeof a.list === "object") {
			Y = a.list.length; if (Y !== 0) {
				c = "Did you mean?"; if (typeof a.listHeading === "string") c =
a.listHeading; var d = $('<div class="LHP-Disambiguation-Msg-Holder">'); d.append('<div class="' + l + 'LHP-Disambiguation-Msg">' + c); d.append($('<div class="' + l + 'LHP-Disambiguation-Msg-Close cursor-pointer" title="Hide \'did you mean\'"></div>').toggle(function () { $(".ambiguousResultsList").hide(); $(this).addClass("closed").attr("title", "Show 'did you mean'"); ba() }, function () { $(this).removeClass("closed").attr("title", "Hide 'did you mean'"); $(".ambiguousResultsList").show(); ba() })); d.append('<div class="clearer"></div>');
				Ma = $('<ul class="ambiguousResultsList">'); var j = 0; $.each(a.list, function (k, m) { var n = ""; if (k > ka && Y > ka) { n = ' class="MoreSearchResults"'; j++ } var s = m.address; if (typeof a.inputBox === "string") s = a.inputBox; Ma.append($("<li" + n + ">" + m.address + "</li>").bind("click", function () { e("==================================searchBoxHeading:" + s); aa({ Lat: m.Point.coordinates[1], Lng: m.Point.coordinates[0], q: s, LHP: { Heading: "Showing routes near " + s} }) })) }); if (j > 0) {
					e("totalAmbiResults:" + Y); e("TotalPosibleGeoResultsToShow:" + ka);
					Ma.append($('<li class="more">' + (Y - ka) + " more...</li>").bind("click", function () { $(".MoreSearchResults").removeClass("MoreSearchResults"); $(this).remove(); ba() }))
				} d.append(Ma); b.append(d).show()
			} 
		} b.show(); e("KKKKKKKKKKKKKKKKKKKKKKKKK")
	} function sc(a) { if (a.indexOf("N") != -1) return true; else if (a.indexOf("W") != -1) return true; return false } function kc() {
		e("f userSearch"); Z = 0; Cb(); var a = Za($("." + l + "inputTxt-SearchBox").val()); if (a == "") {
			Nb = "Please enter a search term.<br /> Either a Route no, postcode, address, landmark or station.";
			ec(Nb)
		} else {
			var b = false, c = a.indexOf(":"); if (c > 0) { c = a.substring(0, c); var d = a.split(":", 2)[1]; switch (c) { case "route": if (Lb(d)) { e("search - triggered - JUST A ROUTE"); a = t = d; $("." + l + "inputTxt-SearchBox").val(a); N({ Heading: "Showing route " + a }); ca({ url: "tfl-bus-map/dotnet/FullRoute.aspx?route=" + a + "&run=1", CallFunction: Ob }); b = true } break; case "stop": e("STOP = " + d); StopCode = d; b = O("sv"); tc(StopCode, b); if (b !== "") { ta = point; o.openStreetView(point) } b = true } } if (!b) {
				t = a.toUpperCase().replace(/ROUTE /, ""); a += ", London, UK";
				if (Lb(t)) {
					e("search - 01 - is a route That could be a postcode"); C.setSearchCompleteCallback(null, function () { if (C.results[0] && C.results[0].addressLines[0].indexOf("London") != -1) { var j = []; j.push(C.results[0].lng); j.push(C.results[0].lat); Ya.push({ address: "Postcode " + t, Point: { coordinates: j }, inputBox: t }); N({ Heading: "Showing route " + t, list: Ya }) } else { e("search - 02 - JUST A ROUTE"); N({ Heading: "Showing route " + t }) } }); sc(t) ? C.execute(a) : N({ Heading: "Showing route " + t }); ca({ url: "tfl-bus-map/dotnet/FullRoute.aspx?route=" +
t + "&run=1", CallFunction: Ob
					})
				} else if (gc(t)) { e("search - 03 - IS A POSTCODE"); C.setSearchCompleteCallback(null, function () { C.results[0] && aa({ Lat: C.results[0].lat, Lng: C.results[0].lng, q: a, LHP: { Heading: "Showing routes near " + a} }) }); C.execute(a) } else {
					e("search - 04 - Just a location"); e("search string: " + a); Na.getLocations(a, function (j) {
						if (j.Status.code == G_GEO_SUCCESS) {
							var k, m = []; $.each(j.Placemark, function (s, F) { k = F; pC = k.Point.coordinates; var da = pC[1], ua = pC[0]; da < gb && da > hb && ua > ib && ua < jb && m.push(F) }); if (m !==
null) { k = m[0].Point.coordinates; var n = new GLatLng(k[1], k[0]); $.each(m, function (s, F) { s !== 0 && (new GLatLng(F.Point.coordinates[1], F.Point.coordinates[0])).distanceFrom(n) >= 1E3 && Xa.push(F) }); a = Za(m[0].address); aa({ Lat: k[1], Lng: k[0], q: t, qInput: a, LHP: { Heading: "Showing routes near " + a, list: Xa} }) } S(); $("#" + l + "LHP-content").show()
						} else A("", "")
					})
				} 
			} 
		} 
	} function Ob(a) {
		e("f ajax_ShowJustOneFullRoute"); if (a.Routes) p = a.Routes; if (a.Stops) r = a.Stops; g.setZoom(12); D("hidden"); K = true; h = 0; eb(p); Q = false; T.show(); $("#busesLeftCol_inner").show();
		$("#" + l + "search-result").show(); S(); $("#" + l + "LHP-content").show(); qa("ajax_ShowJustOneFullRoute"); var b = false; $.each(f, function (c, d) { e("searchStrCleanedUpCase:" + t); e("item.Route:" + d.Route); if (d.Route == t) { e("OK"); if (d.IsDay) b = true } }); R(b)
	} function Pb(a) { if (a.length >= 0) { var b = [], c = []; $.each(a, function (d, j) { var k = new GLatLng(j.Latitude, j.Longitude); c = Qb(k, j.StopCode, "Stop", j.StopName); j.Marker = c; b.push(c); if (oa == j.StopCode) va = c }); uc(b); return a } } function eb(a) {
		e("manager_route"); f = []; e("manager_route2");
		X = W = 0; var b = []; ea = []; wa = []; $.each(a, function (c, d) {
			try {
				b.push(d); var j = "#" + d.Color, k = new GLatLng(d.startPoint.Latitude, d.startPoint.Longitude), m = Rb({ stopPoint: k, RouteID: d.Route, RouteColor: d.Color, IsDay: d.IsDay }); k = new GLatLng(d.endPoint.Latitude, d.endPoint.Longitude); var n = Rb({ stopPoint: k, RouteID: d.Route, RouteColor: d.Color, IsDay: d.IsDay }); Sb(d.Route) && ea.push(d.Route); wa.push(d.Route); $("#" + l + "bus-routes-holder").append(vc({ item: d, iCount: c })); f.push({ Index: c, Route: d.Route, Id: d.Id, oPolyline_1: null,
					oPolyline_2: null, ooStops_1: null, ooStops_2: null, run: 1, color: j, startPoint: m, endPoint: n, From: d.From, Towards: d.Towards, IsDay: d.IsDay, hasRunTwo: d.hasRunTwo
				})
			} catch (s) { e("ERROR - f manager_route") } 
		}); $.each(ea, function (c, d) { $(".ski_24hrs_" + d).text("24hr") }); X <= 0 && W >= 1 && Ta(0); W == 0 && $("#img_buttom_night").hide(); X == 0 && $("#img_buttom_day").hide()
	} function Tb(a, b) {
		xb(); if (kb(a)) { e("~~~~~~~~~~~~~~~~~~bus-routes-item-directionText~~~~~~~~~~~~~~~routeID_ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); e("BB:1"); lb({ Id: b.Id }) } else {
			e("~~~~~ACTIVE~~~~~~~~~~~~~bus-routes-item-directionText~~~~~~~~~~~~~~~routeID_ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
			var c; if (f[i].run == 1) { c = f[i].ooStops_1; w = f[i].oPolyline_1 } else { c = f[i].ooStops_2; w = f[i].oPolyline_2 } ga(); v = Ub(c, w); g.panTo(v); xa && Vb()
		} 
	} function vc(a) {
		if (typeof a.item == "object") if (typeof a.iCount == "number") {
			var b = a.iCount, c = a.item; a = ""; if (c.IsDay) { Wa = c; a = "IsDay_1"; X++ } else { a = "IsDay_0"; W++ } a = $($('<div id="routeID_' + c.Id + '" class="' + l + "bus-routes-item " + a + '">').click(function () { })).hover(function () { try { $(this).hasClass(H) && $(this).removeClass(H).addClass(ha) } catch (d) { } }, function () {
				try {
					$(this).hasClass(ha) &&
$(this).attr("id") != "routeID_" + f[h].Id && $(this).addClass(H)
				} catch (d) { } 
			}); currentItemHolder = $('<div class="' + l + 'bus-routes-item_Holder"></div>'); currentItemHolder.append($('<a href="#" class="' + l + "bus-routes-item_ski ski_img ski_img_" + c.Color + '">' + c.Route + "</a>").click(function () { Tb(this, c); return false })); currentItemHolder.append($('<div class="ski_24hrs_' + c.Route + '"></div>')); a.append(currentItemHolder); a.append($('<div class="' + l + 'bus-routes-item-directionText" id="RouteID_DirectionTextLink_' + c.Id +
'">From <b class="FromLocation_' + b + '">' + c.From + '</b> towards <b class="TowardsLocation_' + b + '">' + c.Towards + "</b></div>").click(function () { Tb(this, c) })); a.append($('<div class="' + l + 'bus-routes-item-SwapRun" id="SwapRunID_' + c.Id + '"><a href="#">Switch direction</a></div>').click(function () {
	e("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~SwapRun ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); e("ajaxNotInProgress:::::" + U); if (U) {
		e("find and swap current run on route."); var d = f[b].run; e("currentRun:" + d); d = d == 1 ? 2 : 1; e("currentRun:" +
d); f[b].run = d; e("swap text in LHP"); d = $(".FromLocation_" + b).text(); var j = $(".TowardsLocation_" + b).text(); $(".FromLocation_" + b).text(j); $(".TowardsLocation_" + b).text(d); if ($("#show-all-stops-link_" + b).hasClass("stops-active")) { $("#RouteStopsHolder_" + b).empty(); Oa = true } Ua(); mb({ Index: b })
	} return false
})); currentItemHoldStopIcon = $('<div class="show-all-stops-link_Hold"></div>'); currentItemHoldStopIcon.append($('<div class="' + l + "show-all-stops-link cursor-pointer trigger_show-all-stops-link_" + c.Id + '" id="show-all-stops-link_' +
b + '"><a href="#" class="show-all-stops-link_' + b + '_aLink">Show all stops</a></div><div id="RouteStopsHolder_' + b + '" class="RouteStopsHolder"></div><div id="AllStopsLoading_' + b + '" class="AllStopsLoading">Loading..</div>').toggle(function () { if (kb(this)) { $("#AllStopsLoading_" + b).addClass("active"); $(".show-all-stops-link_" + b + "_aLink").text("Hide stops"); Oa = true; ja = null; e("BB:3"); lb({ Id: c.Id }); $(this).addClass("stops-active"); return false } }, function () {
	if (kb(this)) {
		$("#AllStopsLoading_" + b).removeClass("active");
		$(".show-all-stops-link_" + b + "_aLink").text("Show all stops"); $(this).removeClass("stops-active"); $(this).siblings(".RouteStopsHolder").html(""); D("inactive"); $(".mm-bus-routes-item").height("auto"); return false
	} 
})); a.append(currentItemHoldStopIcon); return a
		} 
	} function Rb(a) {
		var b = a.stopPoint, c = a.RouteID, d = a.IsDay; a = "tfl-bus-map/img/ski/" + a.RouteColor + ".png"; var j = document.createElement("div"), k = g.fromLatLngToDivPixel(b); k.x -= parseInt(Ka / 2, 10); k.y -= parseInt(ra / 2, 10) - 30; var m = ""; m = document.all ? 'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src="' +
a + '");' : "background:url(" + a + ");"; m += "height:" + ra + "px;line-height:" + ra + "px;"; m += "width:" + Ka + "px;text-align:center;  padding-top:8px;"; j.style.cssText = m + "cursor:pointer;top:" + k.y + "px;left:" + k.x + "px;color:#FFFFFF;position:absolute;z-index:50px; font-size:11px;font-family:Arial,sans-serif;font-weight:bold"; j.innerHTML = c; g.getPane(G_MAP_MARKER_PANE).appendChild(j); if (!d) j.style.display = "none"; GEvent.addDomListener(j, "click", function () {
	ia = true; var n = document.createElement("div"); n.innerHTML = '<div id="maxContentDiv"></div>';
	g.openInfoWindowHtml(b, "__ROUTE__" + c, { maxContent: n, maxTitle: b })
}); return { div: j, latlng: b}
	} function Qb(a, b, c) { switch (c) { case "Stop": c = sa; break; default: c = new GIcon(G_DEFAULT_ICON) } c = new GMarker(a, { icon: c }); J.extend(a); GEvent.addListener(c, "click", function () { v = a; StopCode = b; Pa() }); return c } function pc() {
		GEvent.addListener(g, "infowindowopen", function () {
			var a = g.getInfoWindow(); ya = $(a.getContentContainers()[0].innerHTML).text(); v = a.getPoint(); if (ya.indexOf("__STOP__") != -1) {
				a.hide(); if (g.getZoom() <= nb) {
					e("ZOOM IN");
					g.setCenter(v, nb + 2)
				} else { StopCode = $.trim(ya.replace(/__STOP__/, "")); Pa(); L({ showHide: false }) } 
			} else if (ya.indexOf("__ROUTE__") != -1) { a.hide(); CurrentActiveRun = $.trim(ya.replace(/__ROUTE__/, "")); fa = v; e("@3"); Ca(CurrentActiveRun); e("@3.1"); L({ showHide: false }) } 
		})
	} function Ca(a) { e("LoadRouteID:" + a); xa = true; a = Wb(a, "Id"); e("FindRoute :" + a); $("#RouteID_DirectionTextLink_" + a).trigger("click") } function Pa() {
		ob = true; e("build_createInfoWindowStop"); e("StopCode = " + StopCode); e("currentStopCodeCord = " + v); g.panTo(v);
		var a = document.createElement("div"); a.innerHTML = '<div id="maxContentDiv">max content stub</div>'; null != g.getInfoWindow() && g.closeInfoWindow(); g.openInfoWindowHtml(v, '<div id="InfoWindowPrimary"></div><div id="StopRouteInfoHolder"></div><div id="planJourneyFromHere" class="listPoint"></div><div id="searchFromHere"></div><div class="LoadingData">Loading stop details...<br /><br /><p class="StopGreyText">(Select stop again if data does not show within 5 seconds.)</p><br /><br /><br /><br /></div>', { maxContent: a,
			maxTitle: "Bus stop"
		}); L({ showHide: false }); ca({ url: "tfl-bus-map/dotnet/stopinfo.aspx?stopcode=" + StopCode, CallFunction: wc })
	} function Vb() { e("f createInfoWindowRoute"); g.openInfoWindowHtml(v, '<div id="InfoWindowPrimary"></div><div class="LoadingData">Loading route details...</b><br /><br /><br /></div>'); Xb(); L({ showHide: false }) } function Xb() {
		var a = f[h]; if (a !== null) {
			var b = $(".TowardsLocation_" + h).text(), c = $(".FromLocation_" + h).text(); q = $(".NonMapInfoWindowHolder"); q.empty(); var d = $('<div id="StopWindowHeading"></div>');
			d.append('<div class="bus_route_title">Bus Route:</div>'); var j = $('<div id="RouteName"></div>'); j.append('<div class="StopRouteInfoHolder_routeID RouteInfoWindow_RouteID withStopLetter ski_' + a.color.replace(/#/, "") + '">' + a.Route + "</div>"); j.append('<div class="RouteInfoWindow_FromTowards">' + c + ' <span class="nonBold">towards</span> <br />' + b + "</div>"); d.append(j); q.append(d); q.append('<div class="clearer"></div>'); q.append($('<div class="listPoint RouteInfoWindow_ShowFullRoute">Show all of route ' +
a.Route + "</div>").click(function () { e("SHOW ROUTE"); za({ Route: a.Route }) })); q.append('<div class="listPoint RouteInfoWindow_ShowFullRoute"><a class="planned-disruptions" href="' + Yb + a.Route + '">Check for planned disruptions for route ' + f[h].Route + "</a></div>"); q.find(".planned-disruptions").click(function () { window.open(this.href, "_blank", "scrollbars=yes, location=yes, status=yes, titlebar=yes, toolbar=yes, resizable=yes"); return false }); var k = xc({ Route: a.Route }); if (k !== null) {
				b = u ? "Night bus" : "Day bus";
				c = k.color; c = c.replace(/#/, ""); q.append('<div class="Pre_myOtherRouteIs_Spacer"></div>'); q.append('<div class="StopRouteInfoHolder_routeID RouteInfoWindow_RouteID withStopLetter ski_' + c + '">' + k.Route + "</div>"); q.append('<div class="myOtherRouteIs_Text_Type">' + b + "</div>"); q.append('<div class="clearer"></div>'); q.append($('<div class="listPoint myOtherRouteIs_Text">View route ' + k.Route + "</div>").click(function () { Va = false; za({ Route: k.Route, NoDayCheck: true }) }))
			} V = 0; pb()
		} else setTimeout(function () { Xb() },
200)
	} function xc(a) { var b = a.Route, c = null; if (u) { b = "N" + b; $.each(f, function (j, k) { if (k.Route == b && k.IsDay != u) c = k }) } else { var d = b.replace(/N/, ""); $.each(f, function (j, k) { if (k.Route == d && k.IsDay != u && k.Route != b) c = k }) } return c } function ga() { g.getInfoWindow().hide(); $(".NonMapInfoWindowHolder").empty() } function Sb(a) { var b = false; $.each(wa, function (c, d) { if (d == a) b = true }); return b } function yc(a) {
		var b = null; $.each(f, function (c, d) { if (d.Route == a && d.IsDay == u) b = d.color; if (d.Route == a && d.IsDay != u && b === null) b = d.color });
		return b
	} function zc(a) { var b = false; $.each(ea, function (c, d) { if (a == d) b = true }); return b } function Zb(a) { return $.parseJSON($.ajax({ type: "GET", url: a, async: false, contentType: "application/json; charset=utf-8", dataType: "json" }).responseText) } function tc(a) {
		e("setUpStopSearch"); try {
			var b = Zb("tfl-bus-map/dotnet/stopinfo.aspx?stopcode=" + a); if (b === "") { A("", ""); return false } h = 0; f = []; if (b.Routes && b.Stops) { f = p = b.Routes; aStops = r = b.Stops } else { A("", ""); return false } if (p.length > 0 && r.length > 0) {
				var c = p[h].Route, d = r[0],
j = "&Lat=" + Ia(d.Latitude, 3) + "&Lng=" + Ia(d.Longitude, 3); searchStr = t = d.StopName; v = new GLatLng(d.Latitude, d.Longitude); N({ Heading: "Showing routes near " + d.StopName }); $("#" + l + "search-result").empty(); $("." + l + "inputTxt-SearchBox").val(d.StopName); $("#textVersionLink").attr("href", "tfl-bus-map/text/stopinfo.aspx?s=" + d.StopCode + "&r=" + c); var k = "tfl-bus-map/dotnet/Search.aspx?searchStr=" + d.StopName + "&width=" + $("#" + l + "map").width() + "&height=" + $("#" + l + "map").height() + "&zoom=16" + j, m = Zb(k); if (m == "") { A("", ""); return false } if (m.CoOrds ==
"" || m.Count == "") { A("", ""); return false } p = m.Routes; r = m.Stops; E = m.CoOrds; a = 16; if (E.Zoom != "") a = E.Zoom; g.setCenter(new GLatLng(E.Latitude, E.Longitude), a); eb(p); T.show(); $("#busesLeftCol_inner").show(); $("#" + l + "search-result").show(); S(); $("#" + l + "LHP-content").show(); setTimeout(function () { ba() }, 2E3); point = new GLatLng(d.Latitude, d.Longitude); oa = d.StopCode; v = point; StopCode = d.StopCode; Qa = false; Pa(); g.addOverlay(Qb(point, StopCode, "Stop", d.StopName)); $(".LoadingData").hide()
			} else { A("", ""); return false } return true
		} catch (n) {
			e("setUpStopSearch :: " +
n.Message); A("", ""); $(".LoadingData").hide(); return false
		} 
	} function wc(a) {
		if (a.Routes) p = a.Routes; if (a.Stops) r = a.Stops; if (null == h) h = 0; if (null == f) f = []; a = 0; var b = ""; if (r.length > 0) a = r[0].StopCode; if (p.length > 0) { if (h >= p.length) h = p.length - 1; b = p[h].Route } q = $(".NonMapInfoWindowHolder"); q.empty(); var c = $('<div id="StopWindowHeading"></div>'); c.append('<div class="bus_stop_title">Bus stop:</div>'); var d = $('<div id="StopName"></div>'); if (r[0].PointLetter != "") {
			d.append($('<span id="stopPointLetter" title="Stop letter ' +
r[0].PointLetter + '">' + r[0].PointLetter + "</span>")); d.addClass("withStopLetter")
		} d.append('<div id="StopNameText"><a title="go to stop page" href="tfl-bus-map/text/stopinfo.aspx?s=' + a + "&r=" + b + '">' + r[0].StopName + "</a></div>"); c.append(d); q.append(c); q.append($('<div class="clearer"></div><a href="#" class="stopTimeTableHeading">Timetables and frequency:</a>').click(function () { $("#Route_" + b).trigger("click"); return false })); var j = 0; Aa = $('<div id="routeList"></div>'); var k, m; ea = []; wa = []; $.each(p, function (n,
s) {
			if (Sb(s.Route)) ea.push(s.Route); else {
				j++; if (j == 1) k = $('<ul class="tabsL">'); var F = "#ffffff", da = false; itemColorTemp = yc(s.Route); if (itemColorTemp != null) { F = itemColorTemp; da = true } var ua = F.replace(/#/, ""); m = $($('<li id="Route_' + s.Route + '">').click(function () { e("Route" + s.Route + "  Clicked"); g.getInfoWindow().enableMaximize(); Ha = StopCode; ab = s.Route; bb = ua; Fb = da; na ? g.getInfoWindow().maximize() : Eb({ RouteID: ab, StopCode: Ha, From: s.From, Towards: s.Towards, SkiID: bb, RouteInSearchResults: da }) })); m.html('<a><span class="ski_' +
ua + " Ski_Route_" + s.Route + '"><span>' + s.Route + "</span></span></a>"); k.append(m); if (j === 8) { Aa.append(k); q.append(Aa); k = $('<ul class="tabsL">'); j = 0 } wa.push(s.Route)
			} 
		}); if (j > 0) { Aa.append(k); q.append(Aa) } q.append('<div class="clearer"></div><div id="StopRouteInfoHolder"></div>'); q.append($('<div class="listPoint" id="searchFromHere">Search for routes near here</div>').bind("click", function () { aa({ Lat: r[0].Latitude, Lng: r[0].Longitude, q: r[0].StopName, LHP: { Heading: "Showing routes near " + r[0].StopName} }); return false }));
		q.append('<div class="clearer"></div><div class="listPointNoLine">Plan a journey: <a href="http://journeyplanner.tfl.gov.uk/user/XSLT_TRIP_REQUEST2?language=en&amp;execInst=&amp;sessionID=0&amp;ptOptionsActive=-1&amp;place_destination=London&amp;name_destination=' + r[0].StopName + '&amp;type_destination=stop&amp;includedMeans=checkbox&amp;inclMOT_5=on" target="_blank">To here</a> - <a href="http://journeyplanner.tfl.gov.uk/user/XSLT_TRIP_REQUEST2?language=en&amp;execInst=&amp;sessionID=0&amp;ptOptionsActive=-1&amp;place_origin=London&amp;name_origin=' +
r[0].StopName + '&amp;type_origin=stop&amp;includedMeans=checkbox&amp;inclMOT_5=on" target="_blank">From here</a></div>'); q.append('<div class="clearer"></div>'); $(".LoadingData").hide(); $("#stopItem_" + r[0].StopCode).addClass("stop-item-active"); V = 0; pb()
	} function pb() {
		e("logic_checkInfoWindowIsPopulated"); q = $(".NonMapInfoWindowHolder"); MapInfoWindowPrimary = $("#InfoWindowPrimary"); if (MapInfoWindowPrimary.text() == "") {
			$(".LoadingData").hide(); q.clone(true).prependTo(MapInfoWindowPrimary); MapInfoWindowPrimary.find(".NonMapInfoWindowHolder").removeClass("NonMapInfoWindowHolder").show();
			g.updateInfoWindow(); if (ob) { ob = false; g.getInfoWindow().disableMaximize() } V++; if (V <= Ac) setTimeout(function () { pb() }, 200); else { e("Close IW"); setTimeout(function () { ga() }, 300) } 
		} else { e("."); V = 0; if (Qa) { Qa = false; $("#Route_" + f[h].Route).trigger("click") } } 
	} function Eb(a) {
		var b = a.RouteID, c = a.StopCode, d = a.Towards, j = a.From, k = ""; if (typeof a.SkiID === "string") k = a.SkiID; z = $("#StopRouteInfoHolder"); z.empty(); if (null == b) z.append($('<div id="Stop_Route_TimeTable" class="TimeTableActive"><img alt="" class="no_resultsIcon" src="/tfl-global/images/exclamation.png"/><div class="Stop_TimeTable_SorryMsg">Please select a route from above</div></div>').show());
		else {
			z.append('<div class="StopRouteInfoHolder_routeID ski_' + k + '">' + b + "</div>"); J_Stop_Route_TimeTableHold = $('<div class="StopRouteInfoHolder_TowardsFrom_Holder"></div>'); J_Stop_Route_TimeTableHold.append($('<div class="StopRouteInfoHolder_From"><b>' + j + "</b></div>")); J_Stop_Route_TimeTableHold.append($('<div class="StopRouteInfoHolder_Towards">towards <b>' + d + "</b></div>")); zc(b) && J_Stop_Route_TimeTableHold.append('<img alt="24hr route" class="twentFourIcon" src="tfl-bus-map/img/24-hour.gif"/>'); z.append(J_Stop_Route_TimeTableHold);
			z.append('<div class="clearer"></div>'); z.append('<div id="Stop_Route_TimeTable_Loading">Loading timetable info...</div>'); var m = Bc + b + "_" + c + ".htm"; e("busTimeTableURL:" + m); $.ajax({ type: "GET", url: m, timeout: 2E4, tryCount: 1, retryLimit: 2, success: function (n) {
				$("#Stop_Route_TimeTable_Loading").remove(); qb = $('<div id="Stop_Route_TimeTable" class="printWrapper">' + n.replace(/black/, "") + "</div>"); z.append(qb); n = $(".NonMapInfoWindowHolder").find("#StopRouteInfoHolder"); n.empty(); qb.clone(true).prependTo(n); n =
$('<div class="otherRouteInfo"></div>'); a.RouteInSearchResults && n.append($('<div class="listPoint RouteInfoWindow_ShowFullRoute listPoint_sameLine_left">Show all of route ' + b + " </div>").bind("click", function () { za({ Route: b }) })); n.append('<div class="listPoint RouteInfoWindow_ShowFullRoute listPoint_sameLine_right"><a class="planned-disruptions" href="' + Yb + b + '">Check for planned disruptions for route ' + b + "</a></div>"); n.find(".planned-disruptions").click(function () {
	window.open(this.href, "_blank", "scrollbars=yes, location=yes, status=yes, titlebar=yes, toolbar=yes, resizable=yes");
	return false
}); z.append(n); z.append('<div class="clearer"></div>'); $("#MainBody").show(); $("#TT_Page").show(); $("#Route_" + b).addClass("TabRouteLineActive").siblings().removeClass("TabRouteLineActive"); $(".Ski_Route_" + b).addClass("selected").siblings().removeClass("selected")
			}, error: function (n, s) {
				$("#Route_" + b).addClass("TabRouteLineActive").siblings().removeClass("TabRouteLineActive"); $(".Ski_Route_" + b).addClass("selected").siblings().removeClass("selected"); if (s == "timeout") {
					this.tryCount++; this.tryCount <=
this.retryLimit && $.ajax(this)
				} else {
					$("#Stop_Route_TimeTable_Loading").remove(); z.append($('<div id="Stop_Route_TimeTable" class="TimeTableActive"><img alt="" class="no_resultsIcon" src="/tfl-global/images/exclamation.png"/><div class="Stop_TimeTable_SorryMsg">' + Cc + "</div></div>").show()); a.RouteInSearchResults && z.append($('<div class="listPoint RouteInfoWindow_ShowFullRoute">Show all of route ' + b + " </div>").bind("click", function () { za({ Route: b }) })); e("Error on " + m + " called from function action_GetTimeTableInfo. Code " +
n.status + ".")
				} 
			} 
			})
		} 
	} function L(a) {
		try {
			var b = h; if (typeof a.HideAll !== "undefined") b = null; e("f action_showHideStartEndPoints:"); var c = a.showHide; qa("action_showHideStartEndPoints"); if (c) if (h != null && f[h] != null) { f[h].startPoint.div.style.display = "block"; f[h].endPoint.div.style.display = "block" } else switch (G) { case "multi": $.each(f, function (j, k) { if (u == k.IsDay) { k.startPoint.div.style.display = "block"; k.endPoint.div.style.display = "block" } }) } else {
				$.each(f, function (j, k) {
					k.startPoint.div.style.display = "none"; k.endPoint.div.style.display =
"none"
				}); if (b != null) { f[h].startPoint.div.style.display = "block"; f[h].endPoint.div.style.display = "block" } 
			} ub()
		} catch (d) { e("ERROR - f action_showHideStartEndPoints") } 
	} function Ja() { g.setZoom(g.getBoundsZoomLevel(J)); g.setCenter(J.getCenter()) } function Ub(a, b) {
		try {
			DistanceFromNearestLat = null; var c = b.getVertexCount(); e("vertexCount:" + c); if (K && searchWas_RouteOnly_FirstOpen) { e("**"); var d = b.getVertex(Math.round(c / 2)); return DistanceFromNearestLat = new GLatLng(d.lat(), d.lng()) } for (var j = g.getCenter(), k = 9999999999,
m = 0; m < c; m++) { d = b.getVertex(m); var n = new GLatLng(d.lat(), d.lng()), s = d.distanceFrom(j); if (s <= k) { k = s; DistanceFromNearestLat = n } } return DistanceFromNearestLat
		} catch (F) { } 
	} function Ib(a) { e("f cache_RoutePolyline_Set"); if (f[h].run == 1) f[h].oPolyline_1 = a; else f[h].oPolyline_2 = a } function Jb(a) { if (f[h].run == 1) f[h].ooStops_1 = a; else f[h].ooStops_2 = a } function Dc(a) {
		if (a.Routes) p = a.Routes; if (a.Stops) r = a.Stops; e("encode polyline data into a GMap Object"); e("++++++++++++++++++++++++++++++"); var b = 0; e("dayOrNightActive:" +
u); $.each(p, function (c, d) { d.Index = c; e("item.IsDay:" + d.IsDay); if (d.IsDay == u) b = d.Index }); e("RenderItemIndex:" + b); w = Hb(p[b].encodedPoints, p[b].encodedLevels, f[h].color, "FullRoute", p[b].Route); Ib(w); f[h].From = r[b]; f[h].Towards = r[r.length - 1]; f[h].hasRunTwo = p[b].hasRunTwo; B = Pb(r); Jb(B); e("reCallFunction_renderOneRoute:" + Ra); if (Ra) { Ra = false; e("=======   action_renderOneRoute: 3"); mb(ma) } 
	} function lb(a) {
		if (la != "") { a = la; la = "" } if (typeof a.Id !== "undefined") h = $b(a.Id, "Index"); J = new GLatLngBounds; if (h <= 0) h = 0;
		$("." + I).removeClass(I); $("." + H).removeClass(H); try { var b = $("#routeID_" + f[h].Id).siblings(); $("#routeID_" + f[h].Id).addClass(I); b.addClass(H); var c = b.children(); c.find(".RouteStopsHolder").html(""); c.find(".mm-show-all-stops-link").child().text("Show all stops").removeClass("stops-active") } catch (d) { e("ERROR - f addInActiveClassesToLHP") } if (!K) switch (G) { case "multi": $(".mm-LHP-Disambiguation-Msg-Close").hasClass("closed") || $(".mm-LHP-Disambiguation-Msg-Close").trigger("click") } Da(); switch (G) { case "multi": D("active") } L({ showHide: false });
		e("=======   action_renderOneRoute: 4"); mb({ Index: h }); wb(f[h].Id)
	} function wb(a) { e("f action_scrollTo"); try { if (ja != a) { ja = a; setTimeout(function () { $("#mm-bus-routes-holder").scrollTo($("#routeID_" + ja), 900, "y"); ba() }, 500) } } catch (b) { e("ERROR - f action_scrollTo") } } function uc(a) { if (M !== null) { M.addMarkers(a); e("f action_popUpStopInfo"); e("popUpStopWindowMarker:" + va); if (va != null) { e("trigger"); GEvent.trigger(va, "click"); va = oa = null } } else { M = null; M = new MarkerClusterer(g, a, { maxZoom: nb, gridSize: 80, styles: Ec[0] }) } }
	function Fc(a) { stopsDiv = $("#RouteStopsHolder_" + h); $.each(a, function (b, c) { stopsDiv.append($('<div id="stopItem_' + c.StopCode + '" class="stopItem"><a href="#">' + c.StopName + "</a></div>").click(function () { point = new GLatLng(c.Latitude, c.Longitude); oa = c.StopCode; v = point; StopCode = c.StopCode; Qa = true; Pa(); return false })) }); $("#AllStopsLoading_" + h).removeClass("active"); D("active") } function za(a) {
		try {
			if (Sa != "") { Route = Sa; Sa = "" } else Route = a.Route; e("action_viewFullRoute"); ga(); var b; b = typeof a.NoDayCheck !== "undefined" ?
Gc(Route, "Index") : Wb(Route, "Index"); if (h == null || h == 0 || h == "") h = 0; if (u != f[b].IsDay) { R(f[b].IsDay); Sa = Route; setTimeout(function () { za(a) }, 1E3) } e("CurrentActiveRoute:" + h); e(f[b].Id + ":" + f[h].Id); if (f[b].Id != f[h].Id) { rb = true; e("BB:4"); e("showRoute :" + f[b].Id); lb({ Id: f[b].Id }) } else { ac(); Ja(); qa("action_viewFullRoute") } 
		} catch (c) { e("ERROR - f action_viewFullRoute") } 
	} function Gc(a, b) { for (i = 0; i < f.length; i++) if (f[i].Route == a) return f[i][b] } function Wb(a, b) {
		var c = null; for (i = 0; i < f.length; i++) if (f[i].Route == a && f[i].IsDay ==
u) { c = f[i][b]; break } return c
	} function $b(a, b) { e("find_returnRouteInfoById:" + a); e("GetThis:" + b); for (i = 0; i < f.length; i++) if (f[i].Id == a) { e("FOUND"); try { e("return:" + f[i][b]); return f[i][b] } catch (c) { e("not found"); return null } } } function ac() {
		B = f[h].run == 1 ? f[h].ooStops_1 : f[h].ooStops_2; var a = 180, b = 180, c = -180, d = -180; $.each(B, function (m, n) { if (n.Latitude < a) a = n.Latitude; if (n.Latitude > c) c = n.Latitude; if (n.Longitude < b) b = n.Longitude; if (n.Longitude > d) d = n.Longitude }); var j = new GLatLng(a, b), k = new GLatLng(c, d); J.extend(j,
k); J.extend(f[h].startPoint.latlng); J.extend(f[h].endPoint.latlng)
	} function mb(a) {
		e("action_renderOneRoute"); if (ma != "") { a = la; ma = "" } else { Ab(); Bb(); try { $("#routeID_" + f[h].Id).removeClass("inActive").removeClass(ha) } catch (b) { e("ERROR - f CheckActiveRouteIsActive") } if (typeof a.Id !== "undefined") h = $b(a.Id, "Index"); if (typeof a.Index !== "undefined") h = a.Index } e("CurrentActiveRoute:" + h); if (f[h].run == 1) { w = f[h].oPolyline_1; B = f[h].ooStops_1 } else { w = f[h].oPolyline_2; B = f[h].ooStops_2 } if (w == null) {
			Ra = true; ma = a; ca({ url: "tfl-bus-map/dotnet/FullRoute.aspx?route=" +
f[h].Route + "&run=" + f[h].run, CallFunction: Dc
			})
		} else {
			g.addOverlay(w); B = Pb(B); a = f[h].hasRunTwo; try { e("userCon_ShowSwitchDirection:" + a); $(".mm-bus-routes-item-SwapRun").removeClass("active"); a && $("#SwapRunID_" + f[h].Id).addClass("active") } catch (c) { e("ERROR - f userCon_ShowSwitchDirection") } e("currentStopCodeCord_ROUTE:" + fa); if (fa === null) a = Ub(B, w); else { a = fa; fa = null } g.panTo(a); var d = document.createElement("div"); d.innerHTML = '<div id="maxContentDiv"></div>'; g.openInfoWindowHtml(a, "__ROUTE__" + f[h].Route, { maxContent: d,
				maxTitle: "Route"
			}); if (rb) { rb = false; ac(); xa === false && Ja() } e("PopUpRouteInfoWindowAfterRouteLoad:" + xa); v = a; Vb(); xa = false; if (Oa) { Oa = false; Fc(B) } if (K && searchWas_RouteOnly_FirstOpen) { searchWas_RouteOnly_FirstOpen = false; Ja() } qa("action_renderOneRoute")
		} 
	} function xb() { try { $("#show-all-stops-link_" + h).attr("class").indexOf("stops-active") != -1 && $("#show-all-stops-link_" + h).trigger("click") } catch (a) { e("ERROR - f closeShowAllStops") } } function Hb(a, b, c, d, j) {
		a = GPolyline.fromEncoded({ color: c, weight: 5, opacity: 0.8,
			points: a, levels: b, numLevels: 18, zoomFactor: 2
		}); GEvent.addListener(a, "mouseover", function () { }); GEvent.addListener(a, "mouseout", function () { }); GEvent.addListener(a, "click", function (k) { fa = k; Ca(j) }); return a
	} function kb(a) { if (ia) { ia = false; return true } else { e("checkActive"); sb = $(a).parent().attr("class"); e("parrentClass:" + sb); if (sb.indexOf(I) == -1) { e("IS TRUE"); return true } } } function ba() {
		e("autoSizeLHPHeights:"); $(".mm-bus-routes-item").height("auto"); var a = parseInt($("#mm-bus-routes-holder").css("height"));
		if (h !== null) if ($("#show-all-stops-link_" + f[h].Index).hasClass("stops-active")) { var b = $("#routeID_" + f[h].Id).height(); e("scroll333"); if (b < a) { e("scroll1"); $("#routeID_" + f[h].Id).height(a); if (f[h].Id == Wa.Id) { e("scroll"); $("#mm-bus-routes-holder").scrollTo(999999, 900, "y") } } } b = $("#mm-LHP-content").height(); a = b <= Ba ? a + (Ba - b) : a - (b - Ba); $("#mm-bus-routes-holder").height(a)
	} function A(a, b) {
		a && b ? g.setCenter(new GLatLng(a, b), 13) : g.setCenter(new GLatLng(51.515232, -0.141792), 13); $("." + l + "LHP-NoResults_content").text($("." +
l + "inputTxt-SearchBox").val()); g.addOverlay(Ga); S(); $("#busesLeftCol_inner").hide(); $("#mm-LHP-NoResults").show(); $("#mm-LHP-content").hide(); g.getInfoWindow().hide()
	} function Hc(a) { if (a.code != 200) { GLog.write("showPanoData: Server rejected with code: " + a.code); ta = null } else { e("OK:" + a.location.latlng); ta = a.location.latlng; $(".streeViewContext").slideDown("fast") } } function lc() {
		x.style.visibility = "hidden"; x.style.background = "#ffffff"; x.style.border = "1px solid #565656"; x.innerHTML = '<div class="context"><a href="javascript:busMapApplication.searchHere()">Search for routes near here</a></div>';
		x.innerHTML += '<div class="context borderTop streeViewContext"><a href="javascript:busMapApplication.openStreetView({})" >View Streetview</a></div>'; g.getContainer().appendChild(x); var a = new GStreetviewClient; GEvent.addListener(g, "singlerightclick", function (b) {
			if (Ea) {
				$(".streeViewContext").hide(); tb = b; var c = g.fromContainerPixelToLatLng(tb); a.getNearestPanorama(c, Hc); c = b.x; b = b.y; if (c > g.getSize().width - 120) c = g.getSize().width - 120; if (b > g.getSize().height - 100) b = g.getSize().height - 100; (new GControlPosition(G_ANCHOR_TOP_LEFT,
new GSize(c, b))).apply(x); x.style.visibility = "visible"
			} 
		}); GEvent.addListener(g, "click", function () { boundsAllreadyChecked = false; x.style.visibility = "hidden" })
	} function Ic(a) { if (!a || a.Status.code != 200) A("", ""); else { place = a.Placemark[0]; aa({ Lat: place.Point.coordinates[1], Lng: place.Point.coordinates[0], q: place.address, LHP: { Heading: "Showing routes near " + place.address} }) } } function Jc() {
		x.style.visibility = "hidden"; panoramaOptions = { latlng: ta }; var a = new GStreetviewPanorama(document.getElementById("pano"), panoramaOptions);
		GEvent.addListener(a, "initialized", function () { $("#pano_Loading").hide() }); GEvent.addListener(a, "error", function (b) { b == 600 && $("#pano").text("Sorry no Streetview in this area."); b == 603 && $("#pano").text("Flash required for Streetview") })
	} var bc = "http://" + document.domain, Bc = bc + "/tfl/syndication/feeds/html/timetables/buses/", Yb = bc + "/tfl/livetravelnews/realtime/buses/default.html#bus-", Cc = "Sorry, we are unable to provide a stop specific timetable for this route online.<br />Please call our Travel Information Line (0843 222 1234 \u2013 24 hours a day).<br />You'll pay no more than 5p per minute if calling from a BT landline. Charges from mobiles or other landline providers may vary.",
hb = 51.08, ib = -0.78, gb = 51.81, jb = 0.33, nb = 15, Ba = 600, cc, nc = 2, rc = 988870871, G = O("mode"), H = "inActive", ha = "inActive_hover", I = "route_active"; if (G != "multi") { G = "SingleLine"; H = "inActive_SingleLine"; ha = "inActive_hover_SingleLine"; I = "route_active_SingleLine" } var w = null, B = null, Ya = [], xa = false, Y = 0, ob = false, ya, u = 1, ka = 1, K = false, U = true, f = [], h = null, rb = false, ab, bb, Ha, v, oa, Fb, ia = false, cb, db, Z = 0, Gb, Ga, Mb = [], p = [], r = [], E, Fa = 1, Wa, P = null, na = true, q = null, g = "", fb = "", M = null, T, Q = false, va, Aa, Ea = false, Ma, ja = "", Ka = 38, ra = 28, Nb = "", t, W =
0, X = 0, la = [], Xa = [], V = 0, Ac = 10, l = "mm-", tb, x = document.createElement("div"), Qa = false, Sa = "", vb, Va = true, zb, $a = false, Db, wa = [], ea = [], fa = null, z, qb, sb, Ra = false, Oa = false, ma = "", ta = null, Ec = [[{ url: "tfl-bus-map/img/cluster.png", height: 32, width: 32, anchor: [3, 0], textColor: "#FF00FF" }, { url: "tfl-bus-map/img/cluster.png", height: 32, width: 32, opt_anchor: [6, 0], opt_textColor: "#FF0000" }, { url: "tfl-bus-map/img/cluster.png", height: 32, width: 32, opt_anchor: [8, 0]}]], J = new GLatLngBounds, Na = new GClientGeocoder, y = new GLatLngBounds(new GLatLng(hb -
0.3, ib - 0.3), new GLatLng(gb + 0.3, jb + 0.3)), sa = new GIcon, pa = new GIcon, La = new GIcon, C = new google.search.LocalSearch, dc = O("debug"), o = {}; o.MapSizeSmall = "S"; o.MapSizeLarge = "L"; o.setContainingElement = function (a) { containingElement = a }; o.setMapSize = function (a) { if (a !== o.MapSizeLarge) a = o.MapSizeSmall; cc = a }; o.ResizeMap = function () {
	var a = 0, b = $(containingElement).width(), c = b - 208; switch (cc) {
		case o.MapSizeSmall: $("#busesLeftCol").show(); $("#busesRightCol").width(c); a = c; $("#" + l + "but_showLHP").hide(); break; case o.MapSizeLarge: $("#busesLeftCol").hide();
			$("#busesRightCol").width(b); a = b; $("#" + l + "but_showLHP").show()
	} Ba = $("#mm-map").height(); fb.height(Ba); fb.width(a); g.checkResize()
}; o.openStreetView = function (a) {
	a = typeof a.point === "string" ? a.point : ta; $("#InfoWindowPrimary").text(""); ga(); var b = document.createElement("div"); b.innerHTML = '<h1>StreetView</h1><div name="pano" id="pano" style="width: 400px; height: 300px"><div id="pano_Loading">Loading...</div></div>'; $("#InfoWindowPrimary").text("StreetView"); g.openInfoWindowHtml(a, b); x.style.visibility =
"hidden"; setTimeout(function () { Jc() }, 300)
}; o.searchHere = function () { var a = g.fromContainerPixelToLatLng(tb); x.style.visibility = "hidden"; if (a != null) { address = a; Na.getLocations(a, Ic) } }; o.Initialise = function (a) { Na.setBaseCountryCode("UK"); Na.setViewport(new GLatLngBounds(new GLatLng(hb, ib), new GLatLng(gb, jb))); o.setMapSize(o.MapSizeSmall); o.setContainingElement(a); oc(); jc(); o.ResizeMap() }; o.printMap = function () { window.print() }; return o
} ();

