//
// Cookie-Handling 
//

function setKekse(names,values,verfall) {
   /* Schreibe cookie, names und values sind Listen, verfall sind Tage */
   path=""
   verfall = verfall*24*60*60*1000
   var now = new Date();
   end = new Date(now.getTime() + verfall);
   anzahl = names.length;
   for (i=0; i<anzahl; i++) {
      if (values[i]) {
        document.cookie = names[i]+"="+escape(values[i])+";expires="+end.toGMTString()+";path="+escape(path);
      }
   }
}

function getKekse(names) {
   /* auslesen des cookies */
   wert = ""
   if (document.cookie) {
      index = document.cookie.indexOf(names);
      if (index != -1) {
            countbegin = (document.cookie.indexOf("=", index) + 1);
            countend = document.cookie.indexOf(";", index);
            if (countend == -1) { countend = document.cookie.length; }
            wert = unescape(document.cookie.substring(countbegin,countend));
      }
    }
    return wert
}

function cleanKekse(names) {
   /*Cookie wird zurueckgesetzt*/
   path = ""
   var now = new Date();
   end = new Date(now.getTime());
   anzahl = names.length;
   for (i=0; i<anzahl; i++) {
      document.cookie = names[i]+"="+escape(" ")+";expires="+end.toGMTString()+";path="+escape(path);
   }
}






function checkSkip(struk_id, ts) {
   kekse = getKekse("skp" + struk_id);
   return (kekse == ts);
};

function saveSkip(struk_id, ts) {

   skip = document.skipform.skip.checked;

   if (skip) {
      setKekse(["skp" + struk_id], [ts], 14);
   } else {
      cleanKekse(["skp" + struk_id]);
   };
};


