var _gaq=_gaq||[];_gaq.push(["_setAccount","UA-226181-1"]);_gaq.push(["_trackPageview"]);function render(){var b=new aw.ComponentBus();b.setApplicationKey(_awApplicationKey);var a=new DNow({container:$(document.getElementsByTagName("body")[0]),componentBus:b});showSignUp=function(c){a._onSignup(c)}}DNow=Class.create(aw.ui,{initialize:function(c,b){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));this.componentBus.registerEvent("onloaduser",this._onLoadUser.bind(this));if(_DNowGooglePageTracker=="on"){this.componentBus.registerEvent("onrequestinitialized",this._onRequestInitialized.bind(this));(function(){var e=document.createElement("script");e.type="text/javascript";e.async=true;e.src=("https:"==document.location.protocol?"https://ssl":"http://www")+".google-analytics.com/ga.js";var d=document.getElementsByTagName("script")[0];d.parentNode.insertBefore(e,d)})()}var a=new aw.Messenger({componentBus:this.componentBus});a.registerEvent("activemessages",this._onActiveMessagesReceived.bind(this));a.loadMessageFile("./custom/js/Messages.js","_DNowMessages")},draw:function(){aw.ui.prototype.draw.apply(this);var f=new aw.AccountManager({componentBus:this.componentBus});var b=new aw.HelpManager({componentBus:this.componentBus});var g=new DNow.HTMLViewer({componentBus:this.componentBus,title:"Home"});var h=new DNow.ReportViewer({componentBus:this.componentBus,title:"Report",disabled:true});var c=new DNow.MapViewer({componentBus:this.componentBus,title:"Map",disabled:true});var d=new DNow.FileViewer({componentBus:this.componentBus,title:"Files",disabled:true});var a=new DNow.QueryViewer({componentBus:this.componentBus,title:"Query",disabled:true});var e=new DNow.WizardViewer({componentBus:this.componentBus,title:"Wizards",disabled:true});var j=this.canvas.down("span.about");if(j){aw.EventManager.register(j,"click",this._onAboutClick.bind(this))}j=null;this._DNowPanel=new aw.ui.Panel.Tab({titleVisibility:false,container:this.canvas.down('div[id="app"]'),showBgd:false,cssClass:"DNow_TabPanel",showBgd:false,items:[g,h,c,a,e,d]});aw.EventManager.register((document.onresize?document:window),"resize",this._onResize.bind(this,this._DNowPanel));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},_classicLogInOut:function(a){var b=this.getId("awf");var d=null;try{d=document.createElement('<iframe name="'+b+'">');d.id=b}catch(c){d=document.createElement("iframe");d.name=b;d.id=b}if(!d){return}$(document.getElementsByTagName("body")[0]).insert(d);$(d).hide();d.src=a;aw.EventManager.register(d,"load",function(e){this._removeClassicLoginFrame.bind(this,e).delay(2)}.bind(this,d))},_hideClassicLink:function(){if(this.canvas){var a=this.canvas.down("div.header div.classicLink");if(a){a.update("");a.hide()}}},_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 DNow.AccountDialog({componentBus:this.componentBus})},_onActiveMessagesReceived:function(c){if((c)&&(c.length>0)){var a=c[0];var e=this.canvas.down("div.header");if(e){e.insert('<div class="notification">'+a.title+"</div>");var b=e.down("div.notification");var d=new aw.ui.Tooltip({title:a.title,content:a.shortContent,onclick:true,target:b,clickCallback:(a.fullContent)?function(g,f){new aw.ui.Dialog({title:g,content:f,centerable:true})}.bind(this,a.title,a.fullContent):null});if(a.shown!==true){d.showTip()}}}},_onAuthenticationFailure:function(){var h=["DNow.ReportViewer","DNow.FileViewer","DNow.MapViewer","DNow.QueryViewer","DNow.WizardViewer"];var f=null;for(var e=0,c=h.length;e<c;e++){f=this.componentBus.getComponentReferences(h[e]);if((f)&&(f.length>0)){f[0].disable()}}var a=this.componentBus.getComponentReferences("DNow.Admin");if((a)&&(a.length>0)){this._DNowPanel.remove(a[0]);a[0].destroy()}if(this.canvas){var k=this.canvas.down("div.header div.login");if(k){k.update('<span class="signup">Sign-Up</span><span class="login">Log In</span>');aw.EventManager.register(k.down("span.signup"),"click",this._onSignup.bind(this));aw.EventManager.register(k.down("span.login"),"click",this._onLoginClick.bind(this))}this._hideClassicLink()}var b=["aw.UserDataManager","aw.GeographyManager","aw.ReportManager","aw.QueryManager","aw.WizardManager","aw.CustomPolygonManager","aw.AnnotationManager","aw.ThematicsManager","aw.IconManager"];var g=null;for(var d=0;d<b.length;d++){g=this.componentBus.getComponentReferences(b[d]);if((g)&&(g.length>0)){g[0].destroy();g[0]=null}}this._classicLogInOut(_DNowClassicURL+"On_DNowClassicLogout.srct")},_onAuthenticationSuccess:function(){var p=new aw.UserDataManager({componentBus:this.componentBus});var d=new aw.GeographyManager({componentBus:this.componentBus});var g=new aw.ReportManager({componentBus:this.componentBus});this._onReportDatasetChanged_fx=this._onReportDatasetChanged.bind(this);g.registerEvent("onreportdatasetchanged",this._onReportDatasetChanged_fx);var m=new aw.CustomPolygonManager({componentBus:this.componentBus});var f=new aw.AnnotationManager({componentBus:this.componentBus});var q=new aw.ThematicsManager({componentBus:this.componentBus});var o=new aw.WizardManager({componentBus:this.componentBus});var e=new aw.Geocoder({componentBus:this.componentBus});var k=new aw.IconManager({componentBus:this.componentBus});var n=new aw.GeographyCollection(null,"3825 Iris Avenue, Boulder CO","Geography Selection",{x:-105.246211,y:40.036617});n.addGeography(new aw.Geography.Radius(null,"3825 Iris Avenue, Boulder CO","1 Mile Radius",1,-105.246211,40.036617,"Miles"));n.addGeography(new aw.Geography.Radius(null,"3825 Iris Avenue, Boulder CO","3 Mile Radius",3,-105.246211,40.036617,"Miles"));n.addGeography(new aw.Geography.Radius(null,"3825 Iris Avenue, Boulder CO","5 Mile Radius",5,-105.246211,40.036617,"Miles"));d.setActiveGeography(n);var j=["DNow.ReportViewer","DNow.FileViewer","DNow.MapViewer","DNow.QueryViewer","DNow.WizardViewer"];var c=null;for(var b=0,a=j.length;b<a;b++){c=this.componentBus.getComponentReferences(j[b]);if((c)&&(c.length>0)){c=c[0];c.enable();if(c.CLASS_NAME=="DNow.ReportViewer"){c.show()}}}if(this.componentBus.getUserType()===2){this._DNowPanel.add(new DNow.Admin({componentBus:this.componentBus,title:"Admin"}))}if(this.canvas){var h=this.canvas.down("div.header div.login");if(h){h.update('<span class="account">Account Info</span><span class="logout">Logout</span><div class="welcome">Welcome '+this.readCookie("username")+"</div>");aw.EventManager.register(h.down("span.account"),"click",this._onAccountClick.bind(this));aw.EventManager.register(h.down("span.logout"),"click",this._onLogoutClick.bind(this))}this._showClassicLink()}},_onHistoryGeographiesChanged:function(){var d=this.componentBus.getComponentReferences("aw.GeographyManager")[0];var a=d.getAllHistoryGeographies()[0];var c=this.componentBus.getComponentReferences("aw.UserDataManager")[0];if(a){if(a.geoCollection&&a.geoCollection!==null){d.setActiveGeography(a.geoCollection)}else{c.retrieveData("HistoryGeography",a.name,null,function(f,e){if((e[0])&&(e[0].geoCollection)){f.setActiveGeography(e[0].geoCollection)}}.bind(this,d))}}else{var b=new aw.GeographyCollection(null,"3825 Iris Avenue, Boulder CO","Geography Selection",{x:-105.246211,y:40.036617});b.addGeography(new aw.Geography.Radius(null,"3825 Iris Avenue, Boulder CO","1 Mile Radius",1,-105.246211,40.036617,"Miles"));b.addGeography(new aw.Geography.Radius(null,"3825 Iris Avenue, Boulder CO","3 Mile Radius",3,-105.246211,40.036617,"Miles"));b.addGeography(new aw.Geography.Radius(null,"3825 Iris Avenue, Boulder CO","5 Mile Radius",5,-105.246211,40.036617,"Miles"));d.setActiveGeography(b)}d.unregisterEvent("onhistorygeographieschanged",this._onHistoryGeographiesChanged_fx);this._onHistoryGeographiesChanged_fx=null},_onLoadUser:function(b,a){this._classicLogInOut(_DNowClassicURL+"On_DNowClassicLogin.srct?UserEmail="+b+"&UserPswd="+a)},_onLoginClick:function(){new DNow.LoginDialog({componentBus:this.componentBus})},_onLogoutClick:function(){this.componentBus.unloadUser()},_onReportDatasetChanged:function(){var a=new aw.QueryManager({componentBus:this.componentBus});var b=this.componentBus.getComponentReferences("aw.ReportManager")[0];b.unregisterEvent("onreportdatasetchanged",this._onReportDatasetChanged_fx);this._onReportDatasetChanged_fx=null},_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])}},_onResize:function(a,b){if(b===true){a.setSize();if(this._resizeTimeout){clearTimeout(this._resizeTimeout);this._resizeTimeout=null}return}if(this._resizeTimeout){clearTimeout(this._resizeTimeout)}this._resizeTimeout=setTimeout(this._onResize.bind(this,a,true),250)},_onSignup:function(a){new DNow.AccountDialog({componentBus:this.componentBus})},_removeClassicLoginFrame:function(a){if(a){a.remove();a=null}},_showClassicLink:function(){var a=this.canvas.down("div.header div.classicLink");if(a){a.update('<a href="'+_DNowClassicURL+'AllocateOnline.srct?MfcIsapiCommand=OnLogin_Go" class="text">Switch to Classic</a>');a.show()}},_templates:{ui:new Template('<div class="header"><img src="./custom/img/DNowLogo.png" alt="DemographicsNow - Powered by Alteryx" /><div class="classicLink"></div><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; <a href="mailto:sales@alteryx.com">sales@alteryx.com</a></div></div>')},VALID_PROPERTIES:["container","componentBus"],CLASS_NAME:"DNow"});DNow.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(b){if((!b)||(!b.length>0)){return}var d=this.canvas.down("div.form");if(!d){return}d.update("");this._form=new aw.ui.Form();var c=null,e=null,f,l=null;for(var h=0;c=b[h];h++){e=this.getId();d.insert(this._local_templates.category.evaluate({key:e,category:c.category}));f=d.down('div[key="'+e+'"]');for(var g=0;l=c.fields[g];g++){if((l.type=="text")||(l.type=="password")){this._form.add(new aw.ui.Control.TextBox({type:l.type,label:l.label+((l.required===true)?"*":""),name:l.name,value:l.defaultValue,container:f}));if(l.type=="password"){pwConfirm=l;pwConfirm.name="passwordConfirm";pwConfirm.label="Password Confirmation";this._form.add(new aw.ui.Control.TextBox({type:pwConfirm.type,label:pwConfirm.label+((l.required===true)?"*":""),name:pwConfirm.name,value:pwConfirm.defaultValue,container:f}))}}else{if(l.type=="select"){l.values.unshift({value:"",label:"-- Select One --"});var k=new aw.ui.Control.DropDown({label:l.label+((l.required===true)?"*":""),name:l.name,options:l.values,container:f});if((l.defaultValue)&&(l.defaultValue!=="")){k.selectByValue(l.defaultValue)}this._form.add(k)}else{if((l.type=="date")&&((this.componentBus)&&(this.componentBus.isSessionValidated()))){this._date=new aw.ui.Control.TextBox({type:"text",label:l.label+((l.required===true)?"*":""),name:l.name,value:((l.defaultValue)?l.defaultValue:""),container:f});this._form.add(this._date.disable())}}}}}if((this.componentBus)&&(!this.componentBus.isSessionValidated())){d.insert('<div class="accept">By signing up, I accept the <span class="tos">Terms and Conditions of the License Agreement</span></div>');var a=d.down("span.tos");if(a){a.observe("click",function(){window.open("custom/license.htm","tos","height=600,width=1040,scrollbars=1")}.bind(this))}}},_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 DemographicsNow. Please register for access to features such as reporting and mapping.</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, Inc.<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, Inc.<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:"DNow.AccountDialog"});DNow.Admin=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);this.add(new DNow.Admin.SearchUsers({componentBus:this.componentBus}));return this.canvas},CLASS_NAME:"DNow.Admin"});DNow.Admin.AddEditUser=Class.create(aw.ui.Dialog,{admin:false,create:false,email:"",expiresNever:true,initialize:function(b,a){this.inheritCSS=true;this.admin=false;this.create=false;this.expires=false;this.user=null;this._allPartNumbers=[];this._currentPartNumbers=[];this._addedPartNumbers=[];this._removedPartNumbers=[];aw.ui.Dialog.prototype.initialize.apply(this,arguments);this._currentPartNumbers=((this.user)&&(this.user.partNumbers))?this.user.partNumbers.slice(0):[];var c=this.componentBus.getComponentReferences("aw.AccountManager");if((c)&&(c.length>0)){c[0].retrieveAvailablePartNumbers(this._onPartNumbersReceived.bind(this))}},afterDraw:function(){aw.ui.Dialog.prototype.afterDraw.apply(this)},draw:function(){aw.ui.Dialog.prototype.draw.apply(this);var s=this.canvas.down(".contents");if(!s){return null}var f,a;var h=new aw.ui.Panel.Tab({container:s,titleVisibility:false,items:[f=new aw.ui.Panel({title:"User Information",items:[this._addUserForm=new aw.ui.Form()]}),a=new aw.ui.Panel({title:"Permissions",items:[new aw.ui.HTML({html:'<div class="cf"><div class="availableList"><span>Available Permissions</span><div class="search"></div></div><div class="add_remove_controls"></div><div class="selectedList"><span>Selected Permissions</span><div class="search"></div></div></div></div>'})]})]});var q=this._addUserForm;var u=aw.ui.Control;var c=this.expiresNever;var k=this.admin;var t=this.create;var b;var m=this.user.fields;var g=(this.componentBus.getAuthenticationMethod()=="windowsAuthentication")?true:false;var e=this.user;var n=null,d=null,o;for(var r=0;n=e[r];r++){d=this.getId();q.canvas.insert(this._local_templates.category.evaluate({key:d,category:n.category}));o=q.canvas.down('div[key="'+d+'"]');for(var p=0;b=n.fields[p];p++){if((b.type=="text")||((b.type=="password")&&(!k||t))){this._addUserForm.add(new aw.ui.Control.TextBox({type:b.type,label:b.label+((b.required===true)?"*":""),name:b.name,value:b.defaultValue,container:o}));if(b.name=="email"){this.email=b.defaultValue}if(b.type=="password"){pwConfirm=b;pwConfirm.name="passwordConfirm";pwConfirm.label="Password Confirmation";this._addUserForm.add(new aw.ui.Control.TextBox({type:pwConfirm.type,label:pwConfirm.label+((b.required===true)?"*":""),name:pwConfirm.name,value:pwConfirm.defaultValue,container:o}))}}else{if(b.type=="select"){b.values.unshift({value:"",label:"-- Select One --"});var l=new aw.ui.Control.DropDown({label:b.label+((b.required===true)?"*":""),name:b.name,options:b.values,container:o});if((b.defaultValue)&&(b.defaultValue!=="")){l.selectByValue(b.defaultValue)}this._addUserForm.add(l)}else{if(b.type=="checkbox"){this._addUserForm.add(new aw.ui.Control.Checkbox({label:b.label,name:b.name,value:b.value,checked:b.checked,container:o}))}else{if(b.type=="date"){this._date=new aw.ui.Control.Date({type:b.type,label:b.label+((b.required===true)?"*":""),name:b.name,value:b.defaultValue,container:o,customSerialize:{json:this._dateControlSerialize.bind(this)}});this._setDateState();this._addUserForm.add(this._date);this._expires=new aw.ui.Control.Checkbox({label:"User never expires",name:"expires",checked:c,container:o},{change:this._toggleExpiration.bind(this)});this._addUserForm.add(this._expires)}}}}}}_permissionsContents=a.canvas;this._availablePermissionsList=new aw.ui.Grid({container:_permissionsContents.down(".availableList"),columns:[{index:"displayName",label:"description",sorted:true,sortDirection:"asc",searchable:true}],data:[{name:'<div class="loader"><img src="custom/img/loader.gif" />Loading Permissions ...</div>',_key:"",disabled:true}],selectMultiple:true,recordsPerPage:0,showFooters:false,showHeaders:false});new aw.ui.Control.TextBox({container:_permissionsContents.down(".availableList .search"),name:"availPermissionSearch"},{change:this._onSearchChange.bind(this,this._availablePermissionsList)});this._addControl=new aw.ui.Control.Button({alt:"Add Permissions",container:_permissionsContents.down(".add_remove_controls"),label:"&#8250;"},{click:this._onAddClicked.bind(this)});this._removeControl=new aw.ui.Control.Button({alt:"Remove Permissions",container:_permissionsContents.down(".add_remove_controls"),label:"&#8249;"},{click:this._onRemoveClicked.bind(this)});this._selectedPermissionsList=new aw.ui.Grid({container:_permissionsContents.down(".selectedList"),columns:[{index:"displayName",label:"description",sorted:true,sortDirection:"asc",searchable:true}],selectMultiple:true,recordsPerPage:0,showFooters:false,showHeaders:false});new aw.ui.Control.TextBox({container:_permissionsContents.down(".selectedList .search"),name:"selectedPermissionSearch"},{change:this._onSearchChange.bind(this,this._selectedPermissionsList)});if(k&&!t){q.add(new u.TextBox({container:q.canvas,type:"hidden",name:"user_id",value:this.user.user_id,cssClass:"hidden"}));if(!g){q.add(new u.Button({container:q.canvas,label:"Resend Password Email",alt:"Resend Password Email"},{click:this._onResendPasswordClick.bind(this,this.email)}))}}this._renderButton("Cancel",this.close.bind(this));this._renderButton("Save & Close",this._onSaveAndCloseClick.bind(this));if(k&&t){this._renderButton("Save & New",this._onSaveAndNewClick.bind(this))}this.canvas.down(".buttons").addClassName("cf");return this.canvas},_addUser:function(c,a){a=a||false;if(!this.admin){return}var b=this.componentBus.getComponentReferences("aw.AccountManager")[0];if(!b){return}b.createAccount(c,function(d,f,e){if(d=="failure"){this._showFailure(f)}else{if((this._addedPartNumbers)&&(this._addedPartNumbers.length>0)){b.updateUserPermissions(e,this._addedPartNumbers,null,function(g,h,i){if(g=="success"){this._showSuccess("The user was successfully created.",a);this.triggerEvent("onuserupdated",null)}else{this._showFailure(i);if(success.length>0){this.triggerEvent("onuserupdated",null)}}}.bind(this))}else{this._addUserForm.reset();this._showSuccess(f,a);this.triggerEvent("onuserupdated",null)}}}.bind(this))},_dateControlSerialize:function(){var a=(this.expiresNever)?"-1":this._date.getFormattedDate();return a},_onAddClicked:function(){var c=this._availablePermissionsList.getSelectedRecords();if((c)&&(c.length>0)){var b,a=c.length;for(b=0;b<a;b++){this._onAddPartNumber(c[b].partNumber)}this._selectedPermissionsList.clearSelection();this._updatePermissionLists()}},_onAddPartNumber:function(d){var c,b=this._currentPartNumbers.length;var a=this._currentPartNumbers.indexOf(d);if(a<0){this._currentPartNumbers.push(d)}},_onRemoveClicked:function(){var c=this._selectedPermissionsList.getSelectedRecords();if((c)&&(c.length>0)){var b,a=c.length;for(b=0;b<a;b++){this._onRemovePartNumber(c[b].partNumber)}this._availablePermissionsList.clearSelection();this._updatePermissionLists()}},_onRemovePartNumber:function(d){var c,b=this._currentPartNumbers.length;var a=this._currentPartNumbers.indexOf(d);if(a>-1){this._currentPartNumbers.splice(a,1)}},_onPartNumbersReceived:function(c){if((!c)||(!c.length>0)){return}var b,a=c.length;for(b=0;b<a;b++){c[b].displayName="<b>"+c[b].description+"</b> <i>&lt;"+c[b].partNumber+"&gt;</i>";this._allPartNumbers.push(c[b])}this._updatePermissionLists()},_onResendPasswordClick:function(a){var b=this.componentBus.getComponentReferences("aw.AccountManager");if(!b||!b[0]){return}b[0].resendActivationEmail(a,function(d){var c;var e;if(d&&d.status){c=d.status;if(c=="success"){e="Your request was successful."}else{e="The requested action failed."}new aw.ui.Dialog.Alert({title:"Resend Password",content:e,centerable:true})}})},_onSaveAndCloseClick:function(){var a=this._addUserForm.serialize();if(!a){return}if((a.password)&&(a.password=="*-*-*-*-*")){delete a.password}if((a.passwordConfirm)&&(a.passwordConfirm=="*-*-*-*-*")){delete a.passwordConfirm}if((a.disabled)&&(a.disabled!=="1")){a.disabled="0"}if(!this.create){this._updateUser(a,true)}else{this._addUser(a,true)}},_onSaveAndNewClick:function(){var a=this._addUserForm.serialize();this._addUser(a,false)},_onSearchChange:function(b,d){var a=["partNumber","description"];var c=d.getValue();c=(c&&c.length>0)?c.toLowerCase().split(" "):[];b.setFilter(function(n,l,m){var k,h,g=n.length,f=l.length;var e;for(k=0;k<g;k++){e=false;for(h=0;h<f;h++){if(n[k].length<1||m[l[h]].toLowerCase().match(n[k])){e=true;break}}if(!e){return false}}return true}.bind(b,c,a))},_setDateState:function(){if(this.expiresNever===true){this._date.disable()}else{if(this.expiresNever===false){this._date.enable()}}},_toggleExpiration:function(a){this.expiresNever=a.checked;this._setDateState()},_showFailure:function(a){new aw.ui.Dialog.Error({title:"Error!",content:"<ul><li>"+((a instanceof Array)?a.join("</li><li>"):a)+"</li></ul>",centerable:true})},_showSuccess:function(a,b){if(b){new aw.ui.Dialog.Alert({title:"User Updated",content:a,centerable:true});this.close()}else{document.getElementById("addEditFormResponse").getElementsByTagName("ul")[0].innerHTML="<li>"+((a instanceof Array)?a.join("</li><li>"):a)+"</li>"}},_updatePermissionLists:function(){var d,a=this._allPartNumbers.length,c=null,b=[],e=[];for(d=0;d<a;d++){c=this._allPartNumbers[d];if(this._currentPartNumbers.indexOf(c.partNumber)>-1){e.push(c)}else{b.push(c)}}this._availablePermissionsList.loadData(b);this._selectedPermissionsList.loadData(e);this._addedPartNumbers=[];this._removedPartNumbers=[];a=this._currentPartNumbers.length;for(d=0;d<a;d++){if(this.user.partNumbers.indexOf(this._currentPartNumbers[d])<0){this._addedPartNumbers.push(this._currentPartNumbers[d])}}a=this.user.partNumbers.length;for(d=0;d<a;d++){if(this._currentPartNumbers.indexOf(this.user.partNumbers[d])<0){this._removedPartNumbers.push(this.user.partNumbers[d])}}},_updateUser:function(c,a){a=a||false;var b=this.componentBus.getComponentReferences("aw.AccountManager")[0];if(!b){return}if(!c.userType){c.userType=this.componentBus.getUserType()}b.updateAccount(c,function(d,e){if(d=="failure"){this._showFailure(e)}else{if(((this._addedPartNumbers)&&(this._addedPartNumbers.length>0))||((this._removedPartNumbers)&&(this._removedPartNumbers.length>0))){b.updateUserPermissions(this.user.user_id,this._addedPartNumbers,this._removedPartNumbers,function(f,g,h){if(f=="success"){this._showSuccess("The user was successfully updated.",a);this.triggerEvent("onuserupdated",this.user.user_id)}else{this._showFailure(h);if(success.length>0){this.triggerEvent("onuserupdated",this.user.user_id)}}}.bind(this))}else{this._showSuccess(e,a);this.triggerEvent("onuserupdated",this.user.user_id)}}}.bind(this))},_local_templates:{category:new Template('<div class="category" key="#{key}"><h1>#{category}</h1><div class="fields"></div></div>')},EVENTS:["onuserupdated"],VALID_PROPERTIES:["admin","title","dialog","expiresNever","closeable","content","items","moveable","centerable","cssClass","componentBus","create","width","maskedExportFormats","renamedExportFormats","user"],CLASS_NAME:"DNow.Admin.AddEditUser"});DNow.Admin.SearchUsers=Class.create(aw.ui.Panel,{_onClick_fx:null,initialize:function(b,a){this._onClick_fx=null;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.update(this._local_templates.ui);this._searchField=new aw.ui.Control.TextBox({container:a.down("#searchControls"),cssClass:"searchControl",label:"Search for Users:",name:"search",value:""},{change:this._makeSearchRequest.bind(this)});this._disabledUsersCheck=new aw.ui.Control.Checkbox({container:a.down("#searchControls"),label:"Show disabled users",name:"showDisabledUsers",cssClass:"searchControl"},{change:this._onDisabledUsersChanged.bind(this)});this._addUserButton=new aw.ui.Control.Button({container:a.down(".managerControls"),componentBus:this.componentBus,cssClass:"add_Record_Button",label:"Add User",alt:"Add User"},{click:this._onAddUserClick.bind(this)});this._resultsGrid=new aw.ui.Grid({componentBus:this.componentBus,container:a.down("div#searchResultsGrid"),columns:[{index:"firstName",label:"First Name",sorted:true,sortDirection:"asc"},{index:"lastName",label:"Last Name"},{index:"email",label:"Email"},{index:"lastLogin",label:"Last Login Date",type:"date"},{index:"userTypeLabel",label:"User Type"},{index:"userDisabledLabel",label:"User is Disabled"},{index:"expiry_dt",label:"Expiration Date"},{index:"edit",label:"",cssClass:"editRecord"}],selectMultiple:false,recordsPerPage:30,showFooters:false,baseRequest:{cn:"SRC.Web.Client.Handler.AccountManagementHandler",service:"adminsearch"},recordOverride:function(b){b.userDisabled=b.disabled;delete b.disabled;if(b.expiry_dt===""){b.expiry_dt="--"}b.userTypeLabel=(b.userType===1)?"User":"Admin";b.userDisabledLabel=(b.userDisabled)?"Yes":"No";return b}});if(!this._onClick_fx){this._onClick_fx=this._onClick.bind(this);aw.EventManager.unregister(this._resultsGrid.canvas,"click",this._onClick_fx);aw.EventManager.register(this._resultsGrid.canvas,"click",this._onClick_fx)}}this._makeSearchRequest(true);return this.canvas},_loadSearchResults:function(a){if(!a){return}this._resultsGrid.loadData(a)},_makeSearchRequest:function(a){if(a===true){this._resultsGrid.baseRequest={cn:"SRC.Web.Client.Handler.AccountManagementHandler",service:"adminsearch",search:this._searchField.value,showDisabled:this._disabledUsersCheck.checked};this._resultsGrid.retrieveRecords(0);return}if(this._makeSearchRequestTimeout){clearTimeout(this._makeSearchRequestTimeout);this._makeSearchRequestTimeout=null}this._makeSearchRequestTimeout=setTimeout(this._makeSearchRequest.bind(this,true),200)},_onAddUserClick:function(){var a=this.componentBus.getComponentReferences("aw.AccountManager")[0];if(!a){return}a.retrieveAccountInfo("anewuser",function(b){b.push({category:"User Settings",fields:[{type:"select",label:"User Type",name:"userType",values:[{value:1,label:"User",selected:true},{value:2,label:"Admin"}]},{type:"checkbox",label:"User is disabled",name:"disabled",value:"1",checked:false}]});new DNow.Admin.AddEditUser({componentBus:this.componentBus,title:"Edit User Account Info",admin:true,user:b,create:true,centerable:true},{onuserupdated:this._onUserUpdated.bind(this)})}.bind(this))},_onClick:function(f){f=f||window.event;var d=f.target||f.srcElement;if(!d||(!~d.className.indexOf("editRecord"))||(~d.parentNode.className.indexOf("disabled"))){return}var b=d.parentNode.readAttribute("key");var a=this._resultsGrid.getRecordBy({_key:b});if(!a){return}var c=this.componentBus.getComponentReferences("aw.AccountManager")[0];if(!c){return}c.retrieveAccountInfo(a.email,function(e){e.push({category:"User Settings",fields:[{type:"select",label:"User Type",name:"userType",values:[{value:1,label:"User",selected:(a.userType===1)},{value:2,label:"Admin",selected:(a.userType===2)}]},{type:"checkbox",label:"User is disabled",name:"disabled",value:"1",checked:a.userDisabled}]});e.user_id=a.id;e.partNumbers=a.partNumbers;new DNow.Admin.AddEditUser({componentBus:this.componentBus,title:"Edit User Account Info",admin:(parseInt(a.id,10)!==parseInt(this.componentBus._user.id,10)),user:e,expiresNever:((a.expiry_dt==="--")?true:false),centerable:true},{onuserupdated:this._onUserUpdated.bind(this)})}.bind(this))},_onDisabledUsersChanged:function(){this._makeSearchRequest()},_onUserUpdated:function(a){this._makeSearchRequest(true)},_local_templates:{ui:'<div id="searchControls" class="cf"></div><div id="searchResultsGrid"></div><div class="managerControls"></div>'},CLASS_NAME:"DNow.Admin.SearchUsers"});DNow.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,arguments);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("DNow.MapViewer");if((a)&&(a.length>0)){a[0]._map.pickPoint(this._onMapPointClick.bind(this));a[0].show();this.hide();new aw.ui.Dialog.Alert({title:"Pick Point From Map",content:"Click a location on the map to add it to your list of points."})}},_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:"DNow.CustomRadiiDialog"});DNow.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,_onWizardJobUpdated_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._onDataTypesChanged_fx=this._onDataTypesChanged.bind(this);this._onUserDataActionExecuted_fx=this._onUserDataActionExecuted.bind(this);d.registerEvent("ondatatypeschanged",this._onDataTypesChanged_fx);d.registerEvent("onactionexecuted",this._onUserDataActionExecuted_fx);if((d.dataTypes)&&(d.dataTypes.length>0)){this._onDataTypesChanged(d.dataTypes)}}}.bind(this));this.componentBus.getComponentReferences("aw.WizardManager",function(c){if((c)&&(c.length>0)){var d=c[0];this._onWizardJobUpdated_fx=this._onWizardJobUpdated.bind(this);d.registerEvent("onwizardjobupdated",this._onWizardJobUpdated_fx)}}.bind(this))},destroy:function(){if(this.componentBus){var b=this.componentBus.getComponentReferences("aw.UserDataManager");if((b)&&(b.length>0)){b=b[0];if(this._onDataTypesChanged_fx){b.unregisterEvent("ondatatypeschanged",this._onDataTypesChanged_fx);this._onDataTypesChanged_fx=null}if(this._onUserDataActionExecuted_fx){b.unregisterEvent("onactionexecuted",this._onUserDataActionExecuted_fx);this._onUserDataActionExecuted_fx=null}}var a=this.componentBus.getComponentReferences("aw.WizardManager");if((a)&&(a.length>0)){a=a[0];if(this._onWizardJobUpdated_fx){a.unregisterEvent("onwizardjobupdated",this._onWizardJobUpdated_fx);this._onWizardJobUpdated_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:"nameTruncated",sorted:true,sortDirection:"asc"},{label:"Type",index:"typeLabel"},{label:"Date Created",index:"dateCreated",type:"date"},{label:"Date Modified",index:"dateModified",type:"date"}]},{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:"DNow_Toolbar",items:[new aw.ui.Toolbar.Group({label:"Geography Selection",cssClass:"geoselection",items:[new DNow.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:File Controls")})]}));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,nameTruncated:(e.name.length>57)?(e.name.substring(0,57)+"..."):e.name,type:e.type,typeLabel:e.typeLabel,dateCreated:e.dateCreated,dateModified:e.dateModified})}this._grid.loadData(b);this._onGridSelectionChanged(this._grid.getSelectedRecords())}},_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)}}}},_onGridSelectionChanged:function(a){if(this._propertiesPanel){this._propertiesPanel.clear();var e,n=0,h=0,c=0,m,j,f,g=[],b=[],k=[],l=[],d=null;for(e=0,n=a.length;e<n;e++){g.push(this._getDataRecordByKey(a[e]._key))}if((g)&&(g.length>0)){for(e=0,h=g.length;e<h;e++){f=g[e];if(b.indexOf(f.type)<0){b.push(f.type)}if(k.length>0){k.intersect(f.getActions())}else{k=f.getActions()}}}if((!g)||(h<1)){j="<strong>No files selected.</strong>"}else{if(h===1){f=g[0];j='<div class="properties"><p><strong>File Name:</strong> '+f.name+"</p><p><strong>Type:</strong> "+f.type+"</p><p><strong>Date Created:</strong> "+f.dateCreated+"</p><p><strong>Date Modified:</strong> "+f.dateModified+'</p><hr size="1" /><div class="details"><p><strong>Loading details....</strong></p></div></div>';var o=this.componentBus.getComponentReferences("aw.UserDataManager");if((o)&&(o.length>0)){m=(f.type==="CustomPolygon")?["PolygonName"]:null;o[0].retrieveData(f.type,f.name,null,this._onSelectionDetailsReceived.bind(this),null,m)}}else{if(h>1){j="<p><strong>Number of Items:</strong> "+h+"</p><p><strong>Type:</strong> "+(b.length>1)?"Multiple Types":b[0]+"</p>"}}}for(e=0,c=k.length;e<c;e++){d=k[e];l.push(new aw.ui.Control.Button({label:d},{click:this._onActionClicked.bind(this,d,g)}))}this._propertiesPanel.add(new aw.ui.Toolbar({region:"bottom",height:60,items:[new aw.ui.Toolbar.Row({items:l})]}));this._propertiesPanel.add(new aw.ui.HTML({html:j}))}},_onHelpClick:function(b){if(this.componentBus){var a=this.componentBus.getComponentReferences("DNow.Help");if((a)&&(a.length>0)){a[0].loadTopicByTitle(b);return}}new DNow.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>")}}},_onUploadFileClick:function(a){new aw.ui.Dialog.Geocode({componentBus:this.componentBus})},_onUserDataActionExecuted:function(a){if((!this._activeDataType)||(this._activeDataType.key==="")||(a.datatype.toLowerCase()==this._activeDataType.key.toLowerCase())){if(a.action.match("save|delete|copy|rename|export")){this.setActiveDataType(this._activeDataType)}}},_onUserSettingsReceived:function(a){if((!a)||(!this._uploadFileButton)){return}if(a.enableUploadedLocations===true){this._uploadFileButton.enable()}else{this._uploadFileButton.disable()}},_onWizardJobUpdated:function(g){if(!g||!g.disposition||g.disposition===""||g.userDataTypes.length<1){return}var e=false;if(g.disposition.toLowerCase()==="complete"){var h=this._activeDataType.key.toLowerCase();if(h===""){e=true}else{var a;var c=g.userDataTypes;for(var d=0,b=c.length;d<b;d++){if(h===c[d].toLowerCase()){e=true;break}}}}if(e===true){var f=this.componentBus.getComponentReferences("aw.UserDataManager");if((f)&&(f.length>0)){f[0].retrieveData(h,null,null,this._onDataRetrieved.bind(this))}}},CLASS_NAME:"DNow.FileViewer"});DNow.GeographyBar=Class.create(aw.ui.GeographyBar,{initialize:function(b,a){this.inheritCSS=true;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"},{label:"Select Saved Geography...",callback:this._onSelectSavedGeographyClicked.bind(this),icon:"./core/img/GeographyBar/saved.png"}]});aw.ui.GeographyBar.prototype.initialize.apply(this,[b,a])},_onCreateCustomLocationsClicked:function(){new DNow.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 DNow.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 DNow.GeographyDialog({componentBus:this.componentBus},{ongeographyselected:this._onGeographySelected.bind(this)})},_onSelectSavedGeographyClicked:function(){if(this.isSessionValidated()===true){new DNow.SavedGeographyDialog({componentBus:this.componentBus})}else{new aw.ui.Dialog.Error({title:"Error",content:"You must be logged in to access this functionality."})}},CLASS_NAME:"DNow.GeographyBar"});DNow.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,arguments)},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,selected: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 DNow.CustomRadiiDialog({componentBus:this.componentBus},{onpointscreated:function(a){if(this._geographyTree){this._geographyTree.removeChildNodesByKey("CUSTOM");this._geographyTree.addNodes(this._buildCustomGeographyNodes(a))}this.show()}.bind(this)});this.hide()},_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:"DNow.GeographyDialog"});DNow.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","_DNowHelp")}}}.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:"DNow_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:"DNow.Help"});DNow.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.htm"></iframe>');this._frame=this.canvas.down("iframe")}return this.canvas},setURL:function(a){this._frame.src=a},CLASS_NAME:"DNow.HTMLViewer"});DNow.LoginDialog=Class.create(aw.ui.Dialog,{initialize:function(b,a){Object.extend(b,{title:"Login",centerable:true});this.inheritCSS=true;aw.ui.Dialog.prototype.initialize.apply(this,arguments);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:"User Name:",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)});this._rememberEmailCheck=new aw.ui.Control.Checkbox({label:"Remember User Name",name:"rememberUser",value:true});aw.EventManager.register(a.down("span.forgotPassword"),"click",this._onForgotPasswordClick.bind(this));aw.EventManager.register(a.down("span.signup"),"click",this._onSignupClick.bind(this));aw.EventManager.register(a.down("span.tos"),"click",function(){window.open("custom/license.htm","tos","height=600,width=1040,scrollbars=1")});this._renderButton("Login",this._onLoginClick.bind(this));this._renderButton("Cancel",this.close.bind(this));this.centerDialog();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...",centerable:true})},_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("DNow");if((a)&&(a.length>0)){a[0]._onSignup();this.close()}},_local_templates:{ui:'<div class="login"><h3>Please enter your email and password below to login.</h3><div class="inputEmail"></div><div class="inputPassword"></div><div class="rememberUser"></div><div class="links"><span class="forgotPassword">Forgot Password?</span> &#160; | &#160; <span class="signup">Need an account?</span></div><div class="accept">By logging in,	I accept the <span class="tos">Terms and Conditions of the License Agreement</span>.</div></div>'},CLASS_NAME:"DNow.LoginDialog"});DNow.MapViewer=Class.create(aw.ui.Panel,{attributions:{},_customPolygonsButton:null,_customPolygonsControl:null,_map:null,_panelDropButton:null,_userLocationFiles:[],_onWizardJobUpdated_fx:null,initialize:function(b,a){this.attributions={tomTom:"&#169 2006-"+new Date().getFullYear()+" TomTom",digitalGlobe:"&#169 "+new Date().getFullYear()+". DigitalGlobe, Inc. All rights reserved."};this._customPolygonsButton=null;this._customPolygonsControl=null;this._map=null;this._panelDropButton=null;this._userLocationFiles=[];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));d.registerEvent("onallocatedatasetchanged",this._onAllocateDatasetChanged.bind(this));if(d.activeGeography){this._onActiveGeographyChanged(d.activeGeography,true)}if(d.allocateDataset){this._onAllocateDatasetChanged(d.allocateDataset)}}}.bind(this));this.componentBus.getComponentReferences("aw.UserDataManager",function(c){if((c)&&(c.length>0)){var d=c[0];d.registerEvent("onusersettingsreceived",this._onUserSettingsReceived.bind(this));d.registerEvent("onactionexecuted",this._onUserDataActionExecuted.bind(this));if(d.userSettings){this._onUserSettingsReceived(d.userSettings)}this._initializeUserPoints()}}.bind(this));this.componentBus.getComponentReferences("aw.ThematicsManager",function(d){if((d)&&(d.length>0)){var c=d[0];c.registerEvent("activethematicchanged",this._onActiveThematicChanged.bind(this));c.registerEvent("thematicschanged",this._onThematicsChanged.bind(this));c.registerEvent("paletteschanged",this._onPalettesChanged.bind(this));c.registerEvent("geographylevelschanged",this._onGeographyLevelsChanged.bind(this));c.registerEvent("variableschanged",this._onVariablesChanged.bind(this));if(c.variables){this._onVariablesChanged(c.variables)}}}.bind(this));this.componentBus.getComponentReferences("aw.WizardManager",function(c){if((c)&&(c.length>0)){var d=c[0];this._onWizardJobUpdated_fx=this._onWizardJobUpdated.bind(this);d.registerEvent("onwizardjobupdated",this._onWizardJobUpdated_fx)}}.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:"aerial",label:"Aerial",drawPriority:1,visible:false,icon:"./core/img/Map/Layer/aerial.png",parameters:{service:"satellite"},attribution:this.attributions.digitalGlobe}),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,labelControllable:true,labelTemplate:"GeographySelectionLabel"}),new aw.ui.Map.Layer.Label({visible:true,drawPriority:300})],controls:[new aw.ui.Map.Control.Features({group:"Mapping Tools",componentBus:this.componentBus}),new aw.ui.Map.Control.Annotations({group:"Mapping Tools",componentBus:this.componentBus,drawPriority:301})]},{controladded:this._onMapControlAdded.bind(this),controlremoved:this._onMapControlRemoved.bind(this),controltoggled:this._onMapControlToggled.bind(this),zoomchanged:this._onMapZoomChanged.bind(this)});this._mappingToolsButton=new aw.ui.Control.Button.Toggle({label:"Mapping Tools",toggled:true,icon:"./core/img/Map/Control/wrench.png"},{toggle:this._onMappingToolsButtonToggled.bind(this)});this._variableDropDown=new aw.ui.Control.DropDown({label:"Variable:",options:[{value:null,label:"Loading..."}]},{change:this._onVariableDropDownChange.bind(this)});this._geographyDropDown=new aw.ui.Control.DropDown({label:"Geography (based on zoom):",options:[{value:null,label:"Loading..."}]},{change:this._onGeographyDropDownChange.bind(this)});this._colorsDropDown=new aw.ui.Control.DropDown({label:"Colors:",options:[{value:null,label:"Loading..."}]},{change:this._onColorsDropDownChange.bind(this)});this.add([this._map,new aw.ui.Toolbar({region:"top",height:100,cssClass:"DNow_Toolbar",items:[new aw.ui.Toolbar.Group({label:"Geography Selection",cssClass:"geoselection",items:[new DNow.GeographyBar({componentBus:this.componentBus})],helpCallback:this._onHelpClick.bind(this,"Geography Selection")}),new aw.ui.Toolbar.Group({label:"Mapping Options",items:[new aw.ui.Toolbar.Row({items:[this._mappingToolsButton,new aw.ui.Control.Button({label:"Export Map"},{click:this._onExportMapClick.bind(this)})]})],helpCallback:this._onHelpClick.bind(this,"Map:Mapping Options")}),new aw.ui.Toolbar.Group({label:"Thematic Controls",items:[new aw.ui.Toolbar.Row({items:[this._toggleThematicsButton,new aw.ui.Toolbar.Column({items:[this._variableDropDown,this._geographyDropDown,this._colorsDropDown]})]})],helpCallback:this._onHelpClick.bind(this,"Map:Thematic Controls")})]}),new aw.ui.HTML({html:'<div class="mapAttribution">'+this.attributions.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()}},_getUserLocationFileByName:function(a){if((!a)||(!this._userLocationFiles)||(!this._userLocationFiles.length>0)){return null}for(var b=0;b<this._userLocationFiles.length;b++){if(this._userLocationFiles[b].name==a){return this._userLocationFiles[b]}}return null},_initializeUserPoints:function(){var a=this.componentBus.getComponentReferences("aw.UserDataManager");if((!a)||(!a.length>0)){return}a=a[0];a.retrieveData("UserLocationFile",null,null,function(c){this._userLocationFiles=[];if((!c)||(!c.length>0)){if(this._userPointsMapGroup){this._map.removeLayer(this._userPointsMapGroup)}}else{if(this._userPointsMapGroup){this._userPointsMapGroup.removeAllLayers()}else{this._userPointsMapGroup=this._map.addLayer(new aw.ui.Map.Layer.Group({drawPriority:7,key:"UserLocationFiles",label:"Location Files",visible:true}))}for(var b=0;b<c.length;b++){this._userPointsMapGroup.addLayer(new aw.ui.Map.Layer.Point.LocationFile({key:c[b].key,label:c[b].name,labelControllable:true,labelTemplate:"UserLocationLabel",options:true,visible:false}))}this._userLocationFiles=c}}.bind(this))},_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)}}}}},_onActiveThematicChanged:function(g){if((!g)||(!this._variableDropDown)||(!this._geographyDropDown)||(!this._colorsDropDown)||(!this._map)||(!this._map.layers)){return}var c=this.componentBus.getComponentReferences("aw.ThematicsManager");if((!c)||(!c.length>0)){return}c=c[0];this._variableDropDown.selectByValue(c.activeThematic.variable,false);this._geographyDropDown.selectByValue(c.activeThematic.geography,false);this._colorsDropDown.selectByValue(c.activeThematic.palette,false);var f=null;var d=c.getVariableByKey(this._variableDropDown.getValue());if(d){this._variableDropDown.setAlt(d.namePath)}var a=null;if(this._geographyDropDown.getValue()=="auto"){a=c.getAutoGeographyLevel(this._map.getScale())}else{a=c.getGeographyLevelByKey(this._geographyDropDown.getValue())}var b=c.getPaletteByKey(this._colorsDropDown.getValue());var e=this._map.layers.length;while(e--){f=this._map.layers[e];if(f.derivesFrom("aw.ui.Map.Layer.Thematic")===true){f.setVariable(d);f.setGeography(a);if((b)&&(f.palette!=b.key)){f.setPalette(b.key);f.setColors(b.colors)}}}},_onAllocateDatasetChanged:function(c){if(this._map){var d=null;var b=this._map.layers.length;while(b--){d=this._map.layers[b];if(d.derivesFrom("aw.ui.Map.Layer.Thematic")===true){this._map.removeLayer(layer)}}}var a=this.componentBus.getComponentReferences("aw.ThematicsManager");if((a)&&(a.length>0)){a[0].setAllocateDataset(c)}},_onBoundsChanged:function(b,a,d,c){if((b)&&(a)&&(d)&&(c)){this._map.zoomToExtent(b,a,d,c)}},_onColorsDropDownChange:function(d){if((!d)||(!d.getValue())){return}var b=this.componentBus.getComponentReferences("aw.ThematicsManager");if((!b)||(!b.length>0)){return}b=b[0];var a=b.getPaletteByKey(d.getValue());if(a){b.setActiveThematicPalette(a);var e=null;var c=this._map.layers.length;while(c--){e=this._map.layers[c];if(e.derivesFrom("aw.ui.Map.Layer.Thematic")===true){if(e.palette!=a.key){e.setPalette(a.key);e.setColors(a.colors)}}}}},_onExportMapClick:function(a){if(this.isSessionValidated()!==true){new aw.ui.Dialog.Error({title:"Access Denied",content:"You must be logged in to access this functionality."});return}new aw.ui.Dialog.ExportMap({componentBus:this.componentBus,map:this._map})},_onGeographyDropDownChange:function(d){if((!d)||(!d.getValue())){return}var b=this.componentBus.getComponentReferences("aw.ThematicsManager");if((!b)||(!b.length>0)){return}b=b[0];var a=null;if(d.getValue()=="auto"){a=b.getAutoGeographyLevel(this._map.getScale())}else{a=b.getGeographyLevelByKey(d.getValue())}if(a){b.setActiveThematicGeography(a);var e=null;var c=this._map.layers.length;while(c--){e=this._map.layers[c];if(e.derivesFrom("aw.ui.Map.Layer.Thematic")===true){e.setGeography(a)}}}},_onGeographyLevelsChanged:function(a){this._updateGeographyDropDown(this._map.getScale())},_onHelpClick:function(b){if(this.componentBus){var a=this.componentBus.getComponentReferences("DNow.Help");if((a)&&(a.length>0)){a[0].loadTopicByTitle(b);return}}new DNow.Help({componentBus:this.componentBus,activeTopicKey:b})},_onMapControlAdded:function(a){},_onMapControlRemoved:function(a){},_onMapControlToggled:function(a){if((!a)||(!this._mappingToolsButton)){return}this._mappingToolsButton.setToggled(a.isVisible(),false)},_onMappingToolsButtonToggled:function(b){if((!this._map)||(!this._map.controlGroups)){return}for(var a in this._map.controlGroups){this._map.controlGroups[a].toggle()}},_onMapZoomChanged:function(a){this._updateGeographyDropDown(a)},_onPalettesChanged:function(e){if(!this._colorsDropDown){return}this._colorsDropDown.clear();var b=null,c=[];for(var d=0;b=e[d];d++){c.push({value:b.key,label:b.name})}this._colorsDropDown.addOptions(c);var a=this.componentBus.getComponentReferences("aw.ThematicsManager");if((a)&&(a.length>0)&&(a[0].activeThematic)){this._onActiveThematicChanged(a[0].activeThematic)}},_onThematicsChanged:function(b){if((!this._map)||(!this._map.layers)||(!this._map.layers.length>0)){return}var e,a;var h=this._map.layers;var d=null;for(e=0,a=h.length;e<a;e++){d=this._map.layers[e];if(d.derivesFrom("aw.ui.Map.Layer.Thematic")===true){this._map.removeLayer(d)}}if((b)&&(b.length>0)){var f=null,g=null,c=null;for(e=0,a=b.length;e<a;e++){f=b[e];c={active:f.active,colors:(f.colors)?f.colors:[],cutoffs:(f.ranges)?f.ranges:[],dataset:f.dataset,name:f.name,drawPriority:3,opacity:0.8};if(f.key){Object.extend(c,{key:f.key})}g=new aw.ui.Map.Layer.Thematic(c);this._map.addLayer(g)}}},_onUserDataActionExecuted:function(b){if(!b){return}if(b.datatype=="UserLocationFile"){if(b.action=="delete"){this._onUserLocationFileDeleted(b)}else{this._initializeUserPoints()}}else{if((b.datatype=="CustomPolygon")&&(b.action=="View/Edit")){var a=this.componentBus.getComponentReferences("aw.CustomPolygonManager");if((a)&&(a.length>0)){a[0].setActivePolygonSetByName(b.name)}this.show()}}},_onUserLocationFileDeleted:function(b){if((!b)||(!this._map)){return}if(this._userPointsMapGroup){var a=this._getUserLocationFileByName(b.name);if(!a){return}this._userPointsMapGroup.removeLayerByKey(a.key);if(this._userPointsMapGroup.layers.length<1){this._map.removeLayer(this._userPointsMapGroup);this._userPointsMapGroup=null}}},_onUserSettingsReceived:function(a){if(!a){return}if(a.enableCustomPolygons===true){if(!this._customPolygonsControl){this._customPolygonsControl=new aw.ui.Map.Control.CustomPolygons({group:"Mapping Tools",componentBus:this.componentBus,drawPriority:5});this._map.addControl(this._customPolygonsControl)}}else{if(this._customPolygonsControl){this._map.removeControl(this._customPolygonsControl);this._customPolygonsControl=null}}},_onWizardJobUpdated:function(e){if(!e||!e.disposition||e.disposition===""||e.userDataTypes.length<1){return}if(e.disposition.toLowerCase()==="complete"){var b=e.userDataTypes;for(var d=0,a=b.length;d<a;d++){switch(b[d]){case"CustomPolygon":var c=this.componentBus.getComponentReferences("aw.CustomPolygonManager")[0];if(c){c._getCustomPolygonSets()}break;case"UserLocationFile":this._initializeUserPoints();break;default:break}}}},_onVariableDropDownChange:function(d){if((!d)||(!d.getValue())){return}if(d.getValue()=="more"){new DNow.VariableDialog({componentBus:this.componentBus},{onvariableselected:this._onVariableSelected.bind(this)});return}var a=this.componentBus.getComponentReferences("aw.ThematicsManager");if((!a)||(!a.length>0)){return}a=a[0];var b=a.getVariableByKey(d.getValue());if(b){a.setActiveThematicVariable(b);var e=null;var c=this._map.layers.length;while(c--){e=this._map.layers[c];if(e.derivesFrom("aw.ui.Map.Layer.Thematic")===true){e.setVariable(b)}}}},_onVariablesChanged:function(f){if(!this._variableDropDown){return}this._variableDropDown.clear();var c=null,b=[],e=null;for(var d=0;c=f[d];d++){e=(c.namePath)?c.namePath:"Unknown";b.push({value:c.variableKey,label:((e.length>40)?"..."+e.substring(e.length-40):e)})}b.push({value:"more",label:"More variables..."});this._variableDropDown.addOptions(b);var a=this.componentBus.getComponentReferences("aw.ThematicsManager");if((a)&&(a.length>0)&&(a[0].activeThematic)){this._onActiveThematicChanged(a[0].activeThematic)}},_onVariableSelected:function(b){if(!b){return}var a=this.componentBus.getComponentReferences("aw.ThematicsManager");if((!a)||(!a.length>0)){return}a=a[0];a.setActiveThematicVariable(b);var d=null;var c=this._map.layers.length;while(c--){d=this._map.layers[c];if(d.derivesFrom("aw.ui.Map.Layer.Thematic")===true){d.setVariable(b)}}},_updateGeographyDropDown:function(f){if((!f)||(!this._geographyDropDown)){return}var b=this.componentBus.getComponentReferences("aw.ThematicsManager");if((!b)||(!b.length>0)){return}b=b[0];this._geographyDropDown.clear();var c=b.getGeographyLevelsByScale(f);if((c)&&(c.length>0)){var d=[],a=null;for(var e=0;a=c[e];e++){d.push({value:a.key,label:a.name})}this._geographyDropDown.addOptions(d);this._onActiveThematicChanged(b.activeThematic)}else{this._geographyDropDown.addOption(null,"No Geographies Available")}},CLASS_NAME:"DNow.MapViewer"});DNow.QueryViewer=Class.create(aw.ui.Panel,{_datasetDropDown:null,_fieldTree:null,_querySummaryTree:null,_activeFilter:null,_rangeBeginComboBox:null,_rangeEndComboBox:null,_deleteFilterButton:null,_isUserLocationData:null,_savedFilters:[],_listDatasets:[],initialize:function(b,a){this._datasetDropDown=null;this._fieldTree=null;this._querySummaryTree=null;this._activeFilter=null;this._rangeBeginComboBox=null;this._rangeEndComboBox=null;this._deleteFilterButton=null;this._isUserLocationData=null;this._savedFilters=[];this._listDatasets=[];this.inheritCSS=true;aw.ui.Panel.prototype.initialize.apply(this,arguments);if(this.componentBus){this.componentBus.getComponentReferences("aw.QueryManager",function(e){if((e)&&(e.length>0)){var d=e[0];d.registerEvent("onquerydatasetschanged",this._onQueryDatasetsChanged.bind(this));d.registerEvent("onquerydatasetchanged",this._onQueryDatasetChanged.bind(this));d.registerEvent("onquerycountreceived",this._onQueryCountReceived.bind(this));d.registerEvent("ondatasetmetadatareceived",this._onQueryDatasetMetadataReceived.bind(this));d.registerEvent("onactivequerychanged",this._onActiveQueryChanged.bind(this));d.registerEvent("onquerysaved",this._onQuerySaved.bind(this));var c=d.getAllQueryDatasets();if((c)&&(c.length>0)){this._onQueryDatasetsChanged(c)}if(d.activeQueryDataset){this._onQueryDatasetChanged(d.activeQueryDataset)}}}.bind(this));this.componentBus.getComponentReferences("aw.GeographyManager",function(c){if((c)&&(c.length>0)){var d=c[0];d.registerEvent("onactivegeographychanged",this._onActiveGeographyChanged.bind(this));if(d.activeGeography){this._onActiveGeographyChanged(d.activeGeography)}}}.bind(this));this.componentBus.getComponentReferences("aw.UserDataManager",function(c){if((c)&&(c.length>0)){var d=c[0];d.registerEvent("onactionexecuted",this._onUserDataActionExecuted.bind(this))}}.bind(this))}},draw:function(){aw.ui.Panel.prototype.draw.apply(this);this._datasetDropDown=new aw.ui.Control.DropDown({label:"Dataset: ",options:[{value:"",label:"Loading..."}]},{change:this._onDatasetDropDownChanged.bind(this)});this._fieldTree=new aw.ui.Tree({mode:"single",accordion:true,cssClass:"fieldTree"},{onselectionchanged:this._onFieldTreeSelectionChanged.bind(this)});this._querySummaryTree=new aw.ui.Tree({mode:"single"},{onselectionchanged:this._onSummaryTreeSelectionChanged.bind(this)});this._queryNameLabel=new aw.ui.Control.Label({label:"Query Name: ",value:"Temporary Query"});this._queryCountLabel=new aw.ui.Control.Label({label:"Record Count (within current geography): ",value:"0"});this._deleteFilterButton=new aw.ui.Control.Button({label:"Delete Selected Item",align:"right",disabled:true},{click:this._onDeleteFilterClick.bind(this)});this._activeFilterPanel=new aw.ui.Panel({title:"No Field Selected",minWidth:300,width:600,items:[new aw.ui.HTML({html:'<div class="filterSelection"><select name="filterType" id="filterType"></select><div class="filterValue" style="display: none;"></div></div><div class="filterList" style="display: none;"></div><div class="filterTree" style="display: none;"></div><div class="filterOptions"><div class="inverse"><input type="checkbox" name="filterInverse" id="filterInverse" /> Inverse (Not)</div><div class="clear"></div></div>'})]});this.add(new aw.ui.Toolbar({region:"top",height:100,cssClass:"DNow_Toolbar",items:[new aw.ui.Toolbar.Group({label:"Geography Selection",cssClass:"geoselection",items:[new DNow.GeographyBar({componentBus:this.componentBus})],helpCallback:this._onHelpClick.bind(this,"Geography Selection")}),new aw.ui.Toolbar.Group({label:"Query Options",items:[new aw.ui.Toolbar.Column({items:[this._datasetDropDown,new aw.ui.Toolbar.Row({items:[new aw.ui.Control.Button({label:"Open"},{click:this._onOpenQueryClick.bind(this)}),new aw.ui.Control.Button({label:"Save"},{click:this._onSaveQueryClick.bind(this)})]})]})],helpCallback:this._onHelpClick.bind(this,"Query:Query Options")})]}));this.add(new aw.ui.Panel.Splitter({titleVisibility:false,orientation:"horizontal",items:[new aw.ui.Panel({title:"Fields",minWidth:200,width:200,items:[this._fieldTree]}),this._activeFilterPanel,new aw.ui.Panel({title:"Query Summary",minWidth:300,width:300,cssClass:"querySummary",items:[new aw.ui.Toolbar({height:55,region:"top",items:[new aw.ui.Toolbar.Column({items:[this._queryNameLabel,this._queryCountLabel]})]}),this._querySummaryTree,new aw.ui.Toolbar({height:30,region:"bottom",items:[new aw.ui.Toolbar.Row({items:[this._deleteFilterButton]})]})]})]}));this._filterTypeSelect=this._activeFilterPanel.canvas.down('select[id="filterType"]');aw.EventManager.register(this._filterTypeSelect,"change",this._onFilterTypeSelectChanged.bind(this));this._filterValueContainer=this._activeFilterPanel.canvas.down("div.filterValue");this._filterListContainer=this._activeFilterPanel.canvas.down("div.filterList");this._filterTreeContainer=this._activeFilterPanel.canvas.down("div.filterTree");this._filterInverseCheck=this._activeFilterPanel.canvas.down('input[id="filterInverse"]');aw.EventManager.register(this._filterInverseCheck,"click",this._onFilterInverseCheckClick.bind(this));var a=this._activeFilterPanel.canvas.down("div.clear");if(a){a.update("");new aw.ui.Control.Button({label:"Clear",container:a},{click:this._onFilterClearClick.bind(this)})}return this.canvas},_buildQueryLayer:function(c,f){var e=this.componentBus.getComponentReferences("aw.GeographyManager");if((!e)||(!e.length>0)){return}var g=e[0].activeGeography;if(!g){return}var b=g.getGeographyDefinition();var d=this.componentBus.getComponentReferences("aw.ui.Map");if((d)&&(d.length>0)){d=d[0];var a=d.getLayerByKey("activequery");if(a){a.setDataset(f.key);a.setGeoCollection(b);a.setQuery(c)}else{d.addLayer(new aw.ui.Map.Layer.Point.Query({key:"activequery",label:"Active Query",labelTemplate:"ActiveQueryLabel",labelControllable:true,options:false,dataset:f.key,query:c,geoCollection:b,visible:true,drawPriority:6.1,parameters:{fillc:"ff0000"}}))}}},_buildReportQuery:function(b,d){var c=this.componentBus.getComponentReferences("aw.ReportManager");if((c)&&(c.length>0)){c=c[0];c.removeReports(c.getReportsBy({type:"Calgary",format:"List",name:"Temporary List Report"}),false);c.addReport({format:"List",name:"Temporary List Report",type:"Calgary",listOnly:false,variant:d.key,query:b.serialize()});if(this.isVisible()===true){var a=c.getReportsBy({type:"Calgary",format:"List",name:"Temporary List Report"});if((a)&&(a.length>0)){c.setActiveReport(a[0])}}}},_executeQuery:function(f,e){if((!f)||(!e)){return}var c=this.componentBus.getComponentReferences("aw.QueryManager");if((c)&&(c.length>0)){c=c[0]}else{return}var d=null;if(c.activeQuery){d=c.activeQuery;var b=d.getItemsByClassName("aw.Query.Filter.Spatial");if((b)&&(b.length>0)){for(var a=0;a<b.length;a++){b[a].geoCollection=f}}}else{d=new aw.Query.Operator({operator:"And"});d.add(new aw.Query.Filter.Spatial({geoCollection:f}))}c.setActiveQuery(d)},_loadCalgaryReports:function(){var a=this.componentBus.getComponentReferences("aw.QueryManager");if((a)&&(a.length>0)){var c=a[0].activeQueryDataset}else{return}var b=this.componentBus.getComponentReferences("aw.UserDataManager");if((b)&&(b.length>0)){b=b[0];b.retrieveData("CalgaryListFilter",null,c.key,function(h){var k=this.componentBus.getComponentReferences("aw.ReportManager");if((k)&&(k.length>0)){k=k[0];if((this._savedFilters)&&(this._savedFilters.length>0)){var g=null;for(var f=0;g=this._savedFilters[f];f++){k.removeReports(k.getReportsBy({type:"Calgary",format:"List",name:g.name}),false)}}this._savedFilters=[];h.sortBy("name");var d=[];for(var e=0;g=h[e];e++){this._savedFilters.push(g);d.push({format:"List",name:g.name,type:"Calgary",listOnly:false,variant:c.key,query:g.query})}k.addReports(d)}}.bind(this))}},_loadQuery:function(b){var a=this.componentBus.getComponentReferences("aw.QueryManager");if((!a)||(!a.length>0)){return}var d=this.componentBus.getComponentReferences("aw.GeographyManager");if((!d)||(!d.length>0)){return}a=a[0];d=d[0];if(this._loadQuery_fx){a.unregisterEvent("ondatasetmetadatareceived",this._loadQuery_fx);this._loadQuery_fx=null}var c=a.buildQueryObject(b.params.jsonQuery);c.add(new aw.Query.Filter.Spatial({geoCollection:d.activeGeography}));c.name=b.name;a.setActiveQuery(c,b.name);if(this._queryNameLabel){this._queryNameLabel.setValue(b.name)}this.show()},_onActiveGeographyChanged:function(b){var a=this.componentBus.getComponentReferences("aw.QueryManager");if((a)&&(a.length>0)){a=a[0];if(a.activeQueryDataset){this._executeQuery(b,a.activeQueryDataset)}}},_onActiveQueryChanged:function(a){if(this._queryCountLabel){if((this._queryCountLabel.label.match(/does not support/))&&(this._isUserLocationData===false)){this._queryCountLabel.setLabel("Record Count (within current geography): ")}this._queryCountLabel.setValue("Loading...")}if(this._queryNameLabel){this._queryNameLabel.setValue(((a)&&(a.filterName))?a.filterName:"Temporary Query")}},_onDatasetDropDownChanged:function(b){var a=this.componentBus.getComponentReferences("aw.QueryManager");if((a)&&(a.length>0)){a[0].setActiveQueryDatasetByKey(b.getValue())}},_onDeleteFilterClick:function(f){if(!this._querySummaryTree){return}var e=this._querySummaryTree.getSelectedKeys();if((!e)||(!e.length>0)){return}var d=this.componentBus.getComponentReferences("aw.QueryManager");if((d)&&(d.length>0)&&(d[0].activeQuery)){d=d[0]}else{return}var b=null,c=null;for(var a=0;b=e[a];a++){c=d.activeQuery.getItemById(b);if((c)&&(!c.derivesFrom("aw.Query.Filter.Spatial"))){d.activeQuery.remove(c);if(c===this._activeFilter){this._activeFilter=null;this._onFieldTreeSelectionChanged()}d.setActiveQuery(d.activeQuery)}c=null}},_onFieldTreeSelectionChanged:function(a){if(!this._fieldTree){return}var d=this._fieldTree.getSelectedKeys();if((!d)||(d.length!==1)){return}var b=d[0];var c=this.componentBus.getComponentReferences("aw.QueryManager");if((c)&&(c.length>0)){c=c[0];c.setActiveFieldIndexByName(b);var e=c.activeFieldIndex;if(e){this._activeFilterPanel.setTitle(e.shortName);this._setFilterTypeSelect(e)}}},_onFilterClearClick:function(b){if(this._activeFilter){var a=this.componentBus.getComponentReferences("aw.QueryManager");if((a)&&(a.length>0)){a=a[0];if(a.activeQuery){a.activeQuery.remove(this._activeFilter);this._activeFilter=null;this._onFilterTypeSelectChanged();a.setActiveQuery(a.activeQuery)}}}},_onFilterInverseCheckClick:function(){if(this._activeFilter){var a=this.componentBus.getComponentReferences("aw.QueryManager");if((a)&&(a.length>0)){a=a[0];this._activeFilter.inverse=this._filterInverseCheck.checked;a.setActiveQuery(a.activeQuery)}}},_onFilterListClick:function(d){var c=aw.EventManager.getEvent(d);var a=c.target;if(!a){return}if((a.tagName)&&(a.tagName.toLowerCase()=="input")){var b=this.componentBus.getComponentReferences("aw.QueryManager");if((b)&&(b.length>0)){b=b[0];if(!b.activeFieldIndex){return}}else{return}if(!this._activeFilter){this._activeFilter=new aw.Query.Filter.List({name:b.activeFieldIndex.name,label:b.activeFieldIndex.shortName});b.activeQuery.add(this._activeFilter)}if(a.checked===true){this._activeFilter.addValue(a.value)}else{this._activeFilter.removeValue(a.value)}this._activeFilter.inverse=this._filterInverseCheck.checked;b.setActiveQuery(b.activeQuery)}},_onFilterTypeSelectChanged:function(){var e=this._filterTypeSelect.value;var q=this.componentBus.getComponentReferences("aw.QueryManager");if((q)&&(q.length>0)){q=q[0];if(!q.activeFieldIndex){return}}else{return}var d=(q.getFilterClassByVerb(e))?q.getFilterClassByVerb(e).CLASS_NAME:null;if((d)&&(q.activeQuery)){this._activeFilter=q.activeQuery.getFilterBy({name:q.activeFieldIndex.name,supports:q.activeFieldIndex.type,CLASS_NAME:d})}this._filterInverseCheck.checked=false;if(this._activeFilter){this._filterInverseCheck.checked=this._activeFilter.inverse}this._filterValueContainer.update("");this._filterListContainer.update("");this._filterTreeContainer.update("");this._filterValueContainer.hide();this._filterListContainer.hide();this._filterTreeContainer.hide();if(this._filterTreeTimeout){clearTimeout(this._filterTreeTimeout);this._filterTreeTimeout=null}var b=e;var t=[],n=null;if((e=="is")||(e=="contains")||(e=="begins")||(e=="ends")){b="value"}if((q.activeFieldIndex.listTreeEnumerator)&&(e.match("is|list|listBegin"))){this._filterTree=new aw.ui.Tree({componentBus:this.componentBus,container:this._filterTreeContainer,mode:(e=="is")?"single":"multiple",branchSelectable:(e=="is")?false:true,baseRequest:{cn:"SRC.Web.Client.Handler.CalgaryHandler|"+q.activeQueryDataset.variant,service:"tree",sn:q.activeFieldIndex.shortName,k:(this._activeFilter)?(this._activeFilter.value||this._activeFilter.values):null}});this._filterTreeTimeout=setTimeout(this._filterTree.registerEvent.bind(this._filterTree,"onselectionchanged",this._onFilterTreeChanged.bind(this)),150);this._filterTreeContainer.show();return}if(b=="value"){new aw.ui.Control.TextBox({changeDelay:200,label:"Value: ",container:this._filterValueContainer,value:((this._activeFilter)?this._activeFilter.value:null)},{change:this._onFilterValueChanged.bind(this,b)});this._filterValueContainer.show()}else{if(b=="range"){if((q.activeFieldIndex.rangeValues)&&(q.activeFieldIndex.rangeValues.length>0)){for(var l=0;n=q.activeFieldIndex.rangeValues[l];l++){t.push({value:n.key,label:n.value})}}this._rangeBeginComboBox=new aw.ui.Control.ComboBox({label:"Between ",container:this._filterValueContainer,options:t,value:((this._activeFilter)?this._activeFilter.begins:null)},{change:this._onFilterValueChanged.bind(this,b)});this._rangeEndComboBox=new aw.ui.Control.ComboBox({label:" and ",container:this._filterValueContainer,options:t,value:((this._activeFilter)?this._activeFilter.ends:null)},{change:this._onFilterValueChanged.bind(this,b)});this._filterValueContainer.show()}else{if(b=="null"){if(!this._activeFilter){this._activeFilter=new aw.Query.Filter.Null({name:q.activeFieldIndex.name,label:q.activeFieldIndex.shortName});this._activeFilter.inverse=this._filterInverseCheck.checked;q.activeQuery.add(this._activeFilter);q.setActiveQuery(q.activeQuery)}}else{if(b=="list"){if((q.activeFieldIndex.enumeratedValues)&&(q.activeFieldIndex.enumeratedValues.length>0)){var f=3;var s=Math.ceil(q.activeFieldIndex.enumeratedValues.length/f);for(var a=0;a<s;a++){t.push("<tr>");var o=0;for(var h=0;h<q.activeFieldIndex.enumeratedValues.length;h++){if(h%s==a){n=q.activeFieldIndex.enumeratedValues[h];t.push('<td><input type="checkbox" key="fieldValue'+h+'" value="'+n.key+'" /> '+n.value+"</td>");o++}}while(o<f){t.push("<td>&nbsp;</td>");o++}t.push("</tr>")}this._filterListContainer.update('<table cellspacing="0" cellpadding="0">'+t.join("")+"</table>");if((this._activeFilter)&&(this._activeFilter.values)&&(this._activeFilter.values.length>0)){var m=this._filterListContainer.select('input[value="'+this._activeFilter.values.join('"], input[value="')+'"]');if((m)&&(m.length>0)){for(var g=0;g<m.length;g++){m[g].checked=true}}}var p=this._filterListContainer.down("table");if(p){aw.EventManager.register(p,"click",this._onFilterListClick.bindAsEventListener(this))}p=null;this._filterListContainer.show()}}}}}},_onFilterTreeChanged:function(a){if(!a){return}var b=a.getSelectedKeys();var e=this._filterTypeSelect.value;var d=this.componentBus.getComponentReferences("aw.QueryManager");if((d)&&(d.length>0)){d=d[0];if(!d.activeFieldIndex){return}}else{return}if(!this._activeFilter){if(e==="is"){this._activeFilter=new aw.Query.Filter.Is({name:d.activeFieldIndex.name,label:d.activeFieldIndex.shortName})}else{if(e==="list"){this._activeFilter=new aw.Query.Filter.List({name:d.activeFieldIndex.name,label:d.activeFieldIndex.shortName})}else{if(e==="listBegin"){this._activeFilter=new aw.Query.Filter.ListBegin({name:d.activeFieldIndex.name,label:d.activeFieldIndex.shortName})}else{throw"Could not locate appropriate filter type."}}}d.activeQuery.add(this._activeFilter)}if((!b)||(!b.length>0)){d.activeQuery.remove(this._activeFilter);this._activeFilter=null}else{if(e==="is"){this._activeFilter.setValue(b[0])}else{if(e.match("list|listBegin")){this._activeFilter.clear();for(var c=0;c<b.length;c++){this._activeFilter.addValue(b[c])}}else{throw"Could not locate appropriate filter type."}}}if(this._activeFilter){this._activeFilter.inverse=this._filterInverseCheck.checked}d.setActiveQuery(d.activeQuery)},_onFilterValueChanged:function(a,e){var f=this._filterTypeSelect.value;var d=e.getValue();var c=this.componentBus.getComponentReferences("aw.QueryManager");if((c)&&(c.length>0)){c=c[0];if(!c.activeFieldIndex){return}}else{return}if(!this._activeFilter){if(f=="is"){this._activeFilter=new aw.Query.Filter.Is({name:c.activeFieldIndex.name,label:c.activeFieldIndex.shortName})}else{if(f=="begins"){this._activeFilter=new aw.Query.Filter.Begins({name:c.activeFieldIndex.name,label:c.activeFieldIndex.shortName})}else{if(f=="ends"){this._activeFilter=new aw.Query.Filter.Ends({name:c.activeFieldIndex.name,label:c.activeFieldIndex.shortName})}else{if(f=="contains"){this._activeFilter=new aw.Query.Filter.Contains({name:c.activeFieldIndex.name,label:c.activeFieldIndex.shortName})}else{if(f=="range"){this._activeFilter=new aw.Query.Filter.Range({name:c.activeFieldIndex.name,label:c.activeFieldIndex.shortName})}else{if(f=="list"){this._activeFilter=new aw.Query.Filter.List({name:c.activeFieldIndex.name,label:c.activeFieldIndex.shortName})}else{if(f=="listBegin"){this._activeFilter=new aw.Query.Filter.ListBegin({name:c.activeFieldIndex.name,label:c.activeFieldIndex.shortName})}else{if(f=="null"){this._activeFilter=new aw.Query.Filter.Null({name:c.activeFieldIndex.name,label:c.activeFieldIndex.shortName})}else{throw"Could not locate appropriate filter type."}}}}}}}}c.activeQuery.add(this._activeFilter)}if(f=="range"){var b=[this._rangeBeginComboBox.getValue(),this._rangeEndComboBox.getValue()];this._activeFilter.setRangeBegin(Math.min(b[0],b[1]));this._activeFilter.setRangeEnd(Math.max(b[0],b[1]))}else{if(f.match("is|begins|ends|contains")){if((!d)||(d==="")){c.activeQuery.remove(this._activeFilter);this._activeFilter=null}else{this._activeFilter.setValue(d)}}else{throw"Could not locate appropriate filter type."}}if(this._activeFilter){this._activeFilter.inverse=this._filterInverseCheck.checked}c.setActiveQuery(c.activeQuery)},_onHelpClick:function(b){if(this.componentBus){var a=this.componentBus.getComponentReferences("DNow.Help");if((a)&&(a.length>0)){a[0].loadTopicByTitle(b);return}}new DNow.Help({componentBus:this.componentBus,activeTopicKey:b})},_onOpenQueryClick:function(a){if(this.isSessionValidated()===true){new DNow.SavedQueryDialog({componentBus:this.componentBus})}else{new aw.ui.Dialog.Error({title:"Error",content:"You must be logged in to access this functionality."})}},_onQueryCountReceived:function(b){if(!this._querySummaryTree){return}var a=this.componentBus.getComponentReferences("aw.QueryManager");if((a)&&(a.length>0)){a=a[0];if(this._queryCountLabel){if(this._isUserLocationData===true){this._queryCountLabel.setLabel("Record count does not support user location files. ");this._queryCountLabel.setValue("")}else{this._queryCountLabel.setValue(parseFloat(a.activeQuery.count).addCommas())}}this._querySummaryTree.clear();this._renderQuerySummaryTree(a.activeQuery.items);this._buildReportQuery(a.activeQuery,a.activeQueryDataset);this._buildQueryLayer(b,a.activeQueryDataset)}},_onQueryDatasetChanged:function(c){if(this._datasetDropDown){this._datasetDropDown.selectByValue(c.key,false)}var a=this.componentBus.getComponentReferences("aw.QueryManager");if((a)&&(a.length>0)){a[0].clearActiveQuery()}if(c.variant.match(/^userlocationfile:/)){this._isUserLocationData=true}else{this._isUserLocationData=false}var b=this.componentBus.getComponentReferences("aw.GeographyManager");if((b)&&(b.length>0)){b=b[0];if(b.activeGeography){this._executeQuery(b.activeGeography,c)}}this._loadCalgaryReports()},_onQueryDatasetMetadataReceived:function(g,f){if((!g)||(!this._fieldTree)){return}this._fieldTree.clear();var e=null;var c=false,a=false;for(var d in g){this._fieldTree.addNode({key:d.replace(/^\s*|\s*$/,""),label:d,type:"branch",selectable:false,expanded:(a!==true)?true:false});for(var b=0;e=g[d].fields[b];b++){this._fieldTree.addNode({key:e.name,parentKey:d.replace(/^\s*|\s*$/,""),label:e.shortName,selected:(c!==true)?true:false});if(c!==true){c=true}}if(a!==true){a=true}}this._onFieldTreeSelectionChanged(this._fieldTree)},_onQueryDatasetsChanged:function(d){if((!d)||(!this._datasetDropDown)){return}this._datasetDropDown.clear();var n=this.componentBus.getComponentReferences("aw.ReportManager");if((n)&&(n.length>0)){n=n[0];if((this._listDatasets)&&(this._listDatasets.length>0)){var f=null;for(var h=0;f=this._listDatasets[h];h++){n.removeReports(n.getReportsBy({type:"Calgary",format:"List",name:f.name}),false)}}this._listDatasets=[];d.sortBy("name");var l=[];for(var g=0;f=d[g];g++){this._listDatasets.push(f);l.push({format:"List",name:f.name,type:"Calgary",listOnly:false,variant:f.key,query:"<And/>"})}n.addReports(l)}var o=this.componentBus.getComponentReferences("aw.QueryManager");if((!o)||(!o.length>0)){return}o=o[0];for(var e=0;f=d[e];e++){this._datasetDropDown.addOption(f.key,f.name,false,((f===o.activeQueryDataset)?true:false))}var a=this.componentBus.getComponentReferences("aw.ui.Map");if((a)&&(a.length>0)){a=a[0];var b=a.getLayerByKey("pointsets");if(b){b.removeAllLayers()}else{b=a.addLayer(new aw.ui.Map.Layer.Group({key:"pointsets",label:"Point Datasets",drawPriority:6}))}for(var c=0;f=d[c];c++){b.addLayer(new aw.ui.Map.Layer.Point.Query({key:"listlayer"+f.key,label:f.name,labelTemplate:"QueryLabel",labelControllable:true,options:false,dataset:f.key,query:"<All/>"}))}}},_onQuerySaved:function(b,a){if((this._queryNameLabel)&&(a)){this._queryNameLabel.setValue(a)}},_onSaveQueryClick:function(b){if(this.isSessionValidated()===true){var a=this.componentBus.getComponentReferences("aw.QueryManager");if((a)&&(a.length>0)){a[0].saveActiveQuery(null,this._onQuerySaved.bind(this))}}else{new aw.ui.Dialog.Error({title:"Access Denied",content:"You must be logged in to access this functionality."})}},_onSummaryTreeSelectionChanged:function(a){if(this._deleteFilterButton){this._deleteFilterButton.disable()}if(!a){return}var e=a.getSelectedKeys();if((!e)||(e.length!==1)){return}var b=e[0];var d=this.componentBus.getComponentReferences("aw.QueryManager");if((d)&&(d.length>0)&&(d[0].activeQuery)){d=d[0]}else{return}var c=d.activeQuery.getItemById(b);if((!c)||(c.derivesFrom("aw.Query.Filter.Spatial"))){return}if(this._activeFilter===c){return}this._activeFilter=c;this._fieldTree.selectNodeByKey(c.name);if(this._deleteFilterButton){this._deleteFilterButton.enable()}},_onUserDataActionExecuted:function(b){if(!b){return}if(b.datatype=="CalgaryListFilter"){this._loadCalgaryReports();if(b.action=="Edit"){if(!b.params){return}var a=this.componentBus.getComponentReferences("aw.QueryManager");if((!a)||(!a.length>0)){return}a=a[0];if((!a.activeQueryDataset)||(a.activeQueryDataset.key!==b.params.dataset)){a.setActiveQueryDatasetByKey(b.params.dataset);this._loadQuery_fx=this._loadQuery.bind(this,b);a.registerEvent("ondatasetmetadatareceived",this._loadQuery_fx)}else{this._loadQuery(b)}}}},_renderQuerySummaryTree:function(b,d){if((!b)||(!b.length>0)){return}var a=[];var g=null,f=null,c=null;for(var e=0;g=b[e];e++){if(!g.derivesFrom("aw.Query.Filter.Spatial")){c=g.getSummaryLabel();this._querySummaryTree.addNode({key:g.id,label:c,parentKey:(d)?d:null,selectable:true});this._renderQuerySummaryTree(g.items,g.id)}else{this._renderQuerySummaryTree(g.items,d)}}},_setFilterTypeSelect:function(k){if((!k)||(!k.type)||(!this._filterTypeSelect)){return}this._filterTypeSelect.options.length=0;var d=((k.enumeratedValues)&&(k.enumeratedValues.length>0))?true:false;var b=((k.rangeValues)&&(k.rangeValues.length>0))?true:false;var a=[];if(k.type=="Contains"){a.push({verb:"is",label:"Is..."});a.push({verb:"begins",label:"Begins with..."});a.push({verb:"contains",label:"Contains...",selected:true});a.push({verb:"ends",label:"Ends with..."});if(d===true){a.push({verb:"list",label:"Is in List..."})}a.push({verb:"null",label:"Is Null"})}else{if((k.type=="AString")||(k.type=="WString")){a.push({verb:"is",label:"Is...",selected:true});a.push({verb:"begins",label:"Begins with..."});if(b===true){a.push({verb:"range",label:"Is in Range",selected:true})}a.push({verb:"ends",label:"Ends with..."});if((d===true)||(k.listTreeEnumerator===true)){a.push({verb:"list",label:"Is in List...",selected:!k.listTreeEnumerator})}if(k.listTreeEnumerator===true){a.push({verb:"listBegin",label:"Begins with value in list...",selected:true})}}else{if((k.type=="Double")||(k.type=="Byte")||(k.type=="Int64")||(k.type=="Int16")||(k.type=="Float")){a.push({verb:"is",label:"Is..."});a.push({verb:"range",label:"Is in Range",selected:true});if(d===true){a.push({verb:"list",label:"Is in List..."})}a.push({verb:"null",label:"Is Null"})}}}var g=null;var f=0;for(var h=0;g=a[h];h++){var c=document.createElement("option");c.text=g.label;c.value=g.verb;try{this._filterTypeSelect.add(c,null)}catch(j){this._filterTypeSelect.add(c)}if(g.selected===true){f=h}}this._filterTypeSelect.selectedIndex=f;this._onFilterTypeSelectChanged()},CLASS_NAME:"DNow.QueryViewer"});DNow.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,_onActiveIndexBaseChanged_fx:null,initialize:function(b,a){this._activeReportFormat="Comparison";this._frame=null;this._reportDropDown=null;this._reportFormatGroup=null;this._activeFormatButton=null;this._url=null;this.inheritCSS=true;aw.ui.Panel.prototype.initialize.apply(this,arguments);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);this._onActiveIndexBaseChanged_fx=this._onActiveIndexBaseChanged.bind(this);d.registerEvent("onactivegeographychanged",this._onActiveGeographyChanged_fx);d.registerEvent("onactiveindexbasechanged",this._onActiveIndexBaseChanged_fx);if(d.activeGeography){this._onActiveGeographyChanged(d.activeGeography)}if(d.activeIndexBase){this._onActiveIndexBaseChanged(d.activeIndexBase)}}}.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._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"}),new aw.ui.Control.Button.Toggle({label:"List"})]},{toggle:this._onReportFormatToggle.bind(this)});this.add(new aw.ui.Toolbar({region:"top",height:100,cssClass:"DNow_Toolbar",items:[new aw.ui.Toolbar.Group({label:"Geography Selection",cssClass:"geoselection",items:[new DNow.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,"Report:Report Types")}),new aw.ui.Toolbar.Group({label:"File Options",items:[new aw.ui.Toolbar.Column({items:[new aw.ui.Toolbar.Row({items:[new aw.ui.Control.Button({label:"View Saved Reports"},{click:this._onViewSavedReportsClick.bind(this)}),new aw.ui.Control.Button({label:"Save"},{click:this._onSaveReportClick.bind(this)}),new aw.ui.Control.Button({label:"Print",icon:"./core/img/Misc/printer.png"},{click:this._onPrintReportClick.bind(this)})]}),new aw.ui.Toolbar.Row({items:[new aw.ui.Control.Button.Split({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")})]})]})]})],helpCallback:this._onHelpClick.bind(this,"Report:File Options")})]}));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(g,b,a){if((!g)||(!a)){return}if((a.format.toLowerCase()=="comparison")&&(g)&&(g.getGeographyCount()>16)){new aw.ui.Dialog.Alert({title:"Too Many Geographies!",content:"No more than 16 geographies may be selected for a comparison report."});var f=this.componentBus.getComponentReferences("aw.ReportManager");if((f)&&(f.length>0)){var e=f[0].getReportsByFormat("summary");if((e)&&(e.length>0)){f[0].setActiveReport(e[0])}}return}var c=[];c.push("cn=SRC.Web.Client.Handler.ReportHandler");c.push("service=loading");if(this.componentBus.getApplicationKey()){c.push("akey="+this.componentBus.getApplicationKey())}if(this._frame){this._frame.src=this.componentBus.getComponentServer()+"?"+c.join("&")}if(a.type=="Calgary"){var d={cn:"SRC.Web.Client.Handler.CalgaryHandler"+((a.variant)?("|"+a.variant):""),service:"buildCalgaryQuery",query:a.query};Object.extend(d,g.getGeographyDefinition());this.request(d,function(l,h,j,k){if((!k)||(!k.payload)||(!k.payload.query)){return}var i=Object.clone(h);i.query=k.payload.query;this._executeReport(l,b,i)}.bind(this,g,a));return}this._executeReport(g,b,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(e,b,a){var d={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(d,{dataset:a.variant,query:a.query,queryName:a.name})}else{Object.extend(d,{report:a.name})}if((a.format)&&((a.format.toLowerCase()=="summary")||(a.format.toLowerCase()=="list"))){e.summarizeRadii(true)}else{e.summarizeRadii(false)}Object.extend(d,e.getGeographyDefinition());if(b){var c=b.getGeographyDefinition();if((c)&&(c.geodef)){d.indexbase=c.geodef}}this.request(d,function(f,g){if((!g)||(!g.payload)){return}this.renderReport(g.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(c){var b=this.componentBus.getComponentReferences("aw.ReportManager");if((b)&&(b.length>0)){b=b[0];if(b.activeReport){var a=this.componentBus.getComponentReferences("aw.GeographyManager");if((a)&&(a.length>0)){a=a[0]}this.executeReport(c,a.activeIndexBase,b.activeReport)}}},_onActiveIndexBaseChanged:function(c){var b=this.componentBus.getComponentReferences("aw.ReportManager");if((b)&&(b.length>0)){b=b[0];if(b.activeReport){var a=this.componentBus.getComponentReferences("aw.GeographyManager");if((a)&&(a.length>0)){a=a[0]}this.executeReport(a.activeGeography,c,b.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,c.activeIndexBase,b)}}},_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},_onHelpClick:function(b){if(this.componentBus){var a=this.componentBus.getComponentReferences("DNow.Help");if((a)&&(a.length>0)){a[0].loadTopicByTitle(b);return}}new DNow.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("DNow.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:"DNow.ReportViewer"});DNow.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,arguments)},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",type:"date"},{index:"dateModified",label:"Date Modified",type:"date"}],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:"DNow.SavedGeographyDialog"});DNow.SavedQueryDialog=Class.create(aw.ui.Dialog,{initialize:function(b,a){this.inheritCSS=true;Object.extend(b,{title:"Select a Saved Query",content:"Loading..."});aw.ui.Dialog.prototype.initialize.apply(this,arguments)},afterDraw:function(){aw.ui.Dialog.prototype.afterDraw.apply(this);var a=this.componentBus.getComponentReferences("aw.QueryManager");if((a)&&(a.length>0)){a=a[0]}else{return}var b=this.componentBus.getComponentReferences("aw.UserDataManager");if((b)&&(b.length>0)){b=b[0]}else{return}b.retrieveData("CalgaryListFilter",null,a.activeQueryDataset.key,function(d){var c=new aw.ui.Grid({columns:[{index:"name",label:"Name",sorted:true,sortDirection:"asc"},{index:"dateCreated",label:"Date Created",type:"date"},{index:"dateModified",label:"Date Modified",type:"date"}],selectMultiple:false});this.setContent(c.draw());c.loadData(d);this._renderButton("OK",this._onSelectedFilterClick.bind(this,c));this._renderButton("Cancel",this.close.bind(this))}.bind(this))},_onSelectedFilterClick:function(d){if(!d){return}var a=d.getSelectedRecords();if((!a)||(!a.length>0)){return}var b=a[0];var c=this.componentBus.getComponentReferences("aw.QueryManager");if((c)&&(c.length>0)){c=c[0]}else{return}var g=this.componentBus.getComponentReferences("aw.GeographyManager");if((g)&&(g.length>0)){g=g[0]}else{return}if(b.jsonQuery){var f=c.buildQueryObject(b.jsonQuery);f.add(new aw.Query.Filter.Spatial({geoCollection:g.activeGeography}));c.setActiveQuery(f,b.name);this.close()}else{var e=this.componentBus.getComponentReferences("aw.UserDataManager");if((e)&&(e.length>0)){e[0].retrieveData("CalgaryListFilter",b.name,c.activeQueryDataset.key,function(h,k,j){if((j)&&(j.length>0)&&(j[0].jsonQuery)){var i=h.buildQueryObject(j[0].jsonQuery);i.add(new aw.Query.Filter.Spatial({geoCollection:k.activeGeography}));h.setActiveQuery(i,j[0].name);this.close()}}.bind(this,c,g))}}},CLASS_NAME:"DNow.SavedQueryDialog"});DNow.VariableDialog=Class.create(aw.ui.Dialog,{_variableTree:null,initialize:function(b,a){this.inheritCSS=true;this._variableTree=null;Object.extend(b,{title:"Select Variable"});aw.ui.Dialog.prototype.initialize.apply(this,arguments)},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 a=b.down("div.variableTree");if(a){var c=this.componentBus.getComponentReferences("aw.GeographyManager");if((c)&&(c.length>0)){c=c[0];this._variableTree=new aw.ui.Tree({container:a,componentBus:this.componentBus,branchSelectable:false,mode:"single",baseRequest:{cn:"SRC.Web.Client.Handler.AllocateHandler|"+c.allocateDataset.variant,service:"variableTree"}})}}}this._renderButton("OK",this._onSelectVariable.bind(this));this._renderButton("Cancel",this.close.bind(this));return this.canvas},_onSelectVariable:function(){if(!this._variableTree){return}var c=this._variableTree.getSelectedNodes();if((c)&&(c.length===1)){c=c[0];var d=this.componentBus.getComponentReferences("aw.GeographyManager");if((!d)||(!d.length>0)){return}d=d[0];var a=((c.key)&&(c.key.split(".").length>1))?c.key.split(".").last():c.key;var b={cn:"SRC.Web.Client.Handler.AllocateHandler|"+d.allocateDataset.variant,service:"getVariableInfo",varKey:a};this.request(b,function(e,f){if((!f)||(!f.payload)||(!f.payload.variables)){return}if(f.payload.variables.length===1){this.triggerEvent("onvariableselected",f.payload.variables[0]);this.close()}else{new aw.ui.Dialog.Error({title:"Error",content:"You must select exactly one variable."})}}.bind(this))}else{new aw.ui.Dialog.Error({title:"Error",content:"You must select exactly one variable."})}},_local_templates:{ui:new Template('<div class="variableTree"></div><div class="variableHelp">Select a variable from the list at the left and click OK when done.</div>')},EVENTS:["onvariableselected"],VALID_PROPERTIES:["title","closeable","content","moveable","cssClass","componentBus"],CLASS_NAME:"DNow.VariableDialog"});DNow.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,arguments);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,"Wizards: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:"DNow_Toolbar",items:[new aw.ui.Toolbar.Group({label:"Geography Selection",cssClass:"geoselection",items:[new DNow.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,"Wizards: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("DNow.Help");if((a)&&(a.length>0)){a[0].loadTopicByTitle(b);return}}new DNow.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:"DNow.WizardViewer"});
