// Content: js splash
Splash.prototype.WIN_IE50 = (navigator.userAgent.toLowerCase().indexOf("msie 5.0") > 0); 

function Splash () {
	this.countrySelector = document.getElementById('country');
	this.langSelector = document.getElementById('lang');
	this.partner = document.getElementById('partner');
	this.srcFrame = new RPCFrame(window);
	this.srcFrame.setLocation('/travel/klm_splash/languages.html', createContextFunction(this, "fill"));
	this.countrySelector.onchange = createContextFunction(this, "updateLanguages", "updateLanguages");
	this.submitBut = document.getElementById('go');
	this.submitBut.onclick = createContextFunction(this, "go");
	this.externalimg = document.getElementById('externalimg');
	this.externallinkimg = document.getElementById('externallinkimg');
	this.country = '';
	this.language = '';
	this.filled = false;
}
Splash.prototype.fill = function () {
	if (this.filled) return;
	var newOption, txt, value;
	var entries = this.srcFrame.getHTMLByTag('li')
	for (var i = 0; i < entries.length; i++) {
		if (entries[i].parentNode.parentNode.id == 'langdata') {
			txt = entries[i].innerHTML.substr(0, entries[i].innerHTML.toUpperCase().indexOf('<UL>'));
			value = entries[i].id;
			newOption = document.createElement('option');
			newOption.innerHTML = txt;
			if (entries[i].className == 'selected') {
				newOption.selected = true;
			}
			newOption.value = value;
			this.countrySelector.appendChild(newOption);
		}
	}
	this.updateLanguages();
	this.filled = true;
}
Splash.prototype.updateLanguages = function () {
	var c, newOption;
	this.clearLanguages();
	c = this.countrySelector.options[this.countrySelector.selectedIndex].value;
	if (!c) return;
	var entries = this.srcFrame.getHTMLById(c).getElementsByTagName('li');
	for (var i = 0; i < entries.length; i++) {
		newOption = document.createElement('li');
		if (entries[i].getAttribute('url')) 
		{
			if (entries[i].getAttribute('img') != "")
			{
				this.externallinkimg.href = entries[i].getAttribute('url');
  			this.externalimg.src = entries[i].getAttribute('img');
				this.partner.style.display = 'block';
  		}
  		else
  		{
   			this.partner.style.display = 'none';
				txt = entries[i].innerHTML;
				value = entries[i].getAttribute('url');
				newOption = document.createElement('option');
				newOption.innerHTML = txt;
				newOption.value = value;
				this.langSelector.appendChild(newOption);
			}		
		}
		else
		{
			this.partner.style.display = 'none';
			txt = entries[i].innerHTML;
			value = entries[i].className;
			newOption = document.createElement('option');
			newOption.innerHTML = txt;
			newOption.value = value;
			this.langSelector.appendChild(newOption);
		}
		if (entries[i].id == 'selected') {
					newOption.selected = true;
	}
}
}
Splash.prototype.clearLanguages = function () {
	while (this.langSelector.hasChildNodes()) {
		this.langSelector.removeChild(this.langSelector.firstChild);
	}
}
Splash.prototype.go = function () {
	if (this.langSelector.selectedIndex == -1)
  	window.open(this.externallinkimg.href);
	else
	{
		if (this.langSelector.options[this.langSelector.selectedIndex].value.indexOf('http:') != -1)
			document.location.href = this.langSelector.options[this.langSelector.selectedIndex].value;
		else
		{
			this.country = this.countrySelector.options[this.countrySelector.selectedIndex].value;
			this.language = this.langSelector.options[this.langSelector.selectedIndex].value;
			document.location.href = '/travel/klm_splash/index.html?country=' + this.country + '&language=' + this.language + "&remember=" + (document.forms[0].remember.checked == true ? "true" : "false");
		}	
	}
}

function dircountriesredirect(strCountry, strLanguage)
{
	document.location.href = '/travel/klm_splash/index.html?country=' + strCountry + '&language=' + strLanguage + "&remember=" + (document.forms[0].remember.checked == true ? "true" : "false");
}