function HistoryStack()
{this.stack=new Array();this.current=-1;this.stack_limit=15;}
HistoryStack.prototype.getCurrent=function()
{return this.stack[this.current];};HistoryStack.prototype.addResource=function(resource)
{if(this.stack.length>0){this.stack=this.stack.slice(0,this.current+1);}
this.stack.push(resource);while(this.stack.length>this.stack_limit){this.stack.shift();}
this.current=this.stack.length-1;this.save();};HistoryStack.prototype.go=function(increment)
{if(increment<0){this.current=Math.max(0,this.current+increment);}else if(increment>0){this.current=Math.min(this.stack.length-1,this.current+increment);}else{location.reload();}
this.save();};HistoryStack.prototype.hasPrev=function()
{return(this.current>0);};HistoryStack.prototype.hasNext=function()
{return(this.current<this.stack.length-1
&&this.current>-1);};HistoryStack.prototype.save=function()
{this.setCookie('CHStack',this.stack.toString());this.setCookie('CHCurrent',this.current);};HistoryStack.prototype.load=function()
{var tmp_stack=this.getCookie('CHStack');if(tmp_stack!=''){this.stack=tmp_stack.split(',');}
var tmp_current=parseInt(this.getCookie('CHCurrent'));if(tmp_current>=-1){this.current=tmp_current;}};HistoryStack.prototype.setCookie=function(name,value)
{document.cookie="oldpage="+escape(HistoryStack.prototype.getCookie('page'));var cookie_str=name+"="+value;document.cookie=cookie_str;};HistoryStack.prototype.setCookieRegister=function(name,value)
{var expires=14*1000*60*60*24;var today=new Date();today.setTime(today.getTime());var expires_date=new Date(today.getTime()+(expires));var cookie_str=name+"="+value+";expires="+expires_date.toGMTString()+";";document.cookie=cookie_str;};HistoryStack.prototype.getCookie=function(name)
{if(!name)return'';var raw_cookies,tmp,i;var cookies=new Array();raw_cookies=document.cookie.split('; ');for(i=0;i<raw_cookies.length;i++){tmp=raw_cookies[i].split('=');cookies[tmp[0]]=unescape(tmp[1]);}
if(cookies[name]!=null){return cookies[name];}else{return'';}};HistoryStack.prototype.getCookieRegister=function(name)
{if(!name)return'';var raw_cookies,tmp,i;var cookies=new Array();raw_cookies=document.cookie.split('; ');for(i=0;i<raw_cookies.length;i++){tmp=raw_cookies[i].split('=');cookies[tmp[0]]=unescape(tmp[1]);}
if(cookies[name]!=null){return cookies[name];}else{return'';}};
