function merke(raumname_pur, bild_titel, request_base, bildid) {
	var bname = raumname_pur;
	bname = bname.replace(/\+/g, " ");
	var old_value = getCookie("merkliste_" + request_base + "");
	var old_value_check = ";" + old_value; /* bugfix da javascript probleme mit dem ersten zeichen im cookie hat */
	var check = ";" + bildid;
	if(strpos(old_value_check, check, 0)){
		alert(decodeURI(bname)+" ("+ bild_titel +") befindet sich bereits auf der Merkliste.");
	}else{
		// alert("Bild noch nicht vorhanden!");
		new_value = old_value + ";" + bildid;
		setCookie("merkliste_" + request_base + "", new_value, 14, decodeURI(bname)+" ("+ bild_titel +") wurde auf die Merkliste gesetzt.");
	}
}

function merke_del(request_base, bildid){
	var value = getCookie("merkliste_" + request_base + "");
	value = value.replace(";" + bildid, "");
	if (value=="") { value=";" }
	setCookie("merkliste_" + request_base + "", value, 14);
	if(value == ""){
		$("id_" + bildid + "_link").innerHTML = "";
		$("id_" + bildid + "_bild").innerHTML = "";
		$("id_" + bildid + "_clear").innerHTML = "";
		$("merkliste_leer_hidden").style.display = "";
	}else{
		$("id_" + bildid + "_link").innerHTML = "";
		$("id_" + bildid + "_bild").innerHTML = "";
		$("id_" + bildid + "_clear").style.display = "none";
	}
}

function setCookie(name,value,expiredays, message) {

	var xmlHttp = null;
	try {
	    xmlHttp = new XMLHttpRequest();
	} catch(e) {
	    try {
	        xmlHttp  = new ActiveXObject("Microsoft.XMLHTTP");
	    } catch(e) { xmlHttp= null }
        }
        if (xmlHttp) {
		xmlHttp.open('GET', '/cookie/cookie?name='+escape(name)+"&value="+escape(value)+"&rand="+Math.random(), false);
		xmlHttp.send(null);
       		if (xmlHttp.status == 200 && message != undefined) {
	        	alert(message);
    		};
	}
}

	
function getCookie(name) {
	var xmlHttp = null;
	try {
	    xmlHttp = new XMLHttpRequest();
	} catch(e) {
	    try {
	        xmlHttp  = new ActiveXObject("Microsoft.XMLHTTP");
	    } catch(e) { xmlHttp= null }
        }
        if (xmlHttp) {
		xmlHttp.open('GET', '/cookie/cookie?name='+escape(name)+"&rand="+Math.random(), false);
		xmlHttp.send(null);
		if (xmlHttp.status == 200)
                	return xmlHttp.responseText;
		else
			return "";
	}
}

function printBName(bname){
	bname = bname.replace(/\+/g, " ");
	document.writeln(decodeURI(bname));
}

