function using(qualifiedName, alias) {
  var components = qualifiedName.split(".");
  var context = window;
  
  for (var i = 0; i < components.length; ++i) {
    context = context[components[i]];
    
    if (!context) {
      throw "error in using(\"" + qualifiedName + "\"" +
            (alias ? ", \"" + alias + "\"" : "") + ") - " + 
            components.slice(0, i + 1).join(".") + 
            " is undefined.";
    }
  }
  
  var id = alias || components[i - 1];
  
  if (window[id] !== undefined && window[id] !== context) {
    throw "error in using(\"" + qualifiedName + "\"" +
          (alias ? ", \"" + alias + "\"" : "") + ") - " + 
          id + " is already defined.";
  }
  
  window[id] = context;
}

function zz(id) {
	  return (id.constructor == String) ? document.getElementById(id) : id;
	}


function callback(context, method /*, arg1, arg2, ..., argN*/) {
	  var creationArgs = new Array();

	  for(var i = 2; i < arguments.length; ++i) {
	    creationArgs.push(arguments[i]);
	  }

	  return function(/*arg(N+1), arg(N+2), ..., arg(N+M)*/) {
	    var callArgs = Array.copy(creationArgs);

	    for(var i = 0; i < arguments.length; ++i) {
	      callArgs.push(arguments[i]);
	    }

	    return Function.prototype.apply.call(method, context || this, callArgs);
	  };
	}
if (!Array.prototype.shift) {
	  Array.prototype.shift = function() {
	    if (this.length) {
	      return this.splice(0, 1)[0];
	    }
	    
	    return null;
	  };
	}

	if (!Array.prototype.unshift) {
	  Array.prototype.unshift = function(value) {
	    this.splice(0, 0, value);
	  };
	}

Array.copy = function(array) {
	  return array.concat([]);
	};

Array.prototype.first = function() {
	  return this[0];
	};

Array.prototype.last = function() {
	  return this[this.length - 1];
	};

Array.prototype.find = function(value, index) {
	  if (index === undefined) {
	    index = 0;
	  }

	  for (var length = this.length; index < length; ++index) {
	    if (this[index] == value) {
	      return index;
	    }
	  }

	  return -1;
	};

Array.prototype.rfind = function(value, index) {
	  if (index === undefined) {
	    index = this.length - 1;
	  }

	  for (; index >= 0; --index) {
	    if (this[index] == value) {
	      return index;
	    }
	  }

	  return -1;
	};

Array.prototype.remove = function(value) {
	  for (var i = this.find(value); i != -1; i = this.find(value, i)) {
	    this.splice(i, 1);
	  }
	};

