"use strict";LOCMAP={data:{ds:"trhmgPHY_locmap_ds",container:"trhmgPHY_locmap",message:"trhmgPHY_locmap_loading",specList:"trhmgPHY_locmap_specList",pracList:"trhmgPHY_locmap_pracList",map:"trhmgPHY_locmap_map",manager:null,center:[40.375843776960124,-75.91827392578125],visible:null,selected:{specialty:0,practice:null,addresss:null}},onLoad:function(){Event.addListener(window,"unload",google.maps.Unload);
if(google.maps.BrowserIsCompatible()){LOCMAP.init();}else{alert("Sorry, your browser is not compatible with this feature.");}},init:function(){function a(c){for(var b in c){if(c.hasOwnProperty(b)&&Lang.isString(c[b])){c[b]=document.getElementById(c[b]);
}}}a(this.data);this.init_map();this.init_ds();this.init_specList();this.init_pracList();this.data.message.innerHTML="";},init_ds:function(){var a,b;this.data.ds.parentNode.removeChild(this.data.ds);
this.data.ds=Dom.innerText(this.data.ds);this.data.ds=Lang.JSON.parse(this.data.ds);b=this.data.ds.addresses;a=b.length;while(a--){b[a].point=new google.maps.LatLng(b[a].latitude,b[a].longitude);
b[a].marker=new google.maps.Marker(b[a].point);}},init_specList:function(){var a=this.data.ds.specialties.map(function(b){return'<li id="spec'+b.id+'">'+ENCODE.html(b.name)+"</li>";
});a=(a.length)?'<h2>Choose a Specialty...</h2><ul><li id="spec0" class="selected">All Specialties</li>'+a.join("\n")+"</ul>":"<h2>No specialties found.</h2>";this.data.specList.innerHTML=a;
Event.addListener(this.data.specList,"click",this.doClick_specList,this,true);},init_pracList:function(){this.update_pracList();Event.addListener(this.data.pracList,"click",this.doClick_pracList,this,true);
},init_map:function(){this.data.center=new google.maps.LatLng(this.data.center[0],this.data.center[1]);this.data.map=new google.maps.Map2(this.data.map);this.data.map.setCenter(this.data.center,10);
if(this.data.map.setUIToDefault){this.data.map.setUIToDefault();}this.data.manager=new MarkerManager(this.data.map);google.maps.Event.addListener(this.data.map,"click",this.doClick_mapG);
},getPracticesBySpecialty:function(f){var c,b,e,d=[];if(f===0){c=this.data.ds.practices;for(b=0,e=c.length;b<e;b++){d[b]=c[b].id;}return d;}c=this.data.ds.pracspecs;
for(b=0,e=c.length;b<e;b++){if(c[b].specialtyID===f&&d.indexOf(c[b].practiceID)===-1){d[d.length]=c[b].practiceID;}}return d;},getVisibleMarker:function(d){var c=this.data.visible,b=c.length,e=d.getLatLng();
while(b--){if(c[b].getLatLng().equals(e)){return c[b];}}return null;},selectSpecialty:function(a){var b=this.data.specList;b=Dom.getElementsByClassName("selected","li",b);
Dom.removeClass(b,"selected");b="spec"+a.toString();Dom.addClass(b,"selected");if(this.data.selected.specialty===a){return;}this.data.selected.specialty=a;this.update_pracList();
},selectPractice:function(c,e){var i,j,d=this.data.pracList,f=null,h,b=0;function g(){if(f.isHidden()&&b<1000){window.setTimeout(g,100);b++;}else{f.openInfoWindowHtml(h);
}}d=Dom.getElementsByClassName("selected","li",d);Dom.removeClass(d,"selected");d="prac"+c.toString();Dom.addClass(d,"selected");if(this.data.selected.practice===c){if(e===undefined||e===this.data.selected.address){return;
}}this.data.selected.practice=c;i=this.data.ds.addresses;for(j=0;j<i.length;j++){if(i[j].practiceID===c){if(e===undefined||i[j].addressID===e){f=i[j].marker;f=this.getVisibleMarker(f);
if(f){break;}}}}if(f){h=this.renderPractice(c,f);if(f.isHidden()){window.setTimeout(g,100);this.data.map.setCenter(f.getLatLng());}else{g();}}},selectMarker:function(a){var d=a.getLatLng(),e=this.data.ds.addresses,c=this.getPracticesBySpecialty(this.data.selected.specialty),b=this.renderResolve;
e=e.filter(function(f){return(c.indexOf(f.practiceID)!==-1&&f.point.equals(d));});if(e.length===1){this.selectPractice(e[0].practiceID,e[0].addressID);return;}c=this.data.ds.practices.filter(function(f){return(c.indexOf(f.id)!==-1);
});e=e.map(function(h){var f,g;f=c.length;while(f--){if(c[f].id===h.practiceID){g=c[f].name;break;}}return b(h.practiceID,h.addressID,g);});a.openInfoWindowHtml("<h3>There are multiple practices at this location:</h3><ul>"+e.join("\n")+"</ul>");
},renderResolve:function(c,a,b){return'<li onclick="LOCMAP.selectPractice('+c+", "+a+');">'+ENCODE.html(b)+"</li>";},renderPractice:function(b,d){var e=this.data.ds.practices,c=this.data.ds.addresses,k=this.data.ds.addresses,h=this.getPracticesBySpecialty(this.data.selected.specialty),j=this.renderResolve,i=null,f=d.getLatLng(),g,a={};
g=e.length;while(g--){if(e[g].id===b){e=e[g];break;}}c=c.filter(function(l){return(l.practiceID===b);});g=c.length;while(g--){if(c[g].point.equals(f)){i=c[g];break;
}}k=k.filter(function(l){return(l.practiceID!==b&&h.indexOf(l.practiceID)!==-1&&l.point.equals(f));});h=this.data.ds.practices.filter(function(l){return(h.indexOf(l.id)!==-1);
});k=k.map(function(n){var l,m;l=h.length;while(l--){if(h[l].id===n.practiceID){m=h[l].name;break;}}return j(n.practiceID,n.addressID,m);});a.pracName=ENCODE.html(e.name);
a.pracName='<a href="/phy/Page.asp?PageID=Prac'+e.id+'">'+a.pracName+"</a>";a.pracName="<h3>"+a.pracName+"</h3>";a.address=['<div class="vcard">','    <div class="org">','        <div class="organization-name">{organizationName}</div>','        <div class="organization-unit">{organizationUnit}</div>',"    </div>",'    <div class="adr">','        <div class="street-address">{streetAddress}</div>','        <div class="extended-address">{extendedAddress1}</div>','        <div class="extended-address">{extendedAddress2}</div>','        <span class="locality">{locality}</span>','        <span class="region">{region}</span>,','        <span class="postal-code">{postalCode}</span>',"    </div>",'    <div class="geo">','        <span class="latitude">{latitude}</span>,','        <span class="longitude">{longitude}</span>',"    </div>"];
if(i.phone){a.address.push('    <div class="tel">','        <span class="type" title="voice">Phone:</span>','        <span class="value">{phone}</span>',"    </div>");
}if(i.fax){a.address.push('    <div class="tel">','        <span class="type" title="fax">Fax:</span>','        <span class="value">{fax}</span>',"    </div>");}a.address=a.address.join("\n");
a.address=Lang.substitute(a.address,i,function(m,l){return ENCODE.html(l);});a.multiple=(c.length>1)?"<h4>This practice has multiple locations:</h4><ol>"+c.map(function(l){return(l===i)?'<li class="selected">'+ENCODE.html(l.streetAddress)+"</li>":j(l.practiceID,l.addressID,l.streetAddress);
}).join("\n")+"</ol>":"";a.others=(k.length)?"<h4>Other practices at this location:</h4><ol>"+k.join("\n")+"</ol>":"";a=Lang.substitute("{pracName}\n{address}\n{multiple}\n{others}",a);
return a;},update_pracList:function(){var a=this.getPracticesBySpecialty(this.data.selected.specialty),c=this.data.selected.practice,b=false;a=this.data.ds.practices.filter(function(d){return(a.indexOf(d.id)!==-1);
});a=a.map(function(d){if(d.id===c){b=true;return'<li id="prac'+d.id+'" class="selected">'+ENCODE.html(d.name)+"</li>";}return'<li id="prac'+d.id+'">'+ENCODE.html(d.name)+"</li>";
});a=(a.length)?"<h2>Choose a Practice...</h2><ul>"+a.join("\n")+"</ul>":"<h2>No practices found for this specialty.</h2>";this.data.pracList.innerHTML=a;if(b!==true){this.data.selected.practice=null;
}this.update_map();},update_map:function(){var c,b,e=this.data.selected.specialty,f=[];function d(g){var a=f.length,h=g.getLatLng();while(a--){if(f[a].getLatLng().equals(h)){return true;
}}return false;}e=this.getPracticesBySpecialty(e);c=this.data.ds.addresses;b=c.length;while(b--){if(e.indexOf(c[b].practiceID)!==-1&&d(c[b].marker)===false){f.push(c[b].marker);
}}if(this.data.manager){this.data.manager.clearMarkers();this.data.manager.addMarkers(f,3);this.data.manager.refresh();this.data.visible=f;}},doClick_specList:function(b){var a=Event.getTarget(b);
if(a.nodeName!=="LI"){a=Dom.getAncestorByTagName(a,"LI");}if(a===null||a.parentNode.parentNode!==this.data.specList){return;}a=a.id.substring(4);a=parseInt(a,10);
if(isNaN(a)){return;}this.selectSpecialty(a);},doClick_pracList:function(b){var a=Event.getTarget(b);if(a.nodeName!=="LI"){a=Dom.getAncestorByTagName(a,"LI");}if(a===null||a.parentNode.parentNode!==this.data.pracList){return;
}a=a.id.substring(4);a=parseInt(a,10);if(isNaN(a)){return;}this.selectPractice(a);},doClick_mapG:function(a){if(a&&a instanceof google.maps.Marker){LOCMAP.selectMarker(a);
}}};Event.onDOMReady(function(){google.load("maps",2,{callback:LOCMAP.onLoad});});