var geoeye = function() {

    var webmaps = function() {

        var PageInfo = {
            start: 1,
            size: 50,
            totalSize: 0
        };

        var QueryTask = function(url) {
            try {
                // Inherit from the core QueryTask
                this.prototype = new esri.arcgis.gmaps.QueryTask(url);
                this.prototype.constructor = this;
                this.prototype.parent = esri.arcgis.gmaps.QueryTask.prototype;

                // Store the base URL
                this.baseUrl = url;

                // Override the response handler
                this.prototype._coreResponseHandler = this.prototype._responseHandler;
                this.prototype._responseHandler = function(response, error, callback) {
                    if (response.totalFeatureCount) {
                        PageInfo.totalSize = response.totalFeatureCount;
                    }
                    this._coreResponseHandler(response, error, callback);
                }
            }
            catch (e) {
                //alert(e);
                ErrorAlert(ProcessingSearchResultsError);
            }
        }

        QueryTask.prototype.execute = function(params, asGeoXml, callback) {

            try {
                // Handle the paging parameters
                if (!(PageInfo.size === undefined || PageInfo.size === null || PageInfo.size === "")) {
                    PageInfo.totalSize = 0;
                    this.prototype.url = this.baseUrl + "?pageStart=" + PageInfo.start + "&pageSize=" + PageInfo.size + "&spatialRank=false";
                }

                // Call the core execute function
                this.prototype.execute(params, asGeoXml, callback);
            }
            catch (e) {
                //alert(e);
                ErrorAlert(ProcessingSearchResultsError);
            }
        }

        return {
            /***********************
            * geoeye.webmaps.*
            ***********************/
            PageInfo: PageInfo,
            QueryTask: QueryTask
        };
    };

    return {
        /*****************
        * geoeye.*
        *****************/
        webmaps: webmaps()
    };
} ();
