/**
 * JStt (JavaScript tiny toolkit) v1.2.4
 * http://jstt.sourceforge.net/
 *
 * Copyright (c) 2009 Marc-Oliver Stühmer <marc-oliver@stuehmer.info>
 * Licensed under the MIT License.
 */
JStt=(function()
{var ver='1.2.4';return{BASE_URL:'jstt/',DEBUG:false,PROTOTYPING:false,core:{},error:{},data:{},event:{},util:{},ui:{},require:function(name,func)
{var mname=name;if(mname.search(/\./)==-1){mname='base.'+mname;}
mname='inc.'+mname;JStt.core.ScriptLoader.load(JStt.BASE_URL+mname.replace(/\./g,'/')+'.js',{func:function(name){if(JStt.PROTOTYPING&&JStt[name]&&typeof JStt[name].proto=='function'){if(JStt.DEBUG&&typeof console!='undefined'){console.info('Calling proto() function of JStt.'+name);}
JStt[name].proto();}},params:[name]},true);if(func){JStt.core.ScriptLoader.addPostLoadFunction(func);}},ready:function(func)
{JStt.core.ScriptLoader.addPostLoadFunction(func,true);},load:function(urls,func,hp)
{JStt.core.ScriptLoader.load(urls,func,hp);},$:function(id)
{return document.getElementById(id);},getVersion:function()
{return ver;}};})();JStt.core.ScriptLoader=(function()
{var stack=[];var hpstack=[];var loaded=[];var plfuncs=[];var processing=false;var loadNext=function()
{var lstack=hpstack.length>0?hpstack:stack;if(lstack.length>0){var url=lstack.shift();if(url!=null&&!JStt.core.ScriptLoader.isLoaded(url)){if(JStt.DEBUG&&typeof console!='undefined'){var msg='loading: '+url;(console.group?console.group(msg):console.log(msg));}
loaded.push(url);var script=document.createElement('script');script.onload=handleLoad;if(navigator.userAgent.indexOf('Opera')==-1){script.onreadystatechange=handleLoad;}
script.type='text/javascript';script.src=url;document.getElementsByTagName('head')[0].appendChild(script);}else{loadNext();}}else if(plfuncs.length>0){var func=plfuncs.shift();var fn=func.func;var params=func.params==null?[]:func.params;var scope=func.scope===undefined?null:func.scope;fn.apply(scope,params);loadNext();}else{processing=false;}};var handleLoad=function(ev)
{if(ev||this.readyState=='loaded'||this.readyState=='complete'){if(JStt.DEBUG&&typeof console!='undefined'){console.info('loaded: '+this.src);(console.groupEnd&&console.groupEnd());}
loadNext();}};return{load:function(urls,func,hp)
{func=typeof func=='function'?{func:func}:func;hp=hp==null?false:hp;if(typeof urls=='string'){urls=[urls];}
if(!JStt.object.isArray(urls)){throw new TypeError('\'urls\' parameter must be Array or String');}
if(hp){hpstack=urls.concat(hpstack);}else{stack=urls.concat(stack);}
if(func&&typeof func.func=='function'){plfuncs.unshift(func);}else if(func!=null){throw new TypeError('Invalid \'func\' parameter given: '+func);}
if(!processing){processing=true;loadNext();}},addPostLoadFunction:function(func,at_end)
{func=typeof func=='function'?{func:func}:func;at_end=at_end==null?false:at_end;if(at_end){plfuncs.push(func);}else{plfuncs.unshift(func);}
if(!processing){processing=true;loadNext();}},isLoaded:function(url)
{for(var i=0;i<loaded.length;i++){if(loaded[i]==url){return true;}}
return false;}};})();JStt.object={extend:function(child,parent)
{var Obj=new Function();Obj.prototype=parent.prototype;child.prototype=new Obj();child.prototype.constructor=child;},clone:function(object,deep)
{deep=deep==null?false:deep;if(JStt.object.isArray(object)){if(deep){var array=[];for(var i=0;i<object.length;i++){array[i]=JStt.object.clone(object[i],true);}
return array;}
return object.slice(0);}
if(object==null||typeof object!='object'){return object;}
if(typeof object.clone!='function'){var retobj={};for(var k in object){if(object.hasOwnProperty(k)){if(deep){retobj[k]=JStt.object.clone(object[k],true);}else{retobj[k]=object[k];}}}
return retobj;}
return object.clone(deep);},serialize:function(value)
{if(value===null){return'N;';}
if(JStt.object.isArray(value)){var astr='a:'+value.length+':{';for(var i=0;i<value.length;i++){astr+=JStt.object.serialize(i)+JStt.object.serialize(value[i]);}
return astr+'}';}
if(typeof value=='number'){if(Math.floor(value)==value){return'i:'+value+';';}
return'd:'+value+';';}
if(typeof value=='string'){return's:'+value.length+':"'+value+'";';}
if(typeof value=='boolean'){return'b:'+Number(value)+';';}
if(typeof value=='object'){if(typeof value.serialize=='function'){return value.serialize();}
var len=0;var ostr='';var name=typeof value.getClassName=='function'?value.getClassName().replace(/\./g,'__'):'Object';for(var k in value){if(value.hasOwnProperty(k)&&typeof value[k]!='function'){ostr+=JStt.object.serialize(k)+JStt.object.serialize(value[k]);len++;}}
return'O:'+name.length+':"'+name+'":'+len+':{'+ostr+'}';}
throw new TypeError('Could not serialize value: '+value);},unserialize:function(string)
{var unser=function(serialized)
{var readLength=function(str)
{return Number(str.substring(2,str.indexOf(':',2)));};var len,tail;var type=serialized.charAt(0);switch(type){case'N':return[null,serialized.substr(2)];case'a':len=readLength(serialized);tail=serialized.substr(serialized.indexOf(':',2)+2);var arr=[];var index,val;for(var i=0;i<len;i++){index=unser(tail);tail=index[1];val=unser(tail);tail=val[1];arr[index[0]]=val[0];}
tail=tail.substr(1);return[arr,tail];case'i':case'd':var num=Number(serialized.substring(2,serialized.indexOf(';')));tail=serialized.substr(serialized.indexOf(';')+1);return[num,tail];case's':len=readLength(serialized);var start=serialized.indexOf(':',2)+2;var str=serialized.substr(start,len);tail=serialized.substr(start+len+2);return[str,tail];case'b':var bool=Boolean(Number(serialized.substr(2,1)));tail=serialized.substr(4);return[bool,tail];case'O':len=readLength(serialized);var name=serialized.substr(serialized.indexOf(':',2)+2,len).replace(/__/g,'.');tail=serialized.substr(serialized.indexOf(':',2)+2+len);len=readLength(tail);tail=tail.substr(len.toString().length+4);var obj=eval('new '+name+'()');var key,value,func;for(var j=0;j<len;j++){key=unser(tail);tail=key[1];value=unser(tail);tail=value[1];if(key[0].indexOf('\0')!=-1){key[0]=key[0].replace(/\x00.*\x00/,'');func='_set'+key[0].substr(0,1).toUpperCase()+key[0].substr(1);try{obj[func](value[0]);}catch(e){throw new TypeError(name+'.'+func+'() must be implemented');}}else{obj[key[0]]=value[0];}}
tail=tail.substr(1);return[obj,tail];default:throw new TypeError('Could not unserialize string: '+serialized);}};return unser(string)[0];},isSimpleType:function(value)
{return value===null||typeof value=='string'||(typeof value=='number'&&isFinite(value))||typeof value=='boolean';},isNumeric:function(value)
{return value!=null&&typeof value!='boolean'&&value!==''&&!JStt.object.isArray(value)&&isFinite(value);},isArray:function(value)
{return JStt.object.getTypeOf(value)=='array';},getTypeOf:(function()
{var whitelist={'boolean':true,'number':true,'string':true,'array':true,'function':true,'date':true,'error':true,'regexp':true,'object':true};return(function(value){if(value===undefined){return'undefined';}
if(value===null){return'null';}
if(typeof value.getTypeOf=='function'){return value.getTypeOf();}
var type=Object.prototype.toString.call(value).replace(/\[object ([^\]]*)\]/,'$1').toLowerCase();return whitelist.hasOwnProperty(type)?type:'object';});})()};JStt.obj=JStt.object;JStt.error.InvalidArgumentError=function(message)
{this.message=message;this.name='InvalidArgumentError';this.getTypeOf=function()
{return'error';};};JStt.object.extend(JStt.error.InvalidArgumentError,Error);
