 import com.esri.ags.portal.supportClasses.PortalItem;
 import com.esri.ags.portal.supportClasses.PortalQueryParameters;
 import com.esri.ags.portal.supportClasses.PortalQueryResult;
+import com.esri.ags.tasks.JSONTask;
 import com.esri.viewer.AppEvent;
 import com.esri.viewer.ConfigData;
 
 import flash.events.Event;
 import flash.events.EventDispatcher;
+import flash.net.URLVariables;
 import flash.utils.Dictionary;
 
 import mx.resources.ResourceManager;

        updateTotalArcGISBasemaps();
    }

    private function portal_queryGroupsFaultHandler(fault:Fault, token:Object = null):void
    {
        AppEvent.showError(LocalizationUtil.getDefaultString("couldNotQueryPortal"), PORTAL_BASEMAP_APPENDER);

        portalItemToLabel = new Dictionary(true);
        processedArcGISBasemaps = [];
        totalBasemaps = configData.basemaps.length;
        for each (var item:PortalItem in resultItems)
        {
            processPortalItem(item);
        }
    }

    private function processPortalItem(item:PortalItem):void
    {
        if (item.type == PortalItem.TYPE_WEB_MAP)
        {
            portalItemOrder.push(item);
            processWebMapPortalItem(item);
        }
        else if (item.type == PortalItem.TYPE_MAP_SERVICE)
        {
            portalItemOrder.push(item);
            processMapServicePortalItem(item);
        }
        else
        {
            updateTotalArcGISBasemaps();
        }
    }

    private function processWebMapPortalItem(item:PortalItem):void
    {
        item.getJSONData(new AsyncResponder(item_getJSONDataResultHandler,
                                            item_getJSONDataFaultHandler,
                                            item));
    }

    private function item_getJSONDataResultHandler(itemData:Object, item:PortalItem):void
    {
        createBasemapLayerObjectFromWebMapItemAndData(item, itemData);
        if (isDefaultBasemap(itemData.baseMap))
