var xhtml = false;
if (document.contentType && document.contentType == "application/xhtml+xml") {
	// document.documentElement.namespaceURI == "http://www.w3.org/1999/xhtml"
	xhtml = true;
}

function setCookie (name, value, domain, expires, path, secure) {
	var today = new Date();
	today.setTime(today.getTime());
	if (expires) {
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date(today.getTime() + expires);
	var cookie = name + "=" + encodeURIComponent(value);
	if (expires)
		 cookie += "; expires=" + expires_date.toGMTString();
	if (path)
		cookie += "; path=" + path;
	if (domain)
		cookie += "; domain=" + domain;
	if (secure)
		cookie += ";secure";
	document.cookie = cookie;
}
function getCookie (name) {
	var name_index = document.cookie.indexOf(name + "=");
	if (name_index == -1)
		return null;
	var value_index = name_index + name.length + 1;
	var end = document.cookie.indexOf(";", value_index);
	if (end == -1)
		end = document.cookie.length;
	var value = decodeURIComponent(document.cookie.substring(value_index, end));
	return value;
}
function deleteCookie (name, domain, path) {
	if (getCookie(name)) {
		var cookie = name + "=";
		if (path)
			cookie += "; path=" + path;
		if (domain)
			cookie += "; domain=" + domain;
		cookie += "; expires=Thu, 01-Jan-1970 00:00:01 GMT";
		document.cookie = cookie;
	}
}

function schriftgroesse_setzen () {
	window.fontsize = Number(getCookie("fontsize"));
	if (window.fontsize && !xhtml) {
		document.write('<style type="text/css">body {font-size: ' + window.fontsize + '%;}</style>');
	} else {
		window.fontsize = 85;
	}
}
schriftgroesse_setzen();

function  schrift_verkleinern () {
	//if (window.fontsize > 60)
		window.fontsize -= 10;
	document.body.style.fontSize = window.fontsize + "%";
	setCookie("fontsize", window.fontsize);
}
function schrift_vergroessern () {
	//if (window.fontsize < 300)
		window.fontsize += 10;
	document.body.style.fontSize = window.fontsize + "%";
	setCookie("fontsize", window.fontsize);
}
function schriftgroessenwahl () {
	if (xhtml) {
		document.body.style.fontSize = window.fontsize + "%";
	}
	var container = document.createElement("div");
	if (!container)
		return;
	container.id = "schriftgroesse";
	container.appendChild(document.createTextNode("Schrift: "));
	var groesser_element = document.createElement("a");
	groesser_element.href = "javascript:schrift_vergroessern()";
	groesser_element.title = "Schrift vergrößern";
	groesser_element.appendChild(document.createTextNode("+ vergrößern"));
	container.appendChild(groesser_element);
	container.appendChild(document.createTextNode(" "));
	var kleiner_element = document.createElement("a");
	kleiner_element.appendChild(document.createTextNode("- verkleinern"));
	kleiner_element.href = "javascript:schrift_verkleinern()";
	kleiner_element.title = "Schrift verkleinern";
	container.appendChild(kleiner_element);
	document.body.insertBefore(container, document.getElementById("navibox"));
}



/* ----------------------------------------------------------------------- */
/* Es folgt Code zur Darstellung der Umfrage auf der Seite stadt-kassel.de */

function toggleVisibility(id, NNtype, IEtype, WC3type) {
    if (document.getElementById) {
        eval("document.getElementById(id).style.visibility = \"" + WC3type + "\"");
    } else {
        if (document.layers) {
            document.layers[id].visibility = NNtype;
        } else {
            if (document.all) {
                eval("document.all." + id + ".style.visibility = \"" + IEtype + "\"");
            }
        }
    }
}

function setCookie(name, value, Days, path) {
	var expires = new Date()
    expires.setTime(expires.getTime() + 1000*60*60*24*Days);
    document.cookie = name + "=" + escape(value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path))
	}

function getCookie(name) {
	var search = name + "="

	if (document.cookie.length > 0) {
		offset = document.cookie.indexOf(search)

		if (offset != -1) {
			offset += search.length
			end = document.cookie.indexOf(";", offset)

			if (end == -1) {
				end = document.cookie.length
			}

			return unescape(document.cookie.substring(offset, end))
		}
	}
}

function itestKysely() {
    var iTest_cookie = getCookie("kassel");

    //setCookie after one check.
    setCookie("kassel", "True", 120, "/");
        //show kysely if it hasn't been shown
    //Added test to do kysely to only 100% of the visitors
    if (iTest_cookie == null && (Math.random()<1)) {
		code = "<div id=itestLayer style='position:absolute; left:200px; top:80px; width:460px; height:250px; z-index:100'>";
		code += "<table width='100%' border=0 cellspacing=0 cellpadding=0>";
		code += "<tr valign=top><td width=17% height=201>";
		code += "<div align=left><img src='http://www.awed.de/Umfrage/kassel.jpg' width=460 height=250 border=0 usemap=#itestMap>";
		code += "<map name=itestMap>";
		code += "<area shape=rect coords='379,15,447,29' href=# onClick=toggleVisibility('itestLayer','hidden','hidden','hidden')>";
		code += "<area shape=rect coords='269,192,379,222' href=# onClick=toggleVisibility('itestLayer','hidden','hidden','hidden')>";
		code += "<area shape=rect coords='79,192,189,222' href=http://digiumenterprise.com/answer/?sid=262505&chk=QAJ444BK";
		code += " target=_blank onClick=toggleVisibility('itestLayer','hidden','hidden','hidden')>";
		code += "<\/map><\/div><\/td><\/tr><\/table><\/div>";
		return code;
	}
	 else {
		code = "";
		return code;
	}
}

