/*
	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.data.SnapLogicStore"],["require","dojo.io.script"],["require","dojo.data.util.sorter"]],defineResource:function(_4,_5,_6){if(!_4._hasResource["dojox.data.SnapLogicStore"]){_4._hasResource["dojox.data.SnapLogicStore"]=true;_4.provide("dojox.data.SnapLogicStore");_4.require("dojo.io.script");_4.require("dojo.data.util.sorter");_4.declare("dojox.data.SnapLogicStore",null,{Parts:{DATA:"data",COUNT:"count"},url:"",constructor:function(_7){if(_7.url){this.url=_7.url;}this._parameters=_7.parameters;},_assertIsItem:function(_8){if(!this.isItem(_8)){throw new Error("dojox.data.SnapLogicStore: a function was passed an item argument that was not an item");}},_assertIsAttribute:function(_9){if(typeof _9!=="string"){throw new Error("dojox.data.SnapLogicStore: a function was passed an attribute argument that was not an attribute name string");}},getFeatures:function(){return {"dojo.data.api.Read":true};},getValue:function(_a,_b,_c){this._assertIsItem(_a);this._assertIsAttribute(_b);var i=_4.indexOf(_a.attributes,_b);if(i!==-1){return _a.values[i];}return _c;},getAttributes:function(_d){this._assertIsItem(_d);return _d.attributes;},hasAttribute:function(_e,_f){this._assertIsItem(_e);this._assertIsAttribute(_f);for(var i=0;i<_e.attributes.length;++i){if(_f==_e.attributes[i]){return true;}}return false;},isItemLoaded:function(_10){return this.isItem(_10);},loadItem:function(_11){},getLabel:function(_12){return undefined;},getLabelAttributes:function(_13){return null;},containsValue:function(_14,_15,_16){return this.getValue(_14,_15)===_16;},getValues:function(_17,_18){this._assertIsItem(_17);this._assertIsAttribute(_18);var i=_4.indexOf(_17.attributes,_18);if(i!==-1){return [_17.values[i]];}return [];},isItem:function(_19){if(_19&&_19._store===this){return true;}return false;},close:function(_1a){},_fetchHandler:function(_1b){var _1c=_1b.scope||_4.global;if(_1b.onBegin){_1b.onBegin.call(_1c,_1b._countResponse[0],_1b);}if(_1b.onItem||_1b.onComplete){var _1d=_1b._dataResponse;if(!_1d.length){_1b.onError.call(_1c,new Error("dojox.data.SnapLogicStore: invalid response of length 0"),_1b);return;}else{if(_1b.query!="record count"){var _1e=_1d.shift();var _1f=[];for(var i=0;i<_1d.length;++i){if(_1b._aborted){break;}_1f.push({attributes:_1e,values:_1d[i],_store:this});}if(_1b.sort&&!_1b._aborted){_1f.sort(_4.data.util.sorter.createSortFunction(_1b.sort,self));}}else{_1f=[({attributes:["count"],values:_1d,_store:this})];}}if(_1b.onItem){for(var i=0;i<_1f.length;++i){if(_1b._aborted){break;}_1b.onItem.call(_1c,_1f[i],_1b);}_1f=null;}if(_1b.onComplete&&!_1b._aborted){_1b.onComplete.call(_1c,_1f,_1b);}}},_partHandler:function(_20,_21,_22){if(_22 instanceof Error){if(_21==this.Parts.DATA){_20._dataHandle=null;}else{_20._countHandle=null;}_20._aborted=true;if(_20.onError){_20.onError.call(_20.scope,_22,_20);}}else{if(_20._aborted){return;}if(_21==this.Parts.DATA){_20._dataResponse=_22;}else{_20._countResponse=_22;}if((!_20._dataHandle||_20._dataResponse!==null)&&(!_20._countHandle||_20._countResponse!==null)){this._fetchHandler(_20);}}},fetch:function(_23){_23._countResponse=null;_23._dataResponse=null;_23._aborted=false;_23.abort=function(){if(!_23._aborted){_23._aborted=true;if(_23._dataHandle&&_23._dataHandle.cancel){_23._dataHandle.cancel();}if(_23._countHandle&&_23._countHandle.cancel){_23._countHandle.cancel();}}};if(_23.onItem||_23.onComplete){var _24=this._parameters||{};if(_23.start){if(_23.start<0){throw new Error("dojox.data.SnapLogicStore: request start value must be 0 or greater");}_24["sn.start"]=_23.start+1;}if(_23.count){if(_23.count<0){throw new Error("dojox.data.SnapLogicStore: request count value 0 or greater");}_24["sn.limit"]=_23.count;}_24["sn.content_type"]="application/javascript";var _25=this;var _26=function(_27,_28){if(_27 instanceof Error){_25._fetchHandler(_27,_23);}};var _29={url:this.url,content:_24,timeout:60000,callbackParamName:"sn.stream_header",handle:_4.hitch(this,"_partHandler",_23,this.Parts.DATA)};_23._dataHandle=_4.io.script.get(_29);}if(_23.onBegin){var _24={};_24["sn.count"]="records";_24["sn.content_type"]="application/javascript";var _29={url:this.url,content:_24,timeout:60000,callbackParamName:"sn.stream_header",handle:_4.hitch(this,"_partHandler",_23,this.Parts.COUNT)};_23._countHandle=_4.io.script.get(_29);}return _23;}});}}};});