var lang = 'de';
var pfad = '';

function navhighlight(a, high, hover) {
	var lnk = a.children('a');
	if (high == true) {
		if (hover == true) {
			a.css('color', '#000000');
			a.css('background-color', '#FF571D');
			lnk.css('color', '#000000');					
		} else {
			a.css('color', '#000000');
			a.css('background-color', '#ffffff');
			lnk.css('color', '#000000');			
		}					
	} else {
		a.css('background-color', '#231F20');
		a.css('color', '#ffffff');
		lnk.css('color', '#ffffff');
	}
}

function navhoverin(where) {
	navhighlight($('td#navcell_' + where), true, true);
}

function navhoverout(where) {
	navhighlight($('td#navcell_' + where), 'navcell_' + where == $("td[name='active']").attr('id'), false);
}

function navinit(where) {
	var a = $('td#navcell_' + where);
	a.hover(function () { navhoverin(where); }, function () { navhoverout(where); });
}

function closemodal() {
	$('div#dialog').jqmHide();
	return false;
}

function showmodal(what) {
	var what_array = what.split("/");
	$('div#dialog').load(pfad + 'html/' + lang + '/' + what_array[what_array.length - 1] + '.html', null, function() { 
		var dlg = $('div#dialog');
		dlg.append('<div id="dlgclose"><a href="" onclick="return closemodal();"><img src="' + pfad + 'img/closelabel.gif" border="0"/></a></div>');
		dlg.jqmShow(); 
		});
	window.scrollTo(0, 0);
	return false;
}

$(document).ready(function() {
	$('#dialog').jqm();
	
	items = $('#menuitems').attr('value').split(";");
	for(var i = 0; i < items.length-1; i++){
		navinit(items[i]);
		if($('#navcell_' + items[i]).attr('class') == 'nav_active')
			currentnav = items[i];
	}
	lang = $('#active_lang').attr('name');
	pfad = (lang == 'en') ? '../': '';
});