var SponChannel = '2';
v_sponkopf = 'sponkopf';

//menu_anz = 5;

menu_height = 23;
//menu_offset_x = -12;
menu_offset_x = 0;

//menu_offset_y = -5;
menu_offset_y = -3;


function InhaltNavigation(menuindex){
	var NavInhalt;
	var ColChannel = '#FFFFFF';//document.getElementById(v_sponkopf).getAttribute('bgcolor');
	NavInhalt = '<table id="tsponmenue" width="200" bgcolor="'+ColChannel+'" cellpadding="0" cellspacing="0" border="0">';

	//for(j in aNav) {
	j = menuindex;
		for(i in aNav[j]) {
			if(aNav[j][i]!=""){ 
				NavInhalt += '<tr><td><a href="' + aNav[j][i][1] + '" title="' + aNav[j][i][3] + '"' + aNav[j][i][2] + ' class="sponnav" onmouseover="hili('+i+')" onmouseout="hili('+i+')">' +aNav[j][i][0]+ '<\/a><\/td><\/tr>';
			} else if(aNav[j][i]==""){
				NavInhalt += '<tr><td height="18" class="sponnav"><br><\/td><\/tr>';
			}
			if(i==aNav[j].length-1) NavInhalt += '<tr><td height="7" width="154"><spacer type="block" width="1" height="7"><\/td><\/tr>';
		}
	//}
		
	NavInhalt += '<\/table>';
	document.getElementById(v_dsponmenue).innerHTML=NavInhalt;
}

// ######## POSITIONIERUNG ########
function PositionNavigation(){
	var PosX, PosY
	var NS6 = (navigator.appName.indexOf("Netscape") != -1 && document.getElementById && navigator.userAgent.indexOf("rv:0")!=-1) ? 1 : 0;
	if (document.getElementById && !NS6) {
		//PosX = document.getElementById(v_sponkopf).offsetLeft + document.getElementById(v_sponmenue).offsetLeft;
		//PosY = document.getElementById(v_sponkopf).offsetTop + document.getElementById(v_sponmenue).offsetTop + document.getElementById(v_isponmenue).offsetHeight;
		PosX = document.getElementById(v_sponmenue).offsetLeft + menu_offset_x;
		PosY = document.getElementById(v_sponmenue).offsetTop + menu_height + menu_offset_y;

	}
	if (NS6) {
		PosX = document.getElementById(v_isponmenue).offsetLeft;
		PosY = document.getElementById(v_isponmenue).offsetTop + document.getElementById(v_isponmenue).offsetHeight;
	}
	//document.getElementById(v_dsponmenue).style.left = PosX+'px';  
	//document.getElementById(v_dsponmenue).style.top = PosY+'px';
	document.getElementById(v_dsponmenue).style.left = PosX+'px';  
	document.getElementById(v_dsponmenue).style.top = PosY+'px';
	
//	alert(v_dsponmenue);
}

// ############ ZEIGEN - VERBERGEN ###############
var NavHide=0;
function ShowHideNavi(status) {

	vv_dsponmenue = 'dsponmenue_' + aktuellerindex;


	if(status==0){
		document.getElementById(vv_dsponmenue).style.visibility = 'hidden';
		hili(SponChannel);
	} else {
		document.getElementById(vv_dsponmenue).style.visibility = 'visible';
	}
	
	for (k=0;k<menu_anz;k++) {
		if (k!=aktuellerindex) {
			vv_dsponmenue = 'dsponmenue_' + k;
			document.getElementById(vv_dsponmenue).style.visibility = 'hidden';
//			ShowHideNavi(0);
		}
	}
		

	if (NavHide) clearTimeout(NavHide);
		NavHide=setTimeout("aus()",500);
}

function aus() {
	if(!NavOn) ShowHideNavi(0);
}

// ######### HIGHLIGHTING ##########
function hili(id){
	with(document){
	if (getElementById('iNavPfeil'+id)) getElementById('iNavPfeil'+id).style.visibility= (document.getElementById('iNavPfeil'+id).style.visibility=="visible")? "hidden" : "visible";
	if (getElementById('iNavPfeil'+SponChannel)) getElementById('iNavPfeil'+SponChannel).style.visibility = (NavOn)? "visible" : "hidden";
	}
}

// ######## NAVIGATION AUFRUFEN ##############
function SetNavi(menuindex) {
	v_isponmenue = 'isponmenue_' + menuindex;
	v_dsponmenue = 'dsponmenue_' + menuindex;
	v_sponmenue = 'sponmenue_' + menuindex;
			
	aktuellerindex = menuindex;
	
	InhaltNavigation(menuindex);
	PositionNavigation();
	ShowHideNavi(0);
	ShowHideNavi(1);
	NavOn=1;
	hili(SponChannel);
}

// ######## MAUSBEWEGUNG KONTROLLIEREN #########
document.onmouseover=OnSponNav;
var NavOn;
function OnSponNav(el) {
	if (document.all) {
		var thisEl = event.srcElement;
	}
	if (document.getElementById && !document.all) {
		var thisEl = el.target
	}
	if (thisEl!=-1) {
		var i = 0;
		var DomPath="";
		DomPathArray = [];
		var node = thisEl;
		while(node.tagName!="HTML") {
			if(node.tagName!="undefined") {
				DomPathArray[i] = node.id;
				DomPath += DomPathArray[i]+'/';
				i++;
			}
			node = node.parentNode;
		}
		if ( (DomPath.match("dsponmenue")) || (DomPath.match("isponmenue")) ) NavOn = 1;	
		if ( ( !DomPath.match("dsponmenue") && !DomPath.match("isponmenue") ) && NavOn) {NavOn = 0; ShowHideNavi(1);}
	}
}

