/*  DuckSoup
 *  (c) 2007 Maioli Giacomo Luca
 *
 * Requires LayerZero
/*--------------------------------------------------------------------------*/

if (typeof DuckSoup == "undefined") {
    var DuckSoup = {};
}

DuckSoup = {

	/** recursively add namespaces in the format make.love.not.war */
	addNamespace : function(){
		var result = null
		var identifiers = []
	    for (var i = 0; i < arguments.length; i++) {
	        identifiers = arguments[i].split(".")
			identifiers.changeIfValueIs("DuckSoup", "")
	        result = DuckSoup

			for (var j = 0; j < identifiers.length; j++){
				if (classAdd(result, identifiers[j])){
					result = result[identifiers[j]]
				}
	        }
	    }
	},

	/* the page namespace manage page loading tasks */
  
	page : {
		loadingTasks: new Array(),
	
		addOnLoadTask : function(task){
			if (typeof task == "function"){
				this.loadingTasks.push(task)
			}
		},
	
		load : function(){
			for (i=0; i < this.loadingTasks.length; i++){
				this.loadingTasks[i]()
			}
			delete this.load
			delete this.addOnLoadTask
		}
	},

	init: function(){
		if (DuckSoup.flash.bridge){
			DuckSoup.flash.bridge.setReady()
		}
		DuckSoup.page.load()
	}
}
