
var aggregateRequest=null;function refreshCachesFull(e)
{refreshCaches_inner("full");}
function refreshCachesSimple(e)
{refreshCaches_inner("mini");}
function refreshCaches_inner(mapType)
{if(aggregateRequest!=null)
{try
{window.clearTimeout(aggregateRequest);aggregateRequest=null;}
catch(e)
{aggregateRequest=null;}}
try
{aggregateRequest=window.setTimeout("_refreshCaches('"+mapType+"')",refreshRate);}
catch(e)
{}}
function _refreshCaches(mapType)
{beginWaitCursor();aggregateRequest=null;mapstraction.removeAllMarkers();var strQuery="&minlat="+mapstraction.getBounds().sw.lat+"&minlon="+mapstraction.getBounds().sw.lon+"&maxlat="+mapstraction.getBounds().ne.lat+"&maxlon="+mapstraction.getBounds().ne.lon;ajax_serverRequest("/query/caches/?mapType="+mapType+strQuery,handler_refreshCaches);}
function getXMLValue(parentElement,tagName)
{if((parentElement.getElementsByTagName(tagName))[0].firstChild!=null)
{return(parentElement.getElementsByTagName(tagName))[0].firstChild.data;}
return"";}
function handler_refreshCaches(responseText,responseXML)
{try
{var mapType=getXMLValue(responseXML.documentElement,"mapType");var allWaypoints=responseXML.documentElement.getElementsByTagName("waypoint");for(i=0;i<allWaypoints.length;i++)
{if(mapType=="full")
{fullWaypoint(allWaypoints[i]);}
else
{simpleWaypoint(allWaypoints[i]);}}}
catch(e)
{}
endWaitCursor();}
function fullWaypoint(waypoint)
{var baseURL=$("#baseURL").val();var bubbleTemplate=$("#bubbleTemplate").html();var wpID=getXMLValue(waypoint,"id");var wpIcon=getXMLValue(waypoint,"icon");var strBubble=bubbleTemplate;strBubble=strBubble.replace("##ICON##",wpIcon);strBubble=strBubble.replace("##URL##",getXMLValue(waypoint,"url"));strBubble=strBubble.replace("##LABL##",getXMLValue(waypoint,"label"));strBubble=strBubble.replace("##SIZE##",getXMLValue(waypoint,"size"));strBubble=strBubble.replace("##DIFF##",getXMLValue(waypoint,"difficulty"));strBubble=strBubble.replace("##TERR##",getXMLValue(waypoint,"terrain"));strBubble=strBubble.replace("##OWNR##",getXMLValue(waypoint,"owner"));strBubble=strBubble.replace("##DESC##",getXMLValue(waypoint,"description"));strBubble=strBubble.replace("##LAT##",parseInt(getXMLValue(waypoint,"lat")));strBubble=strBubble.replace("##LON##",parseInt(getXMLValue(waypoint,"lon")));mapstraction.addMarkerWithData(new Marker(new LatLonPoint(parseFloat(getXMLValue(waypoint,"lat")),parseFloat(getXMLValue(waypoint,"lon")))),{infoBubble:strBubble,label:wpID,iconShadow:baseURL+'/images/cache/map/blank.png',iconShadowSize:[0,0],icon:baseURL+'/images/cache/map/full/'+wpIcon,iconSize:[16,16],draggable:false,hover:false});}
function simpleWaypoint(waypoint)
{var baseURL=$("#baseURL").val();mapstraction.addMarkerWithData(new Marker(new LatLonPoint(parseFloat(getXMLValue(waypoint,"lat")),parseFloat(getXMLValue(waypoint,"lon")))),{label:getXMLValue(waypoint,"id"),iconShadow:baseURL+'/images/cache/map/blank.png',iconShadowSize:[0,0],icon:baseURL+'/images/cache/map/mini/'+getXMLValue(waypoint,"icon"),iconSize:[7,7],draggable:false,hover:false});}
function beginWaitCursor()
{var baseURL=$("#baseURL").val();$.blockUI({message:$('#waitMessage'),css:{border:'none',padding:'15px',backgroundColor:'#000','-webkit-border-radius':'10px','-moz-border-radius':'10px',opacity:.5,color:'#fff'}});}
function endWaitCursor()
{$.unblockUI();}
