var copSignUpWindow,agencyStore,agencyMarkers=[],agencyMarkersLoaded=!1,jumpInProgress=!1,analyticsInit=!1,resolutionSlider,endDate=new Date,startDate=new Date(endDate.getFullYear(),endDate.getMonth(),endDate.getDate());startDate.setDate(startDate.getDate()-14);
Ext.apply(Ext.form.VTypes,{daterange:function(a,b){var c=b.parseDate(a);if(c){if(b.startDateField&&(!this.dateRangeMax||c.getTime()!=this.dateRangeMax.getTime())){var d=Ext.getCmp(b.startDateField);d.setMaxValue(c);this.dateRangeMax=c;d.validate()}else if(b.endDateField&&(!this.dateRangeMin||c.getTime()!=this.dateRangeMin.getTime()))d=Ext.getCmp(b.endDateField),d.setMinValue(c),this.dateRangeMin=c,d.validate();return!0}}});
var startDateHandler=function(){var a=Ext.getCmp("startdt"),b=Ext.getCmp("enddt"),a=a.getValue();b.setMinValue(a);startDate.getTime();startDate=a;quickDateComboBox.clearValue();loadData()},endDateHandler=function(){var a=Ext.getCmp("startdt"),b=Ext.getCmp("enddt").getValue();a.setMaxValue(b);endDate=b;quickDateComboBox.clearValue();loadData()},quickDateHandler=function(){endDate=new Date;startDate=endDate.add(Date.DAY,-quickDateComboBox.getValue());Ext.getCmp("enddt").setValue(endDate);Ext.getCmp("startdt").setValue(startDate);
loadData()},quickDateDataStore=new Ext.data.ArrayStore({fields:["display","value"],data:[["Yesterday","1"],["3 days","3"],["1 week","7"],["2 weeks","14"],["1 month","31"],["6 months","183"],["1 year","365"]]}),quickDateComboBox=new Ext.form.ComboBox({name:"quickdate",hiddenName:"quickdate",store:quickDateDataStore,displayField:"display",valueField:"value",listeners:{select:quickDateHandler},typeAhead:!0,triggerAction:"all",width:207,emptyText:"Select a pre-defined range...",forceSelection:!0,selectOnFocus:!0,
mode:"local",renderTo:"quickDateDiv"}),requestAgencyHandler;function getIEVersionNumber(){var a=navigator.userAgent,b=a.indexOf("MSIE ");return-1==b?0:parseFloat(a.substring(b+5,a.indexOf(";",b)))}
Ext.onReady(function(){Ext.isIE6&&(9<=getIEVersionNumber()||showMessage("Incompatible Browser","RAIDS Online does not support IE6. RAIDS Online is best viewed in Internet Explorer 7+, Firefox and Chrome. <a href='http://www.google.com/chrome' class='messageBox'>Click here</a> to download Chrome."));loadToolTips();!0===Ext.isChrome&&Ext.util.CSS.createStyleSheet(".x-date-picker {border-color: #1b376c;background-color:#fff;position: relative;width: 185px;}","chromeDatePickerStyle");var a=new Ext.state.CookieProvider({expires:new Date((new Date).getTime()+
31536E6)});Ext.state.Manager.setProvider(a);var a=new Ext.FormPanel({border:!1,autoWidth:!0,defaults:{width:100},defaultType:"datefield",labelWidth:60,items:[{fieldLabel:"Start Date",name:"startdt",id:"startdt",vtype:"daterange",listeners:{select:startDateHandler},value:startDate,maxValue:endDate,editable:!1,endDateField:"enddt"},{fieldLabel:"End Date",name:"enddt",id:"enddt",vtype:"daterange",listeners:{select:endDateHandler},value:endDate,maxValue:endDate,editable:!1,startDateField:"startdt"}]}),
b=new Ext.slider.Tip({getText:function(a){return String.format("<b>{0}</b>",250==a.value?"Low":500==a.value?"Medium":"High")}});resolutionSlider=new Ext.Slider({renderTo:"densityResolutionSlider",width:60,increment:250,minValue:250,maxValue:750,value:500,plugins:b});(function(){$.getJSON("JumpCities",function(a){agencyStore=new Ext.data.ArrayStore({fields:"name,address,location,lng,lat,sheriff".split(","),data:a});var b=new Ext.form.ComboBox({store:agencyStore,displayField:"location",valueField:"address",
typeAhead:!0,mode:"local",emptyText:"Start typing or click the arrow...",selectOnFocus:!0,width:207,listeners:{select:{fn:function(){centerMap(b.getValue().replace("\\",""));Ext.get("search-address-input").dom.value=b.getValue().replace("\\","")},scope:this}},triggerAction:"all",applyTo:"agency-jump-dropdown"})});$.getJSON("COPAgencies",function(a){new Ext.data.ArrayStore({fields:["ori","name"],data:a})})})();a={title:"Menu",region:"west",collapsible:!0,width:250,autoScroll:!0,defaults:{autoWidth:!0,
collapsible:!0,collapsed:!0,collapsedCls:"collapsedMenubox",bodyCssClass:"menubox"},items:[{title:"Search Address",collapsed:!1,contentEl:"searchMenuDiv"},{title:"Crime Types",contentEl:"crimeTypesDiv",bodyStyle:"padding: 0px;"},{title:"Date Range",items:[{border:!1,bodyCssClass:"menubox-subheader",html:"Quick Date"},quickDateComboBox,{border:!1,bodyStyle:"margin-top: 10px",bodyCssClass:"menubox-subheader",html:"Date Range"},a],contentEl:"dateRangeDiv"},{title:"Analytic Layers",contentEl:"analyticLayersDiv"},
{title:"About RAIDS Online",contentEl:"aboutDiv"}],bodyStyle:"background-color: #eaeaea; padding: 4px",contentEl:"sidebarDiv"};b={region:"center",border:!1,layout:"fit",bodyStyle:"background-color: #444b4d;",items:[new Ext.TabPanel({id:"tabs",activeTab:0,items:[{title:"Map",layout:"fit",listeners:{resize:{fn:function(){map&&map.checkResize()},scope:this}},contentEl:"mapDiv"},{title:"Data Grid",layout:"fit",listeners:{resize:{fn:function(){var a=Ext.getCmp("gridPanel");a.setWidth($("#gridDiv").width());
a.setHeight(Ext.getCmp("tabs").getHeight()-30);Ext.isIE&&a.setWidth(Ext.getBody().getWidth()-250)},scope:this}},autoWidth:!0,contentEl:"gridDiv"},{id:"analyticsTab",title:"Analytics",layout:"fit",listeners:{activate:{fn:function(){!1==maximized?updateAnalytics():updateSingleAnalytic(maximizedAnalytic)},scope:this},resize:{fn:function(){var a=Ext.getCmp("analyticsPanel");a.setWidth($("#analyticsDiv").width());a.setHeight(Ext.getCmp("tabs").getHeight()-30);Ext.isIE&&(a.setWidth(Ext.getBody().getWidth()-
250),Ext.get("analytics_canvas").setWidth(a.getWidth()),Ext.get("analyticsDiv").setWidth(a.getWidth()));!1==maximized?updateAnalytics():updateSingleAnalytic(maximizedAnalytic)},scope:this}},contentEl:"analyticsDiv"},{title:"Metadata",autoScroll:!0,listeners:{activate:{fn:function(){updateMetadata()},scope:this}},contentEl:"metadataDiv"}]})],contentEl:"contentDiv"};new Ext.Viewport({layout:"border",items:[{region:"north",height:85,border:!1,bodyStyle:"background-color: #444b4d;",contentEl:"headerDiv"},
{id:"foot",region:"south",height:25,border:!1,bodyStyle:"background-color: #191b1d; color: #fff; padding: 4px; align: right",contentEl:"footerDiv"},a,b]});var c=new Ext.FormPanel({labelWidth:50,frame:!1,border:!1,region:"center",closable:!0,bodyStyle:"padding: 4px 0 0 8px;",defaults:{width:280},defaultType:"textfield",items:[{xtype:"hidden",name:"id",value:"5682"},{fieldLabel:"Name",name:"name",allowBlank:!1},{fieldLabel:"Email",name:"email",vtype:"email",allowBlank:!1},{fieldLabel:"Phone",name:"phone"},
new Ext.form.ComboBox({fieldLabel:"Carrier",name:"carrier",store:new Ext.data.JsonStore({url:"Carriers",root:"carriers",idProperty:"name",fields:["name"]}),displayField:"name",typeAhead:!0,mode:"remote",triggerAction:"all",emptyText:"Select a carrier...",selectOnFocus:!0})],buttons:[{text:"Sign Up",handler:function(){c.getForm().submit({clientValidation:!0,url:"CopSignUp",success:function(a,b){copSignUpWindow.hide();showMessage(b.result.title,b.result.message)},failure:function(a,b){switch(b.failureType){case Ext.form.Action.CLIENT_INVALID:Ext.Msg.alert("Invalid Input",
"Please hover your mouse over the red underlines to learn more about the problem.");break;case Ext.form.Action.CONNECT_FAILURE:showMessage("Connection Failure","Unable to connect to server.");break;case Ext.form.Action.SERVER_INVALID:showMessage(b.result.title,b.result.message)}}})}},{text:"Cancel",handler:function(){copSignUpWindow.hide(this)}}]}),a=new Ext.Panel({region:"north",bodyStyle:"padding:8px",frame:!1,border:!1,html:"Sign up for Outbound Alerts to become an active partner in your local law enforcement's fight against crime. Outbound Alerts allow your law enforcement agency to send you important crime information and alerts that will allow you to act as another pair of eyes on the street."});
copSignUpWindow=new Ext.Window({title:"Outbound Alert Signup: Missouri City Police Department",layout:"border",width:400,height:300,plain:!0,items:[a,c],border:!1,modal:!0,closeAction:"hide"});copSignUpWindow.render(document.body);Ext.get("nwrButton").on("click",function(){if(void 0===h){var a=new Ext.data.ArrayStore({fields:["display","value"],data:[["12:00 a.m.","0"],["1:00 a.m.","100"],["2:00 a.m.","200"],["3:00 a.m.","300"],["4:00 a.m.","400"],["5:00 a.m.","500"],["6:00 a.m.","600"],["7:00 a.m.",
"700"],["8:00 a.m.","800"],["9:00 a.m.","900"],["10:00 a.m.","1000"],["11:00 a.m.","1100"],["12:00 p.m.","1200"],["1:00 p.m.","1300"],["2:00 p.m.","1400"],["3:00 p.m.","1500"],["4:00 p.m.","1600"],["5:00 p.m.","1700"],["6:00 p.m.","1800"],["7:00 p.m.","1900"],["8:00 p.m.","2000"],["9:00 p.m.","2100"],["10:00 p.m.","2200"],["11:00 p.m.","2300"]]}),a=new Ext.form.ComboBox({name:"time",hiddenName:"time",store:a,displayField:"display",valueField:"value",fieldLabel:"Time",typeAhead:!0,triggerAction:"all",
width:135,emptyText:"Select a time to receive the report...",forceSelection:!0,selectOnFocus:!0,mode:"local",allowBlank:!1}),b=new Ext.data.ArrayStore({fields:["display","value"],data:[["1000 ft","0.189393939"],["0.5 miles","0.5"],["1 mile","1"],["2 miles","2"],["3 miles","3"],["4 miles","4"],["5 miles","5"]]}),b=new Ext.form.ComboBox({name:"distance",hiddenName:"distance",store:b,displayField:"display",valueField:"value",fieldLabel:"Distance",typeAhead:!0,triggerAction:"all",width:135,emptyText:"Select a radius...",
forceSelection:!0,selectOnFocus:!0,mode:"local",allowBlank:!1}),c=100*(6-(new Date).getTimezoneOffset()/60),d=new Ext.FormPanel({labelWidth:70,frame:!1,border:!1,region:"center",closable:!0,bodyStyle:"padding: 4px 0 0 8px;",defaults:{width:230},defaultType:"textfield",items:[{fieldLabel:"First Name",name:"first",width:150,allowBlank:!1},{fieldLabel:"Last Name",name:"last",width:150,allowBlank:!1},{fieldLabel:"Email",name:"email",vtype:"email",width:300,allowBlank:!1},{fieldLabel:"Address",name:"address",
width:300,allowBlank:!1},{fieldLabel:"City",name:"city",width:300,allowBlank:!1},{fieldLabel:"State",name:"state",width:300,allowBlank:!1},b,{xtype:"radiogroup",fieldLabel:"Frequency",items:[{boxLabel:"Daily",name:"frequency",inputValue:1},{boxLabel:"Weekly",name:"frequency",inputValue:7,checked:!0},{boxLabel:"Monthly",name:"frequency",inputValue:30}]},a,{xtype:"hidden",name:"offset",value:c},{xtype:"checkboxgroup",fieldLabel:"Crime Types",width:650,columns:3,items:[{boxLabel:"Homicide",name:"h",
checked:!0,layout:"fit"},{boxLabel:"Attempted Homicide",name:"ah",checked:!0,layout:"fit"},{boxLabel:"Death Investigation",name:"di",checked:!0,layout:"fit"},{boxLabel:"Sexual Assault",name:"sxa",checked:!0,layout:"fit"},{boxLabel:"Sexual Offense - All Other",name:"so",checked:!0,layout:"fit"},{boxLabel:"Robbery - Commercial",name:"rc",checked:!0,layout:"fit"},{boxLabel:"Robbery - Residential",name:"ri",checked:!0,layout:"fit"},{boxLabel:"Aggravated Assault",name:"aa",checked:!0,layout:"fit"},{boxLabel:"Assault - Other",
name:"ao",checked:!0,layout:"fit"},{boxLabel:"Burglary - Commercial",name:"bc",checked:!0,layout:"fit"},{boxLabel:"Burglary - Residential",name:"br",checked:!0,layout:"fit"},{boxLabel:"Theft",name:"t",checked:!0,layout:"fit"},{boxLabel:"Fraud",name:"f",checked:!0,layout:"fit"},{boxLabel:"Shoplifting",name:"s",checked:!0,layout:"fit"},{boxLabel:"Theft - Other",name:"to",checked:!0,layout:"fit"},{boxLabel:"Motor Vehicle Theft",name:"mvt",checked:!0,layout:"fit"},{boxLabel:"Burglary from Motor Vehicle",
name:"bfv",checked:!0,layout:"fit"},{boxLabel:"Arson",name:"a",checked:!0,layout:"fit"},{boxLabel:"Disorderly Conduct",name:"dc",checked:!0,layout:"fit"},{boxLabel:"DUI",name:"dui",checked:!0,layout:"fit"},{boxLabel:"Alcohol Violation",name:"av",checked:!0,layout:"fit"},{boxLabel:"Drugs / Narcotics Violation",name:"dnv",checked:!0,layout:"fit"},{boxLabel:"Traffic Incident",name:"ti",checked:!0,layout:"fit"},{boxLabel:"Vandalism",name:"v",checked:!0,layout:"fit"},{boxLabel:"Weapons Violation",name:"wv",
checked:!0,layout:"fit"},{boxLabel:"All Other - Criminal",name:"oc",checked:!0,layout:"fit"},{boxLabel:"All Other - Non-Criminal",name:"onc",checked:!0,layout:"fit"}]}],buttons:[{text:"Sign Up",handler:function(){d.getForm().submit({clientValidation:!0,url:"NeighborhoodWatchSignUp",success:function(a,b){showMessage(b.result.title,b.result.message);h.hide()},failure:function(a,b){switch(b.failureType){case Ext.form.Action.CLIENT_INVALID:Ext.Msg.alert("Invalid Input","Please hover your mouse over the red underlines to learn more about the problem.");
break;case Ext.form.Action.CONNECT_FAILURE:showMessage("Connection Failure","Unable to connect to server.");break;case Ext.form.Action.SERVER_INVALID:showMessage(b.result.title,b.result.message)}}})}},{text:"Cancel",handler:function(){h.hide()}}]}),a=new Ext.Panel({region:"north",bodyStyle:"padding:8px",frame:!1,border:!1,html:"<b>Sign up for daily, weekly, or monthly email alerts about crime occurring within a certain distance of an address of interest, such as your home, workplace or school.</b> Please note that the quality of Neighborhood Watch Reports depends directly on the frequency agencies upload their data. If an agency does not upload data on a daily basis, then your report will not include all the crime that occurred in your area."}),
h=new Ext.Window({title:"Create a Customized Neighborhood Watch Report Subscription",layout:"border",width:700,height:600,plain:!0,items:[a,d],border:!1,modal:!0,closeAction:"hide"});h.render(document.body)}h.show(this)});a=Ext.get("requestAgencyButton");requestAgencyHandler=function(){if(void 0===c){var a=new Ext.FormPanel({labelWidth:50,frame:!1,border:!1,closable:!0,region:"center",bodyStyle:"padding: 4px 0 0 8px;",defaults:{width:230},defaultType:"textfield",items:[{fieldLabel:"Agency",name:"agency",
allowBlank:!1,emptyText:"Example: Scottsdale Police Department"},{fieldLabel:"City",name:"city"},{fieldLabel:"County",name:"county"},{fieldLabel:"State",name:"state",allowBlank:!1}],buttons:[{text:"Send Request",handler:function(){a.getForm().submit({clientValidation:!0,url:"AgencyRequest",success:function(a,b){showMessage(b.result.title,b.result.message);c.hide()},failure:function(a,b){switch(b.failureType){case Ext.form.Action.CLIENT_INVALID:Ext.Msg.alert("Invalid Input","Please hover your mouse over the red underlines to learn more about the problem.");
break;case Ext.form.Action.CONNECT_FAILURE:showMessage("Connection Failure","Unable to connect to server.");break;case Ext.form.Action.SERVER_INVALID:showMessage(b.result.title,b.result.message)}}})}},{text:"Cancel",handler:function(){c.hide(this)}}]}),b=new Ext.Panel({region:"north",bodyStyle:"padding:8px",frame:!1,border:!1,html:"Don't see your city's crimes? Ask your city to start sharing their crime data by submitting your anonymous request to RAIDS Online. RAIDS Online will compile the requests and submit the total number of requests directly to the law enforcement agency."}),
c=new Ext.Window({title:"Request an Agency",layout:"border",width:350,height:260,plain:!0,items:[b,a],border:!1,modal:!0,closeAction:"hide"});c.render(document.body)}c.show(this)};a.on("click",requestAgencyHandler);if(!1==(!0==Ext.state.Manager.getProvider().get("terms")?!0:!1)){var d=new Ext.Window({title:"Please Accept the RAIDS Online Disclaimer and Terms of Use",layout:"fit",width:350,height:150,plain:!0,html:'<div style="padding:10px;">All users of raidsonline.com must agree to the <a href="overview/terms-of-use.html" style="color: #3D5599" target="_blank">Disclaimer and Terms of Use</a>. By clicking "Continue" you agree to the <i>Disclaimer and Terms of Use</i>.</div>',
border:!1,modal:!0,closable:!1,buttons:[{text:"Continue",handler:function(){d.close();Ext.state.Manager.getProvider().set("terms",!0)}}]});d.render(document.body);d.show(this)}Ext.get("loading").remove();Ext.get("loading-mask").fadeOut({remove:!0})});var timeSliderWindow;
function openTimeSlider(a){quickDateComboBox.clearValue();void 0===timeSliderWindow&&(timeSliderWindow=new Ext.Window({applyTo:"timeSliderWindowDiv",layout:"fit",width:300,listeners:{hide:function(){$("#display-time-slider").attr("checked",!1);resetTimeSlider()}},closeAction:"hide",plain:!0,contentEl:"timeSliderBox"}));"object"==typeof a?timeSliderWindow.show(a):timeSliderWindow.show()}function closeTimeSlider(){timeSliderWindow.hide()}
function loadToolTips(){Ext.QuickTips.init();new Ext.ToolTip({target:"aggravated-assault",html:"The unlawful attack by one person upon another for the purpose of inflicting severe or aggravated bodily injury. This type of assault usually is accompanied by the use of a weapon or by means likely to produce death or great bodily harm."});new Ext.ToolTip({target:"arson",html:"The crime of intentionally and maliciously setting fire to structures or wildland areas."});new Ext.ToolTip({target:"burglary",
html:"The unlawful entry of a structure (including commercial buildings, residential buildings and motor vehicles) to commit a felony or theft."});new Ext.ToolTip({target:"homicide",html:"The willful (non-negligent) killing of one human being by another."});new Ext.ToolTip({target:"larceny",html:"The unlawful taking, carrying, leading or riding away of property from the possession or constructive possession of another."});new Ext.ToolTip({target:"motor-vehicle-theft",html:"The theft or attempted theft of a motor vehicle."});
new Ext.ToolTip({target:"robbery",html:"The taking or attempting to take anything of value from the care, custody or control of a person or persons by force or threat of force or violence and/or by putting the victim in fear."});new Ext.ToolTip({target:"sexual-assault",html:"The carnal knowledge of a female forcibly and against her will."});new Ext.ToolTip({target:"other",html:"Other includes all other data that an agency would like to share with the public. These data may include: Part II crimes, registered sex offenders, non-criminal events, etc."});
new Ext.ToolTip({target:"densityMap",html:"Density maps help determine areas of dense crime activity."});new Ext.ToolTip({target:"temporalTopology",html:"Temporal topology identifies the level of crime activity at a particular day and hour."})}var map,geocoder=new GClientGeocoder,maxNumCrimes=500,agencies=[],navMapLayer=new GGeoXml("http://www.raidsonline.com/RAIDSkml/national_agencies.kmz"),densityMapLayer,selectedLayers=[];selectedLayers.navmap=!0;
var navMapLayerOn=selectedLayers.densityMap=!1,densityMapLayerOn=!1,mapCenterOverlay,mapCenter,centerIcon=new GIcon;centerIcon.image="images/icons/center.png";centerIcon.iconSize=new GSize(26,26);centerIcon.iconAnchor=new GPoint(13,13);centerIcon.infoWindowAnchor=new GPoint(5,1);var addressBuffer,crimes=[],crimeMarkers=[],selectedCrimeTypes=[];selectedCrimeTypes.homicide=!0;selectedCrimeTypes["attempted-homicide"]=!1;selectedCrimeTypes.death=!1;selectedCrimeTypes["sexual-assault"]=!0;
selectedCrimeTypes["sexual-offense"]=!1;selectedCrimeTypes["robbery-commercial"]=!0;selectedCrimeTypes["robbery-individual"]=!0;selectedCrimeTypes["aggravated-assault"]=!0;selectedCrimeTypes["assault-other"]=!1;selectedCrimeTypes["burglary-commercial"]=!0;selectedCrimeTypes["burglary-residential"]=!0;selectedCrimeTypes.theft=!0;selectedCrimeTypes.fraud=!1;selectedCrimeTypes.shoplifting=!1;selectedCrimeTypes["theft-other"]=!1;selectedCrimeTypes["motor-vehicle-theft"]=!0;
selectedCrimeTypes["burglary-from-vehicle"]=!1;selectedCrimeTypes.arson=!0;selectedCrimeTypes.disorderly=!1;selectedCrimeTypes.dui=!1;selectedCrimeTypes.alcohol=!1;selectedCrimeTypes.drugs=!1;selectedCrimeTypes.traffic=!1;selectedCrimeTypes.vandalism=!1;selectedCrimeTypes.weapons=!1;selectedCrimeTypes["other-criminal"]=!1;selectedCrimeTypes["other-non-criminal"]=!1;var crimeTypeLookup=[];crimeTypeLookup.homicide="Homicide";crimeTypeLookup["attempted-homicide"]="Attempted Homicide";
crimeTypeLookup.death="Death Investigation";crimeTypeLookup["sexual-assault"]="Sexual Assault";crimeTypeLookup["sexual-offense"]="Sexual Offenses - Other";crimeTypeLookup["robbery-commercial"]="Robbery - Commercial";crimeTypeLookup["robbery-individual"]="Robbery - Individual";crimeTypeLookup["aggravated-assault"]="Aggravated Assault";crimeTypeLookup["assault-other"]="Assault - Other";crimeTypeLookup["burglary-commercial"]="Burglary - Commercial";crimeTypeLookup["burglary-residential"]="Burglary - Residential";
crimeTypeLookup.theft="Theft";crimeTypeLookup.fraud="Fraud";crimeTypeLookup.shoplifting="Shoplifting";crimeTypeLookup["theft-other"]="Theft \u00d0 Other";crimeTypeLookup["motor-vehicle-theft"]="Motor Vehicle Theft";crimeTypeLookup["burglary-from-vehicle"]="Burglary from Motor Vehicle";crimeTypeLookup.arson="Arson";crimeTypeLookup.disorderly="Disorderly Conduct";crimeTypeLookup.dui="DUI";crimeTypeLookup.alcohol="Alcohol Violations";crimeTypeLookup.drugs="Drugs / Narcotics Violations";
crimeTypeLookup.traffic="Traffic Incident";crimeTypeLookup.vandalism="Vandalism";crimeTypeLookup.weapons="Weapons Violations";crimeTypeLookup["other-criminal"]="All Other - Criminal";crimeTypeLookup["other-non-criminal"]="All Other - Non-Criminal";var loadedIconType,radiusDistance=0.5,onlyRadiusMarkers=!1,crimesLoading=!1,loading=0;
function initialize(){var a=void 0,b=document.URL.split("?");if(1<b.length){if(void 0!=Ext.urlDecode(b[1]).agency)a=Ext.urlDecode(b[1]).agency;else if(void 0!=Ext.urlDecode(b[1]).address)a=Ext.urlDecode(b[1]).address,"Riley County,KS"==a&&(a="Manhattan,KS");void 0!=Ext.urlDecode(b[1]).rms?loadRMSLogo(Ext.urlDecode(b[1]).rms):loadRMSLogo("raidsonline")}else loadRMSLogo("raidsonline");if(GBrowserIsCompatible())Ext.get("map_canvas").setHeight(Ext.getBody().getHeight()-140),Ext.get("map_canvas").setWidth(Ext.getBody().getWidth()-
200),map=new GMap2(document.getElementById("map_canvas")),mapCenter=new GLatLng(37.037708,-95.626438),map.setCenter(mapCenter,4),map.setUIToDefault(),G_PHYSICAL_MAP.getMinimumResolution=function(){return 4},G_NORMAL_MAP.getMinimumResolution=function(){return 4},G_SATELLITE_MAP.getMinimumResolution=function(){return 4},G_HYBRID_MAP.getMinimumResolution=function(){return 4},map.setMapType(G_PHYSICAL_MAP),void 0!=a?centerMap(a):setTimeout("showBanner('Click on a state to begin.', 5000)",1E3),drawLayers(),
GEvent.addListener(map,"zoomend",function(a,b){checkZoom(a,b)}),GEvent.addListener(map,"moveend",function(){onMove()}),Ext.get("map_canvas").setHeight("100%"),Ext.get("map_canvas").setWidth("100%"),previousZoom=map.getZoom(),GEvent.addListener(map,"infowindowprepareopen",function(a){a[0].contentElem.innerHTML=Ext.isIE?a[0].contentElem.innerHTML.replace(/href=\"http:\/\/(www\.)??raidsonline.com\/@@?/g,'href="javascript:centerMap(&#39;'):a[0].contentElem.innerHTML.replace(/href=\"@@/g,'href="javascript:centerMap(&#39;');
a[0].contentElem.innerHTML=a[0].contentElem.innerHTML.replace(/@\"/g,'&#39;);"');a[0].contentElem.innerHTML=a[0].contentElem.innerHTML.replace(/#requestagencylink#/g,"<br /><br /><h4 style='font-size: 14px; margin-bottom: 6px;'>Don't see your city?</h4><a href='javascript:requestAgencyHandler()' style='color: #000'>Ask your city to participate</a> in this free service.<br /><br />");a[0].contentElem.innerHTML=a[0].contentElem.innerHTML.replace(/_blank/g,"_parent")})}
function loadRMSLogo(a){Ext.fly("logoDiv").update('<img src="images/logos/'+a+'.png" style="margin-bottom: 4px;" id="logo" />')}function checkZoom(a,b){if(4<b&&selectedLayers.navmap)selectedLayers.navmap=!1,drawLayers();10>b&&9<a&&unloadData();10>b&&!selectedLayers.navmap&&!agencyMarkersLoaded&&loadAgencyMarkers()}function onMove(){9<map.getZoom()&&!jumpInProgress&&loadData()}
function getLoadedCrimes(){var a="[";if(crimes)for(var b=0;b<crimes.length;b++){var c=crimes[b],a=a+'{ir:"'+c[3]+'",lat:'+c[0]+",lng:"+c[1]+',d:"'+c[5]+'",c:"'+c[4]+'"}';b<crimes.length-1&&(a+=",")}return a+"]"}
function getSelectedCrimeTypes(){return"{h:"+selectedCrimeTypes.homicide+",ah:"+selectedCrimeTypes["attempted-homicide"]+",di:"+selectedCrimeTypes.death+",sxa:"+selectedCrimeTypes["sexual-assault"]+",so:"+selectedCrimeTypes["sexual-offense"]+",rc:"+selectedCrimeTypes["robbery-commercial"]+",ri:"+selectedCrimeTypes["robbery-individual"]+",aa:"+selectedCrimeTypes["aggravated-assault"]+",ao:"+selectedCrimeTypes["assault-other"]+",bc:"+selectedCrimeTypes["burglary-commercial"]+",br:"+selectedCrimeTypes["burglary-residential"]+
",t:"+selectedCrimeTypes.theft+",f:"+selectedCrimeTypes.fraud+",s:"+selectedCrimeTypes.shoplifting+",to:"+selectedCrimeTypes["theft-other"]+",mvt:"+selectedCrimeTypes["motor-vehicle-theft"]+",bfv:"+selectedCrimeTypes["burglary-from-vehicle"]+",a:"+selectedCrimeTypes.arson+",dc:"+selectedCrimeTypes.disorderly+",dui:"+selectedCrimeTypes.dui+",av:"+selectedCrimeTypes.alcohol+",dnv:"+selectedCrimeTypes.drugs+",ti:"+selectedCrimeTypes.traffic+",v:"+selectedCrimeTypes.vandalism+",wv:"+selectedCrimeTypes.weapons+
",oc:"+selectedCrimeTypes["other-criminal"]+",onc:"+selectedCrimeTypes["other-non-criminal"]+"}"}function getJSONBounds(a){var b=a.getSouthWest().lng(),c=a.getSouthWest().lat(),d=a.getNorthEast().lng(),a=a.getNorthEast().lat();return"{swx: "+b+", swy: "+c+", nex: "+d+", ney: "+a+"}"}function getRadiusDistanceValue(){return onlyRadiusMarkers?radiusDistance:0}
function parseCrimes(a){if(a.records)for(var b=0;b<a.records.length;b++){var c=[];c[0]=a.records[b][0];c[1]=a.records[b][1];c[2]=a.records[b][2];c[3]=a.records[b][3];c[4]=a.records[b][4];c[5]=a.records[b][5];c[6]=a.records[b][6];c[7]=a.records[b][7];c[8]=a.records[b][8];c[9]=a.records[b][9];c[10]=a.records[b][10];c[11]=a.records[b][11];c[12]=a.records[b][12];c[13]=a.records[b][13];c[14]=a.records[b][14];c[15]=!0;crimes.push(c)}}
function unloadCrimes(a){if(a)for(var b=0;b<a.length;b++)removeCrimeMarker(a[b])}function unloadData(){removeCrimeMarkers();othersLoaded=!1;agencies=[];metadataCheck();crimes=[];clearGrid();addressBuffer&&hideAddressBuffer();mapCenterOverlay&&(map.removeOverlay(mapCenterOverlay),mapCenterOverlay=void 0)}
function loadData(){9<map.getZoom()&&(loading++,void 0===mapCenterOverlay&&(mapCenterOverlay=new GMarker(mapCenter,{icon:centerIcon}),map.addOverlay(mapCenterOverlay)),checkAddressBuffer(),unloadAgencyMarkers(),$.post("Raids",{d1:toSQLdate(startDate),d2:toSQLdate(endDate),currentBounds:getJSONBounds(map.getBounds()),x:mapCenter.lng(),y:mapCenter.lat(),loaded:getLoadedCrimes(),crimeTypes:getSelectedCrimeTypes(),radius:getRadiusDistanceValue()},function(a){if(a&&1>=loading)!0===a.removeAll?(crimes=
[],removeCrimeMarkers()):unloadCrimes(a.unload),parseCrimes(a),agencies=a.agencies,0<crimes.length?loadGrid():clearGrid(),drawMarkers(),metadataCheck(),analyticsCheck(),checkMaxCrimes(a.first);loading--},"json"))}function checkAddressBuffer(){addressBuffer&&drawAddressBuffer(80,"#000",2,1,"#000",0.4)}
function drawMarkers(){checkAddressBuffer();if(crimes&&9<map.getZoom()){var a=map.getZoom(),a=13<a?"marker":11<a?"dots":"points";if(a!=loadedIconType){crimeMarkers&&removeCrimeMarkers();for(var b=0;b<crimes.length;b++)crimes[b][crimes[b].length-1]=!0}for(b=0;b<crimes.length;b++){var c=crimes[b];if(!0===c[c.length-1]){var d=new GLatLng(c[0],c[1]),d=createMarker(d,c[2],c[3],c[4],new Date(c[5]),c[6],c[7],c[8],c[12],c[11],c[10],c[13],c[14]);map.addOverlay(d);crimeMarkers.push(d);c[c.length-1]=!1}}loadedIconType=
a}}
function createMarker(a,b,c,d,e,f,j,k,h,o,p,n,l){var i=d,d=crimeTypeLookup[d],m;if(13<map.getZoom()){var g=new GIcon;g.iconSize=new GSize(32,37);g.iconAnchor=new GPoint(16,37);g.infoWindowAnchor=new GPoint(32,0);g.image="images/icons/"+i+".png"}else 11<map.getZoom()?(g=new GIcon,g.iconSize=new GSize(18,18),g.iconAnchor=new GPoint(9,9),g.infoWindowAnchor=new GPoint(9,9),g.image="images/icons/dots-"+i+".png"):(g=new GIcon,g.iconSize=new GSize(11,11),g.iconAnchor=new GPoint(5,5),g.infoWindowAnchor=new GPoint(5,
5),g.image="images/icons/points-"+i+".png");m=new GMarker(a,{icon:g,title:c});a="";!0===l&&(a="<br/><br/><small>** This point has been randomly offset at the request of the agency to protect victim privacy.</small>");l="";"0"!=n&&(l="<br /><div style='border-top: 1px solid #C0C0C0; margin: 10px 0 8px 0;'></div><img src='images/logos/tip411-10x32.png' style='margin-right: 4px;' /><a href='http://www.citizenobserver.com/cov6/app/webTipForm.html?id="+n+"&ir="+c+"' target='_blank' class='tip-link'>Submit an anonymous tip</a>");
var q="<div style='width: 264px'><div><div style='position: absolute; top: -15px; height: 30px; left: -16px; width: 30px;'><img src='images/popups/"+i+"-pop-corner-left.png' style='border: 0px; margin: 0px; padding: 0px; position: absolute; left: 0px; top: 0px; width: 30px; height: 30px;' /></div><div style='position: absolute; top: -15px; height: 30px; left: 14px; width: 236px;'><img src='images/popups/"+i+"-pop-center.png' style='border: 0px; margin: 0px; padding: 0px; position: absolute; left: 0px; top: 0px; width: 236px; height: 30px;' /></div><div style='position: absolute; top: -15px; height: 30px; left: 250px; width: 30px;'><img src='images/popups/"+
i+"-pop-corner-right.png' style='border: 0px; margin: 0px; padding: 0px; position: absolute; left: 0px; top: 0px; width: 30px; height: 30px;' /></div></div><div style='position: absolute; left: 0px; top: -12px; padding-top: 5px; font-size: 18px;font-family: sans-serif; font-weight: bold; color: #fff; '>"+d+"</div><div style='margin-top: 25px;'><span style='font-size: 12px; font-family: sans-serif;'><b>Crime:</b> "+b+"<br /><b>Incident:</b> "+c+"<br/><b>Date:</b> "+(e.getMonth()+1)+"-"+e.getDate()+
"-"+e.getFullYear()+"<br /><b>Time:</b> "+o+"<br/><b>Location:</b> "+f+"<br /><b>Address:</b> "+j+"<br /><b>Geocode Accuracy:</b>  "+p+"<br /><div style='border-top: 1px solid #C0C0C0; margin: 10px 0 8px 0;'></div><b>Distance:</b>  "+h+"<br /><div style='border-top: 1px solid #C0C0C0; margin: 10px 0 8px 0;'></div><b>Agency:</b>  "+k+l+a+"</span></div></div>";GEvent.addListener(m,"click",function(){m.openInfoWindowHtml(q)});return m}
function createAgencyMarker(a,b,c,d,e){a=a.replace("\\","");a=new GIcon;a.iconSize=new GSize(32,37);a.iconAnchor=new GPoint(16,37);a.infoWindowAnchor=new GPoint(32,0);a.image=e?"images/icons/sheriff.png":"images/icons/police.png";b=new GMarker(new GLatLng(d,c),{title:b,icon:a});GEvent.addListener(b,"click",function(){centerMap(new GLatLng(d,c))});return b}
function loadAgencyMarkers(){agencyStore&&(agencyStore.each(function(a){a=a.data;a=createAgencyMarker(a.name,a.location,a.lng,a.lat,a.sheriff);map.addOverlay(a);agencyMarkers.push(a)}),agencyMarkersLoaded=!0)}function unloadAgencyMarkers(){if(agencyMarkersLoaded){for(var a=0;a<agencyMarkers.length;a++)map.removeOverlay(agencyMarkers[a]);agencyMarkers=[];agencyMarkersLoaded=!1}}
function centerMap(a){geocoder.getLatLng(a,function(b){b?(mapCenter=b,mapCenterOverlay&&map.removeOverlay(mapCenterOverlay),mapCenterOverlay=new GMarker(b,{icon:centerIcon}),map.addOverlay(mapCenterOverlay),map.savePosition(),jumpInProgress=!0,10>map.getZoom()&&map.setZoom(13),jumpInProgress=!1,map.setCenter(mapCenter),$.get("Log",{type:"address",address:a,x:b.x,y:b.y})):showMessage("Address Not Found","Please check the address for accuracy and try again.")})}
function drawAddressBuffer(a){if(9<map.getZoom()){for(var b=[],c=mapCenter.lat(),d=mapCenter.lng(),e=radiusDistance/3963*(180/Math.PI),f=e/Math.cos(c*(Math.PI/180)),j=0;j<a;j++){var k=Math.PI*(j/(a/2));Cx=d+f*Math.cos(k);Cy=c+e*Math.sin(k);b.push(new GLatLng(Cy,Cx))}addressBuffer&&map.removeOverlay(addressBuffer);b.push(b[0]);addressBuffer=new GPolygon(b,"#000000",2,1,"#000000",0.4);map.addOverlay(addressBuffer)}}function hideAddressBuffer(){map.removeOverlay(addressBuffer)}
function removeAddressBuffer(a){addressBuffer&&(map.removeOverlay(addressBuffer),addressBuffer=a)}function removeCrimeMarkers(){for(var a=0;a<crimeMarkers.length;a++)map.removeOverlay(crimeMarkers[a]);crimeMarkers=[]}function removeCrimeMarker(a){for(var b=0,c=0,d=0;d<crimeMarkers.length;d++)if(crimeMarkers[d].getTitle()==a){map.removeOverlay(crimeMarkers[d]);b=d;break}for(d=0;d<crimes.length;d++)if(crimes[d][3]==a){c=d;break}crimeMarkers.splice(b,1);crimes.splice(c,1)}
function toSQLdate(a){return a.getMonth()+1+"-"+a.getDate()+"-"+a.getFullYear()}function drawLayers(){selectedLayers.navmap?(map.addOverlay(navMapLayer),navMapLayerOn=!0):navMapLayerOn&&(map.removeOverlay(navMapLayer),navMapLayerOn=!1);selectedLayers.densityMap?(densityMapLayer?map.addOverlay(densityMapLayer):calculateDensityMap(),densityMapLayerOn=!0):densityMapLayerOn&&(map.removeOverlay(densityMapLayer),densityMapLayerOn=!1)}
function overlayDensityMap(a){densityMapLayer=new GGroundOverlay("DensityMapStream?id="+a,map.getBounds());map.addOverlay(densityMapLayer)}function checkMaxCrimes(a){crimes.length>=maxNumCrimes&&(showBanner("You have reached the max number of incidents. The 500 most recent crimes are showing.",5E3),a&&(startDate=new Date(a),Ext.getCmp("startdt").setValue(startDate)))}
function showBanner(a,b){Ext.fly("banner").update("<center>"+a+"</center>");Ext.get("banner").fadeIn({endOpacity:0.8});setTimeout("Ext.get('banner').fadeOut({useDisplay:true})",b)}function showMessage(a,b){Ext.MessageBox.show({title:a,msg:b,buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.INFO})}
var grid,gridFields=[{name:"Class"},{name:"Incident"},{name:"Crime"},{name:"DateTime",type:"date",dateFormat:"Y-m-d H:i"},{name:"Location"},{name:"Address"},{name:"Distance"},{name:"Accuracy"},{name:"Agency"}],gridColumns=[{header:"Class",width:55,sortable:!0,dataIndex:"Class"},{header:"Incident",sortable:!0,dataIndex:"Incident"},{id:"Crime",header:"Crime",sortable:!0,dataIndex:"Crime"},{header:"Date / Time",sortable:!0,dataIndex:"DateTime",renderer:Ext.util.Format.dateRenderer("M j, Y g:i a")},{header:"Location",
sortable:!0,dataIndex:"Location"},{header:"Address",sortable:!0,dataIndex:"Address"},{header:"Distance",sortable:!0,dataIndex:"Distance"},{header:"Accuracy",sortable:!0,dataIndex:"Accuracy"},{header:"Agency",sortable:!0,dataIndex:"Agency"}],gridStore=new Ext.data.JsonStore({url:"Grid",root:"records",totalProperty:"count",fields:gridFields,remoteSort:!0,sortInfo:{field:"DateTime",direction:"DESC"}});
Ext.onReady(function(){grid=new Ext.grid.GridPanel({id:"gridPanel",viewConfig:{forceFit:!0},store:gridStore,columns:gridColumns,renderTo:"grid_canvas",border:!1,loadMask:!0,columnLines:!0,stripeRows:!0,bbar:new Ext.PagingToolbar({pageSize:20,store:gridStore,displayInfo:!0,displayMsg:"Displaying records {0} - {1} of {2}",emptyMsg:"No crime in view"}),stateful:!0,stateId:"grid"});gridStore.on("beforeload",function(){gridStore.setBaseParam("d1",toSQLdate(startDate));gridStore.setBaseParam("d2",toSQLdate(endDate));
gridStore.setBaseParam("currentBounds",getJSONBounds(map.getBounds()));gridStore.setBaseParam("crimeTypes",getSelectedCrimeTypes());gridStore.setBaseParam("radius",getRadiusDistanceValue());gridStore.setBaseParam("x",mapCenter.lng());gridStore.setBaseParam("y",mapCenter.lat());gridStore.setBaseParam("n",crimes.length)});grid.getBottomToolbar().refresh.hideParent=!0;grid.getBottomToolbar().refresh.hide()});
function loadGrid(){9<map.getZoom()&&gridStore.load({params:{start:0,limit:20,d1:toSQLdate(startDate),d2:toSQLdate(endDate),currentBounds:getJSONBounds(map.getBounds()),crimeTypes:getSelectedCrimeTypes(),radius:getRadiusDistanceValue(),x:mapCenter.lng(),y:mapCenter.lat(),n:crimes.length}})}function clearGrid(){gridStore.removeAll()}google.load("visualization","1",{packages:["piechart"]});google.load("visualization","1",{packages:["barchart"]});google.load("visualization","1",{packages:["linechart"]});
var tools,analyticPanel,dashboardPanel,maximized=!1,maximizedAnalytic,analytics=[],analysisTitleLookup=[];analysisTitleLookup.crimeTypePieChart="Crime Type Frequency";analysisTitleLookup.crimeTypeByDayOfWeek="Crime Type by Day of Week";analysisTitleLookup.crimeTypeTimeline="Crime Type Timeline";analysisTitleLookup.temporalTopology="Temporal Topology";var analysisIdLookup=[];analysisIdLookup["Crime Type Frequency"]="crimeTypePieChart";analysisIdLookup["Crime Type by Day of Week"]="crimeTypeByDayOfWeek";
analysisIdLookup["Crime Type Timeline"]="crimeTypeTimeline";analysisIdLookup["Temporal Topology"]="temporalTopology";
Ext.onReady(function(){var a=$("#map_canvas").width(),b=$("#map_canvas").height();!Ext.isChrome&&!Ext.isSafari&&(tools=[{id:"minimize",hidden:!0,handler:function(a,b,e){maximized=!1;var a=Ext.getCmp("center-panel"),b=Ext.getCmp("center-panel-col0"),f=0;b.remove(e,!1);b.hide();e.tools.maximize.setVisible(!0);e.tools.minimize.setVisible(!1);e.setSize(e.originalSize);Ext.isIE||e.setHeight(e.originalHeight);e.originalOwnerCt.insert(e.originalPosition,e);for(e.originalOwnerCt.doLayout();f<a.items.keys.length;)a.items.keys[f]!=
b.id&&a.items.items[f].el.setDisplayed("inline"),++f;a.doLayout();maximizedAnalytic=void 0;updateAnalytics()}},{id:"maximize",handler:function(a,b,e){maximized=!0;e.originalOwnerCt=e.ownerCt;e.originalPosition=e.ownerCt.items.indexOf(e);e.originalSize=e.getSize();e.originalHeight=e.getInnerHeight();for(var a=Ext.getCmp("center-panel"),b=Ext.getCmp("center-panel-col0"),f=0;f<a.items.keys.length;)a.items.keys[f]!=b.id&&a.items.items[f].el.setDisplayed("none"),++f;e.ownerCt.remove(e,!1);b.setWidth(b.ownerCt.getWidth()-
2);b.setHeight(b.ownerCt.getHeight()-2);b.doLayout();b.show();e.tools.maximize.setVisible(!1);e.tools.minimize.setVisible(!0);e.setWidth(b.ownerCt.getInnerWidth());e.setHeight(b.ownerCt.getInnerHeight());b.items.add(e);maximizedAnalytic=analysisIdLookup[e.title];redraw(analysisIdLookup[e.title],"100%")}}]);dashboardPanel=[{xtype:"portal",region:"center",id:"center-panel",border:!1,frame:!1,listeners:{resize:{fn:function(){var a=Ext.getCmp("center-panel-col0");a.isVisible()&&a.setSize(a.ownerCt.getSize())},
scope:this},drop:function(a){redraw(analysisIdLookup[a.panel.title],getPortletHeight())}},autoScroll:!0,items:[{columnWidth:1,id:"center-panel-col0",layout:"fit",hidden:!0},{columnWidth:0.5,id:"center-panel-col1",style:"padding:5px 0 0 5px",items:[]},{columnWidth:0.5,id:"center-panel-col2",style:"padding:5px 5px 0 5px",items:[]}]}];analyticPanel=new Ext.Panel({id:"analyticsPanel",renderTo:"analytics_canvas",width:a,height:b,layout:"border",border:!1,items:[dashboardPanel]});loadDefaultAnalytics()});
function loadDefaultAnalytics(){addPortlet("crimeTypePieChart");addPortlet("crimeTypeByDayOfWeek");addPortlet("crimeTypeTimeline");addPortlet("temporalTopology")}function addPortlet(a){if(!analysisExists(a)){var b=Ext.getCmp("center-panel"),c=Ext.getCmp("center-panel-col1"),d=Ext.getCmp("center-panel-col2");(d.items.length>=c.items.length?c:d).add({bodyStyle:"backgroundColor: #FFFFFF;",title:analysisTitleLookup[a],tools:tools,contentEl:a});b.doLayout();addAnalytic(a)}}
function redraw(a){for(var b,c=0;c<analytics.length;c++)analytics[c].analysisID==a&&(b=analytics[c]);void 0!=b&&setTimeout("this.draw()",50);this.draw=function(){var c=getPortletWidth(),e=getPortletHeight();maximizedAnalytic==a&&(c=getPortalWidth(),e=getPortalHeight(),Ext.getCmp("center-panel-col0").setWidth(c));$("#"+a).empty();$("#"+a).width(c);$("#"+a).height(e);b.redraw()}}
function updateAnalytics(){for(var a=getPortletWidth(),b=getPortletHeight(),c=getCrimesToAnalyze(),d=analytics.length,e=0;e<d;e++){var f=analytics[e].analysisID;$("#"+f).empty();crimes&&0<crimes.length?($("#"+f).width(a),$("#"+f).height(b),$.post("Analytics",{analysis:f,crimes:c,width:a,height:b},function(a){a=eval(a);analytics.push(a);a.draw()},"script")):(f=getEmptyAnalytic(f),analytics.push(f),f.draw())}for(e=0;e<d;e++)analytics.shift()}
function updateSingleAnalytic(a){$("#"+a).empty();var b=getPortletWidth(),c=getPortletHeight();maximizedAnalytic==a&&(b=getPortalWidth(),c=getPortalHeight(),Ext.getCmp("center-panel-col0").setWidth(b));$("#"+a).width(b);$("#"+a).height(c);if(crimes&&0<crimes.length){var d=getCrimesToAnalyze();$.post("Analytics",{analysis:a,crimes:d,width:b,height:c},function(b){b=eval(b);removeAnalytic(a);analytics.push(b);b.draw()},"script")}else b=getEmptyAnalytic(a),analytics.push(b),b.draw()}
function addAnalytic(a){var b=getPortletWidth(),c=getPortletHeight();$("#"+a).height(c);if(crimes&&0<crimes.length){var d=getCrimesToAnalyze();$.post("Analytics",{analysis:a,crimes:d,width:b,height:c},function(a){a=eval(a);analytics.push(a);a.draw()},"script")}else a=getEmptyAnalytic(a),analytics.push(a),a.draw()}function getPortletHeight(){return Math.round($("#analytics_canvas").height()/2-25-15)}function getPortletWidth(){return Math.round($("#analytics_canvas").width()/2-15)}
function getPortalWidth(){return Math.round($("#analytics_canvas").width())}function getPortalHeight(){return Math.round($("#analytics_canvas").height()-25)}
function getEmptyAnalytic(a){var b=getPortletHeight()/3,c=getPortletWidth()/4,b="padding: "+b+" "+c+" 0 "+c,c="<b>Zoom Level Too High</b><br/>Zoom in to an area with crime to view analytics.";map&&9<map.getZoom()&&(c="<b>No Crime in View</b><br/>Navigate to an area with crime to view analytics.");var d='<div style="'+b+'; color: #333">'+c+"</div>";return new function(){this.analysisID=a;this.initialized=!1;this.draw=function(){$("#"+a).html(d)};this.redraw=function(){this.draw()}}}
function removeAnalytic(a){for(var b,c=0;c<analytics.length;c++)analytics[c].analysisID==a&&(b=c);analytics.splice(b,1)}function analysisExists(a){for(var b=!1,c=0;c<analytics.length;c++)analytics[c].analysisID==a&&(b=!0);return b}
function calculateDensityMap(){9<map.getZoom()&&1<crimes.length?($("#calcDensityCell").html('<span class="calculateLink">Calculating...</span>'),densityMapLayer&&map.removeOverlay(densityMapLayer),$.post("Analytics",{analysis:"densityMap",crimes:getCrimesToAnalyze(),bounds:getBoundsObject(),resolution:resolutionSlider.getValue()},function(a){overlayDensityMap(a);$("#calcDensityCell").html('<a class="calculateLink" href="javascript:calculateDensityMap();">Calculate</a>')},"text")):showMessage("No Crime in View",
"Please move to an area with multiple incidents in order to view a density map.")}function getCrimesToAnalyze(){var a="{crimes: [";for(x in crimes)crime=crimes[x],void 0!=crime[0]&&"other"!=crime[4]&&(a=a+'{x:"'+crime[1]+'",',a=a+'y:"'+crime[0]+'",',a=a+'u:"'+crime[4]+'",',a=a+'c:"'+crime[2]+'",',a=a+'i:"'+crime[3]+'",',a=a+'d:"'+crime[5]+'",',a=a+'t:"'+crime[9]+'",',a=a+'l:"'+crime[6]+'",',a=a+'a:"'+crime[7]+'",',a=a+'p:"'+crime[8]+'"},');return a+"]}"}
function getBoundsObject(){var a=map.getBounds(),b=a.getSouthWest().lng(),c=a.getSouthWest().lat(),d=a.getNorthEast().lng(),a=a.getNorthEast().lat();return"{bounds:{swx: "+b+", swy: "+c+", nex: "+d+", ney: "+a+"}}"}function analyticsCheck(){"Analytics"==Ext.getCmp("tabs").getActiveTab().title&&(!1==maximized?updateAnalytics():updateSingleAnalytic(maximizedAnalytic))}
function updateMetadata(){$.post("Metadata",{agencies:Ext.encode(agencies),crimes:Ext.encode(getMetadataCrimes())},function(a){Ext.fly("metadata_canvas").update(a)},"html")}function getMetadataCrimes(){var a=[];if(crimes)for(var b=0;b<crimes.length;b++){var c=crimes[b];a[b]={d:new Date(c[5]),a:c[10],n:c[8]}}return a}function metadataCheck(){"Metadata"==Ext.getCmp("tabs").getActiveTab().title&&updateMetadata()}
$(function(){function a(a){return a.getMonth()+1+"-"+a.getDate()+"-"+a.getFullYear()}Ext.get("search-address-input").dom.value="";$("#radius-on").hide();$("#toggle-radius").attr("checked",!1);$("#radius-display-checkbox").attr("checked",!1);$("#radius-display-checkbox").attr("disabled",!0);$("#radius-distance-dropdown").attr("disabled",!0);$("#default-distance-option").attr("selected",!0);$("#aggravated-assault-checkbox").attr("checked",!0);$("#arson-checkbox").attr("checked",!0);$("#burglary-checkbox").attr("checked",
!0);$("#homicide-checkbox").attr("checked",!0);$("#larceny-checkbox").attr("checked",!0);$("#motor-vehicle-theft-checkbox").attr("checked",!0);$("#robbery-checkbox").attr("checked",!0);$("#sexual-assault-checkbox").attr("checked",!0);$("#other-checkbox").attr("checked",!1);$("#densityMap-checkbox").attr("checked",!1);$("#toggle-radius").click(function(){$(this).attr("checked")?void 0===mapCenterOverlay?(showMessage("No Map Center Selected","Please select a location using the address search field or the jump agency menu before turning on the address buffer."),
$("#toggle-radius").attr("checked",!1)):($("#radius-distance-dropdown").attr("disabled",!1),$("#radius-display-checkbox").attr("disabled",!1),$("#radius-on").show(),$("#radius-off").hide(),$("#radius-display-label").removeClass("radius-display-label-off"),$("#radius-display-checkbox").attr("checked")&&(onlyRadiusMarkers=!0),addressBuffer=!0,onlyRadiusMarkers?loadData():(drawMarkers(),analyticsCheck(),metadataCheck())):($("#radius-distance-dropdown").attr("disabled",!0),$("#radius-display-checkbox").attr("disabled",
!0),$("#radius-on").hide(),$("#radius-off").show(),$("#radius-display-label").addClass("radius-display-label-off"),onlyRadiusMarkers?(onlyRadiusMarkers=!1,loadData()):(onlyRadiusMarkers=!1,drawMarkers(),analyticsCheck(),metadataCheck()),removeAddressBuffer(!1))});$("#radius-distance-dropdown").change(function(){var a=$("#radius-distance-dropdown").val();"1000 ft"==a?a=0.189393939:(a=a.replace(" miles",""),a=a.replace(" mile",""));radiusDistance=a;onlyRadiusMarkers?loadData():(drawMarkers(),analyticsCheck(),
metadataCheck())});$("#radius-display-checkbox").click(function(){onlyRadiusMarkers=$(this).attr("checked")?!0:!1;loadData()});$(".crime-type-row").click(function(){selectedCrimeTypes[this.id]?(selectedCrimeTypes[this.id]=!1,$("#"+this.id+"-checkbox").attr("checked",!1)):(selectedCrimeTypes[this.id]=!0,$("#"+this.id+"-checkbox").attr("checked",!0));loadData()});$("#select-button").click(function(){$("#homicide-checkbox").attr("checked",!0);$("#attempted-homicide-checkbox").attr("checked",!0);$("#death-checkbox").attr("checked",
!0);$("#sexual-assault-checkbox").attr("checked",!0);$("#sexual-offense-checkbox").attr("checked",!0);$("#robbery-commercial-checkbox").attr("checked",!0);$("#robbery-individual-checkbox").attr("checked",!0);$("#aggravated-assault-checkbox").attr("checked",!0);$("#assault-other-checkbox").attr("checked",!0);$("#burglary-commercial-checkbox").attr("checked",!0);$("#burglary-residential-checkbox").attr("checked",!0);$("#theft-checkbox").attr("checked",!0);$("#fraud-checkbox").attr("checked",!0);$("#shoplifting-checkbox").attr("checked",
!0);$("#theft-other-checkbox").attr("checked",!0);$("#motor-vehicle-theft-checkbox").attr("checked",!0);$("#burglary-from-vehicle-checkbox").attr("checked",!0);$("#arson-checkbox").attr("checked",!0);$("#disorderly-checkbox").attr("checked",!0);$("#dui-checkbox").attr("checked",!0);$("#alcohol-checkbox").attr("checked",!0);$("#drugs-checkbox").attr("checked",!0);$("#traffic-checkbox").attr("checked",!0);$("#vandalism-checkbox").attr("checked",!0);$("#weapons-checkbox").attr("checked",!0);$("#other-criminal-checkbox").attr("checked",
!0);$("#other-non-criminal-checkbox").attr("checked",!0);selectedCrimeTypes.homicide=!0;selectedCrimeTypes["attempted-homicide"]=!0;selectedCrimeTypes.death=!0;selectedCrimeTypes["sexual-assault"]=!0;selectedCrimeTypes["sexual-offense"]=!0;selectedCrimeTypes["robbery-commercial"]=!0;selectedCrimeTypes["robbery-individual"]=!0;selectedCrimeTypes["aggravated-assault"]=!0;selectedCrimeTypes["assault-other"]=!0;selectedCrimeTypes["burglary-commercial"]=!0;selectedCrimeTypes["burglary-residential"]=!0;
selectedCrimeTypes.theft=!0;selectedCrimeTypes.fraud=!0;selectedCrimeTypes.shoplifting=!0;selectedCrimeTypes["theft-other"]=!0;selectedCrimeTypes["motor-vehicle-theft"]=!0;selectedCrimeTypes["burglary-from-vehicle"]=!0;selectedCrimeTypes.arson=!0;selectedCrimeTypes.disorderly=!0;selectedCrimeTypes.dui=!0;selectedCrimeTypes.alcohol=!0;selectedCrimeTypes.drugs=!0;selectedCrimeTypes.traffic=!0;selectedCrimeTypes.vandalism=!0;selectedCrimeTypes.weapons=!0;selectedCrimeTypes["other-criminal"]=!0;selectedCrimeTypes["other-non-criminal"]=
!0;loadData()});$("#deselect-button").click(function(){$("#homicide-checkbox").attr("checked",!1);$("#attempted-homicide-checkbox").attr("checked",!1);$("#death-checkbox").attr("checked",!1);$("#sexual-assault-checkbox").attr("checked",!1);$("#sexual-offense-checkbox").attr("checked",!1);$("#robbery-commercial-checkbox").attr("checked",!1);$("#robbery-individual-checkbox").attr("checked",!1);$("#aggravated-assault-checkbox").attr("checked",!1);$("#assault-other-checkbox").attr("checked",!1);$("#burglary-commercial-checkbox").attr("checked",
!1);$("#burglary-residential-checkbox").attr("checked",!1);$("#theft-checkbox").attr("checked",!1);$("#fraud-checkbox").attr("checked",!1);$("#shoplifting-checkbox").attr("checked",!1);$("#theft-other-checkbox").attr("checked",!1);$("#motor-vehicle-theft-checkbox").attr("checked",!1);$("#burglary-from-vehicle-checkbox").attr("checked",!1);$("#arson-checkbox").attr("checked",!1);$("#disorderly-checkbox").attr("checked",!1);$("#dui-checkbox").attr("checked",!1);$("#alcohol-checkbox").attr("checked",
!1);$("#drugs-checkbox").attr("checked",!1);$("#traffic-checkbox").attr("checked",!1);$("#vandalism-checkbox").attr("checked",!1);$("#weapons-checkbox").attr("checked",!1);$("#other-criminal-checkbox").attr("checked",!1);$("#other-non-criminal-checkbox").attr("checked",!1);selectedCrimeTypes.homicide=!1;selectedCrimeTypes["attempted-homicide"]=!1;selectedCrimeTypes.death=!1;selectedCrimeTypes["sexual-assault"]=!1;selectedCrimeTypes["sexual-offense"]=!1;selectedCrimeTypes["robbery-commercial"]=!1;
selectedCrimeTypes["robbery-individual"]=!1;selectedCrimeTypes["aggravated-assault"]=!1;selectedCrimeTypes["assault-other"]=!1;selectedCrimeTypes["burglary-commercial"]=!1;selectedCrimeTypes["burglary-residential"]=!1;selectedCrimeTypes.theft=!1;selectedCrimeTypes.fraud=!1;selectedCrimeTypes.shoplifting=!1;selectedCrimeTypes["theft-other"]=!1;selectedCrimeTypes["motor-vehicle-theft"]=!1;selectedCrimeTypes["burglary-from-vehicle"]=!1;selectedCrimeTypes.arson=!1;selectedCrimeTypes.disorderly=!1;selectedCrimeTypes.dui=
!1;selectedCrimeTypes.alcohol=!1;selectedCrimeTypes.drugs=!1;selectedCrimeTypes.traffic=!1;selectedCrimeTypes.vandalism=!1;selectedCrimeTypes.weapons=!1;selectedCrimeTypes["other-criminal"]=!1;selectedCrimeTypes["other-non-criminal"]=!1;loadData()});$("#display-time-slider").click(function(){var b=Ext.getCmp("startdt"),c=Ext.getCmp("enddt");if($("#display-time-slider").attr("checked")){var c=Math.round((c.getValue()-b.getValue())/864E5),d=Math.round(c/4),e=b.getValue();$("#timeSlider").slider({range:!0,
min:0,max:c,values:[d,c-d],slide:function(b,c){startDate=e.getTime()+864E5*c.values[0];endDate=e.getTime()+864E5*c.values[1];$("#date-range-label").val("Range: "+a(new Date(startDate))+" to "+a(new Date(endDate)));startDate=new Date(startDate);endDate=new Date(endDate);loadData();Ext.getCmp("startdt").setValue(startDate);Ext.getCmp("enddt").setValue(endDate)}});startDate=e.getTime()+864E5*$("#timeSlider").slider("values",0);endDate=e.getTime()+864E5*$("#timeSlider").slider("values",1);$("#date-range-label").val("Range: "+
a(new Date(startDate))+" to "+a(new Date(endDate)));startDate=new Date(startDate);endDate=new Date(endDate);loadData();openTimeSlider();Ext.getCmp("startdt").setValue(startDate);Ext.getCmp("enddt").setValue(endDate)}else resetTimeSlider()});$(".layers-cell").click(function(){var a=$(this).closest("tr").attr("id");selectedLayers[a]?("densityMap"==a&&$("#calcDensityCell").html(""),selectedLayers[a]=!1,$("#"+a+"-checkbox").attr("checked",!1)):(selectedLayers[a]=!0,$("#"+a+"-checkbox").attr("checked",
!0),"densityMap"==a&&(9<map.getZoom()&&1<crimes.length?$("#calcDensityCell").html('<a class="calculateLink" href="javascript:calculateDensityMap();">Calculate</a>'):(selectedLayers[a]=!1,$("#"+a+"-checkbox").attr("checked",!1),showMessage("No Crime in View","Please move to an area with multiple incidents in order to view a density map."))));drawLayers()});$().ajaxSend(function(){var a=$(window).width()/2-55,c=$(window).height()/2-20;$("#contentLoading").css("left",a+"px");$("#contentLoading").css("top",
c+"px");$("#contentLoading").fadeIn("fast")});$().ajaxStop(function(){$("#contentLoading").fadeOut("fast")})});function resetTimeSlider(){closeTimeSlider();$("#timeSlider").slider("destroy");$("#date-range-label").val("");Ext.getCmp("startdt").setValue(new Date(startDate));Ext.getCmp("enddt").setValue(new Date(endDate))}
function startLoad(){var a=Ext.get("contentLoading"),b=$(window).width()/2,c=$(window).height()/2;a.setStyle("left",b+"px");a.setStyle("top",c+"px");a.setStyle("visibility","visible")}function endLoad(){Ext.get("contentLoading").setStyle("visibility","hidden")}
Ext.override(Ext.data.Store,{add:function(a){a=[].concat(a);if(!(1>a.length)){for(var b=0,c=a.length;b<c;b++)a[b].join(this);b=this.data.length;this.data.addAll(a);this.snapshot&&this.snapshot.addAll(a);this.totalLength+=a.length;this.fireEvent("add",this,a,b)}},insert:function(a,b){for(var b=[].concat(b),c=0,d=b.length;c<d;c++)this.data.insert(a,b[c]),b[c].join(this);this.snapshot&&this.snapshot.addAll(b);this.totalLength+=b.length;this.fireEvent("add",this,b,a)},remove:function(a){Ext.isArray(a)&&
Ext.each(a,function(a){this.remove(a)},this);var b=this.data.indexOf(a);-1<b&&(a.join(null),this.data.removeAt(b),this.totalLength--);this.pruneModifiedRecords&&this.modified.remove(a);this.snapshot&&this.snapshot.remove(a);-1<b&&this.fireEvent("remove",this,a,b)},removeAll:function(a){var b=[];this.each(function(a){b.push(a)});this.clearData();this.totalLength=0;this.snapshot&&this.snapshot.clear();if(this.pruneModifiedRecords)this.modified=[];!0!==a&&this.fireEvent("clear",this,b)}});
Ext.override(Ext.PagingToolbar,{bindStore:function(a,b){var c;if(!b&&this.store&&(a!==this.store&&this.store.autoDestroy?this.store.destroy():(this.store.un("beforeload",this.beforeLoad,this),this.store.un("load",this.onLoad,this),this.store.un("exception",this.onLoadError,this),this.store.un("datachanged",this.onChange,this),this.store.un("add",this.onChange,this),this.store.un("remove",this.onChange,this),this.store.un("clear",this.onClear,this)),!a))this.store=null;a&&(a=Ext.StoreMgr.lookup(a),
a.on({scope:this,beforeload:this.beforeLoad,load:this.onLoad,exception:this.onLoadError,datachanged:this.onChange,add:this.onChange,remove:this.onChange,clear:this.onClear}),c=!0);this.store=a;if(c)this.onLoad(a,null,{})},onLoad:function(a,b,c){this.rendered?(a=this.getParams(),this.cursor=c.params&&c.params[a.start]?c.params[a.start]:0,this.getPageData(),this.onChange()):this.dsLoaded=[a,b,c]},onChange:function(){if(this.rendered){var a=this.getPageData(),b=a.activePage,c=a.pages;this.afterTextItem.setText(String.format(this.afterPageText,
a.pages));this.inputItem.setValue(b);this.first.setDisabled(1==b);this.prev.setDisabled(1==b);this.next.setDisabled(b==c);this.last.setDisabled(b==c);this.refresh.enable();this.updateInfo()}this.fireEvent("change",this,a)},onClear:function(){this.cursor=0;this.onChange()}});
