﻿function AsyncRequest($a,$b){this.callbackObject=$a;this.callbackFunction=$b;this.xmlHttp=null;this.error=null;};AsyncRequest.asyncReqs=new Array();AsyncRequest.GetXmlHttp=function(){var $c;if(window.XMLHttpRequest){$c=new XMLHttpRequest();}else{try{$c=new ActiveXObject("Msxml2.XMLHTTP");}catch(ex){try{$c=new ActiveXObject("Microsoft.XMLHTTP");}catch(ex){$c=null;}}};return $c;};AsyncRequest.OnReadyStateChange=function(){var i;var $d;if(!AsyncRequest.asyncReqs)return;for(i=0;i<AsyncRequest.asyncReqs.length;i++){$d=AsyncRequest.asyncReqs[i];if($d.xmlHttp.readyState==4){AsyncRequest.asyncReqs.splice(i,1);if($d.xmlHttp.status!=200)$d.error="HTTP "+$d.xmlHttp.status+" - "+$d.xmlHttp.statusText;if($d.callbackObject&&$d.callbackFunction)$d.callbackFunction.call($d.callbackObject,$d);else if($d.callbackFunction)$d.callbackFunction($d);}}};AsyncRequest.prototype.GetDocument=function($e,$f,$g){var $c=AsyncRequest.GetXmlHttp();if($c){this.xmlHttp=$c;AsyncRequest.asyncReqs.push(this);$c.onreadystatechange=AsyncRequest.OnReadyStateChange;$c.open("GET",$e);$c.send(null);}else{this.error="Your browser does not support XmlHttpRequests.";if(this.callbackObject&&this.callbackFunction)this.callbackFunction.call(this.callbackObject,this);else if(this.callbackFunction)this.callbackFunction(this);}};﻿function Coord(x,y){this.x=x;this.y=y;};Coord.prototype.IsEmpty=function(){if(this.x==0.0&&this.y==0.0)return true;return false;};Coord.prototype.Empty=function(){this.x=0.0;this.y=0.0;};﻿function XB(){};XB.CheckFunctionality=function(){if(!window.addEventListener&&!window.attachEvent)return "No support for advanced event handling!";if(!document.body.offsetWidth&&!document.body.offsetLeft)return "No support for dynamic position detection!";if(!window.XMLHttpRequest&&!window.ActiveXObject)return "No support for AJAX!";return "";};XB.AddOnloadEvent=function($h){var $i=window.onload;if(typeof window.onload!="function"){window.onload=$h;}else{window.onload=function(){$i();$h();};}};XB.AddEventListener=function($j,$k,$h,$l){if($j.addEventListener)$j.addEventListener($k,$h,$l);else $j.attachEvent("on"+$k,$h);};XB.RemoveEventListener=function($j,$k,$h,$l){if($j.removeEventListener)$j.removeEventListener($k,$h,$l);else $j.detachEvent("on"+$k,$h);};XB.GetEvent=function($k){return(($k)?$k:window.event);};XB.GetMousePosition=function($k){var $m=new $n(0,0);if($k.pageX||$k.pageY){$m.x=$k.pageX;$m.y=$k.pageY;}else if($k.clientX||$k.clientY){$m.x=$k.clientX-2+document.body.scrollLeft;$m.y=$k.clientY-2+document.body.scrollTop;};return $m;};XB.StopEventPropagation=function($k){$k.cancelBubble=true;if($k.stopPropagation)$k.stopPropagation();};XB.GetElementSize=function($j){var $o=$j.style.width;var $p=$j.style.height;var w=parseInt($j.offsetWidth);var h=parseInt($j.offsetHeight);var dw;var dh;$j.style.width=w+"px";$j.style.height=h+"px";dw=parseInt($j.offsetWidth)-w;dh=parseInt($j.offsetHeight)-h;$j.style.width=$o;$j.style.height=$p;return(new $n(w-dw,h-dh));};XB.GetElementPosition=function($j){var $m=new $n(0,0);var lm=$j;if(lm.style.left.search("px$")>-1){$m.x=parseInt(lm.style.left);}else{while(lm.offsetParent){$m.x+=lm.offsetLeft;lm=lm.offsetParent;}};lm=$j;if(lm.style.top.search("px$")>-1){$m.y=parseInt(lm.style.top);}else{while(lm.offsetParent){$m.y+=lm.offsetTop;lm=lm.offsetParent;}};return $m;};XB.GetClientSize=function(){var $q=new $n(0,0);if(self.innerWidth){$q.x=self.innerWidth;$q.y=self.innerHeight;}else if(document.documentElement&&document.documentElement.clientWidth){$q.x=document.documentElement.clientWidth;$q.y=document.documentElement.clientHeight;}else if(document.body){$q.x=document.body.clientWidth;$q.y=document.body.clientHeight;};return $q;};XB.HtmlEncode=function(s){var $r=new String(s);$r=$r.replace(/&/g,"&amp;");$r=$r.replace(/</g,"&lt;");$r=$r.replace(/>/g,"&gt;");$r=$r.replace(/"/g,"&quot;");return $r;};var $s;function CyberWatch(){this.location=new Coord(0,0);this.address="";this.isAddress=true;this.buffer="2640";this.crimes="";this.wait=false;this.preview=true;this.buttonColor="#397FCF";this.overColor="#CC6600";this.validateText="Validate/Preview";this.loadingImg="./images/loading.jpg";this.errMsg=document.getElementById("errmsg");this.waitDiv=document.getElementById("wait");this.mapData=document.getElementById("mapdata");this.mapImage=document.getElementById("mapimage");this.userData=document.getElementById("userdata");this.watchEmail=document.getElementById("txtemail");this.watchFormat=document.getElementById("lstformat");this.watchAddress=document.getElementById("txtaddress");this.watchStreet=document.getElementById("txtstreet");this.watchCross=document.getElementById("txtcross");this.cancelButton=document.getElementById("cancelbutton");this.validateButton=document.getElementById("validatebutton");this.addrButton=document.getElementById("addrbutton");this.addrContainer=document.getElementById("addrcontainer");this.intrButton=document.getElementById("intrbutton");this.intrContainer=document.getElementById("intrcontainer");this.candContainer=document.getElementById("candcontainer");this.allButton=document.getElementById("allbutton");this.noneButton=document.getElementById("nonebutton");this.confirmText=document.getElementById("confirmtext");this.numCrimes=document.getElementById("numCrimes").value;this.title=document.getElementById("title").value;this.sender=document.getElementById("sender").value;this.webmaster=document.getElementById("webmaster").value;if(this.confirmText.innerHTML=="no"){this.Initialize();}else{this.DisplayConfirmation();}};CyberWatch.prototype.Initialize=function(){this.watchEmail.value="";this.watchEmail.$L=this;this.watchEmail.onkeyup=CyberWatch.KeyUp;this.watchAddress.value="";this.watchAddress.$L=this;this.watchAddress.onkeyup=CyberWatch.KeyUp;this.watchStreet.value="";this.watchStreet.$L=this;this.watchStreet.onkeyup=CyberWatch.KeyUp;this.watchCross.value="";this.watchCross.$L=this;this.watchCross.onkeyup=CyberWatch.KeyUp;this.mapImage.src=this.loadingImg;document.getElementById("waitimg").src="./images/wait.png";this.cancelButton.$L=this;this.cancelButton.innerHTML="Cancel";this.cancelButton.onmouseover=function(){this.style.color=this.$L.overColor};this.cancelButton.onmouseout=function(){this.style.color=this.$L.buttonColor};this.cancelButton.onclick=function(){this.$L.Cancel();};this.validateButton.$L=this;this.validateButton.innerHTML=this.validateText;this.validateButton.onmouseover=function(){this.style.color=this.$L.overColor};this.validateButton.onmouseout=function(){this.style.color=this.$L.buttonColor};this.validateButton.onclick=function(){this.$L.Validate();};this.addrButton.$L=this;this.addrButton.onmouseover=function(){this.style.color=this.$L.overColor};this.addrButton.onmouseout=function(){this.style.color=this.$L.buttonColor};this.addrButton.onclick=function(){this.$L.ShowAddressForm(true);};this.intrButton.$L=this;this.intrButton.onmouseover=function(){this.style.color=this.$L.overColor};this.intrButton.onmouseout=function(){this.style.color=this.$L.buttonColor};this.intrButton.onclick=function(){this.$L.ShowAddressForm(false);};this.allButton.$L=this;this.allButton.onmouseover=function(){this.style.color=this.$L.overColor};this.allButton.onmouseout=function(){this.style.color=this.$L.buttonColor};this.allButton.onclick=function(){this.$L.SelectCrimes(true);};this.noneButton.$L=this;this.noneButton.onmouseover=function(){this.style.color=this.$L.overColor};this.noneButton.onmouseout=function(){this.style.color=this.$L.buttonColor};this.noneButton.onclick=function(){this.$L.SelectCrimes(false);};};CyberWatch.KeyUp=function(e){var $k=XB.GetEvent(e);if($k.keyCode==13)this.$L.Validate();return true;};CyberWatch.prototype.BuildSummary=function(){var $t=new Array("500","1000","1320","2640","5280");var $u=new Array("500 Feet","1000 Feet","1/4 Mile","1/2 Mile","1 Mile");var s="<strong>"+this.title+" Summary</strong><br /><br />";s+="<div class=\"sumheader\">Email Address</div>"+this.watchEmail.value+"<br />";s+="("+this.watchFormat.options[this.watchFormat.selectedIndex].text+")<br /><br />";s+="<div class=\"sumheader\">Location</div>";s+="<span id=\"sumbuffer\">Within ";s+="<select id=\"lstbuffer\">";for(var $v=0;$v<$t.length;$v++){s+="<option value="+$t[$v];if($t[$v]==this.buffer)s+=" selected";s+=">"+$u[$v]+"</option>";};s+="</select> of</span><br />";if(this.isAddress){s+=this.address+"<br /><br />";}else{s+=this.address.replace(" + ","<br />and<br />")+"<br /><br />";};s+="<div class=\"sumheader\">Crime Types</div>";s+=this.crimes;document.getElementById("summary").innerHTML=s;o=document.getElementById("lstbuffer");o.$L=this.watchEmail.$L;o.onchange=function(){this.$L.setBuffer();};};CyberWatch.prototype.Cancel=function(){this.wait=false;this.preview=true;this.ShowMap(false);this.ShowCancel(false);this.ShowWait(this.validateText);};CyberWatch.prototype.ClearData=function(){this.errMsg.innerHTML="";this.watchEmail.value="";this.watchAddress.value="";this.watchStreet.value="";this.watchCross.value="";this.SelectCrimes(false);};CyberWatch.prototype.DisplayConfirmation=function(){this.userData.style.display="none";this.mapData.style.display="none";document.getElementById("messagedata").style.display="block";if(this.confirmText.title=="error"){this.ShowError(this.confirmText.innerHTML);}else if(this.confirmText.title=="unsubscribe"){var $w="<h2>Unsubscribe</h2>"+"Thank you for using "+this.title+".<br /><br />"+"Your subscription has been cancelled.<br /><br />"+"To resubscribe or view other options,<br />click <a href=\"" + this.confirmText.innerHTML + "\">here</a> "+"to return to the "+this.title+" home page.";this.ShowMessage($w);}else{var $w="<h2>Confirmation</h2>"+"Thank you for your interest in "+this.title+".<br /><br />"+"Your subscription has been verified.<br /><br />"+"Click <a href=\"" + this.confirmText.innerHTML + "\">here</a> "+"to return to the "+this.title+" home page.";this.ShowMessage($w);}};CyberWatch.prototype.ShowAddressForm=function($x){if($x){this.isAddress=true;this.addrContainer.style.display="block";this.intrContainer.style.display="none";}else{this.isAddress=false;this.intrContainer.style.display="block";this.addrContainer.style.display="none";}};CyberWatch.prototype.ShowCandidates=function($y){var $z="",$A,i;$z="<h5>Multiple Addresses Found</h5>"
for(i=0;i<$y.length;i++)$z+="<p><span class=\"candidatelink\">"+$y[i].getAttribute("address")+"</span></p>";$z+="<p><span class=\"nocandidatelink\">None of the above</span></p>";$z+="<p class=\"candtext\">(Click an address to select it)</p>"
this.candContainer.innerHTML=$z;$A=this.candContainer.getElementsByTagName("span");for(i=0;i<$A.length-1;i++){$A[i].$M=this;$A[i].$N=new Coord(parseFloat($y[i].getAttribute("x")),parseFloat($y[i].getAttribute("y")));$A[i].$O=$y[i].getAttribute("address");$A[i].onclick=function(){this.$M.location.x=this.$N.x;this.$M.location.y=this.$N.y;this.$M.address=this.$O;this.$M.candContainer.style.display="none";this.$M.ShowAddressForm(this.$M.isAddress);this.$M.GetMap();};};i=$A.length-1;$A[i].$M=this;$A[i].onclick=function(){this.$M.candContainer.style.display="none";this.$M.ShowAddressForm(this.$M.isAddress);this.$M.wait=false;this.$M.ShowWait(this.$M.validateText);};this.addrContainer.style.display="none";this.intrContainer.style.display="none";this.candContainer.style.display="block";};CyberWatch.prototype.ShowCancel=function($B){if($B){this.cancelButton.style.display="block";}else{this.cancelButton.style.display="none";}};CyberWatch.prototype.ShowError=function($C){var $w="An application error occurred while processing your request.<br />"+"Click <a href=\"javascript:window.location.reload(true);\">here</a> to restart the "+"application and try again.<br/>If this problem persists, please contact the "+"<a href=\"mailto:" + this.webmaster + "\">Webmaster</a>.";this.userData.style.display="none";this.mapData.style.display="none";document.getElementById("messagedata").style.display="block";document.getElementById("messagetext").style.display="none";document.getElementById("errortext").style.display="block";document.getElementById("errortext").innerHTML=$w;};CyberWatch.prototype.ShowMap=function($B){if($B){this.userData.style.display="none";this.mapData.style.display="block";}else{this.userData.style.display="block";this.mapData.style.display="none";this.mapImage.src=this.loadingImg;}};CyberWatch.prototype.ShowMessage=function($w){this.userData.style.display="none";this.mapData.style.display="none";document.getElementById("messagedata").style.display="block";document.getElementById("errortext").style.display="none";document.getElementById("messagetext").style.display="block";document.getElementById("messagetext").innerHTML=$w;};CyberWatch.prototype.ShowWait=function($w){if($w==""){this.waitDiv.style.display="block";this.validateButton.style.display="none";}else{this.waitDiv.style.display="none";this.validateButton.style.display="block";this.validateButton.innerHTML=$w;}};CyberWatch.prototype.SelectCrimes=function($D){for(var $v=0;$v<this.numCrimes;$v++){document.getElementById("crime"+$v).checked=$D;}};CyberWatch.prototype.setBuffer=function(){var o=document.getElementById("lstbuffer");this.buffer=o.options[o.selectedIndex].value;this.GetMap();};CyberWatch.prototype.Validate=function(){if(this.preview){this.ValidateFields();}else{this.StartSaveData();}};CyberWatch.prototype.ValidateFields=function(){var $E="";this.errMsg.innerHTML="";$E=this.ValidateEmail();if($E=="")$E=this.ValidateAddress();if($E=="")$E=this.ValidateCrimes();if($E==""){this.StartGeocode();}else{this.errMsg.innerHTML=$E;}};CyberWatch.prototype.ValidateEmail=function(){var $E="";if(this.watchEmail.value==""){$E="Must enter an email address.";}else if(this.watchEmail.value.indexOf("@")==-1){$E="Must enter a valid email address.";}else if(this.watchEmail.value.indexOf(".")==-1){$E="Must enter a complete email address.";};return $E;};CyberWatch.prototype.ValidateAddress=function(){var $E="";if(this.isAddress){if(this.watchAddress.value==""){$E="Must enter an address.";}}else{if(this.watchStreet.value==""){$E="Must enter a street name.";}else if(this.watchCross.value==""){$E="Must enter a cross street name.";}};return $E;};CyberWatch.prototype.ValidateCrimes=function(){var $v=0,br="",$E="";this.crimes="";for($v=0;$v<this.numCrimes;$v++){if(document.getElementById("crime"+$v).checked){this.crimes+=br+document.getElementById("crime"+$v).value;br="<br />";}};if(this.crimes==""){$E="Must select at least one crime type.";};return $E;};CyberWatch.prototype.StartGeocode=function(){var $F="",$G="";var $H=new AsyncRequest(this,this.EndGeocode);this.location.Empty();this.ShowWait("");this.wait=true;if(this.isAddress){$F=XB.HtmlEncode(this.watchAddress.value);}else{$F=XB.HtmlEncode(this.watchStreet.value);$G=XB.HtmlEncode(this.watchCross.value);};$H.GetDocument("Geocoder.aspx?a="+encodeURI($F)+"&c="+encodeURI($G));};CyberWatch.prototype.EndGeocode=function($d){if($d.error){this.wait=false;this.ShowError($d.error);return;};var $I=$d.xmlHttp.responseXML.getElementsByTagName("candidate");if($I.length==0){this.wait=false;this.ShowWait(this.validateText);if(this.isAddress){this.errMsg.innerHTML="Sorry, that address could not be found.";}else{this.errMsg.innerHTML="Sorry, that intersection could not be found.";}}else if($I.length==1){this.location.x=parseFloat($I[0].getAttribute("x"));this.location.y=parseFloat($I[0].getAttribute("y"));this.address=$I[0].getAttribute("address");this.GetMap();}else{this.wait=false;this.ShowCandidates($I);}};CyberWatch.prototype.GetMap=function(){this.ShowMap(true);this.BuildSummary();this.mapImage.src="Imager.aspx?x="+this.location.x+"&y="+this.location.y+"&d="+this.buffer;this.wait=false;this.preview=false;this.ShowCancel(true);this.ShowWait("Save Location");};CyberWatch.prototype.StartSaveData=function(){var $H=new AsyncRequest(this,this.EndSaveData);this.ShowWait("");this.ShowCancel(false);this.wait=true;var f=this.watchFormat.options[this.watchFormat.selectedIndex].value;$H.GetDocument("Database.aspx?e="+this.watchEmail.value+"&f="+f+"&a="+encodeURIComponent(this.address)+"&c="+encodeURI(this.crimes)+"&x="+this.location.x+"&y="+this.location.y+"&d="+this.buffer);};CyberWatch.prototype.EndSaveData=function($d){if($d.error){this.wait=false;this.ShowError($d.error);return;};var $w="";var $J=this.watchEmail.value;var db=$d.xmlHttp.responseXML.getElementsByTagName("database");var $K=db[0].getAttribute("result");this.wait=false;this.preview=true;this.ClearData();this.ShowMap(false);this.ShowWait(this.validateText);if($K=="add"){$w="Thank you for subscribing to the<br />"+this.title+" subscription service.<br />"+"An email has been sent to "+$J+" for verification.<br /><br />"+"After verifying your subscription, you will begin receiving email "+"notifications based on your location and selected crime types.<br /><br />"+"Please note: "+this.sender+" is the email account that sends all emails for the "+this.title+" subscription service. "+"Whitelisting this account will help ensure that your emails are not sent to junk mail or caught by spam filters.<br /><br />"+"Click <a href=\"javascript:window.location.reload(true);\">here</a> to return to the "+this.title+" home page.";this.ShowMessage($w);}else if($K=="update"){$w="Thank you for updating your preferences for the<br />"+this.title+" subscription service.<br />"+"An email has been sent to "+$J+" for verification.<br /><br />"+"The next notification run, after verying your subscription, will reflect your changes.<br /><br />"+"As a reminder, "+this.sender+" is the email account that sends all emails for the "+this.title+" subscription service. "+"Whitelisting this account will help ensure that your emails are not sent to junk mail or caught by spam filters.<br /><br />"+"Click <a href=\"javascript:window.location.reload(true);\">here</a> to return to the "+this.title+" home page.";this.ShowMessage($w);}else{this.ShowError("Unknown EndSaveData action = "+$K);}};function Init(){$s=new CyberWatch();};XB.AddOnloadEvent(Init);

