/* (c) 2009 allesklar.com */
var ak;if(!ak)ak={};ak.namespace=function(ns){var o=null;var d=ns.split(".");var rt=d[0];eval('if (typeof '+rt+' == "undefined"){'+rt+' = {};} o = '+rt+';');for(var i=1;i<d.length;++i){o[d[i]]=o[d[i]]||{};o=o[d[i]];}};
ak.namespace("ak.utils");ak.utils.StopWatch=Class.create({initialize:function()
{this.reset();},lap:function(lapName)
{var now=new Date().getTime();var lapTime=now-this.lapStart;this.lapStart=now;this.lapTimes.push({name:lapName,duration:lapTime});return lapTime;},duration:function(lapName)
{if(lapName)
{var lapTimes=this.lapTimes;for(var i in lapTimes)
{if(lapTimes[i].name==lapName)
{return lapTimes[i].duration;}}
return null;}
else
{var now=new Date().getTime();return now-this.startTime;}},getAllLaps:function()
{return this.lapTimes;},reset:function()
{this.startTime=new Date().getTime();this.lapStart=this.startTime;this.lapTimes=[];},toString:function()
{return this.duration();}});
ak.namespace("ak.utils");ak.utils.RingBuffer=Class.create(Enumerable,{initialize:function(maxSize)
{this.clear();this.maxSize=Object.isUndefined(maxSize)?100:maxSize;if(maxSize==0)
{this.append=function(){};}},append:function(object)
{this.buffer[this.pos++]=object;if(this.pos>=this.maxSize)
{this.pos=0;}},clear:function()
{this.buffer=[];this.pos=0;},_each:function(iterator)
{if(this.buffer.length<this.maxSize)
{for(var i1=0,length1=this.buffer.length;i1<length1;i1++)
{iterator(this.buffer[i1]);}}
else
{for(var i2=0,length2=this.maxSize;i2<length2;i2++)
{iterator(this.buffer[(i2+this.pos)%this.maxSize]);}}},toString:function()
{return"["+this.buffer.toString()+"], pos: "+this.pos;}});
ak.namespace("ak.utils");ak.utils.Queue=Class.create(Enumerable,{initialize:function()
{this.buffer=[];},clear:function()
{this.buffer=[];},isEmpty:function()
{return this.buffer.length==0;},enqueue:function(object)
{this.buffer.push(object);},dequeue:function()
{return this.buffer.shift();},_each:function(iterator)
{for(var i=0,length=this.buffer.length;i<length;i++)
{iterator(this.buffer[i]);}},toString:function()
{return"["+this.buffer.toString()+"]";},remove:function(index)
{delete this.buffer[index];this.buffer=this.buffer.compact();},removeObject:function(element){var index=this.buffer.indexOf(element);this.remove(index);},removeAll:function(predicate)
{for(var i=0,length=this.buffer.length;i<length;i++)
{if(predicate(this.buffer[i]))
{this.buffer[i]=undefined;}}
this.buffer=this.buffer.compact();}});
ak.namespace("ak.utils");ak.utils.string={shorten:function(string,maxLength,postfix,wordbreak){if(string.length<=maxLength)return string;postfix=postfix||'';maxLength-=postfix.length;if(wordbreak===false){string=string.substring(0,maxLength+1);var pos=string.lastIndexOf(' ');if(pos!==-1)maxLength=pos;}
return string.substring(0,maxLength)+postfix;},unHtmlSpecialChar:function(string){string=string.replace(/&amp;/g,"&");string=string.replace(/&szlig;/g,"\xDF");string=string.replace(/&uuml;/g,"\xFC");string=string.replace(/&Uuml;/g,"\xDC");string=string.replace(/&ouml;/g,"\xF6");string=string.replace(/&Ouml;/g,"\xD6");string=string.replace(/&auml;/g,"\xE4");string=string.replace(/&Auml;/g,"\xC4");string=string.replace(/&bdquo;/g,"\"");string=string.replace(/&ldquo;/g,"\"");string=string.replace(/&quot;/g,"'");string=string.replace(/&#223;/g,"\xDF");string=string.replace(/&#252;/g,"\xFC");string=string.replace(/&#220;/g,"\xFC");string=string.replace(/&#246;/g,"\xF6");string=string.replace(/&#214;/g,"\xD6");string=string.replace(/&#228;/g,"\xE4");string=string.replace(/&#196;/g,"\xC4");string=string.replace(/&#224;/g,"\xE0");string=string.replace(/&#8364;/g,"\u20AC");return string;}};
