addLoadEvent(toggleTaalkeuze);

function toggleTaalkeuze() {
	divTaalkeuze = document.getElementById("taalkeuze");
	lnkTaalkeuze = document.getElementById("linkTaalkeuze");
	if(divTaalkeuze && lnkTaalkeuze) {
		lnkTaalkeuze.onclick = function() {
			divTaalkeuze.style.visibility="visible";
			return false;
		}
		lnkCloseTaalkeuze = document.getElementById("closeTaalkeuze");
		if(lnkCloseTaalkeuze) {
			lnkCloseTaalkeuze.onclick = function() {
				divTaalkeuze.style.visibility="hidden";
				return false;
			}
		}
		lnkGo = document.getElementById("linkgo");
		if(lnkGo) {
			lnkGo.onclick = function() {
				do_go(document.startform);
				return false;
			}
		}
	}
}

function do_countriechange(theForm) {
	while (theForm.lang.options.length > 1) {
		theForm.lang.options[(theForm.lang.options.length - 1)] = null;
	}
	theForm.lang.style.display = "none";
	
	var divSelect = document.getElementById("select");
	//if(divSelect) { divSelect.style.left = "100px"; }
	
	if (theForm.xcountry.value == "be") {
		theForm.lang.options[0]= new Option("Taal - Langue", "", true, true);
		theForm.lang.options[1]= new Option("Nederlands", "benl", true, false);
		theForm.lang.options[2]= new Option("Français", "befr", true, false);
		//if(divSelect) { divSelect.style.left = "70px"; }
		theForm.branch.style.display = "none";
		theForm.lang.style.display = "block";
	}
	if (theForm.xcountry.value == "ch") {
		theForm.lang.options[0]= new Option("Sprache - Langue - Lingua", "", true, true);
		theForm.lang.options[1]= new Option("Deutsch", "chde", true, false);
		theForm.lang.options[2]= new Option("Français", "chfr", true, false);
		theForm.lang.options[3]= new Option("Italiano", "chit", true, false);
		//if(divSelect) { divSelect.style.left = "70px"; }
		theForm.branch.style.display = "none";
		theForm.lang.style.display = "block";
	}
	if (theForm.xcountry.value == "ca") {
		theForm.lang.options[0]= new Option("Langue - Language", "", true, true);
		theForm.lang.options[1]= new Option("Français", "cafr", true, false);
		theForm.lang.options[2]= new Option("English", "caen", true, false);
		//if(divSelect) { divSelect.style.left = "70px"; }
		theForm.branch.style.display = "none";
		theForm.lang.style.display = "block";
	}
	if (theForm.xcountry.value == "fr") {
		theForm.lang.options[0]= new Option("Français", "frfr", true, true);
		//if(divSelect) { divSelect.style.left = "118px"; }
		do_languagechange("frfr");
	}
	if (theForm.xcountry.value == "de") {
		theForm.lang.options[0]= new Option("Deutsch", "dede", true, true);
		//if(divSelect) { divSelect.style.left = "118px"; }
		do_languagechange("dede");
	}
	if (theForm.xcountry.value == "at") {
		theForm.lang.options[0]= new Option("Deutsch", "atde", true, true);
		//if(divSelect) { divSelect.style.left = "118px"; }
		do_languagechange("atde");
	}
	if (theForm.xcountry.value == "sk") {
		theForm.lang.options[0]= new Option("Deutsch", "skde", true, true);
		//if(divSelect) { divSelect.style.left = "118px"; }
		do_languagechange("skde");
	}
	if (theForm.xcountry.value == "cz") {
		theForm.lang.options[0]= new Option("Deutsch", "czde", true, true);
		//if(divSelect) { divSelect.style.left = "118px"; }
		do_languagechange("czde");
	}
	if (theForm.xcountry.value == "uk") {
		theForm.lang.options[0]= new Option("English", "uken", true, true);
		//if(divSelect) { divSelect.style.left = "118px"; }
		do_languagechange("uken");
	}
	if (theForm.xcountry.value == "us") {
		theForm.lang.options[0]= new Option("English", "usen", true, true);
		//if(divSelect) { divSelect.style.left = "118px"; }
		do_languagechange("usen");
	}
	if (theForm.xcountry.value == "oc") {
		theForm.lang.options[0]= new Option("English", "ocen", true, true);
		//if(divSelect) { divSelect.style.left = "118px"; }
		do_languagechange("ocen");
	}
	if (theForm.xcountry.value == "nl") {
		theForm.lang.options[0]= new Option("Nederlands", "nlnl", true, true);
		//if(divSelect) { divSelect.style.left = "118px"; }
		do_languagechange("nlnl");
	}
	if (theForm.xcountry.value == "es") {
		theForm.lang.options[0]= new Option("Español", "eses", true, true);
		//if(divSelect) { divSelect.style.left = "118px"; }
		do_languagechange("eses");
	}
	if (theForm.xcountry.value == "it") {
		theForm.lang.options[0]= new Option("Italiano", "itit", true, true);
		//if(divSelect) { divSelect.style.left = "118px"; }
		do_languagechange("itit");
	}
	if (theForm.xcountry.value == "jp") {
		theForm.lang.options[0]= new Option("Japanese", "jpjp", true, true);
		//if(divSelect) { divSelect.style.left = "118px"; }
		do_languagechange("jpjp");
	}
}

function do_languagechange(language) {
	document.getElementById("branch").style.display = "none";
	if (language == "benl" || language == "befr" || language == "cafr" || language == "caen" || language == "chfr" || language == "chde" || language == "chit") {
		document.getElementById("language").style.display = "block";
	} else {
		document.getElementById("language").style.display = "none";
	}
	do_branchchange(language);
}

function do_branchchange(language) {
	correctBranchLabel = window['lbl_lang_branch_' + language];
	correctConfectioneryLabel = window['lbl_general_confectionery_' + language]; //branch1
	correctPastryLabel = window['lbl_general_pastry_' + language]; //branch2
	correctDessertsLabel = window['lbl_general_desserts_' + language]; //branch3
	document.getElementById('branch0').innerHTML = correctBranchLabel;
	document.getElementById('branch1').innerHTML = correctConfectioneryLabel;
	document.getElementById('branch2').innerHTML = correctPastryLabel;
	document.getElementById('branch3').innerHTML = correctDessertsLabel;
	document.getElementById('branch').style.display = 'block';
}

function do_go(theForm) {
	var error = 0;
	if (theForm.xcountry.value == "") {
		alert(lbl_lang_select_country);
		error++;
	}
	if (theForm.lang.value == "" && error == 0) {
		alert(lbl_lang_select_lang);
		error++;
	}
	if (theForm.branch.value == "" && error == 0) {
		alert(lbl_lang_select_branch);
		error++;
	}
	if (!error) {
		theForm.submit();
	}
}
