/*
 * @require jade.js
 * @require log4javascript.js
 */
jade.Log=function(){};jade.Log.FACILITY_ALERT=0;
jade.Log.FACILITY_CONSOLE=1;jade.Log.FACILITY_LOG4JS=2;jade.Log.FACILITY_BROKEN_CONSOLE=3;
jade.Log.DEBUG=0;jade.Log.INFO=1;jade.Log.WARN=2;jade.Log.ERROR=3;jade.Log.level=null;
jade.Log.facility=null;jade.Log.logger=null;jade.Log.print=function(a,e){var c,d,f,b,g,h,j;
if(!e.length){return}switch(this.facility){case this.FACILITY_ALERT:if(a!=this.ERROR){return
}j="";g=e[0];h=0;if(typeof(g)=="string"){h++;b=0;d=0;f=g.length;while(d<f){if(g.charAt(d)=="%"&&"fidos".indexOf(g.charAt(d+1))>=0){j+=g.substring(b,d);
j+=e[h++];d++;b=d+1}d++}j+=g.substring(b,f)}for(d=h;d<e.length;d++){if(j){j+=" "}j+=e[d]
}alert(j);break;case this.FACILITY_LOG4JS:c=[];h=0;g=e[0];if(typeof(g)=="string"){h++;
b=0;d=0;f=g.length;while(d<f){if(g.charAt(d)=="%"&&"fidos".indexOf(g.charAt(d+1))>=0){c.push(g.substring(b,d-1));
c.push(e[h++]);d++;b=d+1}d++}c.push(g.substring(b,f))}for(d=h;d<e.length;d++){c.push(e[d])
}if(a==this.DEBUG){this.logger.debug.apply(this.logger,c)}else{if(a==this.INFO){this.logger.info.apply(this.logger,c)
}else{if(a==this.WARN){this.logger.warn.apply(this.logger,c)}else{this.logger.error.apply(this.logger,c)
}}}break}};jade.Log.log=function(a){this.print(this.DEBUG,arguments)};jade.Log.debug=function(a){this.print(this.DEBUG,arguments)
};jade.Log.info=function(a){this.print(this.INFO,arguments)};jade.Log.warn=function(a){this.print(this.WARN,arguments)
};jade.Log.error=function(a){this.print(this.ERROR,arguments)};jade.Log.init=function(){var b;
if(("console" in window)&&("warn" in window.console)&&("debug" in window.console||"log" in window.console)&&("error" in window.console)&&("info" in window.console)){try{b=console.log;
b();this.facility=this.FACILITY_CONSOLE;this.error=console.error}catch(c){this.facility=this.FACILITY_BROKEN_CONSOLE;
this.error=jade.bind(console.error,console)}}else{if("log4javascript" in window){this.facility=this.FACILITY_LOG4JS;
this.logger=log4javascript.getDefaultLogger()}else{this.facility=this.FACILITY_ALERT
}}this.setLevel(jade.Log.ERROR)};jade.Log.setLevel=function(a){if(this.level!=a){this.level=a;
switch(this.facility){case this.FACILITY_CONSOLE:this.debug=this.isDebugLevel()?console.debug:this.noOp;
if(!this.debug){this.debug=this.isDebugLevel()?console.log:this.noOp}this.info=this.isInfoLevel()?console.info:this.noOp;
this.warn=this.isWarnLevel()?console.warn:this.noOp;break;case this.FACILITY_BROKEN_CONSOLE:this.debug=this.isDebugLevel()?jade.bind(console.debug,console):this.noOp;
this.info=this.isInfoLevel()?jade.bind(console.info,console):this.noOp;this.warn=this.isWarnLevel()?jade.bind(console.warn,console):this.noOp;
break;case this.FACILITY_LOG4JS:if(this.isDebugLevel()){this.logger.setLevel(log4javascript.Level.DEBUG)
}else{if(this.isInfoLevel()){this.logger.setLevel(log4javascript.Level.INFO)}else{if(this.isWarnLevel()){this.logger.setLevel(log4javascript.Level.WARN)
}else{this.logger.setLevel(log4javascript.Level.ERROR)}}}}}if(a==jade.Log.DEBUG){jade.Log.info("Debug logging enabled")
}};jade.Log.noOp=function(){};jade.Log.getLevel=function(){return this.level};jade.Log.isDebugLevel=function(){return this.level==jade.Log.DEBUG
};jade.Log.isInfoLevel=function(){return this.level<=jade.Log.INFO};jade.Log.isWarnLevel=function(){return this.level<=jade.Log.WARN
};jade.Log.init();