// diet exhibition
// ====================
// save works in cookie
// (c) pch : Fre Mär 28 00:23:54 CET 2003
//           Fre Aug 20 13:27:22 CEST 2004

var cookie_path = "/";
var cookie_html = "/cookies.html"

// display cookie
function anzeigen () {
	var show = readCookie("show");
	alert(show);
}

// delete cookie
function loeschen () {
	deleteCookie("show");
}

// call from button to add order to cookie
function ausstellen (werk) {
	var show = readCookie("show");
	if (show.length)
		createCookie("show", show + ',' + werk);
	else
		createCookie("show", werk);
	checkCookie("show");
}

// Cookies
// =======

// fetch cookie
function readCookie (name) {
	var search = name + "=";
	// are there any ?
	if (document.cookie.length <= 0) return "";
	offset = document.cookie.indexOf(search);
	// is ours there ?
	if (offset < 0) return "";
	offset += search.length;
	end = document.cookie.indexOf(";", offset);
	if (end == -1) end = document.cookie.length;
	return unescape (document.cookie.substring(offset, end));
}

// set cookie
function createCookie (name, value, days) {
	var expires = "";
	if (days) {
		var date = new Date();
		date.setTime(date.getTime () + (days * 24 * 60 * 60 * 1000));
		expires = "; expires=" + date.toGMTString ();
	}
	document.cookie = name + "=" + escape(value)
		+ expires + "; path=" + cookie_path + ";";
}

// delete cookie
function deleteCookie (name) {
	var value = "";
	var exp = new Date(0);
	document.cookie = name + "=" + escape (value)
		+ "; expires=" + exp.toGMTString()
		+ "; path=" + cookie_path + ";";
}


// if cookies disabled send user to warning page
function checkCookie (name) {
	if (document.cookie.indexOf(name) < 0)
		window.location.href = cookie_html;
}

// display whether cookies are enabled
function testCookies () {
	createCookie("cookies", "ja");
	if (document.cookie.indexOf("cookies") >= 0)
		document.getElementById("cookies").firstChild.nodeValue
			= "aktiviert";
	deleteCookie("cookies");
}
