function ImagePool() {
	var pathPrefix = "/users/bt1/imgpool/";
  var itemMap = new Array();
  
  this.addItem = function(item) {
    itemMap[item.key] = item;
  }
  
  this.getItem = function(key) {
    return itemMap[key];
  }
  
  this.getImagePath = function(key) {
    var item = this.getItem(key); 
    return pathPrefix + item.filename + item.extension;
  }
}

function ImagePoolItem() {
  this.key;
  this.filename;
	this.extension;
  this.width;
  this.height;
}

function loadImagePool(imagePool, callback) {
  var path = "/users/bt1/imgpool/images.xml?_="+new Date().getTime();

  log.info("Requesting ImagePool: " + path);

  $.get(path, function(data) {
    log.info("Data loaded");
      
    $(data).find("image").each(function () {
			var ipi = new ImagePoolItem();
			ipi.key = $(this).attr("key");
      ipi.filename = $(this).find("filename").text();
      ipi.extension = $(this).find("extension").text();
      ipi.width = parseInt($(this).find("width").text());
      ipi.height = parseInt($(this).find("height").text());
			
			imagePool.addItem(ipi);
    });
    
    if(callback != null) {
      callback();
    }
  });
}

