function toggleLang(lang){
	new ljex.Ajax({
		url: '/index.php5?lang='+lang,
		method: 'GET',
		scope: this,
		callback: function(response){ 
			var regex = /news\.php5/;
            var regex2 = /video\.php5/;
			var regex1 = /id=/;
			var link = document.URL;
			if (document.URL.match(regex)){        
				if (document.URL.match(regex1)){
					var part1=document.URL.split("?");
					var part2=part1[1].split("&");
					link =part1[0];
					var i= 1;
					while(part2.length!=i){
						if(i==1){
							link+="?"+part2[i];
						}
						else{
							link+="&"+part2[i];
						}
						i++;
					}
				}
				
			}

            if (document.URL.match(regex2)){
                  
				if (document.URL.match(regex1)){
					var part1=document.URL.split("?");
					link =part1[0];
					}
				}
			location.href=link;

		}
	}).request();
}

function toggleAnnotation(){
	hk.annotations=(hk.annotations)?false:true;
	document.getElementById("annotation").style.display=(hk.annotations)?'block':'none';
	var a = new Date();
	a = new Date(a.getTime() +1000*60*60*24*365);
	document.cookie='annotations='+( (hk.annotations)?'yes':'no' )+';expires='+a.toGMTString()+';';
}

function isIE(){
	if(navigator.appName=="Microsoft Internet Explorer")
		return true;
	else
		return false;
}

function hideSubPanel(){
	if(subPanel!=null && closeSubPanel){
		subPanel.style.display='none';
		subPanel=null;
		closeSubPanel=false;
	}
}

subPanel=null;
selectedItem=null;
closeSubPanel=false;

function init(){

	ljex.init(hk.lang);

	document.getElementById("navi").onmouseout = function(e){
		closeSubPanel=true;
		window.setTimeout("hideSubPanel()",1000);
	}

	var subpanels=document.getElementById("navilist").getElementsByTagName("div");

	for(i=0;i<subpanels.length;i++){
		if(subpanels[i].className == 'nav-submenu-panel'){
			subpanels[i].onmouseout = function(e){
				closeSubPanel=true;
				window.setTimeout("hideSubPanel()",1000);
			}
			subpanels[i].onmouseover = function(e){
				closeSubPanel=false;
			}
			subpanels[i].style.left=document.getElementById("li"+subpanels[i].id).offsetLeft;
		}
	}


	var items=document.getElementById("navilist").getElementsByTagName("li");

	for(i=0;i<items.length;i++){
		if(items[i].id==hk.selectedIndex){
		//	alert('Hallo');
			items[i].style.backgroundPosition="0px -32px";
			selectedItem=items[i];
		}
		if(items[i].className == 'nav-item' || items[i].className == 'nav-item-submenu'){
			items[i].onmouseover = function(e){
					if(selectedItem!=this) this.style.backgroundPosition="0px -32px";
					if(subPanel!==null){
						subPanel.style.display='none';
						subPanel=null;
					}
					if(this.className == 'nav-item-submenu'){
						closeSubPanel=false;
						if(ljex.isIE()){
							this.firstChild.nextSibling.style.display='block';
							subPanel=this.firstChild.nextSibling;
						}else{
							this.nextSibling.nextSibling.style.display='block';
							subPanel=this.nextSibling.nextSibling;
							new ljex.FX({
								id : subPanel,
								fps : 25
							}).fadeIn();
						}

					}
			}
			items[i].onmouseout = function(e){
				if(selectedItem!=this) this.style.backgroundPosition="0px 0px";
			}
		}else if(items[i].className == 'nav-subitem'){
			items[i].onmouseover = function(e){
				this.style.backgroundColor='#444';
				this.style.opacity='.85';
			}
			items[i].onmouseout = function(e){
				this.style.backgroundColor='#181C18';
				this.style.opacity='1';
			}
		}
   }

}



function toggleSubNavi(id){
	var subnavi=document.getElementById(id+'_subnavi');
	if(!naviems[id].open){
		subnavi.style.display='block';
		navi.items[id].open=true;
	}else{
		subnavi.style.display='none';
		navi.items[id].open=false;
	}
}


