/*
* AJAXCache 1.0
*
* (c) 2007 Jaroslaw Kostrz
* e-mail: jkostrz@gmail.com
* www:  http://ajaxcache.ajaxin.pl/
*       http://ajaxin.pl/
* http://creativecommons.org/licenses/by/2.5/pl/
* W przypadku użycia komercyjnego proszę o informację o tym fakcie.
* In case of commercial use please inform me about that fact.
*/
function AJAXCache(){this.g=[];this._g=function(id){for(var i=this.g.length-1;i>=0;i--){if(this.g[i][0]==id)return i;};return -1;};this._n=function(){return this.g.length;};this._a=function(i,id,t,o){if(!o)o={};if(o.ttl){var to=new Date(new Date().getTime()+o.ttl*1000).getTime();var x=this;setTimeout(function(){x.remove(i)},o.ttl*1000);};this.g[i]=[id,t,to];};this.save=function(id,t,o){var i=this._g(id);if(i>=0){if(this._e(i)||o.overwrite){this._a(i,id,t,o);}}else{this._a(this._n(),id,t,o);}};this.get=function(id){var i=this._g(id);if(i<0||this._e(i)){return 0;}else{return this.g[i][1];}};this.remove=function(i){if(this.g[i])this.g[i].splice(0,2);};this.flush=function(){this.g.splice(0,2);};this._e=function(i){var n=new Date().getTime();if(!this.g[i][2]||(this.g[i][2]-n)>0){return 0;};return 1;};}