(function(n){n.fn.BingMap=function(t){function r(n){n.target.MetaData&&i.setOptions({location:n.target.getLocation(),title:n.target.MetaData.Title,description:n.target.MetaData.Description,visible:!0})}var i,u={Height:400,Width:400,APIKEY:"",ZoomLevel:4,MapMode:"2D",MapType:Microsoft.Maps.MapTypeId.road,ShowMapTypeSelector:!1,ShowPushPin:!0,ShowPinInfoBoxes:!1,ShowDashBoard:!0,ShowScaleBar:!0,DashBoardStyle:"Normal",CenterPoint:null,AutoCenter:!1,AutoZoom:!1,Pins:[]};return t=n.extend(u,t),this.each(function(){var v=n(this),w=v.attr("id"),o,h,c,u,f,l,p,a;if(n(v).css("position","relative").width(t.Width).height(t.Height),t.CenterPoint?(h=t.CenterPoint.Latitude,c=Microsoft.Maps.Location.normalizeLongitude(t.CenterPoint.Longitude),o=new Microsoft.Maps.Location(h,c)):t.Pins.length>0&&(h=t.Pins[0].Latitude,c=Microsoft.Maps.Location.normalizeLongitude(t.Pins[0].Longitude),o=new Microsoft.Maps.Location(h,c)),f={credentials:t.APIKEY,mapTypeId:t.MapType,showMapTypeSelector:t.ShowMapTypeSelector,showScalebar:t.ShowScaleBar,showDashboard:t.ShowDashBoard,enableClickableLogo:!1,center:o,zoom:t.ZoomLevel},t.AutoCenter||t.AutoZoom){for(l=[],u=0;u<t.Pins.length;u++){var y=t.Pins[u],b=y.Latitude,k=Microsoft.Maps.Location.normalizeLongitude(y.Longitude);o=new Microsoft.Maps.Location(b,k);l.push(o)}p=Microsoft.Maps.LocationRect.fromLocations(l);f.bounds=p;f.center=null}if(t.MapType&&(f.MapTypeId=t.MapType),a=new Microsoft.Maps.Map(document.getElementById(w),f),f.center&&(i=new Microsoft.Maps.Infobox(f.center,{visible:!1}),i.setMap(a)),t.ShowPushPin===!0)for(u=0;u<t.Pins.length;u++){var e=t.Pins[u],d=e.Latitude,g=Microsoft.Maps.Location.normalizeLongitude(e.Longitude),nt=new Microsoft.Maps.Location(d,g),s=new Microsoft.Maps.Pushpin(nt,{icon:e.PushPinUrl,anchor:new Microsoft.Maps.Point(20,40)});t.ShowPinTitle&&(s.title=e.Title);t.ShowPinDescription&&(s.subTitle=e.Description);t.ShowPinInfoBoxes&&(s.MetaData={Title:e.Title,Description:e.Description},Microsoft.Maps.Events.addHandler(s,"click",r));a.entities.push(s)}})}})(jQuery)