var BL_ERROR_DEBUG=0;
var BL_ERROR_USER=1;
var BL_ERROR_WARNING=2;
var BL_ERROR_ERROR=3;
var BL_ERROR_CRITICAL=4;
BLError=function(level,discription,code){
	this.level=level;
	this.discription=discription;
	this.code=code;
	this.handler=new BLErrorHandler(this);
}
BLError.prototype={
	level:0,
	discription:'',
	code:'',
	handler:false,
	canceled:false
}

BLErrorHandler=function(error){
	this.error=error;
	code=this.error.code;
	for(scope in this.handlers){
		if(code.indexOf(scope)==0 || scope=='' || scope=='*'){
			for(index in this.handlers[scope]){
				resume=this.handlers[scope][index](error);
				if(!resume){
					this.canceled=true;
					return this;
				}
			}
		}
	}
}
BLErrorHandler.prototype={
	error:false,
	handlers:Object(),
}
BLErrorHandler.register=function(scope,func){
	if(!BLErrorHandler.prototype.handlers[scope]){
		BLErrorHandler.prototype.handlers[scope]=Array();
	}
	BLErrorHandler.prototype.handlers[scope][BLErrorHandler.prototype.handlers[scope].length]=func;
}

function getPhpErrorsWrapper(){
	//we need to provide this wrapper since the function is not always loaded at this time;
	getPhpErrors();
}

document.loadStack.append(getPhpErrorsWrapper);