/*
 COPYRIGHT 2009 ESRI

 TRADE SECRETS: ESRI PROPRIETARY AND CONFIDENTIAL
 Unpublished material - all rights reserved under the
 Copyright Laws of the United States and applicable international
 laws, treaties, and conventions.

 For additional information, contact:
 Environmental Systems Research Institute, Inc.
 Attn: Contracts and Legal Services Department
 380 New York Street
 Redlands, California, 92373
 USA

 email: contracts@esri.com
 */
//>>built
require({cache:{"url:dojox/form/resources/HorizontalRangeSlider.html":"<table class=\"dijit dijitReset dijitSlider dijitSliderH dojoxRangeSlider\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" rules=\"none\" dojoAttachEvent=\"onkeypress:_onKeyPress,onkeyup:_onKeyUp\" role=\"presentation\"\n\t><tr class=\"dijitReset\"\n\t\t><td class=\"dijitReset\" colspan=\"2\"></td\n\t\t><td dojoAttachPoint=\"topDecoration\" class=\"dijitReset dijitSliderDecoration dijitSliderDecorationT dijitSliderDecorationH\"></td\n\t\t><td class=\"dijitReset\" colspan=\"2\"></td\n\t></tr\n\t><tr class=\"dijitReset\"\n\t\t><td class=\"dijitReset dijitSliderButtonContainer dijitSliderButtonContainerH\"\n\t\t\t><div class=\"dijitSliderDecrementIconH\" tabIndex=\"-1\" style=\"display:none\" dojoAttachPoint=\"decrementButton\"><span class=\"dijitSliderButtonInner\">-</span></div\n\t\t></td\n\t\t><td class=\"dijitReset\"\n\t\t\t><div class=\"dijitSliderBar dijitSliderBumper dijitSliderBumperH dijitSliderLeftBumper\" dojoAttachEvent=\"onmousedown:_onClkDecBumper\"></div\n\t\t></td\n\t\t><td class=\"dijitReset\"\n\t\t\t><input dojoAttachPoint=\"valueNode\" type=\"hidden\" ${!nameAttrSetting}\n\t\t\t/><div role=\"presentation\" class=\"dojoxRangeSliderBarContainer\" dojoAttachPoint=\"sliderBarContainer\"\n\t\t\t\t><div dojoAttachPoint=\"sliderHandle\" tabIndex=\"${tabIndex}\" class=\"dijitSliderMoveable dijitSliderMoveableH\" dojoAttachEvent=\"onmousedown:_onHandleClick\" role=\"slider\"\n\t\t\t\t\t><div class=\"dijitSliderImageHandle dijitSliderImageHandleH\"></div\n\t\t\t\t></div\n\t\t\t\t><div role=\"presentation\" dojoAttachPoint=\"progressBar,focusNode\" class=\"dijitSliderBar dijitSliderBarH dijitSliderProgressBar dijitSliderProgressBarH\" dojoAttachEvent=\"onmousedown:_onBarClick\"></div\n\t\t\t\t><div dojoAttachPoint=\"sliderHandleMax\" tabIndex=\"${tabIndex}\" class=\"dijitSliderMoveable dijitSliderMoveableH\" dojoAttachEvent=\"onmousedown:_onHandleClickMax\" role=\"slider\"\n\t\t\t\t\t><div class=\"dijitSliderImageHandle dijitSliderImageHandleH\"></div\n\t\t\t\t></div\n\t\t\t\t><div role=\"presentation\" dojoAttachPoint=\"remainingBar\" class=\"dijitSliderBar dijitSliderBarH dijitSliderRemainingBar dijitSliderRemainingBarH\" dojoAttachEvent=\"onmousedown:_onRemainingBarClick\"></div\n\t\t\t></div\n\t\t></td\n\t\t><td class=\"dijitReset\"\n\t\t\t><div class=\"dijitSliderBar dijitSliderBumper dijitSliderBumperH dijitSliderRightBumper\" dojoAttachEvent=\"onmousedown:_onClkIncBumper\"></div\n\t\t></td\n\t\t><td class=\"dijitReset dijitSliderButtonContainer dijitSliderButtonContainerH\"\n\t\t\t><div class=\"dijitSliderIncrementIconH\" tabIndex=\"-1\" style=\"display:none\" dojoAttachPoint=\"incrementButton\"><span class=\"dijitSliderButtonInner\">+</span></div\n\t\t></td\n\t></tr\n\t><tr class=\"dijitReset\"\n\t\t><td class=\"dijitReset\" colspan=\"2\"></td\n\t\t><td dojoAttachPoint=\"containerNode,bottomDecoration\" class=\"dijitReset dijitSliderDecoration dijitSliderDecorationB dijitSliderDecorationH\"></td\n\t\t><td class=\"dijitReset\" colspan=\"2\"></td\n\t></tr\n></table>\n","url:esri/dijit/templates/HistogramTimeSlider.html":"<div id=\"histogram-timeslider\" class=\"histogram-timeslider esriTimeSlider\">\r\n <div id=\"histogram-timeslider-dijit\">\r\n   <div id=\"focusTip\"></div>\r\n   <div id=\"scale-bar-left\"></div>\r\n   <div id=\"scale-bar-right\"></div>\r\n   <div id=\"histogram-container\"></div>\r\n   <div id=\"histogram-slider\"></div>\r\n   <div id=\"histogram-controls\">\r\n     <div id=\"histogram-range\"></div>\r\n   </div>\r\n  </div>\r\n</div>"}});define("esri/dijit/HistogramTimeSlider",["dojo/_base/declare","dojo/_base/lang","dojo/_base/connect","dojo/has","dojo/dom","dojo/_base/array","dojo/dom-style","dojox/gfx","dijit/_WidgetBase","dijit/_TemplatedMixin","dojox/form/RangeSlider","dijit/form/HorizontalSlider","esri/kernel","esri/lang","esri/TimeExtent","dojo/text!dojox/form/resources/HorizontalRangeSlider.html","dojo/text!esri/dijit/templates/HistogramTimeSlider.html"],function(_1,_2,_3,_4,_5,_6,_7,_8,_9,_a,_b,_c,_d,_e,_f,_10,_11){var _12=_1([_9,_a],{declaredClass:"esri.dijit.HistogramTimeSlider",widgetsInTemplate:false,templateString:_11,constructor:function(_13,_14){var _15=this;this.layers=_13.layers;this.element=_14;this.bins=[];this.fullTimeExtent=[];this._mode=_13.mode||"show_partial";this._resolution="esriTimeUnitsSeconds";this._timeInterval=_13.timeInterval;this._numeric_res=3600000;this._max_bins=1000;this._prev_num_bins=0;this._max_bin_height=0;this._color=_13.color||"rgb(5, 112, 176)";this._active=false;this.is_streaming=false;this.load_count=0;this.dateFormat=_13.dateFormat||"DateString";this._dateTemplate="${date: "+this.dateFormat+"}";this._wire();this._resolutions={"esriTimeUnitsSeconds":[0],"esriTimeUnitsMinutes":[0],"esriTimeUnitsHours":[0],"esriTimeUnitsDays":[0],"esriTimeUnitsMonths":[0],"esriTimeUnitsYears":[0]};this._num_resolutions={"esriTimeUnitsSeconds":1000,"esriTimeUnitsMinutes":60000,"esriTimeUnitsHours":3600000,"esriTimeUnitsDays":86400000,"esriTimeUnitsMonths":2592000000,"esriTimeUnitsYears":31536000000};_6.forEach(this.layers,function(_16,i){var _17=_3.connect(_16,"onUpdateEnd",function(){_3.disconnect(_17);var i,li;_15.fullTimeExtent=_15.getFullTimeExtent();if(_16.declaredClass.match(/StreamLayer/g)){_15._bindStreamingEvents(_16);}if(_16.graphics){_15.updateLength=_16.graphics.length;for(i=0,li=_16.graphics.length;i<li;i++){var _18=_16.graphics[i].attributes[_16.timeInfo.startTimeField];_15._add(_18);}}});});},getFullTimeExtent:function(){var min=null;var max=null;var i,li;for(i=0,li=this.layers.length;i<li;i++){if(this.layers[i].timeInfo.timeExtent.startTime){var _19=this.layers[i].timeInfo.timeExtent.startTime.getTime();var end=this.layers[i].timeInfo.timeExtent.endTime.getTime();if(!min){min=_19;max=end;}else{if(min>_19){min=_19;}else{if(max<end){max=end;}}}}}return [min,max];},getCurrentTimeExtent:function(){},_wire:function(){var _1a=this;_3.connect(window,"onmouseup, blur",function(){if(_1a._active&&(_1a.bins.length!==_1a._prev_num_bins)){_1a._active=false;_1a._prev_num_bins=_1a.bins.length;_1a._drawHistogram();_1a._updateSlider();}});_3.connect(window,"resize",function(){_1a._prev_num_bins=_1a.bins.length;_1a._drawHistogram();_1a._updateSlider();});},_bindStreamingEvents:function(_1b){var _1c=this;_3.connect(_1b,"onMessage",function(m){_1c.is_streaming=true;var _1d=m.graphic.attributes[this.timeInfo.startTimeField];_1c._add(_1d);});_3.connect(_1b,"onRemove",function(m){_1c.is_streaming=true;var _1e=m.graphic.attributes[this.timeInfo.startTimeField];if(_1c._mode==="show_partial"){_1c._remove(_1e);}});},_nextRes:function(){var res;for(res in this._resolutions){if(this._resolutions[res].length<=this._max_bins){return res;}}},_updateAllResolutions:function(_1f,_20){var _21=(this._num_resolutions[this._timeInterval]/1000);var min=Math.floor((_1f*_21)/60),_22=Math.floor((_1f*_21)/(60*60)),day=Math.floor((_1f*_21)/(60*60*24)),_23=Math.floor((_1f*_21)/(60*60*24*30)),_24=Math.floor((_1f*_21)/(60*60*24*365));if(this._timeInterval!=="esriTimeUnitsHours"){var _25=(min-this._resolutions.esriTimeUnitsMinutes.length);var i,j;if(_25>=1){for(i=0;i<_25;i++){this._resolutions.esriTimeUnitsMinutes.push(0);}}if(!this._resolutions.esriTimeUnitsMinutes[min]){this._resolutions.esriTimeUnitsMinutes[min]=0;}!_20?this._resolutions.esriTimeUnitsMinutes[min]++:this._resolutions.esriTimeUnitsMinutes[min]--;}var _26=(_22-this._resolutions.esriTimeUnitsHours.length);if(_26>=1){for(j=0;j<_26;j++){this._resolutions.esriTimeUnitsHours.push(0);}}if(!this._resolutions.esriTimeUnitsHours[_22]){this._resolutions.esriTimeUnitsHours[_22]=0;}!_20?this._resolutions.esriTimeUnitsHours[_22]++:this._resolutions.esriTimeUnitsHours[_22]--;var _27=(day-this._resolutions.esriTimeUnitsDays.length);if(_27>=1){for(j=0;j<_27;j++){this._resolutions.esriTimeUnitsDays.push(0);}}if(!this._resolutions.esriTimeUnitsDays[day]){this._resolutions.esriTimeUnitsDays[day]=0;}!_20?this._resolutions.esriTimeUnitsDays[day]++:this._resolutions.esriTimeUnitsDays[day]--;var _28=(_23-this._resolutions.esriTimeUnitsMonths.length);if(_28>=1){for(j=0;j<_28;j++){this._resolutions.esriTimeUnitsMonths.push(0);}}if(!this._resolutions.esriTimeUnitsMonths[_23]){this._resolutions.esriTimeUnitsMonths[_23]=0;}!_20?this._resolutions.esriTimeUnitsMonths[_23]++:this._resolutions.esriTimeUnitsMonths[_23]--;var _29=(_24-this._resolutions.esriTimeUnitsYears.length);if(_29>=1){for(j=0;j<_29;j++){this._resolutions.esriTimeUnitsYears.push(0);}}if(!this._resolutions.esriTimeUnitsYears[_24]){this._resolutions.esriTimeUnitsYears[_24]=0;}!_20?this._resolutions.esriTimeUnitsYears[_24]++:this._resolutions.esriTimeUnitsYears[_24]--;if(!this._timeInterval){if(this._resolutions[this._resolution].length>=this._max_bins){this._resolution=this._nextRes();}}var _2a;switch(this._resolution){case "esriTimeUnitsSeconds":_2a=_1f;this._numeric_res=1000;break;case "esriTimeUnitsMinutes":_2a=min;this._numeric_res=60000;break;case "esriTimeUnitsHours":_2a=_22;this._numeric_res=3600000;break;case "esriTimeUnitsDays":_2a=day;this._numeric_res=86400000;break;case "esriTimeUnitsMonths":_2a=_23;this._numeric_res=2592000000;break;case "esriTimeUnitsYears":_2a=_24;this._numeric_res=31536000000;break;}this._setBins(_2a);},_setBins:function(_2b){var res=this._timeInterval||this._resolution;this.bins=this._resolutions[res];var _2c=0;var i=0;while(this.bins[i]===0){_2c=i+1;i=i+1;}if(this._active){if(_2c!==this.minVisibleIndex){this.minVisibleIndex=_2c;}return;}else{if(!this.is_steaming&&this.updateLength===this.load_count){if((this.bins.length!==this._prev_num_bins)||(_2c!==this.minVisibleIndex)){this.minVisibleIndex=_2c;this._prev_num_bins=this.bins.length;this._drawHistogram();if(this._slider){this._updateSlider();}}else{this._updateHeights(_2b);}}}},_updateFullTimeExtent:function(_2d){if(!this.fullTimeExtent[0]){this.fullTimeExtent[0]=_2d;}if(!this.fullTimeExtent[1]){this.fullTimeExtent[1]=_2d;}if(_2d<this.fullTimeExtent[0]){this.fullTimeExtent[0]=_2d;}if(_2d>this.fullTimeExtent[1]){this.fullTimeExtent[1]=_2d;}},_getBin:function(_2e){var res=this._timeInterval||this._resolution;var _2f=Math.floor((_2e-this.fullTimeExtent[0])/this._num_resolutions[res]);return _2f;},_add:function(_30){var res=this._timeInterval||this._resolution;if(!this.is_steaming){this.load_count++;}this._updateFullTimeExtent(_30);var _31=this._getBin(_30);var _32=(_31-this._resolutions[res].length);var i;if(_32>=1){for(i=0;i<_32;i++){this._resolutions[res].push(0);}}if(!this._resolutions[res][_31]){this._resolutions[res][_31]=1;}else{this._resolutions[res][_31]++;}this._updateAllResolutions(_31);if(!this._slider){this._createSlider();}},_remove:function(_33){var _34=this._getBin(_33);this._resolutions.esriTimeUnitsSeconds[_34]--;this._updateAllResolutions(_34,true);if(!this._active){this._updateSlider();}},_createSlider:function(){var _35=this;var _36=_1([_c,_b],{templateString:_10});this._slider=new _36({name:"histogram-slider",values:[0,100],minimum:0,maximum:100,showButtons:false,intermediateChanges:true,discreteValues:2,style:"width:100%",onChange:function(_37){var min=Math.floor(_37[0]);var max=Math.floor(_37[1]);_35._getUserExtents(min,max);_35._disableBins(min,max);}},"histogram-slider");},_updateSlider:function(){this._slider.discreteValues=this.histogram.length+1;this._slider.maximum=this.histogram.length;this._slider._setValueAttr([0,this.histogram.length],false,false);},_getUserExtents:function(min,max){var res=this._timeInterval||this._resolution;var _38=new _f();_38.startTime=new Date(this.fullTimeExtent[0]+((min+this.minVisibleIndex)*this._num_resolutions[res]));_38.endTime=new Date(this.fullTimeExtent[0]+((max+this.minVisibleIndex)*this._num_resolutions[res]));this._updateDateRange(_38);this.onTimeExtentChange(_38);},_drawHistogram:function(){var _39=this,_3a=[];if(this.histogramSurface){this.histogramSurface.clear();}else{this.histogramSurface=_8.createSurface("histogram-container",_5.byId(this.element.id).offsetWidth,100);}var max=Math.max.apply(Math,this.bins),_3b=(this.histogramSurface._parent.clientWidth/(this.bins.length-this.minVisibleIndex)),gap=_3b/10,x=0;this.histogram=[];var i,li;for(i=this.minVisibleIndex,li=this.bins.length;i<li;i++){var _3c=(this.bins[i]/max)*100;var y=(100-_3c);var bar=this.histogramSurface.createRect({x:x,y:y,width:_3b-gap,height:_3c}).setFill(this._color);this.histogram.push(bar);x=x+_3b;_3a.push(x);bar.bin=this.bins[i];bar.x=x-_3b;bar.num=i;bar.max=max;bar.connect("onmouseenter",bar,function(){_39._showTipForBin(this.bin,this.num,this.x);});bar.connect("onmouseleave",bar,function(){_39._hideTipForBin();});}this._updateTimeTicks(_3a);this._updateScaleBar(max);this.onUpdate();},_updateHeights:function(_3d){var max=Math.max.apply(Math,this.bins);var _3e;var y;var i,li;if(max!==this._max_bin_height){for(i=this.minVisibleIndex,li=this.histogram.length;i<li;i++){_3e=(this.bins[i]/max)*100;y=100-_3e;this.histogram[i].setShape({y:y,height:_3e});}}else{_3e=(this.bins[_3d]/max)*100;y=100-_3e;this.histogram[_3d-this.minVisibleIndex].setShape({y:y,height:_3e});}this._updateScaleBar(max);this._max_bin_height=max;},_updateTimeTicks:function(_3f){var res=this._timeInterval||this._resolution,_40=Math.floor(this.histogram.length/3),_41,_42,i;for(i=0;i<2;i++){this.histogramSurface.createLine({x1:_3f[_40],y1:0,x2:_3f[_40],y2:this.histogramSurface._parent.clientHeight}).setStroke("rgb(200, 200, 200)");_41=new Date(this.fullTimeExtent[0]+(((_40+1)-this.minVisibleIndex)*this._num_resolutions[res]));_42=_e.substitute({date:_41.getTime()},this._dateTemplate);this.histogramSurface.createText({x:_3f[_40]+2,y:10,text:_42}).setFont({size:"12px"}).setFill("rgb(82, 95, 109)");_40=_40+_40;}},_updateDateRange:function(_43){var _44=_e.substitute({date:new Date(_43.startTime).getTime()},this._dateTemplate);var end=_e.substitute({date:new Date(_43.endTime).getTime()},this._dateTemplate);_5.byId("histogram-range").innerHTML="Date Range: "+_44+" - "+end;},_disableBins:function(min,max){var _45=this;if(min===0&&max===this.histogram.length){this.histogram[0].setFill(this._color);this.histogram[this.histogram.length-1].setFill(this._color);return;}_6.forEach(this.histogram,function(bar,i){if(i<min){bar.setFill("rgb(216,216,216)");}else{if(i>=max){bar.setFill("rgb(216,216,216)");}else{bar.setFill(_45._color);}}});},_updateScaleBar:function(max){if(this.scaleLeft){this.scaleLeft.clear();this.scaleRight.clear();}else{this.scaleRight=_8.createSurface("scale-bar-right",45,110);this.scaleLeft=_8.createSurface("scale-bar-left",45,110);}var _46,_47,_48;_46=(max>99)?_47=10:20;_48=((max/2)>99)?_48=10:20;this.scaleLeft.createLine({x1:40,y1:5,x2:40,y2:130}).setStroke("rgb(82, 95, 109)");this.scaleLeft.createLine({x1:40,y1:5,x2:37,y2:5}).setStroke("rgb(82, 95, 109)");this.scaleLeft.createLine({x1:40,y1:60,x2:37,y2:60}).setStroke("rgb(82, 95, 109)");this.scaleLeft.createText({x:_46,y:10,text:max}).setFont({size:"14px"}).setFill("rgb(82, 95, 109)");this.scaleLeft.createText({x:_48,y:65,text:(Math.floor(max/2))}).setFont({size:"14px"}).setFill("rgb(82, 95, 109)");this.scaleRight.createLine({x1:0,y1:5,x2:0,y2:130}).setStroke("rgb(82, 95, 109)");this.scaleRight.createLine({x1:0,y1:5,x2:3,y2:5}).setStroke("rgb(82, 95, 109)");this.scaleRight.createLine({x1:0,y1:60,x2:3,y2:60}).setStroke("rgb(82, 95, 109)");this.scaleRight.createText({x:4,y:10,text:max}).setFont({size:"14px"}).setFill("rgb(82, 95, 109)");this.scaleRight.createText({x:4,y:65,text:(Math.floor(max/2))}).setFont({size:"14px"}).setFill("rgb(82, 95, 109)");},_showTipForBin:function(bin,cnt,x){var res=this._timeInterval||this._resolution;if(this._active){return;}var _49=new Date(this.fullTimeExtent[0]+((cnt-this.minVisibleIndex)*this._num_resolutions[res]));_49=_e.substitute({date:_49.getTime()},this._dateTemplate);var _4a=new Date(this.fullTimeExtent[0]+(((cnt+1)-this.minVisibleIndex)*this._num_resolutions[res]));_4a=_e.substitute({date:_4a.getTime()},this._dateTemplate);_5.byId("focusTip").innerHTML=("<span style='font-size:8pt'>"+_49+" to "+_4a+"</span> <br /> Count: "+bin);_7.set("focusTip",{"display":"block","left":x+"px","top":"-10px"});},_hideTipForBin:function(){_5.byId("focusTip").style.display="none";},onTimeExtentChange:function(){},onUpdate:function(){}});if(_4("extend-esri")){_2.setObject("dijit.HistogramTimeSlider",_12,_d);}return _12;});