/*
	Copyright (c) 2004-2009, 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
*/

/*
	This is a compiled version of Dojo, built for deployment and not for
	development. To get an editable version, please visit:

		http://dojotoolkit.org

	for documentation and information on getting the source.
*/

if(!dojo._hasResource["dojox.json.query"]){dojo._hasResource["dojox.json.query"]=true;dojo.provide("dojox.json.query");(function(){function _1(_2,_3,_4,_5){var _6=_2.length,_7=[];_4=_4||_6;_3=(_3<0)?Math.max(0,_3+_6):Math.min(_6,_3);_4=(_4<0)?Math.max(0,_4+_6):Math.min(_6,_4);for(var i=_3;i<_4;i+=_5){_7.push(_2[i]);}return _7;};function _8(_9,_a){var _b=[];function _c(_d){if(_a){if(_a===true&&!(_d instanceof Array)){_b.push(_d);}else{if(_d[_a]){_b.push(_d[_a]);}}}for(var i in _d){var _e=_d[i];if(!_a){_b.push(_e);}else{if(_e&&typeof _e=="object"){_c(_e);}}}};if(_a instanceof Array){if(_a.length==1){return _9[_a[0]];}for(var i=0;i<_a.length;i++){_b.push(_9[_a[i]]);}}else{_c(_9);}return _b;};function _f(_10,_11){var _12=[];var _13={};for(var i=0,l=_10.length;i<l;++i){var _14=_10[i];if(_11(_14,i,_10)){if((typeof _14=="object")&&_14){if(!_14.__included){_14.__included=true;_12.push(_14);}}else{if(!_13[_14+typeof _14]){_13[_14+typeof _14]=true;_12.push(_14);}}}}for(i=0,l=_12.length;i<l;++i){if(_12[i]){delete _12[i].__included;}}return _12;};dojox.json.query=function(_15,obj){var _16=0;var str=[];_15=_15.replace(/"(\\.|[^"\\])*"|'(\\.|[^'\\])*'|[\[\]]/g,function(t){_16+=t=="["?1:t=="]"?-1:0;return (t=="]"&&_16>0)?"`]":(t.charAt(0)=="\""||t.charAt(0)=="'")?"`"+(str.push(t)-1):t;});var _17="";function _18(_19){_17=_19+"("+_17;};function _1a(t,a,b,c,d,e,f,g){return str[g].match(/[\*\?]/)||f=="~"?"/^"+str[g].substring(1,str[g].length-1).replace(/\\([btnfr\\"'])|([^\w\*\?])/g,"\\$1$2").replace(/([\*\?])/g,"[\\w\\W]$1")+(f=="~"?"$/i":"$/")+".test("+a+")":t;};_15.replace(/(\]|\)|push|pop|shift|splice|sort|reverse)\s*\(/,function(){throw new Error("Unsafe function call");});_15=_15.replace(/([^=]=)([^=])/g,"$1=$2").replace(/@|(\.\s*)?[a-zA-Z\$_]+(\s*:)?/g,function(t){return t.charAt(0)=="."?t:t=="@"?"$obj":(t.match(/:|^(\$|Math|true|false|null)$/)?"":"$obj.")+t;}).replace(/\.?\.?\[(`\]|[^\]])*\]|\?.*|\.\.([\w\$_]+)|\.\*/g,function(t,a,b){var _1b=t.match(/^\.?\.?(\[\s*\^?\?|\^?\?|\[\s*==)(.*?)\]?$/);if(_1b){var _1c="";if(t.match(/^\./)){_18("expand");_1c=",true)";}_18(_1b[1].match(/\=/)?"dojo.map":_1b[1].match(/\^/)?"distinctFilter":"dojo.filter");return _1c+",function($obj){return "+_1b[2]+"})";}_1b=t.match(/^\[\s*([\/\\].*)\]/);if(_1b){return ".concat().sort(function(a,b){"+_1b[1].replace(/\s*,?\s*([\/\\])\s*([^,\\\/]+)/g,function(t,a,b){return "var av= "+b.replace(/\$obj/,"a")+",bv= "+b.replace(/\$obj/,"b")+";if(av>bv||bv==null){return "+(a=="/"?1:-1)+";}\n"+"if(bv>av||av==null){return "+(a=="/"?-1:1)+";}\n";})+"return 0;})";}_1b=t.match(/^\[(-?[0-9]*):(-?[0-9]*):?(-?[0-9]*)\]/);if(_1b){_18("slice");return ","+(_1b[1]||0)+","+(_1b[2]||0)+","+(_1b[3]||1)+")";}if(t.match(/^\.\.|\.\*|\[\s*\*\s*\]|,/)){_18("expand");return (t.charAt(1)=="."?",'"+b+"'":t.match(/,/)?","+t:"")+")";}return t;}).replace(/(\$obj\s*((\.\s*[\w_$]+\s*)|(\[\s*`([0-9]+)\s*`\]))*)(==|~)\s*`([0-9]+)/g,_1a).replace(/`([0-9]+)\s*(==|~)\s*(\$obj\s*((\.\s*[\w_$]+)|(\[\s*`([0-9]+)\s*`\]))*)/g,function(t,a,b,c,d,e,f,g){return _1a(t,c,d,e,f,g,b,a);});_15=_17+(_15.charAt(0)=="$"?"":"$")+_15.replace(/`([0-9]+|\])/g,function(t,a){return a=="]"?"]":str[a];});var _1d=eval("1&&function($,$1,$2,$3,$4,$5,$6,$7,$8,$9){var $obj=$;return "+_15+"}");for(var i=0;i<arguments.length-1;i++){arguments[i]=arguments[i+1];}return obj?_1d.apply(this,arguments):_1d;};})();}if(!dojo._hasResource["dojo.data.util.filter"]){dojo._hasResource["dojo.data.util.filter"]=true;dojo.provide("dojo.data.util.filter");dojo.data.util.filter.patternToRegExp=function(_1e,_1f){var rxp="^";var c=null;for(var i=0;i<_1e.length;i++){c=_1e.charAt(i);switch(c){case "\\":rxp+=c;i++;rxp+=_1e.charAt(i);break;case "*":rxp+=".*";break;case "?":rxp+=".";break;case "$":case "^":case "/":case "+":case ".":case "|":case "(":case ")":case "{":case "}":case "[":case "]":rxp+="\\";default:rxp+=c;}}rxp+="$";if(_1f){return new RegExp(rxp,"mi");}else{return new RegExp(rxp,"m");}};}if(!dojo._hasResource["dojox.data.ClientFilter"]){dojo._hasResource["dojox.data.ClientFilter"]=true;dojo.provide("dojox.data.ClientFilter");(function(){var cf;var _20=function(_21,_22,_23){return function(_24){_21._updates.push({create:_22&&_24,remove:_23&&_24});cf.onUpdate();};};cf=dojo.declare("dojox.data.ClientFilter",null,{constructor:function(){this.onSet=_20(this,true,true);this.onNew=_20(this,true,false);this.onDelete=_20(this,false,true);this._updates=[];this._fetchCache=[];},clearCache:function(){this._fetchCache=[];},updateResultSet:function(_25,_26){if(this.isUpdateable(_26)){for(var i=_26._version||0;i<this._updates.length;i++){var _27=this._updates[i].create;var _28=this._updates[i].remove;if(_28){for(var j=0;j<_25.length;j++){if(_25[j]==_28){_25.splice(j--,1);var _29=true;}}}if(_27&&this.matchesQuery(_27,_26)&&dojo.indexOf(_25,_27)==-1){_25.push(_27);_29=true;}}if(_26.sort&&_29){_25.sort(this.makeComparator(_26.sort.concat()));}if(_26.count&&_29){_25.splice(_26.count,_25.length);}_26._version=this._updates.length;return _29?2:1;}return 0;},querySuperSet:function(_2a,_2b){if(_2a.query==_2b.query){return {};}if(!(_2b.query instanceof Object&&(!_2a.query||typeof _2a.query=="object"))){return false;}var _2c=dojo.mixin({},_2b.query);for(var i in _2a.query){if(_2c[i]==_2a.query[i]){delete _2c[i];}else{if(!(typeof _2a.query[i]=="string"&&dojo.data.util.filter.patternToRegExp(_2a.query[i]).test(_2c[i]))){return false;}}}return _2c;},serverVersion:0,cachingFetch:function(_2d){var _2e=this;for(var i=0;i<this._fetchCache.length;i++){var _2f=this._fetchCache[i];var _30=this.querySuperSet(_2f,_2d);if(_30!==false){var _31=_2f._loading;if(!_31){_31=new dojo.Deferred();_31.callback(_2f.cacheResults);}_31.addCallback(function(_32){_32=_2e.clientSideFetch({query:_30,sort:_2d.sort,start:_2d.start,count:_2d.count},_32);_31.fullLength=_32._fullLength;return _32;});}}if(!_31){var _33=dojo.mixin({},_2d);var _34=(_2d.queryOptions||0).cache;if(_34===undefined?this.cacheByDefault:_34){if(_2d.start||_2d.count){delete _33.start;delete _33.count;_2d.clientQuery=dojo.mixin(_2d.clientQuery||{},{start:_2d.start,count:_2d.count});}_2d=_33;this._fetchCache.push(_2d);}_31=_2d._loading=this._doQuery(_2d);}var _35=this.serverVersion;_31.addCallback(function(_36){delete _2d._loading;if(_36){_2d._version=_35;_2e.updateResultSet(_36,_2d);_2d.cacheResults=_36;}return _36;});return _31;},isUpdateable:function(_37){return typeof _37.query=="object";},clientSideFetch:function(_38,_39){if(_38.query){var _3a=[];for(var i=0;i<_39.length;i++){var _3b=_39[i];if(_3b&&this.matchesQuery(_3b,_38)){_3a.push(_39[i]);}}}else{_3a=_38.sort?_39.concat():_39;}if(_38.sort){_3a.sort(this.makeComparator(_38.sort.concat()));}return this.clientSidePaging(_38,_3a);},clientSidePaging:function(_3c,_3d){var _3e=_3c.start||0;var _3f=(_3e||_3c.count)?_3d.slice(_3e,_3e+(_3c.count||_3d.length)):_3d;_3f._fullLength=_3d.length;return _3f;},matchesQuery:function(_40,_41){var _42=_41.query;var _43=_41.queryOptions&&_41.queryOptions.ignoreCase;for(var i in _42){var _44=_42[i];var _45=this.getValue(_40,i);if((typeof _44=="string"&&(_44.match(/[\*\.]/)||_43))?!dojo.data.util.filter.patternToRegExp(_44,_43).test(_45):_45!=_44){return false;}}return true;},makeComparator:function(_46){var _47=_46.shift();if(!_47){return function(){};}var _48=_47.attribute;var _49=!!_47.descending;var _4a=this.makeComparator(_46);var _4b=this;return function(a,b){var av=_4b.getValue(a,_48);var bv=_4b.getValue(b,_48);if(av!=bv){return av<bv==_49?1:-1;}return _4a(a,b);};}});cf.onUpdate=function(){};})();}
