function Cookie(document, name, min, path, domain, secure){
  this.$document=document;
  this.$name=name;
  if(min){
    this.$expires=new Date((new Date()).getTime() + min*60*1000);
  }else{
    this.$expires=null;
  }
  if(path){
    this.$path=path;
  }else{
    this.$path=null;
  }
  if(domain){
    this.$domain=domain;
  }else{
    this.$domain=null;
  }
  if(secure){
    this.$secure=true;
  }else{
    this.$secure=false;
  }
}

Cookie.prototype.debug=function(text){
  alert('CookieDebug - (' + text + ')' + this.$document.cookie);
}

Cookie.prototype.save=function(){
  var cookieVals='';
  for(var prop in this){
    if(prop.charAt(0)=='$' || ((typeof this[prop])=='function')){
      continue;
    }
    if(cookieVals!=''){
      cookieVals+='&';
    }
    cookieVals+=prop+':'+escape(this[prop]);
  }

  var cookie=this.$name+'='+cookieVals;
  if(this.$expires){
    cookie+='; expires='+this.$expires.toGMTString();
  }
  if(this.$path){
    cookie+='; path='+this.$path;
  }
  if(this.$domain){
    cookie+='; domain='+this.$domain;
  }
  if(this.$secure){
    cookie+='; secure';
  }
  this.$document.cookie=cookie;
}

Cookie.prototype.load=function(debug){
  var allCookies=this.$document.cookie;
  if(allCookies==''){
    return false;
  }

  var start=allCookies.indexOf(this.$name+'=');
  if(start==-1){
    return false;
  }
  start+=this.$name.length+1; //+1 = rovnitko
  var end=allCookies.indexOf(';', start);
  if(end==-1){
    end=allCookies.length;
  }
  var cookieVals=allCookies.substring(start, end);
  if(debug) alert(cookieVals);
  var arrayCookieVals=cookieVals.split('&');
  for(var i=0; i<arrayCookieVals.length; i++){
    x=arrayCookieVals[i].split(':');
    this[x[0]]=unescape(x[1]);
  }
  return true;
}

Cookie.prototype.del=function(){
  var cookie;
  for(var prop in this){
    if(prop.charAt(0)=='$' || ((typeof this[prop])=='function')){
      continue;
    }
    this[prop]=null;
  }
    
  cookie=this.$name+'=';
  if(this.$path){
    cookie+='; path='+this.$path;
  }
  if(this.$domain){
    cookie+='; domain='+this.$domain;
  }
  cookie+='; expires=Fri, 02-Jan-1970 00:00:00 GMT';
  this.$document.cookie=cookie;
}

cookUSL=new Cookie(document, 'USL', (60*24*365));
cookUSL.load(false);

if(!cookUSL.selSection){
  cookUSL.selSection='idSecHelp';
}
