var languages = {
	de: 'Deutsch',
	en: 'English',
	es: 'Espa&ntilde;ol',
	fr: 'Fran&ccedil;ais',
	nl: 'Nederlands',
	no: 'Norsk',
	sq: 'Shqip'
}

function createCookie(name,value,days){
        if (days)
        {
                var date = new Date();
                date.setTime(date.getTime()+(days*24*60*60*1000));
                var expires = "; expires="+date.toGMTString();
        }
        else var expires = "";
        document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name){
        var nameEQ = name + "=";
        var ca = document.cookie.split(';');
        for(var i=0;i < ca.length;i++)
        {
                var c = ca[i];
                while (c.charAt(0)==' ') c = c.substring(1,c.length);
                if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
        }
        return null;
}

function selectLanguage() {
	language = document.getElementById('language').value;
	createCookie("edt_language", language, 300);
 	window.location.reload();
}


function list() {
	var head = '';
	var niv = 0;

	head += '<select id="language" onchange="selectLanguage()" style="float:right">';
	for (i in languages) {
		head += '<option value="' + i + '"';
		if (i == language) {
			head+= ' selected="true"';
		}
		head += '>' + languages[i] + '</option>';
	}
	head += '</select>';
	head += '<img src="logo.png" /><h1>' + msg['titel'] + '</h1><h2>';
	
	head += '<table>';
	head += '<tr><td><b>' + msg['storing'] + '</b></td><td><b>' + msg['niveau'] + '</d></td><td><b>' + msg['file'] + '</d></td></tr>';
	for (i in storingen) {
		niv = Math.floor(i/100);
		head += '<tr><td>' + storingen[i].name + '</td><td>' + niv + '</td><td>' + i + '.sto</td></tr>';
	}
	head += '</table>';
	
	return head ;
}

function jsload() {
	var div = document.createElement('div');
	div.id = 'log';
	div.innerHTML = list();
	document.getElementsByTagName('body')[0].appendChild(div);
	document.title = "EDT - Electude " + msg['titel'];
}

function init() {
	var script = document.createElement('script');
	script.type = 'text/javascript';
	if (language == null) {
		language = 'en';
	}
	script.src = language + '.js';
	document.getElementsByTagName('head')[0].appendChild(script);
	window.setTimeout('jsload()', 60);
}

var language = readCookie('edt_language');

window.onload=init;
