function setCookie(name, wert, domain, expires, path, secure){
   var cook = name + "=" + unescape(wert)
   cook += (domain) ? "; domain="+ domain : ""
   cook += (expires) ? "; expires="+expires : ""
   cook += (path) ? "; path="+path : ""
   cook += (secure) ? "; secure" : ""
   document.cookie = cook
}

function eraseCookie(name, domain, path){
   var cook="name=; expires=Thu, 01-Jan-70 00:00:01 GMT"
   cook += (domain) ? "domain="+domain : ""
   cook += (path) ? "path="+path : ""
   document.cookie = cook
}

function getCookie(name){
   var i=0  //Suchposition im Cookie
   var suche = name+"="
   while (i<document.cookie.length){
      if (document.cookie.substring(i, i+suche.length)==suche){
         var ende = document.cookie.indexOf(";", i+suche.length)
         ende = (ende>-1) ? ende : document.cookie.length
         var cook = document.cookie.substring(i+suche.length, ende)
         return unescape(cook)
      }
      i++
   }
   return ""
}

function hinzu(produkt) {
   
   //var anz = (istZahl(f) ? f : "0")
   var liste = getCookie("WARENLIT") + produkt + "|"
   
   var datum= new Date()
   var eineWoche = datum.getTime() + (7 * 24 * 60 * 60 * 1000)
   datum.setTime(eineWoche)
   
   setCookie("WARENLIT", liste,"",datum.toGMTString())
   
   if (!document.cookie)
      alert("Aktivieren Sie Cookies in Ihrem Browser!")
   else
      alert("Das Produkt befindet sich in Ihrem Warenkorb!")
}

function listeloeschen() {
   
   setCookie("WARENLIT","","","Thu, 01-Jan-70 00:00:01 GMT")
   if (!document.cookie){
      warenkorb();
      
      	var datum= new Date()
   		var eineWoche = datum.getTime() + (7 * 24 * 60 * 60 * 1000);
   		datum.setTime(eineWoche);
        var ran= Math.random()*10000000000;
   		ran=Math.round(ran)
        setCookie("WARENLIT", ran,"",datum.toGMTString());
      }
   else
      alert("Lieder konnete Ihre Liste nicht gelöscht werden")
}

function cookiesetzen(inh){

   var datum= new Date()
   var eineWoche = datum.getTime() + (7 * 24 * 60 * 60 * 1000)
   datum.setTime(eineWoche)
   
   setCookie("WARENLIT", inh,".liturgie.de",datum.toGMTString())
   
   if (!document.cookie)
      alert("Aktivieren Sie Cookies in Ihrem Browser!")
   //else
      //alert("OK")
}
	