/*
	Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
	Available via Academic Free License >= 2.1 OR the modified BSD license.
	see: http://dojotoolkit.org/license for details
*/


window[esri._dojoScopeName||"dojo"]._xdResourceLoaded(function(_1,_2,_3){return {depends:[["provide","dojox.grid.Selection"]],defineResource:function(_4,_5,_6){if(!_4._hasResource["dojox.grid.Selection"]){_4._hasResource["dojox.grid.Selection"]=true;_4.provide("dojox.grid.Selection");_4.declare("dojox.grid.Selection",null,{constructor:function(_7){this.grid=_7;this.selected=[];this.setMode(_7.selectionMode);},mode:"extended",selected:null,updating:0,selectedIndex:-1,setMode:function(_8){if(this.selected.length){this.deselectAll();}if(_8!="extended"&&_8!="multiple"&&_8!="single"&&_8!="none"){this.mode="extended";}else{this.mode=_8;}},onCanSelect:function(_9){return this.grid.onCanSelect(_9);},onCanDeselect:function(_a){return this.grid.onCanDeselect(_a);},onSelected:function(_b){},onDeselected:function(_c){},onChanging:function(){},onChanged:function(){},isSelected:function(_d){if(this.mode=="none"){return false;}return this.selected[_d];},getFirstSelected:function(){if(!this.selected.length||this.mode=="none"){return -1;}for(var i=0,l=this.selected.length;i<l;i++){if(this.selected[i]){return i;}}return -1;},getNextSelected:function(_e){if(this.mode=="none"){return -1;}for(var i=_e+1,l=this.selected.length;i<l;i++){if(this.selected[i]){return i;}}return -1;},getSelected:function(){var _f=[];for(var i=0,l=this.selected.length;i<l;i++){if(this.selected[i]){_f.push(i);}}return _f;},getSelectedCount:function(){var c=0;for(var i=0;i<this.selected.length;i++){if(this.selected[i]){c++;}}return c;},_beginUpdate:function(){if(this.updating===0){this.onChanging();}this.updating++;},_endUpdate:function(){this.updating--;if(this.updating===0){this.onChanged();}},select:function(_10){if(this.mode=="none"){return;}if(this.mode!="multiple"){this.deselectAll(_10);this.addToSelection(_10);}else{this.toggleSelect(_10);}},addToSelection:function(_11){if(this.mode=="none"){return;}if(_4.isArray(_11)){_4.forEach(_11,this.addToSelection,this);return;}_11=Number(_11);if(this.selected[_11]){this.selectedIndex=_11;}else{if(this.onCanSelect(_11)!==false){this.selectedIndex=_11;var _12=this.grid.getRowNode(_11);if(_12){_4.attr(_12,"aria-selected","true");}this._beginUpdate();this.selected[_11]=true;this.onSelected(_11);this._endUpdate();}}},deselect:function(_13){if(this.mode=="none"){return;}if(_4.isArray(_13)){_4.forEach(_13,this.deselect,this);return;}_13=Number(_13);if(this.selectedIndex==_13){this.selectedIndex=-1;}if(this.selected[_13]){if(this.onCanDeselect(_13)===false){return;}var _14=this.grid.getRowNode(_13);if(_14){_4.attr(_14,"aria-selected","false");}this._beginUpdate();delete this.selected[_13];this.onDeselected(_13);this._endUpdate();}},setSelected:function(_15,_16){this[(_16?"addToSelection":"deselect")](_15);},toggleSelect:function(_17){if(_4.isArray(_17)){_4.forEach(_17,this.toggleSelect,this);return;}this.setSelected(_17,!this.selected[_17]);},_range:function(_18,_19,_1a){var s=(_18>=0?_18:_19),e=_19;if(s>e){e=s;s=_19;}for(var i=s;i<=e;i++){_1a(i);}},selectRange:function(_1b,_1c){this._range(_1b,_1c,_4.hitch(this,"addToSelection"));},deselectRange:function(_1d,_1e){this._range(_1d,_1e,_4.hitch(this,"deselect"));},insert:function(_1f){this.selected.splice(_1f,0,false);if(this.selectedIndex>=_1f){this.selectedIndex++;}},remove:function(_20){this.selected.splice(_20,1);if(this.selectedIndex>=_20){this.selectedIndex--;}},deselectAll:function(_21){for(var i in this.selected){if((i!=_21)&&(this.selected[i]===true)){this.deselect(i);}}},clickSelect:function(_22,_23,_24){if(this.mode=="none"){return;}this._beginUpdate();if(this.mode!="extended"){this.select(_22);}else{var _25=this.selectedIndex;if(!_23){this.deselectAll(_22);}if(_24){this.selectRange(_25,_22);}else{if(_23){this.toggleSelect(_22);}else{this.addToSelection(_22);}}}this._endUpdate();},clickSelectEvent:function(e){this.clickSelect(e.rowIndex,_4.isCopyKey(e),e.shiftKey);},clear:function(){this._beginUpdate();this.deselectAll();this._endUpdate();}});}}};});