(function(){
    
    return;
    
    var showFiltersThrottle;
    var changeLinksIn = function(filters,show)
    {
        if (filters)
        {
            var changeTo = '$1map=' + (show ? '1' : '0');
            var filterlinks = filters.getElementsByTagName('a');
            for(var i=0; i < filterlinks.length; i++)
            {
                var url = filterlinks[i].getAttribute('href');
                if (url && url.replace)
                {
                    url = url.replace(/([?&])map=[01]/,changeTo);
                    filterlinks[i].setAttribute('href',url);
                }
            }
        }
    }

    showGoogleMap = function(link,show)
    {
        if (!showFiltersThrottle)
        {
            var map = $('google-map');
            if (!map) return true;
            if (!show)
            {
                Effect.SlideUp(map,{duration:0.4});
                Effect.BlindUp(link,{duration:0.3});
                Effect.BlindDown($(link).next(),{duration:0.4});
            }
            else
            {
                Effect.SlideDown(map,{duration:0.4});
                Effect.BlindUp(link,{duration:0.4});
                Effect.BlindDown($(link).previous(),{duration:0.3});
            }

            changeLinksIn($('filters'),show);
            changeLinksIn($('results-heading'),show);

            setTimeout(function(){showFiltersThrottle=false},405);
        }
        return false;
    }
    showFilters = function(link)
    {
        if (!showFiltersThrottle)
        {
            link.className='active';

            var otherlink = $(link).next();
            if (otherlink) otherlink.className='';

            var filters = $('filters');
            filters.relativize();
            Effect.BlindDown(filters,{duration:0.2});

            var sortbar = $('sortbar');
            sortbar.hide();
            showFiltersThrottle=true;
            setTimeout(function(){showFiltersThrottle=false},210);
        }
        return false;
    }
    showSortbar = function(link)
    {
        if (!showFiltersThrottle)
        {
            link.className='active';

            var filters = $('filters');
            filters.absolutize();
            Effect.BlindUp(filters,{duration:0.2});

            var otherlink = $(link).previous();
            if (otherlink) otherlink.className='';

            var sortbar = $('sortbar');
            Effect.Appear(sortbar,{duration:0.2});
            showFiltersThrottle=true;
            setTimeout(function(){showFiltersThrottle=false},210);
        }
        return false
    }
})();

function init_search_results_map(map_lat, map_lon, map_zoom, markers, baseurl)
{
	var google_map_static = $('google-map-static');
	if (window.GMap2 && window.GBrowserIsCompatible && GBrowserIsCompatible())
	{
	    setTimeout(function() /* without this GMap breaks layout!? */
	    {
	        try
	        {
				var map_container = $("google-map");
	            window.onunload = GUnload;
	            var map = new GMap2(map_container);
	            map.enableContinuousZoom();
	            map.setCenter(new GLatLng(map_lat, map_lon), map_zoom);
	            map.addControl(new GSmallMapControl());
	            map.addControl(new GScaleControl());
	            map.addControl(new GHierarchicalMapTypeControl());

	            var SearchIcon = new GIcon();
	            SearchIcon.image = "/include/images/map/marker.png";
	            SearchIcon.shadow = "/include/images/map/marker_shadow.png";
	            SearchIcon.transparent = "/include/images/map/marker_transparent.png";
	            SearchIcon.iconSize = new GSize(25, 25);
	            SearchIcon.shadowSize = new GSize(42, 25);
	            SearchIcon.iconAnchor = new GPoint(0, 23);
	            SearchIcon.infoWindowAnchor = new GPoint(5, 1);

	            var moveend = GEvent.bind(map,"moveend",map,function(){
	                GEvent.removeListener(moveend);
	                var search_near_centre = $('search_near_centre');

	                search_near_centre.hide();
	                search_near_centre.innerHTML = 'Search again near current centre of the map';

	                var showing_only_xxx_results = search_near_centre.previous();
	                if (showing_only_xxx_results)
	                    Effect.Fade(showing_only_xxx_results,{duration:0.2, afterFinish:function(){
	                        Effect.Appear(search_near_centre,{duration:0.2});
	                    }});
	                else
	                    Effect.Appear(search_near_centre,{duration:0.2});

	                search_near_centre.onclick = function()
	                {
	                    var mapcenter = map.getCenter();
	                    baseurl = baseurl.replace(/([&?])radius=[^&#]*&?/,'$1').replace(/([&?])(postcode|landmark)=[^&#]*&?/,'$1').replace(/([&?])long_lat=[^&#]*&?/,'$1');
	                    window.location = baseurl.replace(/&?(#.*|$)/, '&long_lat=' + mapcenter.lng() + ',' + mapcenter.lat() + '$1');
	                    return false;
	                }
	            });

				var infoWindow = new function()
				{
					var self = this;
					var element = $(document.createElement('div'));
					element.className = 'map-info-window';
					element.style.position = 'absolute';
					element.style.zIndex = '100';
					element.style.bottom = '50%';
					element.style.left = '50%';
					element.hide();

//					map_container.parentNode.insertBefore(element,map_container.nextSibling);
					map.getPane(G_MAP_FLOAT_PANE).appendChild(element);

					var hideTimer;
					var showTimer;

					this.hide = function()
					{
						if (showTimer)
						{
							clearTimeout(showTimer); showTimer = null;
							Effect.Fade(element,{duration:0.2});
						}
						else
						{
							if (hideTimer) clearTimeout(hideTimer);
							hideTimer = setTimeout(function()
							{
								hideTimer = null;
								Effect.Fade(element,{duration:0.2});//.hide();
							},500);
						}
					}

					var lastPoint;

					this.show = function(point, markerinfo)
					{
						lastPoint = point;

						if (hideTimer) {clearTimeout(hideTimer); hideTimer = null; element.hide()}
						if (showTimer) clearTimeout(showTimer);

						showTimer = setTimeout(function(){
							Effect.Appear(element,{duration:0.1});
//							element.show();
							showTimer = null;
						},250);

//						element.hide();
						while(element.firstChild) element.removeChild(element.firstChild);
						var a = document.createElement('a');
						a.setAttribute('href',markerinfo[4]);
						a.appendChild(document.createTextNode(markerinfo[3]));
						element.appendChild(a);
						if (markerinfo[5]) element.appendChild(document.createTextNode(markerinfo[5]));

						var img = document.createElement('img');
						img.setAttribute('src','/include/images/map/marker_corner.png');
						img.setAttribute('alt','');
						element.appendChild(img);

				        var offset=map.getCurrentMapType().getProjection().fromLatLngToPixel(point,map.getZoom());
						var zeropoint= map.getCurrentMapType().getProjection().fromLatLngToPixel(map.fromDivPixelToLatLng(new GPoint(0,0),true),map.getZoom());

				        var pos = new GControlPosition(G_ANCHOR_TOP_LEFT, offset);

						element.style.bottom = element.parentNode.offsetHeight - (offset.y - zeropoint.y) + 4 + 'px';
						element.style.left = offset.x - zeropoint.x + 6 + 'px';
					}

					element.onmouseover = function()
					{
						if (showTimer) return;
						if (hideTimer) clearTimeout(hideTimer); hideTimer = null;
					}

					element.onmouseout = function()
					{
						if (hideTimer) return;
						if (showTimer) clearTimeout(showTimer); showTimer = null;
						self.hide();
					}

					element.onclick = function()
					{
						if (showTimer) clearTimeout(showTimer); showTimer = null;
						if (hideTimer) clearTimeout(hideTimer); hideTimer = null;
						Effect.Fade(element,{duration:0.2});

						if (lastPoint)
						{
							map.panTo(lastPoint);
		                    if (map.getZoom() < 14) setTimeout(function(){
		                            map.zoomIn();
		                            map.panTo(lastPoint);
		                    },150);
						}
					}
				}

	            var newMarker = function(point,markerinfo)
	            {
					var obj = markerinfo[2] && $(markerinfo[2]);
					if (obj)
					{
						obj.onmouseover = function()
						{
							infoWindow.show(point,markerinfo);
						}
					}

					var marker = new GMarker(point, {icon:SearchIcon});
					var type_specific_image = "/include/images/map/marker.png";

					GEvent.bind(marker,"dblclick", null, function() {
						location = markerinfo[4];
					});

	                GEvent.bind(marker,"click", null, function() {
						infoWindow.show(point,markerinfo);
	                    map.panTo(point);
	                    if (map.getZoom() < 14) setTimeout(function(){
	                            map.zoomIn();
	                            map.panTo(point);
	                    },150);
	                });
	                GEvent.bind(marker,"mouseover", null, function() {
						marker.setImage("/include/images/map/marker_inert.png");
	    				infoWindow.show(point,markerinfo);
	            	});
	                GEvent.bind(marker,"mouseout", null, function() {
						marker.setImage(type_specific_image);
						infoWindow.hide();
	                });
	                map.addOverlay(marker);


					if (markerinfo[2])
					{
						switch(markerinfo[2].charAt(0))
						{
							case 'r': type_specific_image = "/include/images/map/marker_r.png"; break;
							case 'f': case 'd': type_specific_image = "/include/images/map/marker_f.png"; break;
							case 'v': case 'g': case 'e': type_specific_image = "/include/images/map/marker_v.png"; break;
						}
						marker.setImage(type_specific_image);
					}
	            }

	            for(m=0; m < markers.length; m++)
	            {
	                newMarker(new GLatLng(markers[m][1],markers[m][0]), markers[m]);
	            }
	        }
	        catch(e) {if (google_map_static && google_map_static.style) google_map_static.style.display='';} /* oops */
	    },100);
	}
	else if (google_map_static && google_map_static.style) google_map_static.style.display='';
}

