cookieName = "dbv_treffpunkt_mva";
cookieHoursMax = 4800;
testValue = "xxxtestxxx";
cookieDomain = ".treffpunkt-bibliothek.de";
//cookieDomain = ".3pc.de";

function handle_cookie(newValue, toAdd, toReload) {
	var cookieHours = (new Date((new Date()).getTime() + cookieHoursMax * 3600000)).toGMTString();
	var saveValue = read_cookie();
	newValue = "|" + newValue + "|";
	if (toAdd < 0) {
	 saveValue = saveValue.split(newValue).join("");
	} else if (toAdd > 0) {
	 if (saveValue.indexOf(newValue) == -1) {
	   saveValue = saveValue + newValue;
	 }
	}
	set_cookie(cookieName, saveValue, cookieHours);
	return (toReload == 1) ? true : false;
}

function read_cookie() {
	var returnValue = "";
  if (document.cookie != "") {
		var firstChar, lastChar;
		var theCookie = document.cookie;
		firstChar = theCookie.indexOf(cookieName + "=");
		if (firstChar != -1) {
			firstChar = cookieName.length + 1;
			lastChar = theCookie.indexOf(";", firstChar);
			if (lastChar == -1) lastChar = theCookie.length;
			returnValue += theCookie.substring(firstChar, lastChar);
		}
  }
	return returnValue;
}

function set_cookie(cookieName, cookieValue, cookieHours) {
	document.cookie = cookieName + "=" + cookieValue + ";domain=" + cookieDomain + ";expires=" + cookieHours + ";path=/";
}

function do_the_memo(id, to_add) {
    handle_cookie(id, to_add, 0);
    document.va_suche.va_cookie.value = read_cookie();
    showVA(id);
}

function can_set_cookies() {
    handle_cookie(testValue, 1, 0);
    cookieValue_test = read_cookie();
    if (cookieValue_test == ("|" + testValue + "|")) {
      handle_cookie(testValue, -1, 0);
      return true;
    } else {
      return false;
    }
}

