(function(){

  /***************************************
   * Modify this path based on your setup
   ***************************************/
  var DEPLOY_ROOT = location.protocol + '//' + location.host + '/home/';
  
  window.esriGeowConfig = {
  
    /***************************************
     * Basics
     ***************************************/
    baseUrl: DEPLOY_ROOT,
    webmapViewerPath: 'webmap/viewer.html',
    dojoBaseUrl: DEPLOY_ROOT + '/js/dojo/',
    proxyUrl: '',
    proxyServer: location.protocol + '//' + location.host + '/sharing/proxy',
    restBaseUrl: location.protocol + '//' + location.host + '/sharing/',
    reflectorUrl: location.protocol + '//' + location.host + '/sharing/tools/reflect',
    generateUrl: location.protocol + '//' + location.host + '/sharing/content/features/generate',
    kmlService: location.protocol + '//utility.arcgis.com/sharing/kml', 
    print: location.protocol + '//' + location.host + '/sharing/tools/print',
    printGet: location.protocol + '//utility.arcgis.com/sharing/tools/print',
    legend: location.protocol + '//utility.arcgis.com/sharing/tools/legend',
    isRightToLeft: false,         
    /***************************************
     * ArcGIS portal settings
     ***************************************/
    portalHeaderImage: null,
    explorerName: null,
    tokenExpiration: 120,
    longTokenExpiration: 20160,
    esriGlobalAccount: null,
    useDefaultIdentityStore: false,
    signin: 'signin.html',
    signup: 'signup.html',
    createAccount: 'createaccount.html',
    showSignUp: true,
    webSearchEnabed: true,
    showSocialMediaLinks: true,
    showHelpLink: true,
    showForumsLink: true,
    showBlogLink: true,
    addContentSecurityText: null,
    classificationBanner: false,
    bingMapsKey: 'Anz84uRE1RULeLwuJ0qKu5amcu5rugRXy1vKc27wUaKVyIv1SVZrUjqaOfXJJoI0',
    placeFinder : {"url": location.protocol + "//tasks.arcgis.com/ArcGIS/rest/services/WorldLocator/GeocodeServer",
      "northLat" : "North_Lat",
      "southLat" : "South_Lat",
      "eastLon" : "East_Lon",
      "westLon" : "West_Lon"
    },
    contentPageHiddenTypes: null,
    showOrganizationInviteUsers: true,
    showForgotUsername: true,
    isMultiTenant: true,
    createServicesEnabled: true,
    importDataEnabled: true,
    
    //*** parameters for new account creation via ECAS REST API
    //*** to turn on: comment out account_registration and uncomment accountApi, accountApiKey, and accountAppKey
    accountApi: "https://ecasapi.esri.com/1.0/accounts",
    accountApiKey: "54czglhz",
    accountAppKey: "RC10SB959G",
    
    /***************************************
     * Links
     ***************************************/
    bitlyUrl: 'http://api.bit.ly/v3/shorten?login=arcgis&apiKey=R_b8a169f3a8b978b9697f64613bf1db6d',
		bitlyUrlSSL: 'https://api-ssl.bitly.com/v3/shorten?login=arcgis&apiKey=R_b8a169f3a8b978b9697f64613bf1db6d',
    geometryServer: location.protocol + '//utility.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer',
    gcsBasemapService: location.protocol + "//services.arcgisonline.com/ArcGIS/rest/services/ESRI_Imagery_World_2D/MapServer",
    extentService: location.protocol + "//server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer",
    explorerOnline: location.protocol + '//' + location.host + '/explorer',
    resourceCenter: "http://resources.arcgis.com",
    //account_registration: "https://webaccounts.esri.com/cas/index.cfm?fuseaction=Registration.ShowForm&ReturnURL=https%3A%2F%2Fwww.arcgis.com%2Fhome%2Fsignup.html&FailURL=http%3A%2F%2Fwww.arcgis.com&appId=RC10SB959G",
    account_edit: "https://webaccounts.esri.com/CAS/index.cfm?AppId=RC10SB959G&returnurl=https://webaccounts.esri.com/CAS/index.cfm?appid=RC10SB959G",
    forgotPwd: "https://webaccounts.esri.com/cas/index.cfm?fuseaction=Login.ForgotPwd.ShowForm&appId=RC10SB959G&FailURL=http%3A%2F%2Fwww.arcgis.com&ReturnURL=https%3A%2F%2Fwww.arcgis.com%2Fhome%2Fsignin.html",
    signInHelp: "http://links.esri.com/arcgisdotcomhelp/accounttips",
    forums: "http://forums.arcgis.com/forums/30-ArcGIS-Online",
    blog: "http://blogs.esri.com/Support/blogs/arcgisonline",
    help: "http://links.esri.com/arcgisdotcomhelp/welcome",
    helpBase: "http://links.esri.com/arcgisdotcomhelp/",
    footerLinks: [{
      title: "Esri.com",
      url: "http://www.esri.com"
    }, {
      title: "${i18n.termsOfUse}",
      url: "http://www.esri.com/legal/licensing/termsofuse.html"
    }, {
      title: "${i18n.privacy}",
      url: "http://www.esri.com/legal/privacy.html"
    }, {
      title: "${i18n.contactUs}",
      email: "arcgisonline_feedback@esri.com",
      type: "contactUs"
    }, {
      title: "${i18n.reportAbuse}",
      email: "arcgisonline_feedback@esri.com",
      type: "reportAbuse"
    }],
    
    /***************************************
     * Specific groups and owners
     ***************************************/
    //*** Esri user names
    publisherESRI: "(owner:esri OR owner:esri_webapi OR owner:arcgis_explorer OR owner:SLDevTeam OR owner:ArcGISMobileDevTeam OR owner:iOSDevelopmentTeam)",
    
    /*******************************************************************************
     * The following parameters come from the /sharing/accounts/self resource and
     * are no longer defined in this file:
     *******************************************************************************
     * portalName
     * rotatorPanels
     * homePageFeaturedContentCount
     * homePageFeaturedContent
     * featuredItemsGroupQuery
     * basemapGalleryGroupQuery
     * templatesGroupQuery
     * layerTemplatesGroupQuery
     * symbolSetsGroupQuery
     * colorSetsGroupQuery
     * featuredGroups
     * defaultBasemap
     * defaultExtent
     ******************************************************************************/
    
    /*******************************************************************************
     *******************************************************************************
     * DO NOT MODIFY these following parameters
     *******************************************************************************
     *******************************************************************************/
    userInfo: "",
    
    googleServiceSearchString: 'inurl:rest inurl:services "Supported Interfaces" -"Folders" -"KMZ" -"GlobeServer" -"NAServer" -"GPServer" -"GeocodeServer" -"GeoDataServer" -"GeometryServer"',
    
    contentModeCookieName: "contentModePrefs",
    
    //*** search modes (all content, web content only)
    viewQueries: {
      web: " AND ((type:\"service\" -type:\"globe\" -type:\"geodata\" -type:\"Service Definition\") OR type:\"KML\" OR type:\"WMS\" OR type:\"Web Map\" OR type:\"web mapping application\" OR (type:\"feature collection\"  -type:\"Feature Collection Template\") OR type:\"mobile application\") ",
      gis: " -type:\"Code Attachment\" -type:\"Service Definition\" -type:\"Featured Items\" -type:\"Symbol Set\" -type:\"Color Set\" -type:\"Feature Collection\" ",
      none: " -type:\"Code Attachment\" -type:\"Service Definition\" -type:\"Featured Items\" -type:\"Symbol Set\" -type:\"Color Set\" -type:\"Feature Collection\" "
    },
    
    //*** key-value pairs or pre-defined query filters on search results page
    filterQueries: {
      "all": {
        focus: null,
        t: "content",
        f: ""
      },
      "maps": {
        focus: "maps",
        t: "content",
        f: "(type:\"Feature Service\" OR typekeywords:\"map\" OR typekeywords:\"Data\") -type:\"web mapping application\" -type:\"mobile application\" -type:\"Geocoding Service\" -type:\"Network Analysis Service\" -type:\"Geoprocessing Service\" -type:\"Geometry Service\" -type:\"Geodata Service\""
      },
      "applications": {
        focus: "applications",
        t: "content",
        f: "(type:\"Web Mapping Application\" OR type:\"Mobile Application\" OR type:\"Desktop Application Template\")"
      },
      "tools": {
        focus: "tools",
        t: "content",
        f: "(typekeywords:\"tool\" OR type:\"Geodata Service\" OR type:\"Workflow Manager Package\")"
      },
      
      "maps-webmaps": {
        focus: "maps",
        t: "content",
        f: "type:\"Web Map\" -type:\"Web Mapping Application\" -(owner:esri tags:basemap)"
      },
      "maps-mapservices": {
        focus: "maps",
        t: "content",
        f: "(type:\"WMS\" OR type:\"KML\" OR type:\"Map Service\" OR type:\"Image Service\" OR type:\"Feature Service\" OR type:\"Globe Service\")"
      },
      "maps-packages": {
        focus: "maps",
        t: "content",
        f: "(type:\"Layer Package\" OR type:\"Map Package\" OR type:\"Tile Package\")"
      },
      "maps-others": {
        focus: "maps",
        t: "content",
        f: "(type:\"Shapefile\" OR type:\"CSV\" OR type:\"Explorer Map\" OR type:\"Map Document\" OR type:\"Globe Document\" OR type:\"Scene Document\" OR type:\"Layer\" OR type:\"Explorer Layer\" OR type:\"Explorer Map\" OR type:\"Published Map\") -type:\"Layer Package\""
      },
      
      "maps-packages-layer": {
        focus: "maps",
        t: "content",
        f: "type:\"Layer Package\""
      },
      "maps-packages-map": {
        focus: "maps",
        t: "content",
        f: "type:\"Map Package\""
      },
      
      "applications-web": {
        focus: "applications",
        t: "content",
        f: "type:\"Web Mapping Application\""
      },
      
      "applications-web-flex": {
        focus: "applications",
        t: "content",
        f: "type:\"Web Mapping Application\" typekeywords:\"Flex\""
      },
      "applications-web-flex-readytouse": {
        focus: "applications",
        t: "content",
        f: "(type:\"Web Mapping Application\" AND typekeywords:\"Flex\" AND typekeywords:\"Ready To Use\")"
      },
      "applications-web-flex-configurable": {
        focus: "applications",
        t: "content",
        f: "(type:\"Web Mapping Application\" AND typekeywords:\"Flex\" AND typekeywords:\"Configurable\")"
      },
      "applications-web-flex-codesample": {
        focus: "applications",
        t: "content",
        f: "(type:\"Web Mapping Application\" AND typekeywords:\"Flex\" AND typekeywords:\"Code Sample\")"
      },
      
      "applications-web-javascript": {
        focus: "applications",
        t: "content",
        f: "(type:\"Web Mapping Application\" AND typekeywords:\"Javascript\")"
      },
      "applications-web-javascript-readytouse": {
        focus: "applications",
        t: "content",
        f: "(type:\"Web Mapping Application\" AND typekeywords:\"Javascript\" AND typekeywords:\"Ready To Use\")"
      },
      "applications-web-javascript-configurable": {
        focus: "applications",
        t: "content",
        f: "(type:\"Web Mapping Application\" AND typekeywords:\"Javascript\" AND typekeywords:\"Configurable\")"
      },
      "applications-web-javascript-codesample": {
        focus: "applications",
        t: "content",
        f: "(type:\"Web Mapping Application\" AND typekeywords:\"Javascript\" AND typekeywords:\"Code Sample\")"
      },
      
      "applications-web-silverlight": {
        focus: "applications",
        t: "content",
        f: "(type:\"Web Mapping Application\" AND typekeywords:\"Silverlight\")"
      },
      "applications-web-silverlight-readytouse": {
        focus: "applications",
        t: "content",
        f: "(type:\"Web Mapping Application\" AND typekeywords:\"Silverlight\" AND typekeywords:\"Ready To Use\")"
      },
      "applications-web-silverlight-configurable": {
        focus: "applications",
        t: "content",
        f: "(type:\"Web Mapping Application\" AND typekeywords:\"Silverlight\" AND typekeywords:\"Configurable\")"
      },
      "applications-web-silverlight-codesample": {
        focus: "applications",
        t: "content",
        f: "(type:\"Web Mapping Application\" AND typekeywords:\"Silverlight\" AND typekeywords:\"Code Sample\")"
      },
      
      "applications-mobile": {
        focus: "applications",
        t: "content",
        f: "type:\"Mobile Application\""
      },
      
      "applications-mobile-android": {
        focus: "applications",
        t: "content",
        f: "(type:\"Mobile Application\" AND typekeywords:\"ArcGIS for Android\")"
      },
      "applications-mobile-android-readytouse": {
        focus: "applications",
        t: "content",
        f: "(type:\"Mobile Application\" AND typekeywords:\"ArcGIS for Android\" AND typekeywords:\"Ready To Use\")"
      },
      "applications-mobile-android-configurable": {
        focus: "applications",
        t: "content",
        f: "(type:\"Mobile Application\" AND typekeywords:\"ArcGIS for Android\" AND typekeywords:\"Configurable\")"
      },
      "applications-mobile-android-codesample": {
        focus: "applications",
        t: "content",
        f: "(type:\"Mobile Application\" AND typekeywords:\"ArcGIS for Android\" AND typekeywords:\"Code Sample\")"
      },
      
      "applications-mobile-iphone": {
        focus: "applications",
        t: "content",
        f: "(type:\"Mobile Application\" AND typekeywords:\"ArcGIS for iPhone\")"
      },
      "applications-mobile-iphone-readytouse": {
        focus: "applications",
        t: "content",
        f: "(type:\"Mobile Application\" AND typekeywords:\"ArcGIS for iPhone\" AND typekeywords:\"Ready To Use\")"
      },
      "applications-mobile-iphone-configurable": {
        focus: "applications",
        t: "content",
        f: "(type:\"Mobile Application\" AND typekeywords:\"ArcGIS for iPhone\" AND typekeywords:\"Configurable\")"
      },
      "applications-mobile-iphone-codesample": {
        focus: "applications",
        t: "content",
        f: "(type:\"Mobile Application\" AND typekeywords:\"ArcGIS for iPhone\" AND typekeywords:\"Code Sample\")"
      },
      
      "applications-mobile-windowsmobile": {
        focus: "applications",
        t: "content",
        f: "(type:\"Mobile Application\" AND typekeywords:\"Windows Mobile\")"
      },
      "applications-mobile-windowsmobile-readytouse": {
        focus: "applications",
        t: "content",
        f: "(type:\"Mobile Application\" AND typekeywords:\"Windows Mobile\" AND typekeywords:\"Ready To Use\")"
      },
      "applications-mobile-windowsmobile-configurable": {
        focus: "applications",
        t: "content",
        f: "(type:\"Mobile Application\" AND typekeywords:\"Windows Mobile\" AND typekeywords:\"Configurable\")"
      },
      "applications-mobile-windowsmobile-codesample": {
        focus: "applications",
        t: "content",
        f: "(type:\"Mobile Application\" AND typekeywords:\"Windows Mobile\" AND typekeywords:\"Code Sample\")"
      },
      
      "applications-mobile-windowsphone": {
        focus: "applications",
        t: "content",
        f: "(type:\"Mobile Application\" AND typekeywords:\"Windows Phone\")"
      },
      "applications-mobile-windowsphone-readytouse": {
        focus: "applications",
        t: "content",
        f: "(type:\"Mobile Application\" AND typekeywords:\"Windows Phone\" AND typekeywords:\"Ready To Use\")"
      },
      "applications-mobile-windowsphone-configurable": {
        focus: "applications",
        t: "content",
        f: "(type:\"Mobile Application\" AND typekeywords:\"Windows Phone\" AND typekeywords:\"Configurable\")"
      },
      "applications-mobile-windowsphone-codesample": {
        focus: "applications",
        t: "content",
        f: "(type:\"Mobile Application\" AND typekeywords:\"Windows Phone\" AND typekeywords:\"Code Sample\")"
      },
      
      "applications-mobile-android": {
        focus: "applications",
        t: "content",
        f: "(type:\"Mobile Application\" AND typekeywords:\"Android\")"
      },
      "applications-mobile-android-readytouse": {
        focus: "applications",
        t: "content",
        f: "(type:\"Mobile Application\" AND typekeywords:\"Android\" AND typekeywords:\"Ready To Use\")"
      },
      "applications-mobile-android-configurable": {
        focus: "applications",
        t: "content",
        f: "(type:\"Mobile Application\" AND typekeywords:\"Android\" AND typekeywords:\"Configurable\")"
      },
      "applications-mobile-android-codesample": {
        focus: "applications",
        t: "content",
        f: "(type:\"Mobile Application\" AND typekeywords:\"Android\" AND typekeywords:\"Code Sample\")"
      },

      "applications-mobile-javascript": {
        focus: "applications",
        t: "content",
        f: "(type:\"Mobile Application\" AND typekeywords:\"JavaScript\")"
      },
      "applications-mobile-javascript-readytouse": {
        focus: "applications",
        t: "content",
        f: "(type:\"Mobile Application\" AND typekeywords:\"JavaScript\" AND typekeywords:\"Ready To Use\")"
      },
      "applications-mobile-javascript-configurable": {
        focus: "applications",
        t: "content",
        f: "(type:\"Mobile Application\" AND typekeywords:\"JavaScript\" AND typekeywords:\"Configurable\")"
      },
      "applications-mobile-javascript-codesample": {
        focus: "applications",
        t: "content",
        f: "(type:\"Mobile Application\" AND typekeywords:\"JavaScript\" AND typekeywords:\"Code Sample\")"
      },

      "applications-mobile-flex": {
        focus: "applications",
        t: "content",
        f: "(type:\"Mobile Application\" AND typekeywords:\"Flex\")"
      },
      "applications-mobile-flex-readytouse": {
        focus: "applications",
        t: "content",
        f: "(type:\"Mobile Application\" AND typekeywords:\"Flex\" AND typekeywords:\"Ready To Use\")"
      },
      "applications-mobile-flex-configurable": {
        focus: "applications",
        t: "content",
        f: "(type:\"Mobile Application\" AND typekeywords:\"Flex\" AND typekeywords:\"Configurable\")"
      },
      "applications-mobile-flex-codesample": {
        focus: "applications",
        t: "content",
        f: "(type:\"Mobile Application\" AND typekeywords:\"Flex\" AND typekeywords:\"Code Sample\")"
      },
      
      "tools-locators": {
        focus: "tools",
        t: "content",
        f: "(type:\"Geocoding Service\" OR type:\"Locator Package\")"
      },
      "tools-geodatabase": {
        focus: "tools",
        t: "content",
        f: "type:\"Geodata Service\""
      },
      "tools-geometric": {
        focus: "tools",
        t: "content",
        f: "type:\"Geometry Service\""
      },
      "tools-geoprocessing": {
        focus: "tools",
        t: "content",
        f: "(type:\"Geoprocessing Service\" OR type:\"Geoprocessing Package\" OR type:\"Geoprocessing Sample\")"
      },
      "tools-network": {
        focus: "tools",
        t: "content",
        f: "type:\"Network Analysis Service\""
      }
    }
  };
  
  window.djConfig = {
    parseOnLoad: true,
    isDebug: false,
    debugAtAllCosts: false,
    dojoBlankHtmlUrl: "blank.html"
  };
  
}());



//anonymous function call for reading locale cookie and setting rtl logic
(function() {
  
  //esriGeowConfig.testLocale = "ar"; // this is the test locale response from self resource call
  
  //reading locale
  var nameEQ = "arcgisLocale" + "=";
  var sessionCookie = "esri_auth" + "=";
  var ca = document.cookie.split(';');
  var locale = navigator.language? navigator.language : navigator.userLanguage;  //default djConfig.locale to browser language when no cookie present
  if (locale) {
    window.djConfig.locale = locale.toLowerCase();
  }
  loop1:
  for(var i=0;i < ca.length;i++) {
      var c = ca[i];
      while (c.charAt(0)==' ') {
        c = c.substring(1,c.length);
      }
      if (c.indexOf(sessionCookie) == 0)  {
        var sValue =  unescape(c.substring(sessionCookie.length,c.length));
        var userObj = eval('(' + sValue+ ')');
        locale = userObj.culture;
        if (locale) {
          window.djConfig.locale = locale; // change djConfig.locale to the cookie locale when cookie is present
        }
        break loop1;
      }      
      if (c.indexOf(nameEQ) == 0)  {
        locale =  c.substring(nameEQ.length,c.length);
        if (locale) {
          window.djConfig.locale = locale; // change djConfig.locale to the cookie locale when cookie is present
        }
      }
  }  
  
  if (window.djConfig.locale && window.djConfig.locale.indexOf("ar") !== -1) {
    esriGeowConfig.isRightToLeft = true; // esriGeowConfig.isRightToLeft property setting to true when the locale is 'ar'
  }
  else {
    esriGeowConfig.isRightToLeft = false;
  }
  
  
  
  //setting the document dir type to RTL when esriGeowConfig.isRightToLeft is true
  var dirNode = document.getElementsByTagName("html")[0];
  if (esriGeowConfig.isRightToLeft) {
    dirNode.setAttribute("dir", "rtl");
    dirNode.className += " esriRtl";
  }
  else {
    dirNode.setAttribute("dir", "ltr");
    dirNode.className += " esriLtr";
    dirNode.className += " " + window.djConfig.locale.split("-")[0];
  }
})();


