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="+secure : ""
   document.cookie = cook
}

function eraseCookie(name, domain, path){
var ProduktAnzahl = 0;
   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 checkCookie(){
   setCookie("CookieTest", "OK")
   if (!getCookie("CookieTest"))
      return false
   else{
      eraseCookie("CookieTest")
      return true
   }
}

function einfuegen(pid, deeplink, bild, titel, preis){
  var ipid = getCookie("PID") + pid + "|"
  var ideeplink = getCookie("Deeplink") + deeplink + "|"
  var ibild = getCookie("Bild") + bild + "|"
  var ititel = getCookie("Titel") + titel + "|"
  var ipreis = getCookie("Preis") + preis + "|"
  setCookie("PID", ipid,"","Thu, 01-Jan-15 00:00:01 GMT","/")
  setCookie("Deeplink", ideeplink,"","Thu, 01-Jan-15 00:00:01 GMT","/")
  setCookie("Bild", ibild,"","Thu, 01-Jan-15 00:00:01 GMT","/")
  setCookie("Titel", ititel,"","Thu, 01-Jan-15 00:00:01 GMT","/")
  setCookie("Preis", ipreis,"","Thu, 01-Jan-15 00:00:01 GMT","/")
   if (!document.cookie)
     alert("Aktivieren Sie Cookies in Ihrem Browser!")
   else
  {
    alert("Artikel in Merkliste eingetragen - die Seite wird aktualisiert")
	window.location.reload();
  }
}

function menge() {
var ipid = getCookie("PID") 
var ProduktAnzahl = 0
ipid.replace(/\|/g, function () {
   ProduktAnzahl++;
});
 document.write(ProduktAnzahl);
}
