
var adsEnabled=true;var points=new Array();var map;var clearAllMarkers=false;var resizeHeightOffset=0;var resize=false;var displayMarkers=false;var displayMap=false;var iconApprox;var iconGood;var iconApproxHighlight;var iconGoodHighlight;var initAttemps=0;var _ef=function(){};var gMap_Js;var forceDetailsLookup=true;var lastSearch="";var pointRequestCounter=0;var useTrace=false;var tooltip;function trace(msg)
{if(useTrace)
{if(typeof(jsTrace)!='undefined')
{jsTrace.send(msg);}}}
function track(url)
{if(useUrchin)
{urchinTracker(url);}}
function getPointRequestCount()
{return pointRequestCounter;}
function handleKDInSearch()
{var btn=document.getElementById('btnSearch');fnTrapKD(btn,window.event);}
function fnTrapKD(btn,event)
{if(btn==null)
{return;}
trace(btn.value);if(document.all)
{if(event.keyCode==13)
{event.returnValue=false;event.cancelBubble=true;event.cancel=true;trace('In fnTrapKD');btn.click();}}
else if(document.getElementById)
{if(event.which==13)
{event.returnValue=false;event.cancelBubble=true;trace('In fnTrapKD');btn.click();btn.focus();}}
else if(document.layers)
{if(event.which==13)
{event.returnValue=false;event.cancelBubble=true;trace('In fnTrapKD');btn.focus();btn.click();}}}
function cancelKD(event)
{if(document.all)
{event.returnValue=false;event.cancelBubble=true;event.cancel=true;}
else if(document.getElementById)
{event.returnValue=false;event.cancelBubble=true;}
else if(document.layers)
{event.returnValue=false;event.cancelBubble=true;}}
function callMapResize()
{if(typeof(gMap_Js.onResize)!='undefined')
{gMap_Js.onResize();}
else
{gMap_Js.checkResize();}}
function resizeMap()
{resizeMapInternal(false,0,0,0);}
function resizeMapInitial()
{var mapCentreX=document.getElementById("mapCentreX");var mapCentreY=document.getElementById("mapCentreY");var mapZoom=document.getElementById("mapZoom");var zoom=parseInt(mapZoom.value);resizeMapInternal(true,mapCentreX.value,mapCentreY.value,zoom);}
function resizeMapInternal(setPosition,x,y,zoom)
{if(resize)
{map=gMap_Js;if(map)
{var body=document.getElementById("body");var main_top=document.getElementById("main_top");var main_bottom=document.getElementById("main_bottom");var gmap_container_div=document.getElementById("map");if(body==null)
{body=eval("document.all.body");main_top=document.all.main_top;main_bottom=document.all.main_bottom;gmap_container_div=document.all.map;}
var h=body.clientHeight;if(h<(600+72))
{h=600+72;}
h=h-resizeHeightOffset;if(main_top)
{h=h-main_top.scrollHeight;}
if(main_bottom)
{h=h-main_bottom.scrollHeight;}
callMapResize();gmap_container_div.style.height=h+'px';callMapResize();if(setPosition)
{gMap_Js.setCenter(new GLatLng(y,x),zoom,G_NORMAL_MAP);}
trace('resizeMap');onMoveEnd();}}}
function addLoadEvent(func)
{var oldonload=window.onload;if(typeof window.onload!='function')
{window.onload=func;}
else
{window.onload=function()
{func();oldonload();}}}
function AddOnload(myfunc)
{if(window.addEventListener)
{window.addEventListener('load',myfunc,false);}
else if(window.attachEvent)
{window.attachEvent('onload',myfunc);}}
window.onresize=function()
{resizeMap();};function pageLoadMain(_resize,_markers,focusControlName,_map)
{focusControl(focusControlName);resize=_resize;displayMarkers=_markers;displayMap=_map;if(displayMarkers)
{displayMap=true;}
initialise();}
function focusControl(focusControlName)
{if(focusControlName)
{var focusControl=document.getElementById(focusControlName);if(focusControl)
{focusControl.focus();}}}
function createMap()
{if(GBrowserIsCompatible())
{gMap_Js=new GMap2(document.getElementById("map"));gMap_Js.id='gMap';var mapCentreX=document.getElementById("mapCentreX");var mapCentreY=document.getElementById("mapCentreY");var mapZoom=document.getElementById("mapZoom");var zoom=parseInt(mapZoom.value);gMap_Js.setCenter(new GLatLng(mapCentreY.value,mapCentreX.value),zoom,G_NORMAL_MAP);GEvent.addListener(gMap_Js,'infowindowopen',ResizeInfoWindow);new GKeyboardHandler(gMap_Js);GEvent.addDomListener(document.getElementById("map"),"DOMMouseScroll",wheelZoom);GEvent.addDomListener(document.getElementById("map"),"mousewheel",wheelZoom);gMap_Js.addControl(new GLargeMapControl());gMap_Js.addControl(new GMapTypeControl());tooltip=document.createElement("div");gMap_Js.getPane(G_MAP_FLOAT_PANE).appendChild(tooltip);tooltip.style.visibility="hidden";}}
function initialise()
{if(typeof GMap!="function")
{if(initAttemps>10)
{alert("It is taking a long to load the map. If the problem continues then let us know.");}else
{setTimeout("initialise()",1000);}
initAttemps++;return;}
createMap();map=gMap_Js;if(displayMarkers)
{iconApprox=new GIcon();iconApprox.shadow="images/shadow.png";iconApprox.image="images/marker2.png";iconApprox.iconSize=new GSize(20,34);iconApprox.shadowSize=new GSize(37,34);iconApprox.iconAnchor=new GPoint(9,34);iconApprox.infoWindowAnchor=new GPoint(9,2);iconApprox.infoShadowAnchor=new GPoint(18,25);iconGood=new GIcon();iconGood.shadow="images/shadow.png";iconGood.image="images/marker.png";iconGood.iconSize=new GSize(20,34);iconGood.shadowSize=new GSize(37,34);iconGood.iconAnchor=new GPoint(9,34);iconGood.infoWindowAnchor=new GPoint(9,2);iconGood.infoShadowAnchor=new GPoint(18,25);iconApproxHighlight=new GIcon();iconApproxHighlight.shadow="images/shadow.png";iconApproxHighlight.image="images/marker2-highlight.png";iconApproxHighlight.iconSize=new GSize(20,34);iconApproxHighlight.shadowSize=new GSize(37,34);iconApproxHighlight.iconAnchor=new GPoint(9,34);iconApproxHighlight.infoWindowAnchor=new GPoint(9,2);iconApproxHighlight.infoShadowAnchor=new GPoint(18,25);iconGoodHighlight=new GIcon();iconGoodHighlight.shadow="images/shadow.png";iconGoodHighlight.image="images/marker-highlight.png";iconGoodHighlight.iconSize=new GSize(20,34);iconGoodHighlight.shadowSize=new GSize(37,34);iconGoodHighlight.iconAnchor=new GPoint(9,34);iconGoodHighlight.infoWindowAnchor=new GPoint(9,2);iconGoodHighlight.infoShadowAnchor=new GPoint(18,25);if(resize)
{setTimeout("resizeMapInitial()",100);}
else
{setTimeout("loadMarkers()",100);}
GEvent.addListener(map,"moveend",onMoveEnd);}}
function onMoveEnd()
{trace("onMoveEnd - update map");updateMap();}
function updateMap()
{var mapCentreX=document.getElementById("mapCentreX");var mapCentreY=document.getElementById("mapCentreY");var mapZoom=document.getElementById("mapZoom");if(mapCentreX)
{var centrePoint=map.getCenter();var xDelta=Math.abs(centrePoint.lng()-mapCentreX.value);var yDelta=Math.abs(centrePoint.lat()-mapCentreY.value);var bounds=map.getBounds();var span=bounds.toSpan();xDelta=xDelta/span.lng();yDelta=yDelta/span.lat();if(xDelta<0.05&&yDelta<0.05&&mapZoom.value==map.getZoom()&&!forceDetailsLookup)
{trace("updateMap - map not moved much - bailing out");return;}
mapCentreX.value=centrePoint.lng();mapCentreY.value=centrePoint.lat();mapZoom.value=map.getZoom();forceDetailsLookup=false;}
if(displayMarkers)
{if(clearAllMarkers)
{trace("updateMap - reloading markers");reloadMarkers();}
else
{trace("updateMap - loading new markers");removeOutOfBoundsMarkers();loadMarkers();}
if(adsEnabled)
{var adIDElt=document.getElementById("adID");if(mapCentreX==null)
{salsamap.AdsService.GetAdIDGlobalAndIncrement(adIDElt.value,OnGetAdIDComplete,OnGetAdIDTimeout);}
else
{salsamap.AdsService.GetAdIDFromLocationAndIncrement(mapCentreX.value,mapCentreY.value,adIDElt.value,OnGetAdIDComplete,OnGetAdIDTimeout);}}}}
function OnGetAdIDComplete(adID)
{if(adID==""||adID=="0")
{return;}
if(!adsEnabled)
{return;}
var adIDElt=document.getElementById("adID");if(adIDElt.value==adID)
{return;}
var adLink=document.getElementById("adLink");adLink.innerHTML='<img src="adImage.ashx?id='+adID+'" />';adLink.href='adClick.ashx?id='+adID;var adHereElt=document.getElementById("adHere");if(adID=="00000000-0000-0000-0000-000000000000")
{adHereElt.style.visibility="hidden";}
else
{adHereElt.style.visibility="visible";}
adIDElt.value=adID;}
function OnGetAdIDTimeout()
{}
function reloadMarkers()
{clearMarkers();loadMarkers();}
function clearMarkers()
{if(map!=null)
{map.clearOverlays();points=new Array();}}
function removeOutOfBoundsMarkers()
{var bounds=map.getBounds();var minPoint=bounds.getSouthWest();var maxPoint=bounds.getNorthEast();var newPoints=new Array()
var newPointIndex=0;for(var i=0;i<points.length;i++)
{var x=points[i]["x"];var y=points[i]["y"];if(x<minPoint.lng()||y<minPoint.lat()||x>maxPoint.lng()||y>maxPoint.lat())
{var marker=points[i]["marker"];GEvent.clearListeners(marker,"click");map.removeOverlay(marker);}
else
{newPoints[newPointIndex]=points[i];newPointIndex++;}}
points=newPoints;}
function showTooltip(marker,text)
{var html='<div class="tooltip-light">'+text+'</div>';tooltip.innerHTML=html;var point=map.getCurrentMapType().getProjection().fromLatLngToPixel(map.fromDivPixelToLatLng(new GPoint(0,0),true),map.getZoom());var offset=map.getCurrentMapType().getProjection().fromLatLngToPixel(marker.getPoint(),map.getZoom());var anchor=marker.getIcon().iconAnchor;var width=marker.getIcon().iconSize.width;var height=tooltip.clientHeight;var pos=new GControlPosition(G_ANCHOR_TOP_LEFT,new GSize(offset.x-point.x-anchor.x+width,offset.y-point.y-anchor.y-height));pos.apply(tooltip);tooltip.style.visibility="visible";}
function hideTooltip()
{tooltip.style.visibility="hidden";}
function ResizeInfoWindow()
{return;var infoWindow=gMap_Js.getInfoWindow();var containers=infoWindow.getContentContainers();var gmap_container_div=document.getElementById("map");var mapHeight=gmap_container_div.clientHeight;var fudgeAmount=150;trace("mapHeight:"+mapHeight+", fudgeAmount:"+fudgeAmount);var container;var height;var i=0;while(i<containers.length)
{container=containers[i];height=container.clientHeight;trace("containerHeight:"+height);if(height>mapHeight-fudgeAmount)
{container.style.height=(mapHeight-fudgeAmount)+"px";container.style.overflow="auto";}
i++;}
var items=document.getElementsByName("info");var item;i=0;while(i<items.length)
{item=items[i];height=item.clientHeight;trace("itemHeight:"+height);if(height>mapHeight-fudgeAmount)
{item.style.height=(mapHeight-fudgeAmount)+"px";item.style.overflow="auto";}
i++;}}
function ResizeInfoWindowElement(element)
{var gmap_container_div=document.getElementById("map");var mapHeight=gmap_container_div.clientHeight;var fudgeAmount=250;var height;height=element.clientHeight;if(height==0)
{height=element.parentElement.clientHeight;}
if(height>mapHeight-fudgeAmount)
{element.style.height=(mapHeight-fudgeAmount)+"px";element.style.overflow="auto";}}
function markerZindexApprox(marker,b)
{return 0;}
function markerZindexConfirmed(marker,b)
{return 1;}
function markerZIndex(marker,b)
{trace("markerZIndex - returning "+marker.smZIndex);return marker.smZIndex;}
function createMarker(x,y,html,name,approx)
{var icon;var iconHighlight;var zIndexFunction;var zIndex;if(approx==1)
{icon=iconApprox;iconHighlight=iconApproxHighlight;zIndex=0;zIndexFunction=markerZIndex;}
else
{icon=iconGood;iconHighlight=iconGoodHighlight;zIndex=1;zIndexFunction=markerZIndex;}
var position=new GLatLng(y,x);var marker;var marker=new GMarker(position,{icon:icon,zIndexProcess:zIndexFunction});marker.smZIndex=zIndex;marker.smZIndexOriginal=zIndex;marker.smIcon=icon;marker.smIconHighlight=iconHighlight;GEvent.addListener(marker,"click",function()
{var infoElt=document.createElement('div');infoElt.innerHTML=html;marker.openInfoWindow(infoElt);ResizeInfoWindowElement(infoElt);});GEvent.addListener(marker,"mouseover",function()
{trace("marker mouseover ("+name+")");showTooltip(marker,name);marker.setImage(marker.smIconHighlight.image);});GEvent.addListener(marker,"mouseout",function()
{trace("marker mouseout ("+name+")");hideTooltip();marker.setImage(marker.smIcon.image);});return marker;}
function createMarkerTabbed(x,y,tabs,tooltipText,approx)
{var icon;if(approx==1)
{icon=iconApprox}
else
{icon=iconGood;}
var position=new GLatLng(y,x);var zIndexFunction;if(approx)
{zIndexFunction=markerZindexApprox;}
else
{zIndexFunction=markerZindexConfirmed;}
var marker=new GMarker(position,{icon:icon,zIndexProcess:zIndexFunction});GEvent.addListener(marker,"click",function()
{var tabs2=new Array();var infoElts=new Array();var i=0;while(i<tabs.length)
{var infoElt=document.createElement('div');infoElt.innerHTML=tabs[i][1];tabs2[i]=new GInfoWindowTab(tabs[i][0],infoElt);infoElts[i]=infoElt;i++;}
marker.openInfoWindowTabs(tabs2);i=0;while(i<infoElts.length)
{ResizeInfoWindowElement(infoElts[i]);i++;}});GEvent.addListener(marker,"mouseover",function()
{showTooltip(marker,tooltipText);});GEvent.addListener(marker,"mouseout",function()
{hideTooltip();});return marker;}
function getQueryString_levels()
{var levels=0;var checkBox=document.getElementById("chkBeginners");if(checkBox.checked)
{levels|=2;}
checkBox=document.getElementById("chkImprovers");if(checkBox.checked)
{levels|=4;}
checkBox=document.getElementById("chkIntermediates");if(checkBox.checked)
{levels|=8;}
checkBox=document.getElementById("chkAdvanced");if(checkBox.checked)
{levels|=16;}
if(levels==30)
{levels=31;}
return levels;}
function getQueryString_days()
{var days=0;var checkBox=document.getElementById("chkMonday");if(checkBox.checked)
{days|=1;}
checkBox=document.getElementById("chkTuesday");if(checkBox.checked)
{days|=2;}
checkBox=document.getElementById("chkWednesday");if(checkBox.checked)
{days|=4;}
checkBox=document.getElementById("chkThursday");if(checkBox.checked)
{days|=8;}
checkBox=document.getElementById("chkFriday");if(checkBox.checked)
{days|=16;}
checkBox=document.getElementById("chkSaturday");if(checkBox.checked)
{days|=32;}
checkBox=document.getElementById("chkSunday");if(checkBox.checked)
{days|=64;}
return days;}
function getQueryString_danceStyles()
{var danceStyles=0;var checkBox=document.getElementById("checkSalsa_Generic");if(checkBox.checked)
{danceStyles|=1;}
checkBox=document.getElementById("checkSalsa_Cuban");if(checkBox.checked)
{danceStyles|=2;}
checkBox=document.getElementById("checkSalsa_CrossBodyOn1");if(checkBox.checked)
{danceStyles|=4;}
checkBox=document.getElementById("checkSalsa_CrossBodyOn2");if(checkBox.checked)
{danceStyles|=8;}
checkBox=document.getElementById("checkRueda");if(checkBox.checked)
{danceStyles|=16;}
checkBox=document.getElementById("checkBachata");if(checkBox.checked)
{danceStyles|=64;}
checkBox=document.getElementById("checkChaCha");if(checkBox.checked)
{danceStyles|=32;}
checkBox=document.getElementById("checkMerengue");if(checkBox.checked)
{danceStyles|=128;}
return danceStyles;}
function getQueryString_SearchMap()
{var bounds=map.getBounds();var minPoint=bounds.getSouthWest();var maxPoint=bounds.getNorthEast();var queryString="type=normal&minX="+minPoint.lng()+"&minY="+minPoint.lat()+"&maxX="+maxPoint.lng()+"&maxY="+maxPoint.lat()
var levels=getQueryString_levels();queryString+="&levels="+levels;var clubDancing=0;var checkBox=document.getElementById("chkClubDancing");if(checkBox.checked)
{clubDancing=1;}
queryString+="&club="+clubDancing;var days=getQueryString_days();queryString+="&days="+days;var danceStyles=getQueryString_danceStyles();queryString+="&dances="+danceStyles;checkBox=document.getElementById("checkLiveMusic");var liveMusic=0
if(checkBox.checked)
{liveMusic=1;}
queryString+="&liveMusic="+liveMusic;return queryString;}
function getQueryString_SearchMapCalendar()
{var bounds=map.getBounds();var minPoint=bounds.getSouthWest();var maxPoint=bounds.getNorthEast();var queryString="type=calendar&minX="+minPoint.lng()+"&minY="+minPoint.lat()+"&maxX="+maxPoint.lng()+"&maxY="+maxPoint.lat()
var levels=getQueryString_levels();queryString+="&levels="+levels;var textbox=document.getElementById(getTextStartDateName());var startDate=parseDate(textbox.value);if(startDate==null)
{var statusLabel=document.getElementById("status");if(statusLabel)
{statusLabel.innerHTML="Please specify a valid start date (e.g. 15/02/2007)";}
return null;}
queryString+="&startDate="+DateToString(startDate);textbox=document.getElementById(getTextEndDateName());var endDate=parseDate(textbox.value);if(endDate==null)
{var statusLabel=document.getElementById("status");if(statusLabel)
{statusLabel.innerHTML="Please specify a valid end date (e.g. 15/02/2007)";}
return null;}
queryString+="&endDate="+DateToString(endDate);var clubDancing=0;var checkBox=document.getElementById("chkClubDancing");if(checkBox.checked)
{clubDancing=1;}
queryString+="&club="+clubDancing;var danceStyles=getQueryString_danceStyles();queryString+="&dances="+danceStyles;checkBox=document.getElementById("checkLiveMusic");var liveMusic=0
if(checkBox.checked)
{liveMusic=1;}
queryString+="&liveMusic="+liveMusic;return queryString;}
function parseDate(dateString)
{return Date.parseLocale(dateString,"dd/MM/yyyy")}
function DateToString(date)
{return date.format("dd/MM/yyyy");}
function loadMarkers()
{if(map==null)
{return;}
if(displayMarkers)
{clearAllMarkers=false;var statusLabel=document.getElementById("status");if(statusLabel)
{statusLabel.innerHTML="Loading salsa events...";}
var request=false;if(window.XMLHttpRequest)
{request=new XMLHttpRequest();if(request.overrideMimeType)
{request.overrideMimeType('text/xml');}}
else if(window.ActiveXObject)
{request=new ActiveXObject("Microsoft.XMLHTTP");}
pointRequestCounter++;var queryStringTemp=getQueryString();if(queryStringTemp==null)
{return;}
var queryString="salsamapdata.ashx?"+queryStringTemp+"&v=5&counter="+pointRequestCounter;trace("loadMarkers - starting request");request.open("GET",queryString,true);request.onreadystatechange=function()
{if(request.readyState==4)
{var statusLabel=document.getElementById("status");if(statusLabel)
{statusLabel.innerHTML="Got events - adding to the map";}
var xmlDoc=request.responseXML;if(xmlDoc.documentElement)
{trace("loadMarkers - got response from server");var totalPoints=xmlDoc.documentElement.getAttribute("pointCount");var totalEvents=xmlDoc.documentElement.getAttribute("eventCount");var pointElts=xmlDoc.documentElement.getElementsByTagName("point");var requestCount=xmlDoc.documentElement.getAttribute("counter");if(requestCount!=getPointRequestCount())
{trace("Discarding out-of-date map data response");return;}
if(totalPoints)
{}
else
{statusLabel.innerHTML="An error occurred retrieving salsa data. If the error continues, <a href='About_contact.aspx'>let us know</a>";return;}
if(totalPoints!=0&&pointElts.length==0)
{clearMarkers();points=new Array();if(statusLabel)
{statusLabel.innerHTML=totalPoints+" venues ("+totalEvents+" events). There are too many salsa classes/events. Either narrow your selection criteria or zoom in on a smaller area. (<a href='Help.aspx#TooManyEvents'>?</a>)";}
trace("loadMarkers - Done (too many to display)");}
else
{var venueIdToPopup=-1;var markerToPopup=null;if(showVenuePopup)
{var mapVenueIdElt=document.getElementById("mapVenueId");venueIdToPopup=parseInt(mapVenueIdElt.value);}
var numberAdded=totalPoints-points.length;if(statusLabel)
{statusLabel.innerHTML=totalPoints+" venues ("+totalEvents+" events). <span class='link-viewaslist'>(<a href='ShowEvents.aspx?"+getQueryString()+"'>view as a list</a>, or <a onclick='gotoEmailSubscribe();return false;' href='javascript:void(0);'>get emails</a> with events in this area)</span>";}
var oldPointCount=points.length;var gotPoint;for(var i=0;i<pointElts.length;i++)
{var x=pointElts[i].getAttribute("x");var y=pointElts[i].getAttribute("y");gotPoint=false;for(var j=0;j<oldPointCount;j++)
{if(points[j]["x"]==x&&points[j]["y"]==y)
{gotPoint=true;break;}}
if(!gotPoint)
{var currentIndex=points.length;points[currentIndex]=new Array();venueId=pointElts[i].getAttribute("id");points[currentIndex]["x"]=pointElts[i].getAttribute("x");points[currentIndex]["y"]=pointElts[i].getAttribute("y");var approx=pointElts[i].getAttribute("approx");var venueElts=pointElts[i].getElementsByTagName("venue");var venueName;var pointHtml="";var venueTab;var tipText="";var venueId;var saveMarker=false;var htmlTemp;for(var venueIndex=0;venueIndex<venueElts.length;venueIndex++)
{venueId=venueElts[venueIndex].getAttribute("id");venueName=venueElts[venueIndex].getAttribute("name");htmlTemp=venueElts[venueIndex].getAttribute("html");pointHtml+="<div class=\"info\" name=\"info\"><b>"+venueName+"</b><br/>"+htmlTemp+"</div>";if(venueIndex>0)
{tipText+=", ";}
venueName=venueName.replace(/ /g,"&nbsp;");tipText+=venueName;if(showVenuePopup&&venueId==venueIdToPopup)
{saveMarker=true;}}
var marker;marker=createMarker(points[currentIndex]["x"],points[currentIndex]["y"],pointHtml,tipText,approx);if(saveMarker)
{markerToPopup=marker;}
points[currentIndex]["marker"]=marker;map.addOverlay(marker);}}
if(showVenuePopup)
{if(markerToPopup!=null)
{GEvent.trigger(markerToPopup,"click");}
showVenuePopup=false;}
trace("loadMarkers - Done");}}
delete request;}}
request.send(null);}}
function goToPostcode()
{trace('goToPostcode');if(displayMap)
{var postcodeErrorLabel=document.getElementById("postCodeErrorSpan");postcodeErrorLabel.innerHTML="";var statusLabel=document.getElementById("status");if(statusLabel)
{statusLabel.innerHTML="Getting location information...";}
var request=false;if(window.XMLHttpRequest)
{request=new XMLHttpRequest();if(request.overrideMimeType)
{request.overrideMimeType('text/xml');}}
else if(window.ActiveXObject)
{request=new ActiveXObject("Microsoft.XMLHTTP");}
var postcodeElt=document.getElementById("txtSearch");lastSearch=postcodeElt.value;var queryString="salsapostcode.ashx?location="+postcodeElt.value;track('/nonpage/place/'+postcodeElt.value);request.open("GET",queryString,true);request.onreadystatechange=function()
{if(request.readyState==4)
{var statusLabel=document.getElementById("status");var xmlDoc=request.responseXML;if(xmlDoc.documentElement)
{var x=xmlDoc.documentElement.getAttribute("x");var y=xmlDoc.documentElement.getAttribute("y");var zoomString=xmlDoc.documentElement.getAttribute("zoom");var zoom=parseInt(zoomString);zoom=17-zoom;if(x)
{if(statusLabel)
{statusLabel.innerHTML="Got location - moving map";}
clearAllMarkers=true;forceDetailsLookup=true;hideTooltip();map.setCenter(new GLatLng(y,x),zoom)}
else
{var error=xmlDoc.documentElement.getAttribute("error");lastSearch="";if(error)
{postcodeErrorLabel.innerHTML=error;if(statusLabel)
{statusLabel.innerHTML="An error occurred looking up the location";}}
else
{postcodeErrorLabel.innerHTML="Location not recognised. Please try another city or postcode.";if(statusLabel)
{statusLabel.innerHTML="Location not recognised";}}}}
else
{lastSearch="";}
var searchBox=document.getElementById('txtSearch');if(searchBox)
{searchBox.focus();}
delete request;}}
request.send(null);}}
function gotoEmailSubscribe()
{top.location.assign("http://www.salsamap.com/EmailEvents.aspx?"+getQueryString());}
function GetWindowWidth()
{var width=0;if(typeof(window.innerWidth)=='number')
{width=window.innerWidth;}
else if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight))
{width=document.documentElement.clientWidth;}
else if(document.body&&(document.body.clientWidth||document.body.clientHeight))
{width=document.body.clientWidth;}
return width;}
function GetWindowHeight()
{var height=0;if(typeof(window.innerHeight)=='number')
{height=window.innerHeight;}
else if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight))
{height=document.documentElement.clientHeight;}
else if(document.body&&(document.body.clientWidth||document.body.clientHeight))
{height=document.body.clientHeight;}
return height;}
function showLayer(id,width,height,contentId,contentHeight)
{var layerElt=document.getElementById(id);var contentElt=document.getElementById(contentId);var left=(GetWindowWidth()-width)/2;var top=(GetWindowHeight()-height)/2;layerElt.style.visibility='visible';layerElt.style.left=left+'px';layerElt.style.top=top+'px';layerElt.style.width=width+'px';layerElt.style.height=height+'px';if(contentElt!=null)
{contentElt.style.height=contentHeight+'px';}}
function hideLayer(id)
{var layerElt=document.getElementById(id);layerElt.style.visibility='hidden';layerElt.style.left='0px';layerElt.style.top='0px';layerElt.style.width='0px';layerElt.style.height='0px';}
function wheelZoom(event)
{if(event.cancelable)
{event.preventDefault();}
(event.detail||-event.wheelDelta)<0?gMap_Js.zoomIn():gMap_Js.zoomOut();return false;}
function hideItemLink(id)
{var elt=document.getElementById(id);var parent=elt.parentNode;parent.removeChild(elt);delete elt;}
function showItemLinkVenue(href,parent,id)
{showItemLink(href,parent,id,'Use this link in email, IM, or on your website to link to this venue:');}
function showItemLinkVenueMap(href,parent,id)
{showItemLink(href,parent,id,'Use this link in email, IM, or on your website to link to this venue on the Map:');}
function showItemLinkOrganiser(href,parent,id)
{showItemLink(href,parent,id,'Use this link in email, IM, or on your website to link to this organiser:');}
function showItemLinkEvent(href,parent,id)
{showItemLink(href,parent,id,'Use this link in email, IM, or on your website to link to this event:');}
function showItemLink(href,parent,id,text)
{var obody=document.body;if(parent==null||parent==undefined)
{parent=obody;}
if(id==null||id==undefined)
{id='SMItemLinkDiv';}
var div=document.createElement("div");div.setAttribute('id',id);var div2=document.createElement("div");div.appendChild(div2);var linkId=id+'_linkbox'
var html='<div class="full-opacity" style="float:right; top: 5px; margin: 0; padding: 0;">'+'<a href="javascript:void(0);" onclick="hideItemLink(\''+id+'\')"><img src="/images/buttonClose.png" /></a> </div>'+'<table><tr><td><div style="text-decoration:none">'+text+'</div></td></tr><tr>'+'<td><input id="'+linkId+'" type="text" value="'+href+'" style="width:280px;" /></td></tr><table><br />'+'<a href="'+href+'" target="newShowLinkWindow'+(Math.floor(Math.random()*10000+1))+'">Test the link</a> (opens in a new window)';div2.setAttribute('class','showLinkContainer');div2.innerHTML=html;var dstyle=div.style
dstyle.position='absolute';dstyle.zIndex=998;dstyle.fontSize='small';dstyle.padding='0px 0px 0px 10px';dstyle.color='black';var d2style=div2.style
d2style.backgroundColor='#FFEEDD';d2style.visibility='visible';d2style.padding='3px 3px 3px 3px';d2style.border='#FF6633 2px solid';d2style.width='300px';parent.insertBefore(div,parent.firstChild);var linkBox=document.getElementById(linkId);linkBox.select();}
