/**
* Copyright (c) 2006 Andriy Bidochko. All Rights Reserved.
* http://www.mapbuilder.biz
*
* This code (including but not limited to the actual source code, documentation and database schemes) 
* is not freeware and is intended for the use of the original license purchaser according to the license agreement.
* The code all or in part may not be sold, redistributed, or included as part of another application.
* 
* THIS SOFTWARE PRODUCT IS PROVIDED "AS IS" AND LICENSOR MAKE NO WARRANTY AS TO ITS USE, PERFORMANCE, 
* OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

var MAPBUILDER=function(){return{util:{},widget:{},event:{},namespace:function(sNameSpace){if(!sNameSpace||!sNameSpace.length){return null;}
var levels=sNameSpace.split(".");var currentNS=MAPBUILDER;for(var i=(levels[0]=="MAPBUILDER")?1:0;i<levels.length;++i){currentNS[levels[i]]=currentNS[levels[i]]||{};currentNS=currentNS[levels[i]];}
return currentNS;}};}();MAPBUILDER.namespace("MAPBUILDER.widget");MAPBUILDER.widget.MapObject=function(container){if(!container)throw "MapObject initialization failed: no container!";this.container=container;this.apis=new Array();this.divs=new Array();this.icons=new Array();this.gicons=new Array();this.yicons=new Array();this.markers=new Array();this.polylines=new Array();this.DS=new Array();this.maps=new Array();this.title='';this.defCenterLon=-90;this.defCenterLat=35;this.defZoom=15;this.autoZoom=false;this.autoZoomLevel=5;this.sideBar=false;this.addrSearch=true;this.addrSearchValue="123 Main Str, Bellwood, PA";this.addrSearchZoom=2;this.statusBar=false;this.PdMarker=true;this.activeMarkerID=0;this.activeMapID=null;MAPBUILDER.widget.MapObject.Ref=this;this.init=function(){if(typeof this.apis["G"]=="object"){this.activeMapID='G';}
else
if(typeof this.apis["Y"]=="object"){this.activeMapID='Y';}
else{this.IssueError("You need to register at least 1 API to initialize your map");throw("You need to register at least 1 API to initialize your map");}}
this.registerAPI=function(api,key){if(api=="G"){this.apis[api]=new MAPBUILDER.widget.GAPI(key);}
else
if(api=="Y"){this.apis[api]=new MAPBUILDER.widget.YAPI(key);}
else
this.IssueError(api+" is not supported.");}
this.bind=function(name,div){if(name=='addrSearch'||name=='sideBar'){this.divs[name]=div;}
else{IssueWarn("Layer '"+name+"' is not supported.");}}
this.render=function(){var mapDiffWidth=0;var mapDiffHeight=0;if(this.addrSearch){if(this.divs['addrSearch']==undefined){this.divs['addrSearch']=document.createElement('div');this.divs['addrSearch'].id='_addrSearchDiv';this.divs['addrSearch'].style.position='relative';this.divs['addrSearch'].style.height='25px';this.divs['addrSearch'].style.margin='5px 0 5px 0';this.container.appendChild(this.divs['addrSearch']);mapDiffHeight=mapDiffHeight+parseFloat(this.divs['addrSearch'].style.height)+10;}
this.divs['addrSearch'].innerHTML='<form name=\'addrSearchForm\' action=\'\' onsubmit="MAPBUILDER.event.addrSearch(document.getElementById(\'addrSearchInput\').value); return false;"><input id="addrSearchInput" class="addrSearchInput" value="'+this.addrSearchValue+'" size="50"></input>&nbsp;<input type=\'submit\' id=\'addrSearchButton\' class="btnOut" onmouseover="MAPBUILDER.util.changeClass(\'addrSearchButton\',\'btnOver\')" onmouseout="MAPBUILDER.util.changeClass(\'addrSearchButton\',\'btnOut\')" value=\'Address Search\' /></form>';}
if(this.statusBar){if(this.divs['statusBar']==undefined){this.divs['statusBar']=document.createElement('div');this.divs['statusBar'].id='_statusBarDiv';this.divs['statusBar'].style.position='relative';this.divs['statusBar'].style.backgroundColor='#CCCCCC';this.divs['statusBar'].style.height='20px';this.divs['statusBar'].style.overflow='auto';mapDiffHeight=mapDiffHeight+parseFloat(this.divs['statusBar'].style.height);}
this.AddMsg('Status Bar');}
var _mapsContainer=document.createElement('div');_mapsContainer.id='_mapsContainer';_mapsContainer.style.width=this.container.style.width;_mapsContainer.style.height=(parseFloat(this.container.style.height)-mapDiffHeight)+'px';_mapsContainer.style.position='relative';this.container.appendChild(_mapsContainer);this._mapsContainer=_mapsContainer;if(this.statusBar){this.container.appendChild(this.divs['statusBar']);}
if(typeof this.apis["G"]=="object"){var _gmapobjmap=document.createElement('div');_gmapobjmap.id='_gmapobjmap';_gmapobjmap.style.width=this.container.style.width;_gmapobjmap.style.height=this._mapsContainer.style.height;_gmapobjmap.style.position='relative';_gmapobjmap.innerHTML='<div style="font-size: 350%; font-weight: bold; color: #CCCCCC; text-align: center;">Map Object</div>';this._mapsContainer.appendChild(_gmapobjmap);this._gmapobjmap=_gmapobjmap;}
if(typeof this.apis["Y"]=="object"){var _ymapobjmap=document.createElement('div');_ymapobjmap.id='_ymapobjmap';_ymapobjmap.style.width=this.container.style.width;_ymapobjmap.style.height=this.container.style.height;_ymapobjmap.style.position='relative';_ymapobjmap.innerHTML='<div style="font-size: 350%; font-weight: bold; color: #CCCCCC; text-align: center;">Map Object</div>';this._mapsContainer.appendChild(_ymapobjmap);this._ymapobjmap=_ymapobjmap;}
var info=document.createElement('div');info.id='MapBuilderInfo';info.style.position='absolute';info.style.right='1px';info.style.bottom='25px';info.style.backgroundColor='transparent';info.style.zIndex=25500;info.innerHTML='<a id="CreatedByMapBuilder" href="http://www.mapbuilder.net" width="24" height="24" style="font: 10px verdana; text-decoration: none; padding: 2px; color: #FFFFFF;"><img src="http://mapbuilder.net/img/mo24.gif" alt="Powered By MapBuilder.net" border="0"/></a>';this._mapsContainer.appendChild(info);this.changeMapAPI(this.activeMapID);}
this.renderDataLayers=function(){this.renderIcons();this.renderMapInfo();this.renderMarkers();this.renderPolylines();}
this.renderIcons=function(){this.currMap.renderIcons();}
this.renderMapInfo=function(){document.title=this.title;this.currMap.centerAndZoom(this.defCenterLon,this.defCenterLat,this.defZoom);}
this.renderMarkers=function(){this.currMap.renderMarkers();}
this.renderPolylines=function(){this.currMap.renderPolylines();}
this.IssueError=function(msg){alert(msg);}
this.IssueWarn=function(msg){alert(msg);}
this.AddMsg=function(msg){if(this.divs['statusBar']==undefined)return;this.divs['statusBar'].innerHTML=this.divs['statusBar'].innerHTML+"<br />"+msg;}
this.loadData=function(){if(this.DS instanceof Array){if(this.DS.length==0){this.IssueError("There is no valid datasource.");return;}}
else{this.IssueError("Invalid datasource. It supposed to be an array.	");return;}
for(i=0;i<this.DS.length;i++){this.DS[i].loadData();}}
this.changeMapAPI=function(api){this.AddMsg("Setting active map api to '"+api+"'");if(api=="G"){if(typeof this.apis["Y"]=="object"){this._ymapobjmap.style.display="none";}
this._gmapobjmap.style.display="block";if(!GBrowserIsCompatible()){this._gmapobjmap.innerHTML='Your browser is not compatible with Google Maps';return;}
this.activeMapID="G";if(this.maps['G']==undefined){this.maps['G']=new MAPBUILDER.widget._GMap(this._gmapobjmap);}
this.currMap=this.maps[this.activeMapID];}
else
if(api=="Y"){if(typeof this.apis["G"]=="object"){this._gmapobjmap.style.display="none";}
this._ymapobjmap.style.display="block";this.activeMapID="Y";if(this.maps['Y']==undefined){this.maps['Y']=new MAPBUILDER.widget._YMap(this._ymapobjmap);}
this.currMap=this.maps[this.activeMapID];}
else
this.IssueError(api+" is not supported.");this.renderDataLayers();}
this.reset=function(){this.clearOverlays();this.loadData()}
this.filter=function(param,value){this.clearOverlays();this.loadData(this.dataUrl+"?"+encode(param)+"="+encode(value))}
this.clearOverlays=function(){this.currMap.clearOverlays();}
this.zoomIn=function(){currentZoom=this.currMap.getZoomLevel();if(currentZoom!=0){this.currMap.zoomTo((currentZoom-this.autoZoomLevel)<0?(currentZoom-1):(currentZoom-this.autoZoomLevel));}}
this.centerAndZoomIn=function(lng,lat){var nLng=parseFloat(lng);var nLat=parseFloat(lat);if(isNaN(nLng)||isNaN(nLng)){alert("Invalid arguments passed to _MapObject.centerAndZoomIn method.")
return;}
currentZoom=this.currMap.getZoomLevel();if(currentZoom!=0){this.currMap.centerAndZoom(nLng,nLat,((currentZoom-this.autoZoomLevel)<0?(currentZoom-1):(currentZoom-this.autoZoomLevel)));}}
this.centerAndZoomTo=function(lng,lat,zm){var nLng=parseFloat(lng);var nLat=parseFloat(lat);if(isNaN(nLng)||isNaN(nLng)){alert("Invalid arguments passed to _MapObject.centerAndZoomIn method.")
return;}
this.currMap.centerAndZoom(nLng,nLat,zm);}
this.locCenterAndZoomIn=function(id){try{this.centerAndZoomIn(this.markers[id].lng,this.markers[id].lat);}
catch(e){}}
this.showActiveMarker=function(id){try{this.currMap.showActiveMarker(id);}
catch(e){}
try{MAPBUILDER.event.onShowActiveMarker(id);}
catch(e){}}
this.onResize=function(){this.currMap.onResize();}}
MAPBUILDER.widget._YMap=function(container){this.map=new YMap(container);this.markers=new Array();this.init=function(){this.map.addZoomShort();}
this.init();this.clearOverlays=function(){this.map.removeMarkersAll();}
this.centerAndZoom=function(lng,lat,zoom){this.map.drawZoomAndCenter(new YGeoPoint(lat,lng),zoom);}
this.addOverlayPolyLine=function(points,color,width,weight){}
this.addOverlay=function(marker){this.map.addOverlay(marker);}
this.getZoomLevel=function(){return this.map.getZoomLevel();}
this.zoomTo=function(zoomLevel){}
this.onResize=function(){}
this.showActiveMarker=function(id){try{this.markers[id].openSmartWindow(MAPBUILDER.widget.MapObject.Ref.markers[id].infowindow.html);}
catch(e){}}
this.createMarker=function(id,point,html,iconname){if(iconname&&MAPBUILDER.widget.MapObject.Ref.yicons[iconname]){var marker=new YMarker(point);}
else{var marker=new YMarker(point);}
YEvent.Capture(marker,EventsList.MouseClick,function(){if(MAPBUILDER.widget.MapObject.Ref.autoZoom){MAPBUILDER.widget.MapObject.Ref.centerAndZoomIn(point.Lon,point.Lat);}
marker.openSmartWindow(html);MAPBUILDER.event.onMarkerClick(id,point,html,iconname);});return marker;}
this.renderMarkers=function(){this.clearOverlays();if(MAPBUILDER.widget.MapObject.Ref.sideBar){MAPBUILDER.widget.MapObject.Ref.divs['sideBar'].innerHTML="";}
for(var i=0;i<MAPBUILDER.widget.MapObject.Ref.markers.length;i++){if(!MAPBUILDER.widget.MapObject.Ref.markers[i].visible)continue;var point=new YGeoPoint(parseFloat(MAPBUILDER.widget.MapObject.Ref.markers[i].lat),parseFloat(MAPBUILDER.widget.MapObject.Ref.markers[i].lng));var iconname="";try{iconname=MAPBUILDER.widget.MapObject.Ref.markers[i].iconname;}
catch(e){}
var html="";try{html=MAPBUILDER.widget.MapObject.Ref.markers[i].infowindow.html;}
catch(e){}
var marker=this.createMarker(i,point,html,iconname);this.markers[i]=marker;this.map.addOverlay(marker);try{html=MAPBUILDER.widget.MapObject.Ref.markers[i].link;if(MAPBUILDER.widget.MapObject.Ref.sideBar){MAPBUILDER.widget.MapObject.Ref.divs['sideBar'].innerHTML+="<a href='javascript:MAPBUILDER.event.infoLink("+i+");'>"+html+"</a><br>";}}
catch(e){}}
MAPBUILDER.event.onRenderMarkers();}
this.renderPolylines=function(){}
this.renderIcons=function(){for(var i=0;i<MAPBUILDER.widget.MapObject.Ref.icons.length;i++){var name=MAPBUILDER.widget.MapObject.Ref.icons[i].name;var x="";var y="";x=MAPBUILDER.widget.MapObject.Ref.icons[i].copy;var yicon=new YImage();yicon.src=MAPBUILDER.widget.MapObject.Ref.icons[i].imagesrc;if(x&&MAPBUILDER.widget.MapObject.Ref.yicons[x]){yicon.size=new YSize(MAPBUILDER.widget.MapObject.Ref.yicons[x].size.width,MAPBUILDER.widget.MapObject.Ref.yicons[x].size.height);yicon.offsetSmartWindow=new YCoordPoint(Math.round(MAPBUILDER.widget.MapObject.Ref.yicons[x].size.width/2),0);}
else{yicon.size=new YSize(MAPBUILDER.widget.MapObject.Ref.icons[i].imagewidth,MAPBUILDER.widget.MapObject.Ref.icons[i].imageheight);yicon.offsetSmartWindow=new YCoordPoint(Math.round(MAPBUILDER.widget.MapObject.Ref.icons[i].imagewidth/2),0);}
MAPBUILDER.widget.MapObject.Ref.yicons[name]=yicon;}}}
MAPBUILDER.widget._GMap=function(container){this.map=new GMap(container);this.markers=new Array();this.init=function(){this.map.addControl(new GLargeMapControl());this.map.addControl(new GMapTypeControl());}
this.init();this.clearOverlays=function(){this.map.clearOverlays();}
this.centerAndZoom=function(lng,lat,zoom){this.map.centerAndZoom(new GPoint(lng,lat),zoom);}
this.addOverlayPolyLine=function(points,color,width,weight){this.map.addOverlay(new GPolyline(points,color,width,weight));}
this.addOverlay=function(marker){this.map.addOverlay(marker);}
this.getZoomLevel=function(){return this.map.getZoomLevel();}
this.zoomTo=function(zoomLevel){this.map.zoomTo(zoomLevel);}
this.onResize=function(){this.map.onResize();}
this.showActiveMarker=function(id){try{GEvent.trigger(this.markers[id],"click");}
catch(e){}}
this.createMarker=function(id,point,html,iconname){if(iconname&&MAPBUILDER.widget.MapObject.Ref.gicons[iconname]){if(MAPBUILDER.widget.MapObject.Ref.PdMarker==true){var marker=new PdMarker(point,MAPBUILDER.widget.MapObject.Ref.gicons[iconname],MAPBUILDER.widget.MapObject.Ref.markers[id].name);}
else{var marker=new GMarker(point,MAPBUILDER.widget.MapObject.Ref.gicons[iconname]);}}
else{if(MAPBUILDER.widget.MapObject.Ref.PdMarker==true){var marker=new PdMarker(point);marker.setTooltip(MAPBUILDER.widget.MapObject.Ref.markers[id].name);}
else{var marker=new GMarker(point);}}
marker=MAPBUILDER.event.onCreateMarker(id,marker);GEvent.addListener(marker,"click",function(){if(MAPBUILDER.widget.MapObject.Ref.autoZoom){MAPBUILDER.widget.MapObject.Ref.centerAndZoomIn(point.x,point.y);}
marker.openInfoWindowHtml(html);MAPBUILDER.event.onMarkerClick(id,point,html,iconname);});return marker;}
this.renderMarkers=function(){this.clearOverlays();if(MAPBUILDER.widget.MapObject.Ref.sideBar){MAPBUILDER.widget.MapObject.Ref.divs['sideBar'].innerHTML="";}
for(var i=0;i<MAPBUILDER.widget.MapObject.Ref.markers.length;i++){if(!MAPBUILDER.widget.MapObject.Ref.markers[i].visible)continue;var point=new GPoint(parseFloat(MAPBUILDER.widget.MapObject.Ref.markers[i].lng),parseFloat(MAPBUILDER.widget.MapObject.Ref.markers[i].lat));var iconname="";try{iconname=MAPBUILDER.widget.MapObject.Ref.markers[i].iconname;}
catch(e){}
var html="";try{html=MAPBUILDER.widget.MapObject.Ref.markers[i].infowindow.html;}
catch(e){}
var marker=this.createMarker(i,point,html,iconname);this.markers[i]=marker;this.map.addOverlay(marker);try{html=MAPBUILDER.widget.MapObject.Ref.markers[i].link;if(MAPBUILDER.widget.MapObject.Ref.sideBar){MAPBUILDER.widget.MapObject.Ref.divs['sideBar'].innerHTML+="<a href='javascript:MAPBUILDER.event.infoLink("+i+");'>"+html+"</a><br>";}}
catch(e){}}
MAPBUILDER.event.onRenderMarkers();}
this.renderPolylines=function(){for(var i=0;i<MAPBUILDER.widget.MapObject.Ref.polylines.length;i++){var points=new Array();for(j=0;j<MAPBUILDER.widget.MapObject.Ref.polylines[i].markers.length;j++){points.push(new GPoint(MAPBUILDER.widget.MapObject.Ref.polylines[i].markers[j].lng,MAPBUILDER.widget.MapObject.Ref.polylines[i].markers[j].lat));}
this.map.addOverlay(new GPolyline(points,MAPBUILDER.widget.MapObject.Ref.polylines[i].color,MAPBUILDER.widget.MapObject.Ref.polylines[i].width,MAPBUILDER.widget.MapObject.Ref.polylines[i].weight));}}
this.renderIcons=function(){for(var i=0;i<MAPBUILDER.widget.MapObject.Ref.icons.length;i++){var name=MAPBUILDER.widget.MapObject.Ref.icons[i].name;var x="";var y="";x=MAPBUILDER.widget.MapObject.Ref.icons[i].copy;if(x&&MAPBUILDER.widget.MapObject.Ref.gicons[x]){var gicon=new GIcon(MAPBUILDER.widget.MapObject.Ref.gicons[x]);}
else{var gicon=new GIcon();}
gicon.image=MAPBUILDER.widget.MapObject.Ref.icons[i].imagesrc;x="";y="";try{x=MAPBUILDER.widget.MapObject.Ref.icons[i].xanchor;y=MAPBUILDER.widget.MapObject.Ref.icons[i].yanchor;}
catch(e){}
if(x!=null&&y!=null&&x&&y){gicon.iconAnchor=new GPoint(parseInt(x),parseInt(y));}
x="";y="";try{x=MAPBUILDER.widget.MapObject.Ref.icons[i].xiwanchor;y=MAPBUILDER.widget.MapObject.Ref.icons[i].yiwanchor;}
catch(e){}
if(x!=null&&y!=null&&x&&y){gicon.infoWindowAnchor=new GPoint(parseInt(x),parseInt(y));}
x="";y="";try{x=MAPBUILDER.widget.MapObject.Ref.icons[i].xisanchor;y=MAPBUILDER.widget.MapObject.Ref.icons[i].yisanchor;}
catch(e){}
if(x!=null&&y!=null&&x&&y){gicon.infoShadowAnchor=new GPoint(parseInt(x),parseInt(y));}
x="";y="";try{x=MAPBUILDER.widget.MapObject.Ref.icons[i].imagewidth;y=MAPBUILDER.widget.MapObject.Ref.icons[i].imageheight;}
catch(e){}
if(x!=null&&y!=null&&x&&y){gicon.iconSize=new GSize(parseInt(x),parseInt(y));}
x="";try{x=MAPBUILDER.widget.MapObject.Ref.icons[i].shadowsrc;}
catch(e){}
if(x!=null&&x){gicon.shadow=x;}
x="";y="";try{x=MAPBUILDER.widget.MapObject.Ref.icons[i].shadowwidth;y=MAPBUILDER.widget.MapObject.Ref.icons[i].shadowheight;}
catch(e){}
if(x!=null&&y!=null&&x&&y){gicon.shadowSize=new GSize(parseInt(x),parseInt(y));}
MAPBUILDER.widget.MapObject.Ref.gicons[name]=gicon;}}}
MAPBUILDER.namespace("MAPBUILDER.util");MAPBUILDER.util.DS_AJAX=function(dataurl){this._dataurl=dataurl;this.GetXMLHttpRequest=function(){var _XMLHttpRequest;if(window.XMLHttpRequest){_XMLHttpRequest=new XMLHttpRequest();}
else if(window.ActiveXObject){try{_XMLHttpRequest=new ActiveXObject("Msxml2.XMLHTTP");}
catch(e){_XMLHttpRequest=new ActiveXObject("Microsoft.XMLHTTP");}}
return _XMLHttpRequest;}
var datasource=this.GetXMLHttpRequest();this.loadData=function(){datasource.onreadystatechange=function(){if(datasource.readyState==4){if(datasource.status==200){MAPBUILDER.event.AJAXCallBack(datasource.responseXML);}}}
var url=this._dataurl;if(url.search(/\?/)==-1)
url=url+"?mohash="+Math.random();else
url=url+"&mohash="+Math.random();datasource.open("GET",url,true);datasource.send(null);}}
MAPBUILDER.util.DS_JSON=function(dataurl){this._dataurl=dataurl;this.callback="MAPBUILDER.event.JSONCallBack";this.fullUrl=dataurl;if(this.fullUrl.search(/\?/)==-1)
this.fullUrl=this.fullUrl+"?callback="+this.callback
else
this.fullUrl=this.fullUrl+"&callback="+this.callback
this.GetJSONRequest=function(){return new JSONscriptRequest(this.fullUrl);}
var datasource=this.GetJSONRequest();this.loadData=function(){datasource.buildScriptTag();datasource.addScriptTag();}}
MAPBUILDER.widget._Marker=function(lng,lat){this.visible=true;this.lng=parseFloat(lng);this.lat=parseFloat(lat);this.iconname="";this.infowindow="";this.name="";this.description="";this.link="";this.sid=null;this.address='';this.city="";this.zip="";this.state="";this.country="";}
MAPBUILDER.widget._Polyline=function(){this.color="#0000ff";this.weight="1.0";this.width="2";this.markers=new Array();}
MAPBUILDER.widget._Icon=function(){this.name=null;this.copy='';this.imagesrc='';this.imagewidth='';this.imageheight='';this.xanchor="";this.yanchor="";this.xiwanchor="";this.yiwanchor="";this.xisanchor="";this.yisanchor="";this.shadowsrc="";this.shadowwidth="";this.shadowheight="";}
MAPBUILDER.widget._InfoWindow=function(html){this.html=html;}
MAPBUILDER.widget.GAPI=function(id){this.id=id;this.v="1";this.load=function(){var oLoader=new MAPBUILDER.util.JSLoader('http://maps.google.com/maps?file=api&v='+this.v+'&key='+this.id);oLoader.buildScriptTag();oLoader.addScriptTag();}}
MAPBUILDER.widget.YAPI=function(appid){this.appid=appid;this.v='2.0';this.load=function(){var oLoader=new MAPBUILDER.util.JSLoader('http://api.maps.yahoo.com/ajaxymap?v='+this.v+'&appid='+this.appid);oLoader.buildScriptTag();oLoader.addScriptTag();}}
MAPBUILDER.util.JSLoader=function(fullUrl){this.fullUrl=fullUrl;if(this.fullUrl.search(/\?/)==-1)
this.noCacheIE='?noCacheIE='+(new Date()).getTime();else
this.noCacheIE='&noCacheIE='+(new Date()).getTime();this.headLoc=document.getElementsByTagName("head").item(0);this.scriptId='JSLoaderId'+MAPBUILDER.util.JSLoader.scriptCounter++;this.buildScriptTag=function(){this.scriptObj=document.createElement("script");this.scriptObj.setAttribute("type","text/javascript");this.scriptObj.setAttribute("src",this.fullUrl+this.noCacheIE);this.scriptObj.setAttribute("id",this.scriptId);}
this.removeScriptTag=function(){this.headLoc.removeChild(this.scriptObj);}
this.addScriptTag=function(){this.headLoc.appendChild(this.scriptObj);}}
MAPBUILDER.util.staticLoadScript=function(url){document.write('<script src="',url,'" type="text/JavaScript"><\/script>');}
MAPBUILDER.util.JSLoader.scriptCounter=1;MAPBUILDER.namespace("MAPBUILDER.event");MAPBUILDER.event.onAJAXCallBack=function(xmlDoc){}
MAPBUILDER.event.AJAXCallBack=function(xmlDoc){try{mapattr=xmlDoc.getElementsByTagName("map")
try{MAPBUILDER.widget.MapObject.Ref.title=mapattr[0].getAttribute("title");}
catch(e){}
try{MAPBUILDER.widget.MapObject.Ref.defCenterLon=parseFloat(mapattr[0].getAttribute("lng"));}
catch(e){}
try{MAPBUILDER.widget.MapObject.Ref.defCenterLat=parseFloat(mapattr[0].getAttribute("lat"));}
catch(e){}
try{MAPBUILDER.widget.MapObject.Ref.defZoom=parseInt(mapattr[0].getAttribute("zoom"));}
catch(e){}
try{var icons=xmlDoc.getElementsByTagName("icon");for(var i=0;i<icons.length;i++){id=i;MAPBUILDER.widget.MapObject.Ref.icons[id]=new MAPBUILDER.widget._Icon();MAPBUILDER.widget.MapObject.Ref.icons[id].name=icons[i].getAttribute("name");try{MAPBUILDER.widget.MapObject.Ref.icons[id].copy=icons[i].getAttribute("copy");}
catch(e){}
MAPBUILDER.widget.MapObject.Ref.icons[id].imagesrc=icons[i].getElementsByTagName("image")[0].getAttribute("src");try{MAPBUILDER.widget.MapObject.Ref.icons[id].xanchor=icons[i].getAttribute("xanchor");MAPBUILDER.widget.MapObject.Ref.icons[id].yanchor=icons[i].getAttribute("yanchor");}
catch(e){}
try{MAPBUILDER.widget.MapObject.Ref.icons[id].xiwanchor=icons[i].getAttribute("xiwanchor");MAPBUILDER.widget.MapObject.Ref.icons[id].yiwanchor=icons[i].getAttribute("yiwanchor");}
catch(e){}
try{MAPBUILDER.widget.MapObject.Ref.icons[id].xisanchor=icons[i].getAttribute("xisanchor");MAPBUILDER.widget.MapObject.Ref.icons[id].yisanchor=icons[i].getAttribute("yisanchor");}
catch(e){}
try{MAPBUILDER.widget.MapObject.Ref.icons[id].imagewidth=icons[i].getElementsByTagName("image")[0].getAttribute("width");MAPBUILDER.widget.MapObject.Ref.icons[id].imageheight=icons[i].getElementsByTagName("image")[0].getAttribute("height");}
catch(e){}
try{MAPBUILDER.widget.MapObject.Ref.icons[id].shadowsrc=icons[i].getElementsByTagName("shadow")[0].getAttribute("src");}
catch(e){}
try{MAPBUILDER.widget.MapObject.Ref.icons[id].shadowwidth=icons[i].getElementsByTagName("shadow")[0].getAttribute("width");MAPBUILDER.widget.MapObject.Ref.icons[id].shadowheight=icons[i].getElementsByTagName("shadow")[0].getAttribute("height");}
catch(e){}}}
catch(e){}
try{var markers=xmlDoc.getElementsByTagName("marker");for(var i=0;i<markers.length;i++){id=i;MAPBUILDER.widget.MapObject.Ref.markers[id]=new MAPBUILDER.widget._Marker(markers[i].getAttribute("lng"),markers[i].getAttribute("lat"));try{MAPBUILDER.widget.MapObject.Ref.markers[id].iconname=markers[i].getAttribute("iconname");}
catch(e){}
try{MAPBUILDER.widget.MapObject.Ref.markers[id].infowindow=new MAPBUILDER.widget._InfoWindow(markers[i].getElementsByTagName("infowindow")[0].firstChild.nodeValue);}
catch(e){}
try{MAPBUILDER.widget.MapObject.Ref.markers[id].sid=markers[i].getAttribute("id");}
catch(e){}
try{MAPBUILDER.widget.MapObject.Ref.markers[id].name=markers[i].getAttribute("name");}
catch(e){}
try{MAPBUILDER.widget.MapObject.Ref.markers[id].description=markers[i].getAttribute("description");}
catch(e){}
try{MAPBUILDER.widget.MapObject.Ref.markers[id].address=markers[i].getAttribute("address");MAPBUILDER.widget.MapObject.Ref.markers[id].city=markers[i].getAttribute("city");MAPBUILDER.widget.MapObject.Ref.markers[id].zip=markers[i].getAttribute("zip");MAPBUILDER.widget.MapObject.Ref.markers[id].state=markers[i].getAttribute("state");MAPBUILDER.widget.MapObject.Ref.markers[id].country=markers[i].getAttribute("country");}
catch(e){}
try{MAPBUILDER.widget.MapObject.Ref.markers[id].link=markers[i].getElementsByTagName("link")[0].firstChild.nodeValue;}
catch(e){}}}
catch(e){}
try{var polyline=xmlDoc.getElementsByTagName("polyline");for(var i=0;i<polyline.length;i++){id=i;MAPBUILDER.widget.MapObject.Ref.polylines[id]=new MAPBUILDER.widget._Polyline();try{MAPBUILDER.widget.MapObject.Ref.polylines[id].color=polyline[i].getAttribute("color");}
catch(e){}
try{MAPBUILDER.widget.MapObject.Ref.polylines[id].weight=parseFloat(polyline[i].getAttribute("weight"));}
catch(e){}
try{MAPBUILDER.widget.MapObject.Ref.polylines[id].width=parseInt(polyline[i].getAttribute("width"));}
catch(e){}
var point=polyline[i].getElementsByTagName("point");for(j=0;j<point.length;j++){MAPBUILDER.widget.MapObject.Ref.polylines[id].markers[j]=new MAPBUILDER.widget._Marker(parseFloat(point[j].getAttribute("lng")),parseFloat(point[j].getAttribute("lat")));}}}
catch(e){}
try{MAPBUILDER.event.onAJAXCallBack(xmlDoc);}
catch(e){}
try{MAPBUILDER.widget.MapObject.Ref.showActiveMarker(MAPBUILDER.widget.MapObject.Ref.activeMarkerID);MAPBUILDER.widget.MapObject.Ref.activeMarkerID=0;}
catch(e){}}
catch(e){alert("Some error occured during data processing:"+e);}
document.getElementById("loading").innerHTML="";MAPBUILDER.widget.MapObject.Ref.renderDataLayers();}
MAPBUILDER.event.onJSONCallBack=function(jData){}
MAPBUILDER.event.JSONCallBack=function(jData){try{mapdata=jData.map;try{MAPBUILDER.widget.MapObject.Ref.title=mapdata.title;}
catch(e){}
try{MAPBUILDER.widget.MapObject.Ref.defCenterLon=parseFloat(mapdata.lng);}
catch(e){}
try{MAPBUILDER.widget.MapObject.Ref.defCenterLat=parseFloat(mapdata.lat);}
catch(e){}
try{MAPBUILDER.widget.MapObject.Ref.defZoom=parseInt(mapdata.zoom);}
catch(e){}
try{var icons=mapdata.icons
for(var i=0;i<icons.length;i++){id=i;MAPBUILDER.widget.MapObject.Ref.icons[id]=new MAPBUILDER.widget._Icon();MAPBUILDER.widget.MapObject.Ref.icons[id].name=icons[i].name;try{MAPBUILDER.widget.MapObject.Ref.icons[id].copy=icons[i].copy;}
catch(e){}
MAPBUILDER.widget.MapObject.Ref.icons[id].imagesrc=icons[i].image.src;try{MAPBUILDER.widget.MapObject.Ref.icons[id].xanchor=icons[i].xanchor;MAPBUILDER.widget.MapObject.Ref.icons[id].yanchor=icons[i].yanchor;}
catch(e){}
try{MAPBUILDER.widget.MapObject.Ref.icons[id].xiwanchor=icons[i].xiwanchor;MAPBUILDER.widget.MapObject.Ref.icons[id].yiwanchor=icons[i].yiwanchor;}
catch(e){}
try{MAPBUILDER.widget.MapObject.Ref.icons[id].xisanchor=icons[i].xisanchor;MAPBUILDER.widget.MapObject.Ref.icons[id].yisanchor=icons[i].yisanchor;}
catch(e){}
try{MAPBUILDER.widget.MapObject.Ref.icons[id].imagewidth=icons[i].image.width;MAPBUILDER.widget.MapObject.Ref.icons[id].imageheight=icons[i].image.height;}
catch(e){}
try{MAPBUILDER.widget.MapObject.Ref.icons[id].shadowsrc=icons[i].shadow.src;}
catch(e){}
try{MAPBUILDER.widget.MapObject.Ref.icons[id].shadowwidth=icons[i].shadow.width;MAPBUILDER.widget.MapObject.Ref.icons[id].shadowheight=icons[i].shadow.height;}
catch(e){}}}
catch(e){}
try{var markers=mapdata.markers;for(var i=0;i<markers.length;i++){id=i;MAPBUILDER.widget.MapObject.Ref.markers[id]=new MAPBUILDER.widget._Marker(markers[i].lng,markers[i].lat);try{MAPBUILDER.widget.MapObject.Ref.markers[id].iconname=markers[i].iconname;}
catch(e){}
try{MAPBUILDER.widget.MapObject.Ref.markers[id].infowindow=new MAPBUILDER.widget._InfoWindow(markers[i].infowindow.html);}
catch(e){}
try{MAPBUILDER.widget.MapObject.Ref.markers[id].sid=markers[i].id;}
catch(e){}
try{MAPBUILDER.widget.MapObject.Ref.markers[id].name=markers[i].name;}
catch(e){}
try{MAPBUILDER.widget.MapObject.Ref.markers[id].description=markers[i].description;}
catch(e){}
try{MAPBUILDER.widget.MapObject.Ref.markers[id].address=markers[i].address;MAPBUILDER.widget.MapObject.Ref.markers[id].city=markers[i].city;MAPBUILDER.widget.MapObject.Ref.markers[id].zip=markers[i].zip;MAPBUILDER.widget.MapObject.Ref.markers[id].state=markers[i].state;MAPBUILDER.widget.MapObject.Ref.markers[id].country=markers[i].country;}
catch(e){}
try{MAPBUILDER.widget.MapObject.Ref.markers[id].link=markers[i].link;}
catch(e){}}}
catch(e){}
try{var polyline=mapdata.polylines;for(var i=0;i<polyline.length;i++){id=i;MAPBUILDER.widget.MapObject.Ref.polylines[id]=new MAPBUILDER.widget._Polyline();try{MAPBUILDER.widget.MapObject.Ref.polylines[id].color=polyline[i].color;}
catch(e){}
try{MAPBUILDER.widget.MapObject.Ref.polylines[id].weight=parseFloat(polyline[i].weight);}
catch(e){}
try{MAPBUILDER.widget.MapObject.Ref.polylines[id].width=parseInt(polyline[i].width);}
catch(e){}
var points=polyline[i].points;for(j=0;j<points.length;j++){MAPBUILDER.widget.MapObject.Ref.polylines[id].markers[j]=new MAPBUILDER.widget._Marker(parseFloat(points[j].lng),parseFloat(points[j].lat));}}}
catch(e){}
try{MAPBUILDER.event.onJSONCallBack(jData);}
catch(e){}
try{MAPBUILDER.widget.MapObject.Ref.showActiveMarker(MAPBUILDER.widget.MapObject.Ref.activeMarkerID);MAPBUILDER.widget.MapObject.Ref.activeMarkerID=0;}
catch(e){}}
catch(e){alert("Some error occured during data processing:"+e);}
document.getElementById("loading").innerHTML="";MAPBUILDER.widget.MapObject.Ref.renderDataLayers();}
MAPBUILDER.event.infoLink=function(i){MAPBUILDER.widget.MapObject.Ref.showActiveMarker(i);}
MAPBUILDER.event.addrSearch=function(location){request='http://mapbuilder.net/Service/geocode.yahoo.php?appid=mapobject.net&location='+location+'&output=json&callback=MAPBUILDER.event.getLocation';var oLoader=new MAPBUILDER.util.JSLoader(request);oLoader.buildScriptTag();oLoader.addScriptTag();}
MAPBUILDER.event.getLocation=function(jData){if(jData==null){MAPBUILDER.widget.MapObject.Ref.IssueError("There was a problem parsing search results.");return;}
var lat=jData.ResultSet.Result[0].Latitude;var lon=jData.ResultSet.Result[0].Longitude;MAPBUILDER.widget.MapObject.Ref.centerAndZoomTo(lon,lat,MAPBUILDER.widget.MapObject.Ref.addrSearchZoom);}
MAPBUILDER.event.onShowActiveMarker=function(id){};MAPBUILDER.event.onMarkerClick=function(id,point,html,iconname){};MAPBUILDER.event.onCreateMarker=function(id,marker){return marker};MAPBUILDER.event.onRenderMarkers=function(){};