
	dojo.require('dojo.io.*');
	
  var cityCache = new Object();
  
  function cacheCities(countryID, cityData) {
    cityCache[countryID] = cityData;
  }
  
  
  
  function loadCities(countryID, 
                      selectID, 
                      selectCityID, 
                      optional, 
                      updatingString,
                      headerItem,
                      okCallback,
                      errorCallback) {
    
    var dd = dojo.byId(selectID);
    
    if(okCallback == null) {
        okCallback = function() {}
    }
    
    if(errorCallback == null) {
        errorCallback = function() {}
    }

    if(cityCache[countryID] == null) {
      clearDropdown(dd);
      markUpdating(dd, updatingString);

      var bindArgs = {
        url: "ajax/getCities.php",
    
        content: {
          countryID: countryID
        },
    
        error: function(type, data, evt){
            errorCallback(type, data, evt);
        },
      
        load: function(type, data, evt) {
          cityCache[countryID] = data;
          clearDropdown(dd);
          populateCityDropdown(dd, data, selectCityID, optional, headerItem);
          okCallback
        },
      
        mimetype: "text/json"
      };
     
      dojo.io.bind(bindArgs);     
    } else {
      clearDropdown(dd);
      populateCityDropdown(dd, cityCache[countryID], selectCityID, optional, headerItem);
      okCallback();
    }
  }
  
  