
GMap_popup_zIndex=0;var iconRed=standardIcon(baseurl+'icons/icon_critical.png');var iconYellow=standardIcon(baseurl+'icons/icon_stable.png');var iconBuddhist=standardIcon(baseurl+'icons/buddhism.png');var iconChristianity=standardIcon(baseurl+'icons/christianity.png');var iconIslam=standardIcon(baseurl+'icons/islam.png');var iconJudaism=standardIcon(baseurl+'icons/judaism.png');var defaultIcon=standardIcon(baseurl+'icons/icon_critical.png');var noCacheDate=new Date();var noCache='?'+noCacheDate.getUTCFullYear()+((noCacheDate.getUTCMonth()<10)?"0"+noCacheDate.getUTCMonth():noCacheDate.getUTCMonth())+((noCacheDate.getUTCDate()<10)?"0"+noCacheDate.getUTCDate():noCacheDate.getUTCDate());var ebMap=new Object;ebMap.markerXML=baseurl+"eb/ebo_markers/"+noCache;ebMap.centerLat=40.7196806451724;ebMap.centerLng=-73.96270751953125;var religiousMap=new Object;religiousMap.markerXML=baseurl+"religious_institutions/religious_markers/"+noCache;religiousMap.centerLat=40.685956;religiousMap.centerLng=-73.839780;if(programs_services_markers===undefined){var programs_services_markers="";}
var progServiceMap=new Object;progServiceMap.markerXML=baseurl+"maps/programs_services/"+programs_services_markers+'/'+noCache;progServiceMap.centerLat=40.7196806451724;progServiceMap.centerLng=-73.96270751953125;var map;var geocoder=null;var tempPoint=new Object();var currentMarker=null;var currentMap;var customIcons=[];customIcons["Yellow"]=iconYellow;customIcons["Red"]=iconRed;var markers;var map_markers=new Array();var map_marker_overlays=new Array();var currentMarker=null;var building_uses=new Array();var panningTimer;_document.ready(function(){if(programs_services_markers===""){showMap('eb');}else{showMap('progServicesMap');}});function load(){if(GBrowserIsCompatible()){_map=jQuery('#map');map=new GMap2(_map.get(0));map.addControl(new GSmallMapControl());map.addControl(new GMapTypeControl());map.setCenter(new GLatLng(centerLat,centerLng),11);var preload_popups=jQuery('<div style="position: absolute; top: -1000px;"><div class="mywindow"><div class="map_info_window">&nbsp;</div></div><div class="map_tooltip"><div class="tooltip_title">&nbsp;</div></div></div>').appendTo('body');_document.oneTime(500,"preload_popups",function(){preload_popups.remove();});geocoder=new GClientGeocoder();GDownloadUrl(markerXML,function(data){var xml=GXml.parse(data);markers=xml.documentElement.getElementsByTagName("marker");for(var i=0;i<markers.length;i++){var building_name=markers[i].getAttribute("name");if(jQuery.browser.msie){var address=markers[i].childNodes[0].firstChild.nodeValue;var image=markers[i].childNodes[1].firstChild.nodeValue;var building_use=(markers[i].childNodes[2]!=undefined)?markers[i].childNodes[2].firstChild.nodeValue:'';var url_title=(markers[i].childNodes[3]!=undefined)?markers[i].childNodes[3].firstChild.nodeValue:'';}else{var address=markers[i].childNodes[1].firstChild.nodeValue;var image=(markers[i].childNodes[3]!=undefined)?markers[i].childNodes[3].firstChild.nodeValue:'';var building_use=(markers[i].childNodes[5]!=undefined)?markers[i].childNodes[5].firstChild.nodeValue:'';var url_title=(markers[i].childNodes[7]!=undefined)?markers[i].childNodes[7].firstChild.nodeValue:'';}
var ranking=markers[i].getAttribute("ranking");var type=markers[i].getAttribute("type");if((markers[i].getAttribute("lat")!="")&&(markers[i].getAttribute("lng")!="")){var point=new GLatLng(parseFloat(markers[i].getAttribute("lat")),parseFloat(markers[i].getAttribute("lng")));if(point){var marker=createMarker(point,building_name,address,image,ranking,url_title);marker.title=building_name;map.addOverlay(marker);map_markers[map_markers.length]=marker;}}}});}}
event_count=-1;function createMarker(point,name,address,imageurl,ranking,url_title){if(currentMap=='eb'){var marker=new GMarker(point,customIcons[ranking]);}else if(currentMap=='progServicesMap'){var marker=new GMarker(point,customIcons['Red']);}else{var marker=new GMarker(point,getReligiousIcon(ranking));}
var address_info=eval(address);var street_address=address_info[0].street_address;var city=(address_info[0].borough!=undefined)?address_info[0].borough:address_info[0].city;var state=(address_info[0].zip!=undefined)?address_info[0].zip:address_info[0].state;var zipcode=(address_info[0].zipcode!=undefined)?address_info[0].zipcode:'';var image=baseurl+"imagetool/image.php/image.jpg?width=100&height=100&cropratio=1:1&image="+imageurl;var html="";html="<div class='map_info_window'>";html+="<div class='info_window_text_container'><span class='info_window_title'><a href='"+url_title+"'>"+name+"</a></span>";html+="<p class='info_window_text'>"+street_address+"<br>";html+=city;html+=", "+state+zipcode;html+="</p>";html+='<a class="cloth" href="#" onclick="closeOverlay(); return false;">Close</a></div>';html+="<div class='info_window_image_container'><a href='"+url_title+"'><img src='"+image+"' class='info_window_image'></a></div>";html+="</div>";var tooltip_html="<div class='tooltip_title'><b>"+name+"</b></div>";tooltip_html=html;GEvent.addListener(marker,"mouseover",function(){marker._hover=true;marker.tooltip_created=true;if(!currentMarker){if(typeof customOverlay!=='undefined'){if(!marker.tooltip){marker.tooltip_created=false;marker.tooltip=new customOverlay(this,tooltip_html,'tooltip');}
marker.tooltip._div.stopTime("hover");if(!marker.tooltip._hover){map.addOverlay(marker.tooltip);var _maptooltip=marker.tooltip._div;_maptooltip.css('top',Number(_maptooltip.data("map_tooltip-y"))-_maptooltip.height()-6);_maptooltip.css('visibility','visible');}}}});GEvent.addListener(marker,"mouseout",function(){marker._hover=false;if(marker.tooltip){removeTooltip(marker,true);}});marker.html=html;return marker;}
var customOverlay=function(marker,html,type){this.marker=marker;this.html=html;this.overlayType=type;this._hover=false;var div="<div>"+this.html+"</div>";this._div=jQuery(div);this._div.css('position','absolute');if(type=="tooltip"){GEvent.addDomListener(this._div.get(0),'mouseover',function(popup){popup._hover=true;popup._div.stopTime("hover");}.partial(this));GEvent.addDomListener(this._div.get(0),'mouseout',function(popup){popup._hover=false;removeTooltip(popup.marker,false);}.partial(this));GEvent.addDomListener($('a.cloth',this._div).get(0),'click',function(m){closeOverlay(m);}.partial(this.marker));if(jQuery.browser.msie&&jQuery.browser.version<7){GEvent.addDomListener(this._div.get(0),'click',function(){closeOverlay();});}}else{if(jQuery.browser.msie&&jQuery.browser.version<7){GEvent.addDomListener(this._div.get(0),'click',function(){closeOverlay();});}}}
customOverlay.prototype=new GOverlay();customOverlay.prototype.initialize=function(map){this._div.css("z-index",++GMap_popup_zIndex);var div=this._div.get(0);div.className='mywindow';offsetX=-2;offsetY=137;this._div.data("map_tooltip-y",map.fromLatLngToDivPixel(this.marker.getPoint()).y);div.style.visibility="hidden";div.style.left=(map.fromLatLngToDivPixel(this.marker.getPoint()).x-offsetX)+'px';this._map=map;this._div.appendTo(map.getPane(G_MAP_FLOAT_PANE));}
customOverlay.prototype.remove=function(){this._div.remove();}
customOverlay.prototype.redraw=function(){}
function closeOverlay(optional_marker){if(arguments[0]!==undefined)
map.removeOverlay(optional_marker.tooltip);if(currentMarker){map.removeOverlay(currentMarker.overlay);currentMarker=false;}}
function removeTooltip(marker,bMarker){marker.tooltip._div.stopTime("hover");if(bMarker==true){marker.tooltip._div.oneTime(40,"hover",function(m){if(!m.tooltip._hover)map.removeOverlay(marker.tooltip);}.partial(marker));}else{marker.tooltip._div.oneTime(40,"hover",function(m){if(!m._hover)map.removeOverlay(marker.tooltip);}.partial(marker));}}
function random_pan(){closeOverlay();var available_markers=new Array();jQuery.each(map_markers,function(){if(!this.isHidden()){available_markers[available_markers.length]=this;}});if(available_markers.length==0){stop_panning();}
var randomnumber=Math.floor(Math.random()*available_markers.length);var tempMarker=available_markers[randomnumber];var tempOverlay;map.panTo(tempMarker.getLatLng());tempOverlay=new customOverlay(tempMarker,tempMarker.html);currentMarker=tempMarker;currentMarker.overlay=tempOverlay;map.addOverlay(tempOverlay);}
function start_panning(){map.setZoom(14);panningTimer=setInterval("random_pan()",4000);}
function stop_panning(){clearInterval(panningTimer);}
function show_all_building_use(){jQuery.each(map_markers,function(){this.show();});jQuery.each($('.check_type:checkbox'),function(){this.checked=true;});}
function hide_all_building_use(){jQuery.each(map_markers,function(){this.hide();});jQuery.each($('.check_type:checkbox'),function(){this.checked=false;});}
function toggle_building_use(the_building_use){jQuery.each(map_markers,function(){if(this.building_use==the_building_use){if(this.isHidden()){this.show();}else{this.hide();}}});}
function showMap(mapChoice){if(mapChoice=='eb'){tempMap=ebMap;}else if(mapChoice=='religious'){tempMap=religiousMap;}else if(mapChoice=='progServicesMap'){tempMap=progServiceMap;}
currentMap=mapChoice;markerXML=tempMap.markerXML;centerLat=tempMap.centerLat;centerLng=tempMap.centerLng;map_markers=new Array();load();}
function standardIcon(iconURL){if(iconURL==''){iconURL="icons/icon_critical.png";}
var standardIcon=new GIcon();standardIcon.image=iconURL;standardIcon.iconSize=new GSize(32,32);standardIcon.iconAnchor=new GPoint(16,16);standardIcon.infoWindowAnchor=new GPoint(16,16);return standardIcon;}
function geocodeAddress(address){var obj=new Object();if(geocoder){obj=geocoder.getLatLng(address,function(point){if(!point){alert(address+" not found");}else{obj.point=point;}});}else{return false;}
return obj;}
function getReligiousIcon(denomination){var religiousIcons=new Array();religiousIcons["7th Day Adventist"]=iconChristianity;religiousIcons["A.M.E. Zion"]=iconJudaism;religiousIcons["African-American Episcopal"]=iconChristianity;religiousIcons["Assemblies of God"]=iconChristianity;religiousIcons["Baptist"]=iconChristianity;religiousIcons["Bibleway Church Worldwide"]=iconChristianity;religiousIcons["CCHC"]=iconChristianity;religiousIcons["Christ Apostolic Church"]=iconChristianity;religiousIcons["Christian"]=iconChristianity;religiousIcons["Christian(?)"]=iconChristianity;religiousIcons["Church of Christ"]=iconChristianity;religiousIcons["Church of God"]=iconChristianity;religiousIcons["Church of God 7th Day"]=iconChristianity;religiousIcons["Church of God in Christ"]=iconChristianity;religiousIcons["Conservative"]=defaultIcon;religiousIcons["Disciples of Christ, Inc."]=iconChristianity;religiousIcons["Evangelical"]=iconChristianity;religiousIcons["Evangelical Christian"]=iconChristianity;religiousIcons["Evangelical Lutheran Church"]=iconChristianity;religiousIcons["Evangelical Menonite"]=iconChristianity;religiousIcons["Fire Baptized Holiness Church"]=iconChristianity;religiousIcons["Full Gospel Tabernacle Worldwide"]=iconChristianity;religiousIcons["Harvest Army Church"]=iconChristianity;religiousIcons["Hindu"]=defaultIcon;religiousIcons["Independent Christian Evangelical"]=iconChristianity;religiousIcons["Indian Orthodox Church"]=iconChristianity;religiousIcons["International Israelite (African American Jewish)"]=iconJudaism;religiousIcons["Jewish"]=iconJudaism;religiousIcons["Moravian Church in North America"]=iconChristianity;religiousIcons["Muslim"]=iconIslam;religiousIcons["N/A"]=defaultIcon;religiousIcons["Nondenominational Christian"]=iconChristianity;religiousIcons["Pentacostal"]=iconChristianity;religiousIcons["Pentecostal"]=iconChristianity;religiousIcons["Presbyterian"]=iconChristianity;religiousIcons["Reform"]=iconChristianity;religiousIcons["Roman Catholic"]=iconChristianity;religiousIcons["Romanian Orthodox Church"]=iconChristianity;religiousIcons["United Methodist"]=iconChristianity;religiousIcons["unknown Christian"]=iconChristianity;if(religiousIcons[denomination]==null){return defaultIcon;}else{return religiousIcons[denomination];}}