var WecMap={maps:[],markers:[],markerManagers:[],bubbleData:[],directions:[],directionsFromData:[],directionsToData:[],icons:[],locale:'en',init:function(map){if(!(this.icons[map] instanceof Array))this.icons[map]=[];if(!(this.directionsFromData[map] instanceof Array))this.directionsFromData[map]=[];if(!(this.directionsToData[map] instanceof Array))this.directionsToData[map]=[];if(!(this.icons[map] instanceof Array))this.icons[map]=[];if(!(this.bubbleData[map] instanceof Array))this.bubbleData[map]=[];if(!(this.markers[map] instanceof Array))this.markers[map]=[];this.maps[map]=new GMap2(document.getElementById(map));this.markerManagers[map]=new GMarkerManager(this.maps[map])},get:function(map){return this.maps[map]},addMarkersToManager:function(map,groupId,minZoom,maxZoom){this.markerManagers[map].addMarkers(this.markers[map][groupId],minZoom,maxZoom);this.markerManagers[map].refresh()},jumpTo:function(map,groupId,markerId,zoom){var marker=this.markers[map][groupId][markerId];if(zoom)this.maps[map].setZoom(zoom);this.maps[map].panTo(marker.getPoint());setTimeout('GEvent.trigger(WecMap.markers["'+map+'"]["'+groupId+'"]["'+markerId+'"], "click")',300);return false},setDirections:function(map,fromAddr,toAddr){window['gdir_'+map].load('from: '+fromAddr+' to: '+toAddr,{locale:this.locale});this.maps[map].closeInfoWindow();return false},addIcon:function(map,iconId,image,shadow,iconSize,shadowSize,iconAnchor,infoWindowAnchor){var icon=new GIcon();icon.image=image;icon.shadow=shadow;icon.iconSize=iconSize;icon.shadowSize=shadowSize;icon.iconAnchor=iconAnchor;icon.infoWindowAnchor=infoWindowAnchor;if(!iconId)var iconId='default';this.icons[map][iconId]=icon},addBubble:function(map,groupId,markerId,labels,content){if(!(this.bubbleData[map][groupId] instanceof Array))this.bubbleData[map][groupId]=[];for(var i=0;i<content.length;i++)content[i]='<div id="'+map+'_marker_'+groupId+'_'+markerId+'" class="marker">'+content[i]+'</div>';this.bubbleData[map][groupId][markerId]={labels:labels,content:content}},addMarker:function(map,markerId,latlng,iconId,dirTitle,groupId,address){if(!iconId)var iconId='default';var icon=this.icons[map][iconId],point=new GLatLng(latlng[0],latlng[1]),marker=new GMarker(point,icon),tabs=[],tabLabels=this.bubbleData[map][groupId][markerId].labels,text=this.bubbleData[map][groupId][markerId].content;if(text){for(var i=0;i<text.length;i++)tabs.push(new GInfoWindowTab(tabLabels[i],text[i]));if(dirTitle){if(!(this.directionsFromData[map][groupId] instanceof Array))this.directionsFromData[map][groupId]=[];if(!(this.directionsToData[map][groupId] instanceof Array))this.directionsToData[map][groupId]=[];var dirText=text[0]+'<br /><div id="'+map+'_todirform_'+groupId+'_'+markerId+'" class="todirform"><form action="#" onsubmit="return WecMap.setDirections(\''+map+'\', ['+point.y+', '+point.x+'], document.getElementById(\'tx-wecmap-directions-to-'+map+'\').value, \''+dirTitle+'\');">';dirText+='<label class="startendaddress" for="tx-wecmap-directions-to-'+map+'">'+this.labels.endaddress+'</label><input type="text" name="daddr" value="'+address+'" id="tx-wecmap-directions-to-'+map+'" />';dirText+='<input type="submit" name="submit" value="Go" /></form></div>';this.directionsFromData[map][groupId][markerId]=dirText;dirText=text[0]+'<br /><div id="'+map+'_fromdirform_'+groupId+'_'+markerId+'" class="fromdirform"><form action="#" onsubmit="return WecMap.setDirections(\''+map+'\', document.getElementById(\'tx-wecmap-directions-from-'+map+'\').value, ['+point.y+', '+point.x+'], \''+dirTitle+'\');">';dirText+='<label class="startendaddress" for="tx-wecmap-directions-from-'+map+'">'+this.labels.startaddress+'</label><input type="text" name="saddr" value="'+address+'" id="tx-wecmap-directions-from-'+map+'" />';dirText+='<input type="submit" name="submit" value="Go" /></form></div>';this.directionsToData[map][groupId][markerId]=dirText};marker.bindInfoWindowTabsHtml(tabs)};if(!(this.markers[map][groupId] instanceof Array))this.markers[map][groupId]=[];this.markers[map][groupId][markerId]=marker;return marker},openDirectionsToHere:function(map,groupId,markerId){var tabs=[],tabLabels=this.bubbleData[map][groupId][markerId].labels,text=this.bubbleData[map][groupId][markerId].content,dirs=this.directionsToData[map][groupId][markerId];for(var i=0;i<text.length;i++)if(i==0){tabs.push(new GInfoWindowTab(tabLabels[i],dirs))}else tabs.push(new GInfoWindowTab(tabLabels[i],text[i]));this.markers[map][groupId][markerId].openInfoWindowTabsHtml(tabs);return false},openDirectionsFromHere:function(map,groupId,markerId){var tabs=[],tabLabels=this.bubbleData[map][groupId][markerId].labels,text=this.bubbleData[map][groupId][markerId].content,dirs=this.directionsFromData[map][groupId][markerId];for(var i=0;i<text.length;i++)if(i==0){tabs.push(new GInfoWindowTab(tabLabels[i],dirs))}else tabs.push(new GInfoWindowTab(tabLabels[i],text[i]));this.markers[map][groupId][markerId].openInfoWindowTabsHtml(tabs);return false}}
