/*Author: Oliver Steele Copyright: Copyright 2006 Oliver Steele.  All rights reserved. Homepage: http://osteele.com/sources/javascript/ */
try{if(!Readable)throw"undefined"}catch(e){var Readable={};}
Readable.defaults={length:50,level:5,stringLength:50,omitInstanceFunctions:true};Readable.toReadable=function(value,options){if(value==null||value==undefined)
return String(value);if(value.constructor&&typeof value.constructor.toReadable=='function')
return value.constructor.toReadable.apply(value,[options]);return Object.toReadable.apply(value,[options]);try{typeof value.toReadable=='function'}catch(e){return'y'}
return'x';if(typeof value.toReadable=='function')return value.toReadable(options);if(typeof value.toString=='function')return value.toString();return'<value>';};Readable.charEncodingTable={'\r':'\\r','\n':'\\n','\t':'\\t','\f':'\\f','\b':'\\b'};String.toReadable=function(options){if(options==undefined)options=Readable.defaults;var string=this;var length=options.stringLength;if(length&&string.length>length)
string=string.slice(0,length)+'...';string=string.replace(/\\/g,'\\\\');for(var c in Readable.charEncodingTable)
string=string.replace(c,Readable.charEncodingTable[c],'g');if(string.match(/\'/)&&!string.match(/\"/))
return'"'+string+'"';else
return"'"+string.replace(/\'/g,'\\\'')+"'";};Readable.objectToString=Object.toString;Readable.elementToString=function(options){if(this==document)return'document';var s=this.tagName.toLowerCase();var parent=this.parentNode;if(this.id){try{if(typeof $=='function')return"$('"+this.id+"')"}
catch(e){}
s+='#'+this.id;}else if(this.className)
s+='.'+this.className.replace(/\s.*/,'');if(parent){var index,count=0;for(var sibling=this.parentNode.firstChild;sibling;sibling=sibling.nextSibling){if(this.tagName==sibling.tagName)
count++;if(this==sibling)
index=count;}
if(count>1)
s+='['+index+']';s=(parent==document?'':arguments.callee.apply(parent,[options]))+'/'+s;}
return s;};Readable.globals={'Math':Math};try{Readable.globals['document']=document;Readable.globals['window']=window;}catch(e){}
Object.toReadable=function(options){if(options==undefined)options=Readable.defaults;for(var name in Readable.globals)
if(Readable.globals[name]===this)
return name;if(this.constructor==Number||this.constructor==Boolean||this.constructor==RegExp||this.constructor==Error||this.constructor==String)
return this.toString();if(this.parentNode)try{return Readable.elementToString.apply(this,[options])}catch(e){}
var level=options.level;var length=options.length;if(level==0)length=0;if(level)options.level--;var omitFunctions=options.omitFunctions;var segments=[];var cname=null;var delim='{}';if(this.constructor&&this.constructor!=Object){var cstring=this.constructor.toString();var m=cstring.match(/function\s+(\w+)/);if(!m)m=cstring.match(/^\[object\s+(\w+)\]$/);if(!m)m=cstring.match(/^\[(\w+)\]$/);if(m)cname=m[1];}
if(cname){segments.push(cname);delim='()';omitFunctions=options.omitInstanceFunctions;}
segments.push(delim.charAt(0));var count=0;for(var p in this){var value;try{value=this[p]}catch(e){continue}
try{if(value==this.__proto__[p])continue}catch(e){}
if(typeof value=='function'&&omitFunctions)continue;if(count++)segments.push(', ');if(length>=0&&count>length){segments.push('...');break;}
segments.push(p.toString());segments.push(': ');segments.push(Readable.toReadable(value,options));}
if(level)options.level=level;return segments.join('')+delim.charAt(1);};Array.toReadable=function(options){if(options==undefined)options=Readable.defaults;var level=options.level;var length=options.length;if(level==0)return'[...]';if(level)options.level--;var segments=[];for(var i=0;i<this.length;i++){if(length>=0&&i>=length){segments.push('...');break;}
segments.push(Readable.toReadable(this[i],options));}
if(level)options.level=level;return'['+segments.join(', ')+']';};Function.toReadable=function(options){if(options==undefined)options=Readable.defaults;var string=this.toString();if(!options.printFunctions){var match=string.match(/(function\s+\w*)/);if(match)
string=match[1]+'() {...}';}
return string;};try{if(!READABLE_TOSTRING)throw"break";}catch(e){READABLE_TOSTRING=false;Object.prototype.toString=function(){return Object.toReadable.apply(this)}
Array.prototype.toString=Array.toReadable;}
var ReadableLogger={};ReadableLogger.defaults={length:10,stringLength:50,level:2,omitInstanceFunctions:true};ReadableLogger.display=(function(){try{if(typeof alert=='function')return alert}catch(e){}
try{if(typeof print=='function')return print}catch(e){}
return function(){};})();ReadableLogger.log=(function(){try{var loggers={debug:debug,info:info,warn:warn,error:error};for(var i in loggers)
if(typeof loggers[i]!='function')
throw'break';return function(level,message){loggers[level](message)};}catch(e){return function(level,message){ReadableLogger.display(level+': '+message);}}})();ReadableLogger.logValues=function(level,args){var segments=[];for(var i=0;i<args.length;i++){var value=args[i];if(typeof value!='string')
value=Readable.toReadable(value,ReadableLogger.defaults);segments.push(value);}
var msg=segments.join(', ');ReadableLogger.log(level,msg);};info=function(){ReadableLogger.logValues('info',arguments)}
warn=function(){ReadableLogger.logValues('warn',arguments)}
debug=function(){ReadableLogger.logValues('debug',arguments)}
error=function(){ReadableLogger.logValues('error',arguments)}
