var UI = {
path: '/js/',
	cache:Array(),
	ready:false,
	extend:function(p){
		if(typeof p == 'object'){
			for(k in p){
				this[k] = p[k];
			}
		}	
	},
	init:function(file){
		var file = typeof file != 'undefined' ? file : '';
		var me = this;        
		var script = document.createElement('scr'+'ipt');
        script.type = 'text/javascript';
        script.src = this.path + file + '.js';
        $('head',document).get(0).appendChild(script);
		$(window).bind('unload', function(){me.cache = null});
		
		UI._initPage();
	},
	_initPage:function(){
		var me = this;
		if(typeof me.cache['_initTries'] == 'undefined') me.cache['_initTries'] = 0;
		if(this.cache['_initTries'] > 10) return;
		for(k in this){
			if(k == 'initPage'){
				me.ready = true;
				break;
			}
		}	
		if(me.ready === false) {
			setTimeout(function(){me.cache['_initTries']++;me._initPage()},250);
		}else{
			me.initPage();
		}
	}
}