//>>built
define("dojox/data/GoogleSearchStore","dojo/_base/kernel dojo/_base/lang dojo/_base/declare dojo/_base/query dojo/dom-construct dojo/io/script".split(" "),function(q,A,h,F,G,H){q.experimental("dojox.data.GoogleSearchStore");var n=h("dojox.data.GoogleSearchStore",null,{constructor:function(a){a&&(a.label&&(this.label=a.label),a.key&&(this._key=a.key),a.lang&&(this._lang=a.lang),"urlPreventCache"in a&&(this.urlPreventCache=a.urlPreventCache?!0:!1));this._id=dojox.data.GoogleSearchStore.prototype._id++},
_id:0,_requestCount:0,_googleUrl:"http://ajax.googleapis.com/ajax/services/search/",_storeRef:"_S",_attributes:"unescapedUrl url visibleUrl cacheUrl title titleNoFormatting content estimatedResultCount".split(" "),_aggregatedAttributes:{estimatedResultCount:"cursor.estimatedResultCount"},label:"titleNoFormatting",_type:"web",urlPreventCache:!0,_queryAttrs:{text:"q"},_assertIsItem:function(a){if(!this.isItem(a))throw Error("dojox.data.GoogleSearchStore: a function was passed an item argument that was not an item");
},_assertIsAttribute:function(a){if("string"!==typeof a)throw Error("dojox.data.GoogleSearchStore: a function was passed an attribute argument that was not an attribute name string");},getFeatures:function(){return{"dojo.data.api.Read":!0}},getValue:function(a,b,c){return(a=this.getValues(a,b))&&0<a.length?a[0]:c},getAttributes:function(a){return this._attributes},hasAttribute:function(a,b){return this.getValue(a,b)?!0:!1},isItemLoaded:function(a){return this.isItem(a)},loadItem:function(a){},getLabel:function(a){return this.getValue(a,
this.label)},getLabelAttributes:function(a){return[this.label]},containsValue:function(a,b,c){a=this.getValues(a,b);for(b=0;b<a.length;b++)if(a[b]===c)return!0;return!1},getValues:function(a,b){this._assertIsItem(a);this._assertIsAttribute(b);var c=a[b];return A.isArray(c)?c:void 0!==c?[c]:[]},isItem:function(a){return a&&a[this._storeRef]===this?!0:!1},close:function(a){},_format:function(a,b){return a},fetch:function(a){function b(g){B++;w.content.context=w.content.start=g.start;g=H.get(w);x.push(g.ioArgs.id);
g.addErrback(function(k){a.onError&&a.onError.call(c,k,a)})}a=a||{};var c=a.scope||q.global;if(!a.query&&a.onError)a.onError.call(c,Error(this.declaredClass+": A query must be specified."));else{var l={};for(r in this._queryAttrs)l[r]=a.query[r];a={query:l,onComplete:a.onComplete,onError:a.onError,onItem:a.onItem,onBegin:a.onBegin,start:a.start,count:a.count};var u="GoogleSearchStoreCallback_"+this._id+"_"+ ++this._requestCount;l=this._createContent(l,u,a);if("undefined"===typeof a.start||null===
a.start)a.start=0;a.count||(a.count=8);var r={start:a.start-a.start%8};var y=this,w={url:this._googleUrl+this._type,preventCache:this.urlPreventCache,content:l},p=[],z=0,C=!1,t=a.start-1,B=0,x=[],E=function(g,k){0<x.length&&F("#"+x.splice(0,1)).forEach(G.destroy);if(!C){var f=y._getItems(k),e=k?k.cursor:null;if(f){for(var d=0;d<f.length&&d+g<a.count+a.start;d++)y._processItem(f[d],k),p[d+g]=f[d];z++;if(1==z){var D=(d=e?e.pages:null)?Number(d[d.length-1].start):0;a.onBegin&&(e=e?e.estimatedResultCount:
f.length,a.onBegin.call(c,e?Math.min(e,D+f.length):D+f.length,a));f=a.start-a.start%8+8;for(e=1;d&&d[e]&&!(Number(d[e].start)>=a.start+a.count);)Number(d[e].start)>=f&&b({start:d[e].start}),e++}if(a.onItem&&p[t+1]){do t++,a.onItem.call(c,p[t],a);while(p[t+1]&&t<a.start+a.count)}z==B&&(C=!0,q.global[u]=null,a.onItem?a.onComplete.call(c,null,a):(p=p.slice(a.start,a.start+a.count),a.onComplete.call(c,p,a)))}}},m=[],v=r.start-1;q.global[u]=function(g,k,f,e){try{if(200!=f)a.onError&&a.onError.call(c,Error("Response from Google was: "+
f),a),q.global[u]=function(){};else if(g==v+1){if(E(Number(g),k),v+=8,0<m.length)for(m.sort(y._getSort());0<m.length&&m[0].start==v+1;)E(Number(m[0].start),m[0].data),m.splice(0,1),v+=8}else m.push({start:g,data:k})}catch(d){a.onError.call(c,d,a)}};b(r)}},_getSort:function(){return function(a,b){return a.start<b.start?-1:b.start<a.start?1:0}},_processItem:function(a,b){a[this._storeRef]=this;for(var c in this._aggregatedAttributes)a[c]=A.getObject(this._aggregatedAttributes[c],!1,b)},_getItems:function(a){return a.results||
a},_createContent:function(a,b,c){b={v:"1.0",rsz:"large",callback:b,key:this._key,hl:this._lang};for(var l in this._queryAttrs)b[this._queryAttrs[l]]=a[l];return b}}),I=h("dojox.data.GoogleWebSearchStore",n,{}),J=h("dojox.data.GoogleBlogSearchStore",n,{_type:"blogs",_attributes:"blogUrl postUrl title titleNoFormatting content author publishedDate".split(" "),_aggregatedAttributes:{}}),K=h("dojox.data.GoogleLocalSearchStore",n,{_type:"local",_attributes:"title titleNoFormatting url lat lng streetAddress city region country phoneNumbers ddUrl ddUrlToHere ddUrlFromHere staticMapUrl viewport".split(" "),
_aggregatedAttributes:{viewport:"viewport"},_queryAttrs:{text:"q",centerLatLong:"sll",searchSpan:"sspn"}}),L=h("dojox.data.GoogleVideoSearchStore",n,{_type:"video",_attributes:"title titleNoFormatting content url published publisher duration tbWidth tbHeight tbUrl playUrl".split(" "),_aggregatedAttributes:{}}),M=h("dojox.data.GoogleNewsSearchStore",n,{_type:"news",_attributes:"title titleNoFormatting content url unescapedUrl publisher clusterUrl location publishedDate relatedStories".split(" "),_aggregatedAttributes:{}}),
N=h("dojox.data.GoogleBookSearchStore",n,{_type:"books",_attributes:"title titleNoFormatting authors url unescapedUrl bookId pageCount publishedYear".split(" "),_aggregatedAttributes:{}});h=h("dojox.data.GoogleImageSearchStore",n,{_type:"images",_attributes:"title titleNoFormatting visibleUrl url unescapedUrl originalContextUrl width height tbWidth tbHeight tbUrl content contentNoFormatting".split(" "),_aggregatedAttributes:{}});return{Search:n,ImageSearch:h,BookSearch:N,NewsSearch:M,VideoSearch:L,
LocalSearch:K,BlogSearch:J,WebSearch:I}});