function getCookie(name) {
	var myCookies = document.cookie;
	var index = myCookies.indexOf(name);
	if (index != -1) {
		var index2 = document.cookie.indexOf (";", index);
		if (index2 == -1) {
			index2 = document.cookie.length;
		}
		return unescape(document.cookie.substring(index+name.length+1, index2));
	}
	return "";
}
function setCookie(name, value) {
	var newDate = new Date(new Date().getFullYear() + 1, 1, 1);	
	document.cookie = name+"="+value+";expires="+newDate;
}
function switchToLanguage(newLangValue) {
	var oldLangValue = getCookie("lang");
	if (newLangValue != oldLangValue) {
		setCookie("lang", newLangValue)
//		location.reload();
		document.location.href = "/index.aspx?skip=false&t=" + Math.random();
	}
}
function setLanguage (inLang) {
	if (inLang == "sp") inLang = "es";	// correction
	// get alt texts
	var alt1, alt2, url, colofon, disclaimer, total, today;
	switch (inLang) {
	case "nl":
		alt1 = "Anne Franks Boom";
		alt2 = "Een interactief monument";
		colofon = "Colofon";
		disclaimer = "Disclaimer";
		url="http://www.annefrank.org";
		total="Totaal:";
		today="Vandaag:";
		break;
	case "en":
		alt1 = "Anne Frank's Tree";
		alt2 = "An Interactive Monument";
		colofon = "Colophon";
		disclaimer = "Disclaimer";
		url="http://www.annefrank.org";
		total="Total:";
		today="Today:";
		break;
	case "de":
		alt1 = "Anne Franks Baum";
		alt2 = "Ein interaktives Denkmal";
		colofon = "Impressum";
		disclaimer = "Disclaimer";
		url="http://www.annefrank.org";
		total="Insgesamt:";
		today="Heute:";
		break;
	case "fr":
		alt1 = "L'Arbre d'Anne Frank";
		alt2 = "Un monument interactif";
		colofon = "Colophon";
		disclaimer = "Protocole";
		url="http://www.annefrank.org";
		total="Total:";
		today="Aujourd'hui:";
		break;
	case "it":
		alt1 = "L'Albero di Anne Frank";
		alt2 = "Un monumento interattivo";
		colofon = "Colophon";
		disclaimer = "Disclaimer";
		url="http://www.annefrank.org";
		total="Totale:";
		today="Oggi:";
		break;
	case "es":
		alt1 = "El árbol de Ana Frank";
		alt2 = "Un monumento interactivo";
		colofon = "Colof&oacute;n";
		disclaimer = "Aviso legal";
		url="http://www.annefrank.org";
		total="Total:";
		today="Hoy:";
		break;
	}

	var img1 = document.getElementById("annesboom_img");
	img1.src = "img/" + inLang + "/anne-franks-boom.gif";
	img1.alt = img1.title = alt1;

	var img2 = document.getElementById("monument_img");
	img2.src = "img/" + inLang + "/interactief-monument.gif";
	img2.alt = img2.title = alt2;

	// bbrrr
	document.getElementById("stichting").href = url;
	document.getElementById("colofon").innerHTML = colofon;
	document.getElementById("disclaimer").innerHTML = disclaimer;
	document.getElementById("totalcount").innerHTML = total;
	document.getElementById("daycount").innerHTML = today;
	
	// set cookie
	setCookie("lang", inLang);
}
