var _gaq=_gaq||[];_gaq.push(["_setAccount","UA-226181-2"]);_gaq.push(["_trackPageview"]);function render(){var b=new aw.ComponentBus();b.setApplicationKey(_awApplicationKey);var a=new FreeD({container:$(document.getElementsByTagName("body")[0]),componentBus:b});showMapTab=function(){a.showTab("FreeD.MapViewer")};showReportTab=function(){a.showTab("FreeD.ReportViewer")};showSignupForm=function(){a._onSignup()}}FreeD=Class.create(aw.ui,{initialize:function(b,a){aw.ui.prototype.initialize.apply(this,arguments);this.componentBus.registerEvent("onauthenticationfailure",this._onAuthenticationFailure.bind(this));this.componentBus.registerEvent("onauthenticationsuccess",this._onAuthenticationSuccess.bind(this));this.componentBus.registerEvent("onvalidationfailure",this._onAuthenticationFailure.bind(this));this.componentBus.registerEvent("onvalidationsuccess",this._onAuthenticationSuccess.bind(this));if(_FreeDGooglePageTracker==="on"){this.componentBus.registerEvent("onrequestinitialized",this._onRequestInitialized.bind(this));(function(){var h=document.createElement("script");h.type="text/javascript";h.async=true;h.src=("https:"==document.location.protocol?"https://ssl":"http://www")+".google-analytics.com/ga.js";var g=document.getElementsByTagName("script")[0];g.parentNode.insertBefore(h,g)})()}var d=new aw.UserDataManager({componentBus:this.componentBus});var f=new aw.GeographyManager({componentBus:this.componentBus});var e=new aw.ReportManager({componentBus:this.componentBus});var c=new aw.GeographyCollection(null,"3825 Iris Avenue, Boulder CO","Geography Selection",{x:-105.246211,y:40.036617});c.addGeography(new aw.Geography.Radius(null,"3825 Iris Avenue, Boulder CO","1 Mile Radius",1,-105.246211,40.036617,"Miles"));c.addGeography(new aw.Geography.Radius(null,"3825 Iris Avenue, Boulder CO","3 Mile Radius",3,-105.246211,40.036617,"Miles"));c.addGeography(new aw.Geography.Radius(null,"3825 Iris Avenue, Boulder CO","5 Mile Radius",5,-105.246211,40.036617,"Miles"));f.setActiveGeography(c)},draw:function(){aw.ui.prototype.draw.apply(this);var f=new aw.AccountManager({componentBus:this.componentBus});var a=new aw.HelpManager({componentBus:this.componentBus});var g=new FreeD.HTMLViewer({componentBus:this.componentBus,title:"Home"});var h=new FreeD.ReportViewer({componentBus:this.componentBus,title:"Report"});var b=new FreeD.MapViewer({componentBus:this.componentBus,title:"Map"});var d=new FreeD.WizardViewer({componentBus:this.componentBus,title:"2010 Census",disabled:true});var c=new FreeD.FileViewer({componentBus:this.componentBus,title:"Files",disabled:true});var j=this.canvas.down("span.about");if(j){aw.EventManager.register(j,"click",this._onAboutClick.bind(this))}j=null;var e=new aw.ui.Panel.Tab({titleVisibility:false,showBgd:false,container:this.canvas.down('div[id="app"]'),cssClass:"FreeD_TabPanel",items:[g,h,b,d,c]});Event.observe((document.onresize?document:window),"resize",e.setSize.bind(e));var i=document.getURLParameters();if((i)&&(i.activation)){if(i.activation.toLowerCase()=="success"){f.getActivationMessage("success",function(k){new aw.ui.Dialog.Alert({title:"Account Activated",content:k})})}else{if(i.activation.toLowerCase()=="failure"){f.getActivationMessage("failure",function(k){new aw.ui.Dialog.Error({title:"Account Activation Failure",content:k})})}}}return this.canvas},showTab:function(a){var b=this.componentBus.getComponentReferences(a);if((b)&&(b.length>0)){b=b[0];b.show()}},_onAboutClick:function(){new aw.ui.Dialog({title:"About Alteryx web",width:500,centerable:true,cssClass:"credits",content:'<div class="alteryx"><img src="custom/img/Alteryx_logo_orig.png" alt="Alteryx" width="150" /><div>Alteryx web<br />Version: '+aw.BUILD_VERSION+'</div></div>Some Icons are Copyright &copy; <a href="http://p.yusukekamiyamane.com/" target="_blank">Yusuke Kamiyamane</a>. All rights reserved.<br />Licensed under a <a href="http://creativecommons.org/licenses/by/3.0/" target="_blank">Creative Commons Attribution 3.0 license</a>.<br /><br />Some Icons are Copyright &copy; <a href="http://www.famfamfam.com/lab/icons/silk/" target="_blank">FamFamFam</a>. All rights reserved.<br />Licensed under a <a href="http://creativecommons.org/licenses/by/3.0/" target="_blank">Creative Commons Attribution 3.0 license</a>.<div class="tomtom"><div>&copy; 2011 TomTom. All rights reserved. This Material is proprietary and the subject of copyright protection and/or database right protection and/or other intellectual property rights owned by TomTom or its suppliers.  The use of this material is subject to the terms of a license agreement.  Any unauthorized copying or disclosure of this material will lead to criminal and civil liabilities.</div><div class="link"><a href="http://www.tomtom.com/" target="_blank">www.tomtom.com</a></div><img src="custom/img/TomTomLogo.jpg" /></div>'})},_onAccountClick:function(){new FreeD.AccountDialog({componentBus:this.componentBus})},_onAuthenticationFailure:function(){var c=["FreeD.FileViewer","FreeD.WizardViewer"];var a=null;for(var d=0;d<c.length;d++){a=this.componentBus.getComponentReferences(c[d]);if((a)&&(a.length>0)){a[0].disable()}}if(this.canvas){var b=this.canvas.down("div.header div.login");if(b){b.update('<span class="signup">Sign-Up</span><span class="login">Log In</span>');Element.observe(b.down("span.signup"),"click",this._onSignup.bind(this));Element.observe(b.down("span.login"),"click",this._onLoginClick.bind(this))}}},_onAuthenticationSuccess:function(){var e=new aw.WizardManager({componentBus:this.componentBus});var c=["FreeD.FileViewer","FreeD.WizardViewer"];var a=null;for(var d=0;d<c.length;d++){a=this.componentBus.getComponentReferences(c[d]);if((a)&&(a.length>0)){a[0].enable();if(a[0].CLASS_NAME=="FreeD.ReportViewer"){a[0].show()}}}if(this.canvas){var b=this.canvas.down("div.header div.login");if(b){b.update('<span class="account">Account Info</span><span class="logout">Logout</span><div class="welcome">Welcome '+this.readCookie("username")+"</div>");Element.observe(b.down("span.account"),"click",this._onAccountClick.bind(this));Element.observe(b.down("span.logout"),"click",this._onLogoutClick.bind(this))}}},_onLoginClick:function(){new FreeD.LoginDialog({componentBus:this.componentBus})},_onLogoutClick:function(){this.componentBus.unloadUser()},_onRequestInitialized:function(a,c,d){if(_gaq){var b=c;if(c.indexOf("/")>0){b=b.substring(b.lastIndexOf("/"))+(a.cn?("?cn="+a.cn):"")}if((b.indexOf("cn=")>0)&&(a.skey)){b+="&=skey="+a.skey}_gaq.push(["_trackPageview",b])}},_onSignup:function(a){new FreeD.AccountDialog({componentBus:this.componentBus})},_templates:{ui:new Template('<div class="header"><img src="./custom/img/FreeD_Logo.png" alt="FreeDemographics - Powered by Alteryx" /><div class="login"></div></div><div id="app"></div><div class="footer"><div class="copyright">Copyright '+new Date().getFullYear()+' Alteryx, Inc. Irvine, CA. | <span class="build">Build: v'+aw.BUILD_VERSION+'</span> | <span class="about">Credits</span></div><div class="contact">888-836-4274 &#160; | &#160; sales@alteryx.com</div></div>')},VALID_PROPERTIES:["container","componentBus"],CLASS_NAME:"FreeD"});FreeD.AccountDialog=Class.create(aw.ui.Dialog,{_form:null,initialize:function(b,a){this._form=null;this.inheritCSS=true;Object.extend(b,{title:"Sign-up"});aw.ui.Dialog.prototype.initialize.apply(this,[b,a]);if((this.componentBus)&&(this.componentBus.isSessionValidated()===true)){this.setTitle("Account Information")}},afterDraw:function(){var a=this.componentBus.getComponentReferences("aw.AccountManager");if((a)&&(a.length>0)){a=a[0]}else{return}a.retrieveAccountInfo(this._manifestReceived.bind(this))},draw:function(){aw.ui.Dialog.prototype.draw.apply(this);var c=this.canvas.down("div.contents");if(c){c.update(this._local_templates.ui)}var b=this.canvas.down("div.form");if(b){b.update("Loading...")}var a=this.canvas.down("div.details");if((this.componentBus)&&(this.componentBus.isSessionValidated()===true)){this._renderButton("Save",this._onSaveClick.bind(this));if(a){a.update(this._local_templates.accountdetails)}}else{this._renderButton("Sign-up",this._onSignupClick.bind(this));if(a){a.update(this._local_templates.signupdetails)}}this._renderButton("Cancel",this.close.bind(this));return this.canvas},_manifestReceived:function(a){if((!a)||(!a.length>0)){return}var c=this.canvas.down("div.form");if(!c){return}c.update("");this._form=new aw.ui.Form();var b=null,d=null,e,k=null;for(var g=0;b=a[g];g++){d=this.getId();c.insert(this._local_templates.category.evaluate({key:d,category:b.category}));e=c.down('div[key="'+d+'"]');for(var f=0;k=b.fields[f];f++){if((k.type=="text")||(k.type=="password")){this._form.add(new aw.ui.Control.TextBox({type:k.type,label:k.label+((k.required===true)?"*":""),name:k.name,value:k.defaultValue,container:e}));if(k.type=="password"){pwConfirm=k;pwConfirm.name="passwordConfirm";pwConfirm.label="Password Confirmation";this._form.add(new aw.ui.Control.TextBox({type:pwConfirm.type,label:pwConfirm.label+((k.required===true)?"*":""),name:pwConfirm.name,value:pwConfirm.defaultValue,container:e}))}}else{if(k.type=="select"){k.values.unshift({value:"",label:"-- Select One --"});var h=new aw.ui.Control.DropDown({label:k.label+((k.required===true)?"*":""),name:k.name,options:k.values,container:e});if((k.defaultValue)&&(k.defaultValue!=="")){h.selectByValue(k.defaultValue)}this._form.add(h)}}}}},_onSaveClick:function(){if(!this._form){return}var a=this.componentBus.getComponentReferences("aw.AccountManager");if((a)&&(a.length>0)){a=a[0]}else{return}var b=this._form.serialize();if((b.password)&&(b.password=="*-*-*-*-*")){delete b.password}if((b.passwordConfirm)&&(b.passwordConfirm=="*-*-*-*-*")){delete b.passwordConfirm}a.updateAccount(b,function(c,d){if(c=="failure"){new aw.ui.Dialog.Error({title:"Error!",content:d})}else{new aw.ui.Dialog.Alert({title:"Success!",content:d});this.close()}}.bind(this))},_onSignupClick:function(){if(!this._form){return}var a=this.componentBus.getComponentReferences("aw.AccountManager");if((a)&&(a.length>0)){a=a[0]}else{return}var b=this._form.serialize();a.createAccount(b,function(c,d){if(c=="failure"){new aw.ui.Dialog.Error({title:"Error!",content:d})}else{new aw.ui.Dialog.Alert({title:"Success!",content:d});this.close()}}.bind(this))},_local_templates:{ui:'<div class="form"></div><div class="details"></div><div style="clear: both;"></div>',category:new Template('<div class="category" key="#{key}"><h1>#{category}</h1><div class="fields"></div></div>'),signupdetails:'<p>Welcome to FreeDemographics.  Please register for access to features such as reporting, mapping and list generation.</p><p>Please provide the required information on the left. Once your information is submitted, you will receive an email with instructions on how to activate your account.</p><p>If you need further assistance please contact us at:</p>Alteryx, LLC.<br />230 Commerce<br />Suite #250<br />Irvine, CA 92602<br /><a href="mailto:sales@alteryx.com">sales@alteryx.com</a><br />888-836-4274',accountdetails:'<p>Your account information can be changed by editing the fields on the left. Please note that if you change your email address your log in will also change.</p><p>If you need further assistance please contact us at:</p>Alteryx, LLC.<br />230 Commerce<br />Suite #250<br />Irvine, CA 92602<br /><a href="mailto:sales@alteryx.com">sales@alteryx.com</a><br />888-836-4274'},CLASS_NAME:"FreeD.AccountDialog"});FreeD.CustomRadiiDialog=Class.create(aw.ui.Dialog,{_addressField:null,_nameField:null,_latitudeField:null,_longitudeField:null,_rangeField:null,_unitsField:null,_editPointButton:null,_removePointButton:null,_removeAllPointsButton:null,_grid:null,_points:[],initialize:function(b,a){this._points=[];this.inheritCSS=true;Object.extend(b,{title:"Create Custom Locations"});aw.ui.Dialog.prototype.initialize.apply(this,[b,a]);if(this.componentBus){this.componentBus.getComponentReferences("aw.GeographyManager",function(c){if((c)&&(c.length>0)){var d=c[0];this._onActiveGeographyChanged_fx=this._onActiveGeographyChanged.bind(this);this._onGeographySettingsReceived_fx=this._onGeographySettingsReceived.bind(this);d.registerEvent("onactivegeographychanged",this._onActiveGeographyChanged_fx);d.registerEvent("ongeographysettingsreceived",this._onGeographySettingsReceived_fx);if(d.geographySettings){this._onGeographySettingsReceived(d.geographySettings)}if(d.activeGeography){this._onActiveGeographyChanged(d.activeGeography)}}}.bind(this))}},_addPoint:function(a,b,c){this._points.push({key:this.getId(),name:a,latitude:b,longitude:c});if(this._grid){this._grid.loadData(this._points)}},_clearPoints:function(){this._points=[];if(this._grid){this._grid.loadData(this._points)}},draw:function(){aw.ui.Dialog.prototype.draw.apply(this);var g=this.canvas.down("div.contents");if(g){g.update(this._local_templates.ui);var c=g.down("div.addressField");var b=g.down("div.nameField");var a=g.down("div.latitudeField");var d=g.down("div.longitudeField");var f=g.down("div.addpointButton");this._addressField=new aw.ui.Control.TextBox({container:c,name:"address",cssClass:"addressInput"},{enter:this._geocodeAddress.bind(this)});this._nameField=new aw.ui.Control.TextBox({container:b,name:"name",label:"Name:"},{enter:this._onAddPointClick.bind(this)});this._latitudeField=new aw.ui.Control.TextBox({container:a,name:"latitude",label:"Latitude:"},{enter:this._onAddPointClick.bind(this)});this._longitudeField=new aw.ui.Control.TextBox({container:d,name:"longitude",label:"Longitude:"},{enter:this._onAddPointClick.bind(this)});new aw.ui.Control.Button({container:f,label:"Add Point"},{click:this._onAddPointClick.bind(this)});var h=g.down("div.mapButton");new aw.ui.Control.Button({container:h,label:"Go to Map"},{click:this._onGoToMapClick.bind(this)});var e=g.down("div.summary");this._grid=new aw.ui.Grid({columns:[{index:"name",label:"Name",sorted:true,sortDirection:"asc"},{index:"latitude",label:"Latitude"},{index:"longitude",label:"Longitude"}]},{onselectionchanged:this._onPointSelectionChanged.bind(this)});this._editPointButton=new aw.ui.Control.Button({label:"Edit Point",disabled:true},{click:this._onEditPointClick.bind(this)});this._removePointButton=new aw.ui.Control.Button({label:"Remove Point(s)",disabled:true},{click:this._onRemovePointClick.bind(this)});this._removeAllPointsButton=new aw.ui.Control.Button({label:"Remove All Points"},{click:this._onRemoveAllPointsClick.bind(this)});this._rangesInput=new aw.ui.Control.TextBox({label:"Ranges:",value:"1,3,5"});this._unitsSelect=new aw.ui.Control.DropDown({label:"Units:"});new aw.ui.Panel({container:e,title:"Current Points",items:[new aw.ui.Toolbar({height:30,region:"top",items:[new aw.ui.Toolbar.Row({items:[this._editPointButton,this._removePointButton,this._removeAllPointsButton]})]}),new aw.ui.Toolbar({height:30,region:"bottom",items:[new aw.ui.Toolbar.Row({items:[this._rangesInput,this._unitsSelect]})]}),this._grid]})}this._renderButton("OK",this._onCreateCustomRadiiClick.bind(this));this._renderButton("Cancel",this.close.bind(this));return this.canvas},_geocodeAddress:function(){if(!this.componentBus){throw"Could not locate a valid <aw.ComponentBus> class reference."}var a=this.componentBus.getComponentReferences("aw.GeographyManager");if((a)&&(a.length>0)){a=a[0];a.search(this._addressField.value,this._onSearchReceived.bind(this))}},_onAddPointClick:function(){if(this._addressField.value!=""){this._geocodeAddress();return}var a=this._nameField.value;var b=this._latitudeField.value;var c=this._longitudeField.value;if((!a)||(a==="")||(!b)||(b==="")||(!c)||(c==="")){new aw.ui.Dialog.Error({title:"Error",content:"You must enter the name, latitude, and longitude for the point you would like to add."});return}else{if((c<-180)||(c>180)||(b<-90)||(b>90)){new aw.ui.Dialog.Error({title:"Error",content:"Invalid latitude and/or longitude coordinates specified."});return}}this._nameField.setValue("");this._latitudeField.setValue("");this._longitudeField.setValue("");this._addPoint(a,b,c)},_onCreateCustomRadiiClick:function(){var f=this.componentBus.getComponentReferences("aw.GeographyManager");if((f)&&(f.length>0)){f=f[0]}else{return}var e=f.validateRadii(this._rangesInput.getValue(),this._unitsSelect.getValue());if(e.isGood!==true){new aw.ui.Dialog.Error({title:"Error!",content:e.message});return}geoCollection=new aw.GeographyCollection();var a=null,b=null;for(var d=0;a=this._points[d];d++){for(var c=0;b=e.ranges[c];c++){if(this._unitsSelect.getValue()=="DT|Minutes"){geoCollection.addGeography(new aw.Geography.Drivetime(null,a.name,a.name,b,a.longitude,a.latitude,"Minutes"))}else{geoCollection.addGeography(new aw.Geography.Radius(null,a.name,a.name,b,a.longitude,a.latitude,this._unitsSelect.getValue()))}}}geoCollection.generateLabel();this.triggerEvent("onpointscreated",geoCollection);this.close()},_onEditPointClick:function(a){if(!this._grid){return}var b=this._grid.getSelectedRecords();if((b)&&(b.length>0)){this._removePointByKey(b[0].key);this._nameField.setValue(b[0].name);this._latitudeField.setValue(b[0].latitude);this._longitudeField.setValue(b[0].longitude)}},_onGeographySettingsReceived:function(b){if((this._unitsSelect)&&(b)){var a=[{value:"Miles",label:"Miles"},{value:"Kilometers",label:"Kilometers"}];if(b.enableDrivetimeGeography===true){a.push({value:"DT|Minutes",label:"Minutes (Drivetime)"})}this._unitsSelect.clear();this._unitsSelect.addOptions(a);var c=this.componentBus.getComponentReferences("aw.GeographyManager");if((c)&&(c.length>0)){c=c[0];if(c.activeGeography){this._loadGeographyInfo(c.activeGeography)}}}},_onPointSelectionChanged:function(a){this._editPointButton.disable();this._removePointButton.disable();if((a)&&(a.length>0)){this._removePointButton.enable();if(a.length==1){this._editPointButton.enable()}}},_onRemoveAllPointsClick:function(a){this._clearPoints()},_onRemovePointClick:function(d){var c=this._grid;if(!c){return}var e=c.getSelectedRecords();if((e)&&(e.length>0)){var a=null;for(var b=0;a=e[b];b++){this._removePointByKey(a.key)}}},_loadGeographyInfo:function(c){if((!c)||(!c.geos)||(!c.geos.length>0)||(!this._unitsSelect)){return}if((this._rangesInput)&&(this._unitsSelect)){var a=c.getGeographyTypes();if((a.length>1)||((a[0]!="aw.Geography.Radius")&&(a[0]!="aw.Geography.Drivetime"))){return}var b=c.getRadiiInfo();if(b){this._rangesInput.setValue(b.sizes);this._unitsSelect.selectByValue(b.units)}}},_onActiveGeographyChanged:function(a){this._loadGeographyInfo(a)},_onGoToMapClick:function(){var a=this.componentBus.getComponentReferences("FreeD.MapViewer");if((a)&&(a.length>0)){a[0]._map.pickPoint(this._onMapPointClick.bind(this));a[0].show();this.hide()}},_onMapPointClick:function(a,b){if((!b)||(b==="")){new aw.ui.Dialog.Prompt({title:"Enter Point Name",content:"Please enter a name for the point created at "+a.lat+", "+a.lon+"."},{onsubmit:this._onMapPointClick.bind(this,a)})}else{this._addPoint(b,a.lat,a.lon);this.show()}},_onSearchReceived:function(b){for(var a=0;result=b[a];a++){if((result.TypeGeo=="Street")||(result.TypeGeo=="Address")){this._addPoint(result.Name,result.Lat,result.Lon);this._addressField.setValue("");return}}new aw.ui.Dialog.Error({title:"Error",content:"No matches were found for your search."})},_removePointByKey:function(c){if((!c)||(!this._points)||(!this._points.length>0)){return}var e=[],a=null,d=false;for(var b=0;a=this._points[b];b++){if(a.key!=c){e.push(a)}else{d=true}}if(d===true){this._points=e;if(this._grid){this._grid.loadData(this._points)}}},_local_templates:{ui:'<div class="location"><h2>Enter an Address...</h2><div class="addressField"></div><div class="split horizontal"></div><h2>Or Enter a Name and Coordinates...</h2><div class="nameField"></div><div class="latitudeField"></div><div class="longitudeField"></div><div class="addpointButton"></div></div><div class="map"><h2>Pick from Map...</h2><span>Click "Go to Map" to pick your point from the map.</span><div class="mapButton"></div></div><div class="summary"></div>'},EVENTS:["onpointscreated"],CLASS_NAME:"FreeD.CustomRadiiDialog"});FreeD.FeedbackDialog=Class.create(aw.ui.Dialog,{initialize:function(b,a){Object.extend(b,{title:"Feedback"});this.inheritCSS=true;aw.ui.Dialog.prototype.initialize.apply(this,[b,a])},draw:function(){aw.ui.Dialog.prototype.draw.apply(this);var a=this.canvas.down("div.contents");if(!a){return null}a.insert(this._local_templates.ui);this._renderButton("Submit",this._onSubmitClick.bind(this));this._renderButton("Cancel",this.close.bind(this));return this.canvas},_onSubmitClick:function(){var a=this.canvas.down("textarea#feedback");if(a){this.request({cn:"SRC.Web.Client.Handler.AccountManagementHandler",service:"feedback",fb:a.value});new aw.ui.Dialog.Alert({title:"Thank you!",content:"Thank you, your feedback is greatly appeciated!"})}this.close()},_local_templates:{ui:'We\'re always interested in what you have to say!</b><br/>If you\'ve encountered a problem or have a suggestion, please don\'t hesitate to drop us a note.<br/><br/>Thank You!<br /><textarea name="feedback" id="feedback"></textarea>'},CLASS_NAME:"FreeD.FeedbackDialog"});FreeD.FileViewer=Class.create(aw.ui.Panel,{_activeDataType:null,_dataTypeDropDown:null,_dataRecords:null,_grid:null,_propertiesPanel:null,_onUserSettingsReceived_fx:null,_onDataTypesChanged_fx:null,_onUserDataActionExecuted_fx:null,initialize:function(b,a){this._activeDataType=null;this._dataTypeDropDown=null;this._dataRecords=null;this._grid=null;this._propertiesPanel=null;this.inheritCSS=true;aw.ui.Panel.prototype.initialize.apply(this,arguments);this.componentBus.getComponentReferences("aw.UserDataManager",function(c){if((c)&&(c.length>0)){var d=c[0];this._onUserSettingsReceived_fx=this._onUserSettingsReceived.bind(this);this._onDataTypesChanged_fx=this._onDataTypesChanged.bind(this);this._onUserDataActionExecuted_fx=this._onUserDataActionExecuted.bind(this);d.registerEvent("onusersettingsreceived",this._onUserSettingsReceived_fx);d.registerEvent("ondatatypeschanged",this._onDataTypesChanged_fx);d.registerEvent("onactionexecuted",this._onUserDataActionExecuted_fx);if((d.dataTypes)&&(d.dataTypes.length>0)){this._onDataTypesChanged(d.dataTypes)}if(d.userSettings){this._onUserSettingsReceived(d.userSettings)}}}.bind(this))},destroy:function(){if(this.componentBus){var a=this.componentBus.getComponentReferences("aw.UserDataManager");if((a)&&(a.length>0)){a=a[0];if(this._onUserSettingsReceived_fx){a.unregisterEvent("onusersettingsreceived",this._onUserSettingsReceived_fx);this._onUserSettingsReceived_fx=null}if(this._onDataTypesChanged_fx){a.unregisterEvent("ondatatypeschanged",this._onDataTypesChanged_fx);this._onDataTypesChanged_fx=null}if(this._onUserDataActionExecuted_fx){a.unregisterEvent("onactionexecuted",this._onUserDataActionExecuted_fx);this._onUserDataActionExecuted_fx=null}}}this._activeDataType=null;this._dataTypeDropDown=null;this._dataRecords=null;this._grid=null;this._propertiesPanel=null;aw.ui.Panel.prototype.destroy.apply(this)},draw:function(){aw.ui.Panel.prototype.draw.apply(this);this._grid=new aw.ui.Grid({columns:[{label:"Name",index:"name"},{label:"Type",index:"typeLabel"},{label:"Date Created",index:"dateCreated"},{label:"Date Modified",index:"dateModified"}]},{onselectionchanged:this._onGridSelectionChanged.bind(this)});this._propertiesPanel=new aw.ui.Panel({title:"File Properties",titleVisibility:true,minWidth:300,width:300});this._dataTypeDropDown=new aw.ui.Control.DropDown({label:"View:",options:[{label:"Loading..."}]},{change:this._onDataTypeDropDownChange.bind(this)});this.add(new aw.ui.Toolbar({region:"top",height:100,cssClass:"FreeD_Toolbar",items:[new aw.ui.Toolbar.Group({label:"Geography Selection",cssClass:"geoselection",items:[new FreeD.GeographyBar({componentBus:this.componentBus})],helpCallback:this._onHelpClick.bind(this,"Geography Selection")}),new aw.ui.Toolbar.Group({label:"File Controls",items:[new aw.ui.Toolbar.Column({items:[new aw.ui.Toolbar.Row({items:[this._dataTypeDropDown]})]})],helpCallback:this._onHelpClick.bind(this,"Files")}),new aw.ui.Toolbar.Group({label:"Feedback",items:[new aw.ui.Toolbar.Row({items:[new aw.ui.Control.Link({label:"Please provide us with any<br />feedback by filling out this form.",cssClass:"feedbackLink"},{click:this._onFeedbackClick.bind(this)})]})]})]}));this.add(new aw.ui.Panel.Splitter({titleVisibility:false,orientation:"horizontal",items:[new aw.ui.Panel({titleVisibility:false,minWidth:500,width:1000,items:[this._grid]}),this._propertiesPanel]}));return this.canvas},setActiveDataType:function(a){if(!a){return}this._activeDataType=a;if(this._dataTypeDropDown){this._dataTypeDropDown.selectByValue(a.key,false)}var b=this.componentBus.getComponentReferences("aw.UserDataManager");if((b)&&(b.length>0)){b[0].retrieveData(a.key,null,null,this._onDataRetrieved.bind(this))}},_getDataRecordByKey:function(c){if((!c)||(!this._dataRecords)||(!this._dataRecords.length>0)){return null}for(var b=0,a=this._dataRecords.length;b<a;b++){if(this._dataRecords[b].key==c){return this._dataRecords[b]}}return null},_onActionClicked:function(e,b,d){if((!e)||(!b)||(!b.length>0)){return}if((e.toLowerCase()=="delete")&&(d!==true)){new aw.ui.Dialog.Confirm({title:"Delete",content:"Are you certain you want to delete the selected data items?"},{onconfirm:this._onActionClicked.bind(this,e,b,true)});return}for(var c=0,a=b.length;c<a;c++){b[c].executeAction(e)}},_onDataRetrieved:function(c){if(this._grid){this._dataRecords=c;var b=[];var e=null;for(var a=0;e=c[a];a++){b.push({_key:e.key,name:e.name,type:e.type,typeLabel:e.typeLabel,dateCreated:e.dateCreated,dateModified:e.dateModified})}this._grid.loadData(b)}},_onDataTypeDropDownChange:function(b){var a=this.componentBus.getComponentReferences("aw.UserDataManager");if((a)&&(a.length>0)){this.setActiveDataType(a[0].getDataTypeByKey(b.getValue()))}},_onDataTypesChanged:function(c){this._activeDataType=null;if(this._dataTypeDropDown){this._dataTypeDropDown.clear();var b=null;for(var a=0;b=c[a];a++){this._dataTypeDropDown.addOption(b.key,b.label);if(!this._activeDataType){this.setActiveDataType(b)}}}},_onFeedbackClick:function(){new FreeD.FeedbackDialog({componentBus:this.componentBus})},_onGridSelectionChanged:function(a){if(this._propertiesPanel){this._propertiesPanel.clear();var e=[];for(var d=0,f=a.length;d<f;d++){e.push(this._getDataRecordByKey(a[d]._key))}var b=[];var h=[];if((e)&&(e.length>0)){for(var d=0;d<e.length;d++){if(b.indexOf(e[d].type)<0){b.push(e[d].type)}if(h.length>0){h.intersect(e[d].getActions())}else{h=e[d].getActions()}}}var g="";if((!e)||(!e.length>0)){g="<strong>No files selected.</strong>"}else{if(e.length==1){g='<div class="properties"><p><strong>File Name:</strong> '+e[0].name+"</p><p><strong>Type:</strong> "+e[0].type+"</p><p><strong>Date Created:</strong> "+e[0].dateCreated+"</p><p><strong>Date Modified:</strong> "+e[0].dateModified+'</p><hr size="1" /><div class="details"><p><strong>Loading details....</strong></p></div></div>';var k=this.componentBus.getComponentReferences("aw.UserDataManager");if((k)&&(k.length>0)){k[0].retrieveData(e[0].type,e[0].name,null,this._onSelectionDetailsReceived.bind(this))}}else{if(e.length>1){g="<p><strong>Number of Items:</strong> "+e.length+"</p><p><strong>Type:</strong> "+(b.length>1)?"Multiple Types":b[0]+"</p>"}}}var j=[];var c=null;for(var d=0;c=h[d];d++){j.push(new aw.ui.Control.Button({label:c},{click:this._onActionClicked.bind(this,c,e)}))}this._propertiesPanel.add(new aw.ui.Toolbar({region:"bottom",height:60,items:[new aw.ui.Toolbar.Row({items:j})]}));this._propertiesPanel.add(new aw.ui.HTML({html:g}))}},_onHelpClick:function(b){if(this.componentBus){var a=this.componentBus.getComponentReferences("FreeD.Help");if((a)&&(a.length>0)){a[0].loadTopicByTitle(b);return}}new FreeD.Help({componentBus:this.componentBus,activeTopicKey:b})},_onSelectionDetailsReceived:function(c){if((!this._propertiesPanel)||(!c)||(!c.length===1)){return}var a=this._propertiesPanel.canvas.down("div.properties");var e=this._propertiesPanel.canvas.down("div.details");if((a)&&(e)){if(c[0].details){var f=[],b=null;for(b in c[0].details){f.push("<p><strong>"+b+":</strong> "+c[0].details[b]+"</p>")}e.update(f.join(""))}else{e.update("<p><strong>No details found.</strong></p>")}}},_onUserDataActionExecuted:function(a){if((!this._activeDataType)||(this._activeDataType.key=="")||(a.datatype.toLowerCase()==this._activeDataType.key.toLowerCase())){if(a.action.match("save|delete|copy|rename")){this.setActiveDataType(this._activeDataType)}}},_onUserSettingsReceived:function(a){if((!a)||(!this._uploadFileButton)){return}if(a.enableUploadedLocations===true){this._uploadFileButton.enable()}else{this._uploadFileButton.disable()}},CLASS_NAME:"FreeD.FileViewer"});FreeD.GeographyBar=Class.create(aw.ui.GeographyBar,{initialize:function(b,a){this.inheritCSS=true;this._selectSavedGeography={label:"Select Saved Geography...",disabled:true,callback:this._onSelectSavedGeographyClicked.bind(this),icon:"./core/img/GeographyBar/saved.png"};Object.extend(b,{standardOptions:[{label:"Create Custom Location(s)...",callback:this._onCreateCustomLocationsClicked.bind(this),icon:"./core/img/GeographyBar/customlocation.png"},{label:"Pick From Geography List...",callback:this._onPickFromGeographyListClicked.bind(this),icon:"./core/img/GeographyBar/geographylist.png"},this._selectSavedGeography]});aw.ui.GeographyBar.prototype.initialize.apply(this,[b,a])},_onAuthenticationFailure:function(){this._selectSavedGeography.disabled=true;aw.ui.GeographyBar.prototype._onAuthenticationFailure.apply(this)},_onAuthenticationSuccess:function(){this._selectSavedGeography.disabled=false;aw.ui.GeographyBar.prototype._onAuthenticationSuccess.apply(this)},_onCreateCustomLocationsClicked:function(){new FreeD.CustomRadiiDialog({componentBus:this.componentBus},{onpointscreated:this._onCustomPointsCreated.bind(this)})},_onCustomPointsCreated:function(b){var a=this.componentBus.getComponentReferences("aw.GeographyManager");if((a)&&(a.length>0)){a[0].setActiveGeography(b,true)}},_onEditButtonClick:function(b){var a=this.componentBus.getComponentReferences("aw.GeographyManager");if((a)&&(a.length>0)){new FreeD.GeographyDialog({componentBus:this.componentBus,geoCollection:a[0].activeGeography},{ongeographyselected:this._onGeographySelected.bind(this)})}},_onGeographySelected:function(f,b,a,e,d){var c=this.componentBus.getComponentReferences("aw.GeographyManager");if((c)&&(c.length>0)){c[0].setActiveGeography(f,true,b,a,e,d)}},_onPickFromGeographyListClicked:function(){new FreeD.GeographyDialog({componentBus:this.componentBus},{ongeographyselected:this._onGeographySelected.bind(this)})},_onSelectSavedGeographyClicked:function(){if(this.isSessionValidated()===true){new FreeD.SavedGeographyDialog({componentBus:this.componentBus})}else{new aw.ui.Dialog.Error({title:"Error",content:"You must be logged in to access this functionality."})}},CLASS_NAME:"FreeD.GeographyBar"});FreeD.GeographyDialog=Class.create(aw.ui.Dialog,{geoCollection:null,_customGeographies:[],_geographyTree:null,initialize:function(b,a){this.geoCollection=null;this.inheritCSS=true;this._customGeographies=[];this._geographyTree=null;Object.extend(b,{title:"Select Geography"});aw.ui.Dialog.prototype.initialize.apply(this,[b,a])},draw:function(){aw.ui.Dialog.prototype.draw.apply(this);var b=this.canvas.down("div.contents");if(b){b.update(this._local_templates.ui.evaluate({}));var l=b.down("div.geographyTree");if(l){var e=this.componentBus.getComponentReferences("aw.GeographyManager");if((e)&&(e.length>0)){e=e[0];var k=[];if((this.geoCollection)&&(this.geoCollection.geos)&&(this.geoCollection.geos.length>0)){var f=null,a=null,h=null,c=null;for(var d=0,g=this.geoCollection.geos.length;d<g;++d){f=this.geoCollection.geos[d];if(f.derivesFrom("aw.Geography.Standard")){k.push(f.shortGeoName+":"+f.geoKey)}}}var j=this._buildCustomGeographyNodes(this.geoCollection);this._geographyTree=new aw.ui.Tree({container:l,componentBus:this.componentBus,nodes:[{key:"CUSTOM",label:"Custom Radii/Drivetimes",type:((j)&&(j.length>0))?"branch":"leaf",selectable:false,actions:[{label:"Create",callback:this._onCreateRadiiClicked.bind(this)}],children:j}],baseRequest:{cn:"SRC.Web.Client.Handler.AllocateHandler|"+e.allocateDataset.variant,service:"geographyTree",k:k}})}}}this._renderButton("OK",this._onSelectGeography.bind(this));this._renderButton("Cancel",this.close.bind(this));return this.canvas},_getCustomGeographyByKey:function(e){if((!e)||(!this._customGeographies)||(!this._customGeographies.length>0)){return null}var f=null,g=null;var h=[];for(var d=0,a=this._customGeographies.length;d<a;++d){f=this._customGeographies[d];g=(f.type=="aw.Geography.Radius")?aw.Geography.Radius:aw.Geography.Drivetime;if(f.key==e){if((f.radii)&&(f.radii.length>0)){for(var c=0;c<f.radii.length;c++){h.push(new g(null,f.radii[c].name,f.radii[c].label,f.radii[c].radius,f.x,f.y,f.radii[c].units))}}}else{if((f.radii)&&(f.radii.length>0)){for(var b=0;b<f.radii.length;b++){if(f.radii[b].key==e){h.push(new g(null,f.radii[b].name,f.radii[b].label,f.radii[b].radius,f.x,f.y,f.radii[b].units))}}}}}return h},_buildCustomGeographyNodes:function(d){this._customGeographies=[];var a=[],p=[],q=[];if((d)&&(d.geos)&&(d.geos.length>0)){var l=null,b=null,n=null,g=null;for(var h=0,m=d.geos.length;h<m;++h){l=d.geos[h];if(l.derivesFrom("aw.Geography.Radius")){b=l.getCentroid();n={key:this.getId(),name:l.name,label:(l.getRadius()+" "+l.getUnits()+" "+(l.CLASS_NAME=="aw.Geography.Drivetime"?"Drivetime":"Radius")),radius:l.getRadius(),units:l.getUnits()};g=d._containsCentroid(this._customGeographies,l.CLASS_NAME,b);if(g<0){this._customGeographies.push({key:this.getId(),name:l.name,type:l.CLASS_NAME,x:b.x,y:b.y,radii:[n]})}else{this._customGeographies[g].radii.push(n)}}}}if((this._customGeographies)&&(this._customGeographies.length>0)){var o=null;for(var f=0;f<this._customGeographies.length;f++){o={key:"CUSTOM:"+this._customGeographies[f].key,parentKey:"CUSTOM",label:this._customGeographies[f].name,type:"branch",selectable:true,children:[]};for(var e=0;e<this._customGeographies[f].radii.length;e++){o.children.push({key:"CUSTOM:"+this._customGeographies[f].radii[e].key,label:this._customGeographies[f].radii[e].label,type:"leaf",selectable:true})}p.push(o)}}return p},_onCreateRadiiClicked:function(){new FreeD.CustomRadiiDialog({componentBus:this.componentBus},{onpointscreated:function(a){if(this._geographyTree){this._geographyTree.removeChildNodesByKey("CUSTOM");this._geographyTree.addNodes(this._buildCustomGeographyNodes(a))}}.bind(this)})},_onSelectGeography:function(){if(!this._geographyTree){return}var d=this.componentBus.getComponentReferences("aw.GeographyManager");if((d)&&(d.length>0)){d=d[0]}else{return}var b=new aw.GeographyCollection();var g=[];var a=[];var l=this._geographyTree.getSelectedNodes();if((l)&&(l.length>0)){for(var e=0,h=l.length;e<h;++e){a=l[e].key.split(":");if(a[0]=="CUSTOM"){var f=this._getCustomGeographyByKey(a[1]);if((f)&&(f.length>0)){for(var c=0;c<f.length;c++){b.addGeography(f[c])}}}else{b.addGeography(new aw.Geography.Standard(null,l[e].label,l[e].label,a[0],((a.length>1)?a[a.length-1]:"*"),d.allocateDataset.key))}}}b.generateLabel();var k={cn:"SRC.Web.Client.Handler.AllocateHandler|"+d.allocateDataset.variant,service:"computeBounds"};Object.extend(k,b.getGeographyDefinition());this.request(k,function(n,j,m){if((!m)||(!m.payload)){return}var i=m.payload.count;if(i>5000){new aw.ui.Dialog.Error({title:"Error",content:"You may not select more than 5,000 individual geographies."})}else{if(i<1){new aw.ui.Dialog.Error({title:"Error",content:"You must select at least one geography."})}else{n.setGeographyCount(i);this.triggerEvent("ongeographyselected",n,m.payload.minx,m.payload.miny,m.payload.maxx,m.payload.maxy);this.close()}}}.bind(this,b))},_local_templates:{ui:new Template('<div class="geographyTree"></div><div class="geographyHelp">Select one or more geographies from the list at the left and click OK when done.</div>')},EVENTS:["ongeographyselected"],VALID_PROPERTIES:["title","closeable","content","moveable","cssClass","componentBus","geoCollection"],CLASS_NAME:"FreeD.GeographyDialog"});FreeD.Help=Class.create(aw.ui.Panel.Splitter,{activeTopicKey:null,_topicTree:null,_onHelpContentLoaded_fx:null,initialize:function(b,a){this.activeTopicTitle=null;this._topicTree=null;this._onHelpContentLoaded_fx=null;this.inheritCSS=true;Object.extend(b||{},{title:"Help",moveable:true,resizeable:true,closeable:true,orientation:"horizontal",height:400,width:500,container:$(document.getElementsByTagName("body")[0]),position:{top:"100px",left:"200px"}});aw.ui.Panel.Splitter.prototype.initialize.apply(this,[b,a]);if(this.componentBus){this.componentBus.getComponentReferences("aw.HelpManager",function(c){if((c)&&(c.length>0)){var d=c[0];this._onHelpContentLoaded_fx=this._onHelpContentLoaded.bind(this);d.registerEvent("helpcontentloaded",this._onHelpContentLoaded_fx);if((d.helpContent)&&(d.helpContent.length>0)){this._onHelpContentLoaded.bind(d.helpContent)}else{d.loadHelpFile("./custom/js/HelpContent.js","_FreeDHelp")}}}.bind(this))}},close:function(){aw.ui.Panel.Splitter.prototype.close.apply(this);this.destroy()},destroy:function(){if(this.componentBus){if(this._onHelpContentLoaded_fx){this.componentBus.unregisterEvent("helpcontentloaded",this._onHelpContentLoaded_fx);this._onHelpContentLoaded_fx=null}}aw.ui.Panel.Splitter.prototype.destroy.apply(this)},draw:function(){aw.ui.Panel.Splitter.prototype.draw.apply(this);this._topicTree=new aw.ui.Tree({mode:"single",nodes:this._buildTopicNodes()},{onselectionchanged:this._onTopicSelectionChanged.bind(this)});this._contentPanel=new aw.ui.Panel({width:300,minWidth:250,titleVisibility:false,cssClass:"FreeD_Help_Content"});this.add([new aw.ui.Panel({title:"Table of Contents",width:200,minWidth:150,items:[this._topicTree]}),this._contentPanel]);return this.canvas},loadTopicByTitle:function(a){if(this._topicTree){this._topicTree.clearSelection();this._topicTree.selectNodeByKey(a)}else{this._loadTopicByTitle(a)}},_buildTopicNodes:function(g,d){if(((!g)||(!g.length>0))&&(!d)){var f=this.componentBus.getComponentReferences("aw.HelpManager");if((f)&&(f.length>0)){g=f[0].helpContent}}var a=[],e=null,c=null;if((g)&&(g.length>0)){for(var b=0;b<g.length;b++){c=((d)?(d.title+":"):"")+g[b].title;e={key:c,label:g[b].title,selectable:true,type:"leaf",selected:((this.activeTopicKey)&&(c==this.activeTopicKey))?true:false};if((g[b].topics)&&(g[b].topics.length>0)){Object.extend(e,{type:"branch",children:this._buildTopicNodes(g[b].topics,g[b])})}a.push(e)}}return a},_loadTopicByTitle:function(b){if((!b)||(b==="")){return}var c=this.componentBus.getComponentReferences("aw.HelpManager");if((!c)||(!c.length>0)){return}var a=c[0].getTopicByTitle(b);if(!a){return}this.setTitle("Help: "+a.title);this._contentPanel.update(new aw.ui.HTML({html:a.content}));this.activeTopicKey=b},_onHelpContentLoaded:function(a){if((!this._topicTree)||(!a)||(!a.length>0)){return}this._topicTree.clear();this._topicTree.addNodes(this._buildTopicNodes(a));this._onTopicSelectionChanged(this._topicTree)},_onTopicSelectionChanged:function(a){var b=a.getSelectedKeys();if((b)&&(b.length>0)){this._topicTree.expandParentNodesByKey(b[0]);this._loadTopicByTitle(b[0])}},VALID_PROPERTIES:["title","componentBus","container","cssClass","closeable","titleVisibility","height","width","moveable","resizeable","minHeight","minWidth","orientation","disabled","position","activeTopicKey"],CLASS_NAME:"FreeD.Help"});FreeD.HTMLViewer=Class.create(aw.ui.Panel,{initialize:function(b,a){this.inheritCSS=true;aw.ui.Panel.prototype.initialize.apply(this,arguments)},draw:function(){aw.ui.Panel.prototype.draw.apply(this);var a=this.canvas.down("div.contents");if(a){a.insert('<iframe src="./custom/welcome.html"></iframe>');this._frame=this.canvas.down("iframe")}this.add(new aw.ui.Toolbar({height:30,items:[new aw.ui.Toolbar.Row({items:[new aw.ui.Control.Link({label:"Get Started"},{click:this._menuClick.bind(this,"welcome.html")}),new aw.ui.Control.Link({label:"Learn More"},{click:this._menuClick.bind(this,"learnmore.html")}),new aw.ui.Control.Link({label:"About Us"},{click:this._menuClick.bind(this,"aboutus.html")}),new aw.ui.Control.Link({label:"Contact Us"},{click:this._menuClick.bind(this,"contactus.html")}),new aw.ui.Control.Link({label:"Help"},{click:this._menuClick.bind(this,"GlossaryData.html")})]})]}));return this.canvas},setURL:function(a){this._frame.src=a},_menuClick:function(a){this.setURL("./custom/"+a)},CLASS_NAME:"FreeD.HTMLViewer"});FreeD.LoginDialog=Class.create(aw.ui.Dialog,{initialize:function(b,a){Object.extend(b,{title:"Login"});this.inheritCSS=true;aw.ui.Dialog.prototype.initialize.apply(this,[b,a]);if(this.componentBus){this._onLoginFailure_fx=this._onLoginFailure.bind(this);this.componentBus.registerEvent("onloginfailure",this._onLoginFailure_fx);this._onLoginSuccess_fx=this._onLoginSuccess.bind(this);this.componentBus.registerEvent("onloginsuccess",this._onLoginSuccess_fx)}},draw:function(){aw.ui.Dialog.prototype.draw.apply(this);var a=this.canvas.down("div.contents");if(!a){return null}a.insert(this._local_templates.ui);var b=this.readCookie("username");this._userTextbox=new aw.ui.Control.TextBox({label:"Email:",value:this.readCookie("username"),container:a.down("div.inputEmail"),hasFocus:((b)&&(b!==""))?false:true,cssClass:"loginField"},{enter:this._onLoginClick.bind(this)});this._passTextbox=new aw.ui.Control.TextBox({label:"Password:",type:"password",container:a.down("div.inputPassword"),hasFocus:((b)&&(b!==""))?true:false,cssClass:"loginField"},{enter:this._onLoginClick.bind(this)});Element.observe(a.down("span.forgotPassword"),"click",this._onForgotPasswordClick.bind(this));Element.observe(a.down("span.signup"),"click",this._onSignupClick.bind(this));this._renderButton("Login",this._onLoginClick.bind(this));this._renderButton("Cancel",this.close.bind(this));return this.canvas},erase:function(){if(this.componentBus){if(this._onLoginFailure_fx){this.componentBus.unregisterEvent("onloginfailure",this._onLoginFailure_fx);this._onLoginFailure_fx=null}if(this._onLoginSuccess_fx){this.componentBus.unregisterEvent("onloginsuccess",this._onLoginSuccess_fx);this._onLoginSuccess_fx=null}}aw.ui.Dialog.prototype.erase.apply(this)},_destroyLoadingDialog:function(){if(this._loadingDialog){this._loadingDialog.close();this._loadingDialog.destroy();delete this._loadingDialog}},_onForgotPasswordClick:function(){new aw.ui.Dialog.ForgotPassword({componentBus:this.componentBus,defaultEmail:this._userTextbox.getValue()})},_onLoginClick:function(){if(!this.componentBus){return}this.componentBus.loadUser(this._userTextbox.getValue(),this._passTextbox.getValue());this._destroyLoadingDialog();this._loadingDialog=new aw.ui.Dialog.Loading({message:"Logging in..."})},_onLoginFailure:function(a){this._userTextbox.blur();this._passTextbox.blur();this._destroyLoadingDialog();new aw.ui.Dialog.Error({title:"Login Error",content:a})},_onLoginSuccess:function(){this._destroyLoadingDialog();this.destroy();this.close()},_onSignupClick:function(){var a=this.componentBus.getComponentReferences("FreeD");if((a)&&(a.length>0)){a[0]._onSignup();this.close()}},_local_templates:{ui:'<div class="inputEmail"></div><div class="inputPassword"></div><span class="small">(Password field is case sensitive)</span><div class="links"><span class="forgotPassword">Forgot Password?</span> &#160; | &#160; <span class="signup">Need an account?</span></div>'},CLASS_NAME:"FreeD.LoginDialog"});FreeD.MapViewer=Class.create(aw.ui.Panel,{_map:null,initialize:function(b,a){this._map=null;this.inheritCSS=true;aw.ui.Panel.prototype.initialize.apply(this,arguments);if(this.componentBus){this.componentBus.getComponentReferences("aw.GeographyManager",function(c){if((c)&&(c.length>0)){var d=c[0];d.registerEvent("onactivegeographychanged",this._onActiveGeographyChanged.bind(this));d.registerEvent("onboundschanged",this._onBoundsChanged.bind(this));if(d.activeGeography){this._onActiveGeographyChanged(d.activeGeography,true)}}}.bind(this))}},draw:function(){aw.ui.Panel.prototype.draw.apply(this);this._map=new aw.ui.Map({componentBus:this.componentBus,layers:[new aw.ui.Map.Layer.Static({key:"base",label:"Base",drawPriority:0,visible:true,icon:"./core/img/Map/Layer/base.png",parameters:{service:"base"}}),new aw.ui.Map.Layer.Static({key:"roads",label:"Roads",drawPriority:2,visible:true,icon:"./core/img/Map/Layer/roads.png",showInLegend:true,parameters:{service:"roads"}}),new aw.ui.Map.Layer.GeographySelection({visible:true,drawPriority:20,showInLegend:true,opacity:0.5})],controls:[new aw.ui.Map.Control.Features({componentBus:this.componentBus,moveable:true,closeable:false,hideable:false,resizeable:true,position:{top:"10px",right:"10px",left:"auto"},height:300,width:275,minHeight:250,minWidth:275,optionsAvailable:false})]});this.add([this._map,new aw.ui.Toolbar({region:"top",height:100,cssClass:"FreeD_Toolbar",items:[new aw.ui.Toolbar.Group({label:"Geography Selection",cssClass:"geoselection",items:[new FreeD.GeographyBar({componentBus:this.componentBus})],helpCallback:this._onHelpClick.bind(this,"Geography Selection")}),new aw.ui.Toolbar.Group({label:"Feedback",items:[new aw.ui.Toolbar.Row({items:[new aw.ui.Control.Link({label:"Please provide us with any<br />feedback by filling out this form.",cssClass:"feedbackLink"},{click:this._onFeedbackClick.bind(this)})]})]})]}),new aw.ui.HTML({html:'<div class="mapAttribution">&#169 2006-'+new Date().getFullYear()+" TomTom</div>"})]);return this.canvas},hide:function(){aw.ui.Panel.prototype.hide.apply(this);if(this._map){this._map.hide()}},show:function(){aw.ui.Panel.prototype.show.apply(this);if(this._map){this._map.show()}},_onActiveGeographyChanged:function(g,c,b,a,f,e){if(!g){return}c=(c===false?false:true);if((g)&&(g.anchor)&&(g.anchor.x)&&(g.anchor.y)&&(c===true)){this._map.setCenter(g.anchor.y,g.anchor.x)}if((g)&&(g.geos)&&(g.geos.length>0)){if((c===true)&&(b)&&(a)&&(f)&&(e)){this._map.zoomToExtent(b,a,f,e)}else{if(c===true){var d=this.componentBus.getComponentReferences("aw.GeographyManager");if((d)&&(d.length>0)){d[0].computeBounds(g)}}}}},_onBoundsChanged:function(b,a,d,c){if((b)&&(a)&&(d)&&(c)){this._map.zoomToExtent(b,a,d,c)}},_onFeedbackClick:function(){new FreeD.FeedbackDialog({componentBus:this.componentBus})},_onHelpClick:function(b){if(this.componentBus){var a=this.componentBus.getComponentReferences("FreeD.Help");if((a)&&(a.length>0)){a[0].loadTopicByTitle(b);return}}new FreeD.Help({componentBus:this.componentBus,activeTopicKey:b})},CLASS_NAME:"FreeD.MapViewer"});FreeD.ReportViewer=Class.create(aw.ui.Panel,{_activeReportFormat:null,_frame:null,_reportDropDown:null,_reportFormatGroup:null,_activeFormatButton:null,_url:null,_onActiveReportChanged_fx:null,_onReportsChanged_fx:null,_onActiveGeographyChanged_fx:null,initialize:function(b,a){this._activeReportFormat="Comparison";this._frame=null;this._reportDropDown=null;this._printReportButton=null;this._saveReportButton=null;this._viewSavedReportsButton=null;this._exportReportButton=null;this._reportFormatGroup=null;this._activeFormatButton=null;this._url=null;this.inheritCSS=true;aw.ui.Panel.prototype.initialize.apply(this,[b,a]);if(this.componentBus){this.componentBus.getComponentReferences("aw.ReportManager",function(d){if((d)&&(d.length>0)){var e=d[0];this._onActiveReportChanged_fx=this._onActiveReportChanged.bind(this);this._onReportsChanged_fx=this._onReportsChanged.bind(this);e.registerEvent("onactivereportchanged",this._onActiveReportChanged_fx);e.registerEvent("onreportschanged",this._onReportsChanged_fx);var c=e.getAllReports();if((c)&&(c.length>0)){this._onReportsChanged(c)}if(e.activeReport){this._onActiveReportChanged(e.activeReport)}}}.bind(this));this.componentBus.getComponentReferences("aw.GeographyManager",function(c){if((c)&&(c.length>0)){var d=c[0];this._onActiveGeographyChanged_fx=this._onActiveGeographyChanged.bind(this);d.registerEvent("onactivegeographychanged",this._onActiveGeographyChanged_fx);if(d.activeGeography){this._onActiveGeographyChanged(d.activeGeography)}}}.bind(this));this.componentBus.registerEvent("onauthenticationfailure",this._onAuthenticationFailure.bind(this));this.componentBus.registerEvent("onauthenticationsuccess",this._onAuthenticationSuccess.bind(this));this.componentBus.registerEvent("onvalidationfailure",this._onAuthenticationFailure.bind(this));this.componentBus.registerEvent("onvalidationsuccess",this._onAuthenticationSuccess.bind(this))}},destroy:function(){var b=this.componentBus.getComponentReferences("aw.ReportManager");if((b)&&(b.length>0)){b=b[0];if(this._onActiveReportChanged_fx){b.unregisterEvent("onactivereportchanged",this._onActiveReportChanged_fx)}if(this._onReportsChanged_fx){b.unregisterEvent("onreportschanged",this._onReportsChanged_fx)}}var a=this.componentBus.getComponentReferences("aw.GeographyManager");if((a)&&(a.length>0)){a=a[0];if(this._onActiveGeographyChanged_fx){a.unregisterEvent("onactivegeographychanged",this._onActiveGeographyChanged_fx)}}aw.ui.Panel.prototype.destroy.apply(this)},draw:function(){aw.ui.Panel.prototype.draw.apply(this);this._reportDropDown=new aw.ui.Control.DropDown({options:[{value:"",label:"Loading..."}]},{change:this._onReportDropDownChange.bind(this)});this._printReportButton=new aw.ui.Control.Button({label:"Print",icon:"./core/img/Misc/printer.png",disabled:true},{click:this._onPrintReportClick.bind(this)});this._saveReportButton=new aw.ui.Control.Button({label:"Save",disabled:true},{click:this._onSaveReportClick.bind(this)});this._viewSavedReportsButton=new aw.ui.Control.Button({label:"View Saved Reports",disabled:true},{click:this._onViewSavedReportsClick.bind(this)});this._exportReportButton=new aw.ui.Control.Button.Split({disabled:true,items:[new aw.ui.Control.Button({label:"Export As PDF",icon:"./core/img/Misc/acrobat.png"},{click:this._onExportReportClick.bind(this,"pdf")}),new aw.ui.Control.Button({label:"Export As XLSX",icon:"./core/img/Misc/excel.png"},{click:this._onExportReportClick.bind(this,"xlsx")}),new aw.ui.Control.Button({label:"Export As DOCX",icon:"./core/img/Misc/word.png"},{click:this._onExportReportClick.bind(this,"docx")})]});this._activeFormatButton=new aw.ui.Control.Button.Toggle({label:"Comparison",toggled:true});this._reportFormatGroup=new aw.ui.Control.Button.Group({items:[this._activeFormatButton,new aw.ui.Control.Button.Toggle({label:"Summary"}),new aw.ui.Control.Button.Toggle({label:"Rank"})]},{toggle:this._onReportFormatToggle.bind(this)});this.add(new aw.ui.Toolbar({region:"top",height:100,cssClass:"FreeD_Toolbar",items:[new aw.ui.Toolbar.Group({label:"Geography Selection",cssClass:"geoselection",items:[new FreeD.GeographyBar({componentBus:this.componentBus})],helpCallback:this._onHelpClick.bind(this,"Geography Selection")}),new aw.ui.Toolbar.Group({label:"Report Type",items:[new aw.ui.Toolbar.Column({items:[new aw.ui.Toolbar.Row({items:[this._reportFormatGroup]}),new aw.ui.Toolbar.Row({items:[this._reportDropDown]})]})],helpCallback:this._onHelpClick.bind(this,"Reporting:Report Types")}),new aw.ui.Toolbar.Group({label:"File Options",items:[new aw.ui.Toolbar.Column({items:[new aw.ui.Toolbar.Row({items:[this._viewSavedReportsButton,this._saveReportButton,this._printReportButton]}),new aw.ui.Toolbar.Row({items:[this._exportReportButton]})]})],helpCallback:this._onHelpClick.bind(this,"Reporting:Manage Report Files")}),new aw.ui.Toolbar.Group({label:"Feedback",items:[new aw.ui.Toolbar.Row({items:[new aw.ui.Control.Link({label:"Please provide us with any<br />feedback by filling out this form.",cssClass:"feedbackLink"},{click:this._onFeedbackClick.bind(this)})]})]})]}));var b=this.canvas.down("div.contents");if(b){var a=this.getId("awf");b.insert('<iframe id="'+a+'" name="'+a+'"></iframe>');this._frame=this.canvas.down("iframe")}return this.canvas},executeReport:function(d,a){if((!d)||(!a)){return}var b=[];b.push("cn=SRC.Web.Client.Handler.ReportHandler");b.push("service=loading");if(this.componentBus.getApplicationKey()){b.push("akey="+this.componentBus.getApplicationKey())}if(this._frame){this._frame.src=this.componentBus.getComponentServer()+"?"+b.join("&")}if(a.type=="Calgary"){var c={cn:"SRC.Web.Client.Handler.CalgaryHandler"+((a.variant)?("|"+a.variant):""),service:"buildCalgaryQuery",query:a.query};Object.extend(c,d.getGeographyDefinition());this.request(c,function(h,e,f,g){if((!g)||(!g.payload)||(!g.payload.query)){return}e.query=g.payload.query;this._executeReport(h,e)}.bind(this,d,a));return}this._executeReport(d,a)},renderReport:function(b,a){this._url=this._getReportExportURL(b,a);if(this._frame){this._frame.src=this._url}},setActiveReportFormat:function(c){if((!c)||(!c.match("Comparison|Summary|Rank|List"))){return false}var b=this.componentBus.getComponentReferences("aw.ReportManager");if((b)&&(b.length>0)){b=b[0];var a=b.getReportsBy({format:c,listOnly:false});if((!a)||(!a.length>0)){new aw.ui.Dialog.Error({title:"No Reports Available",content:"You do not have any "+c+" reports available.<br />Please contact our sales team."});return false}if(c==this._activeReportFormat){return true}this._activeReportFormat=c;this._onReportsChanged(b.getAllReports());if(this._reportDropDown){this._onReportDropDownChange(this._reportDropDown)}return true}return false},_executeReport:function(c,a){var b={cn:"SRC.Web.Client.Handler."+((a.type=="Alteryx"||a.type=="Calgary")?"AlteryxHandler":"AllocateHandler")+((a.variant&&a.variant!==""&&a.type!="Calgary")?("|"+a.variant):""),service:"executeReport",type:a.type,format:a.format};if(a.type=="Calgary"){Object.extend(b,{dataset:a.variant,query:a.query,queryName:a.name})}else{Object.extend(b,{report:a.name})}if(a.format.toLowerCase()=="summary"){c.summarizeRadii(true)}else{c.summarizeRadii(false)}Object.extend(b,c.getGeographyDefinition());this.request(b,function(d,e){if((!e)||(!e.payload)){return}this.renderReport(e.payload,"html")}.bind(this))},_getReportExportURL:function(c,b){b=((b)&&(b.toLowerCase().match("pdf|xlsx|docx|html")))?b.toLowerCase():"html";var a=[];a.push("cn=SRC.Web.Client.Handler.ReportHandler");a.push("service=render");a.push("report="+escape(c.report));a.push("type="+escape(c.type));a.push("format="+escape(b));a.push("seqId="+this.getId(""));if(this.componentBus.getApplicationKey()){a.push("akey="+this.componentBus.getApplicationKey())}if(this.componentBus.getSessionKey()){a.push("skey="+this.componentBus.getSessionKey())}return this.componentBus.getComponentServer()+"?"+a.join("&")},_onActiveGeographyChanged:function(b){var a=this.componentBus.getComponentReferences("aw.ReportManager");if((a)&&(a.length>0)){a=a[0];if(a.activeReport){this.executeReport(b,a.activeReport)}}},_onActiveReportChanged:function(b){if((this._activeReportFormat!=b.format)&&(this._reportFormatGroup)){var a=this._reportFormatGroup.getItemBy({label:b.format});if(a){a.setToggled(true);return}}this._activeReportFormat=b.format;var d=this.componentBus.getComponentReferences("aw.ReportManager");if((d)&&(d.length>0)){d=d[0];this._onReportsChanged(d.getAllReports())}if(this._reportDropDown){this._reportDropDown.selectByValue(b.key,false)}var c=this.componentBus.getComponentReferences("aw.GeographyManager");if((c)&&(c.length>0)){c=c[0];if(c.activeGeography){this.executeReport(c.activeGeography,b)}}},_onAuthenticationFailure:function(){this._viewSavedReportsButton.disable();this._saveReportButton.disable();this._printReportButton.disable();this._exportReportButton.disable()},_onAuthenticationSuccess:function(){this._viewSavedReportsButton.enable();this._saveReportButton.enable();this._printReportButton.enable();this._exportReportButton.enable()},_onExportReportClick:function(c,b){if(this.isSessionValidated()!==true){new aw.ui.Dialog.Error({title:"Access Denied",content:"You must be logged in to access this functionality."});return}if(!this._frame){return}var a=this._url.replace(/\&format=\w+/gi,"").replace(/\&seqId=\w+/gi,"");a+="&seqId="+this.getId("");a+="&format="+c;this._frame.src=a},_onFeedbackClick:function(){new FreeD.FeedbackDialog({componentBus:this.componentBus})},_onHelpClick:function(b){if(this.componentBus){var a=this.componentBus.getComponentReferences("FreeD.Help");if((a)&&(a.length>0)){a[0].loadTopicByTitle(b);return}}new FreeD.Help({componentBus:this.componentBus,activeTopicKey:b})},_onPrintReportClick:function(a){if(this.isSessionValidated()===true){if(this._frame){if((document)&&(document[this._frame.readAttribute("id")])){document[this._frame.readAttribute("id")].focus();document[this._frame.readAttribute("id")].print()}else{if((window)&&(window.frames)&&(window.frames[this._frame.readAttribute("id")])){window.frames[this._frame.readAttribute("id")].focus();window.frames[this._frame.readAttribute("id")].print()}else{new aw.ui.Dialog.Error({title:"Print Error!",content:"Your browser does not appear to support report printing capabilities."})}}}}else{new aw.ui.Dialog.Error({title:"Access Denied",content:"You must be logged in to access this functionality."})}},_onReportDropDownChange:function(b){var a=this.componentBus.getComponentReferences("aw.ReportManager");if((a)&&(a.length>0)){a=a[0];a.setActiveReportByKey(b.getValue())}},_onReportFormatToggle:function(a,b){if(this._activeFormatButton===b){return}if(this.setActiveReportFormat(b.label)!==true){this._activeFormatButton.setToggled(true);return}this._activeFormatButton=b},_onReportsChanged:function(b){if((!b)||(!this._reportDropDown)){return}this._reportDropDown.clear();var d=this.componentBus.getComponentReferences("aw.ReportManager");if((!d)||(!d.length>0)){return}d=d[0];var a=null;for(var c=0;a=b[c];c++){if(a.format==this._activeReportFormat){this._reportDropDown.addOption(a.key,a.label,a.listOnly,((a===d.activeReport)?true:false))}}},_onSaveReportClick:function(b){if(this.isSessionValidated()===true){var a=this.componentBus.getComponentReferences("aw.ReportManager");if((a)&&(a.length>0)){a[0].saveActiveReport()}}else{new aw.ui.Dialog.Error({title:"Access Denied",content:"You must be logged in to access this functionality."})}},_onViewSavedReportsClick:function(c){if(this.isSessionValidated()===true){var a=this.componentBus.getComponentReferences("aw.UserDataManager");if((a)&&(a.length>0)){var b=this.componentBus.getComponentReferences("FreeD.FileViewer");if((b)&&(b.length>0)){b[0].setActiveDataType(a[0].getDataTypeByLabel("Saved Reports"));b[0].show()}}}else{new aw.ui.Dialog.Error({title:"Access Denied",content:"You must be logged in to access this functionality."})}},CLASS_NAME:"FreeD.ReportViewer"});FreeD.SavedGeographyDialog=Class.create(aw.ui.Dialog,{initialize:function(b,a){this.inheritCSS=true;Object.extend(b,{title:"Select a Saved Geography",content:"Loading..."});aw.ui.Dialog.prototype.initialize.apply(this,[b,a])},afterDraw:function(){aw.ui.Dialog.prototype.afterDraw.apply(this);var a=this.componentBus.getComponentReferences("aw.UserDataManager");if((a)&&(a.length>0)){a=a[0]}else{return}a.retrieveData("SavedGeography",null,null,function(c){var b=new aw.ui.Grid({columns:[{index:"name",label:"Name",sorted:true,sortDirection:"asc"},{index:"dateCreated",label:"Date Created"},{index:"dateModified",label:"Date Modified"}],selectMultiple:false});this.setContent(b.draw());b.loadData(c);this._renderButton("OK",this._onSelectGeographyClick.bind(this,b));this._renderButton("Cancel",this.close.bind(this))}.bind(this))},_onSelectGeographyClick:function(a){if(!a){return}var e=a.getSelectedRecords();if((!e)||(!e.length>0)){return}var d=e[0];var c=this.componentBus.getComponentReferences("aw.GeographyManager");if((c)&&(c.length>0)){c=c[0]}else{return}if(d.geoCollection){c.setActiveGeography(d.geoCollection);this.close()}else{var b=this.componentBus.getComponentReferences("aw.UserDataManager");if((b)&&(b.length>0)){b[0].retrieveData("SavedGeography",d.name,null,function(g,f){if((f)&&(f.length>0)&&(f[0].geoCollection)){g.setActiveGeography(f[0].geoCollection);this.close()}}.bind(this,c))}}},CLASS_NAME:"FreeD.SavedGeographyDialog"});FreeD.WizardViewer=Class.create(aw.ui.Panel,{_wizardTree:null,_wizardInterface:null,_wizardQueue:null,_onWizardsChanged_fx:null,_onActiveWizardChanged_fx:null,initialize:function(b,a){this._wizardTree=null;this._wizardInterface=null;this._wizardQueue=null;this._onWizardsChanged_fx=null;this._onActiveWizardChanged_fx=null;this.inheritCSS=true;aw.ui.Panel.prototype.initialize.apply(this,[b,a]);if(this.componentBus){this.componentBus.getComponentReferences("aw.WizardManager",function(d){if((d)&&(d.length>0)){var e=d[0];this._onWizardsChanged_fx=this._onWizardsChanged.bind(this);this._onActiveWizardChanged_fx=this._onActiveWizardChanged.bind(this);this._onWizardJobUpdated_fx=this._onWizardJobUpdated.bind(this);e.registerEvent("onwizardschanged",this._onWizardsChanged_fx);e.registerEvent("onactivewizardchanged",this._onActiveWizardChanged_fx);e.registerEvent("onwizardjobupdated",this._onWizardJobUpdated_fx);e.registerEvent("onwizardjobcreated",this._onWizardJobUpdated_fx);var c=e.getAllWizards();if((c)&&(c.length>0)){this._onWizardsChanged(c)}if(e.activeWizard){this._onActiveWizardChanged(e.activeWizard);if(e.activeWizard["interface"]){this._onWizardInterfaceReceived(e.activeWizard)}}}}.bind(this))}},draw:function(){aw.ui.Panel.prototype.draw.apply(this);this._wizardTree=new aw.ui.Tree({mode:"single"},{onselectionchanged:this._onWizardTreeSelectionChanged.bind(this)});this._wizardInterface=new aw.ui.WizardInterface({componentBus:this.componentBus});this._wizardQueue=new aw.ui.WizardQueue({componentBus:this.componentBus,title:"Queue",width:400,minWidth:350,helpCallback:this._onHelpClick.bind(this,"2010 Census:Queue"),maskedExportFormats:["mif"],renamedExportFormats:[{format:"vhtml",label:"VHTML (FireFox Only)"},{format:"csv",label:"CSV"},{format:"dbf",label:"DBF"}]});this.add(new aw.ui.Toolbar({region:"top",height:100,cssClass:"FreeD_Toolbar",items:[new aw.ui.Toolbar.Group({label:"Geography Selection",cssClass:"geoselection",items:[new FreeD.GeographyBar({componentBus:this.componentBus})],helpCallback:this._onHelpClick.bind(this,"Geography Selection")})]}));this.add(new aw.ui.Panel.Splitter({titleVisibility:false,orientation:"horizontal",items:[new aw.ui.Panel({title:"Available Wizards",width:"200",minWidth:"150",items:[this._wizardTree],helpCallback:this._onHelpClick.bind(this,"2010 Census:Available Wizards")}),this._wizardInterface,this._wizardQueue]}));return this.canvas},_onActiveWizardChanged:function(a){if(!a){return}if(this._wizardTree){this._wizardTree.selectNodeByKey(a.guid,false)}},_onHelpClick:function(b){if(this.componentBus){var a=this.componentBus.getComponentReferences("FreeD.Help");if((a)&&(a.length>0)){a[0].loadTopicByTitle(b);return}}new FreeD.Help({componentBus:this.componentBus,activeTopicKey:b})},_onWizardJobUpdated:function(b){if(!b){return}if(b.disposition!="complete"){return}var a=this.componentBus.getComponentReferences("aw.WizardManager");if((a)&&(a.length>0)){a=a[0]}else{return}},_onWizardsChanged:function(b){this._wizardTree.clear();var c=null;for(var a=0;c=b[a];a++){this._wizardTree.addNode({key:c.guid,label:c.name,selectable:true})}},_onWizardTreeSelectionChanged:function(a){if((!a)||(!a.getSelectedKeys)){return}var b=a.getSelectedKeys();if((!b)||(b.length!==1)){return}var c=this.componentBus.getComponentReferences("aw.WizardManager");if((c)&&(c.length>0)){c[0].setActiveWizardByKey(b)}},_onWizardInterfaceReceived:function(a){if(!a){return}this._wizardInterface.loadInterface(a.guid,a["interface"])},CLASS_NAME:"FreeD.WizardViewer"});
