  
  var g_NavigationHeight;
    var g_NavigationHeightZero;
    var g_OpenNavigationId;
    var g_opener;
    var movePixel = 0.6; //Headerspan bewegung.
    var g_NavigationLocked;
    var g_SpanId;
	var g_clickOnUpperNode;
	var g_iTimeout;
	var g_ia;
	var g_pageName;
	var g_NavigationPanel;
	var g_lastEndId = 0;
	var g_animLock = false;
	
		
    g_NavigationLocked = 0;
    g_NavigationHeight = 0;
    g_NavigationHeightZero = 0;
    g_OpenNavigationId = 0;
	g_NavigationPanel = 0;
    g_SpanId = 0;
	g_opener = 0;
	EndId = 0;
	function init(page){
		var loc = window.location.href;
		if(loc.toLowerCase().indexOf("default") > 0 || loc.indexOf(".asp") < 0 ){
			rndPage();
			centerStop(page);
			verticalCenterStop();
		}else{
			centerStop(page);
		}
	}
	
     function mouseEventNavigation(Id,EventId,ISubNavID,HauptNavID,SpanId, EndId, currentPage){
			tempId = SpanId +1
			 if(document.getElementById('NavigationBetween' + HauptNavID) != null){ 
			 	//document.getElementById('NavigationBetween' + HauptNavID).style.paddingBottom = "10px";
			 }
			 
			if(EventId == "click" && g_animLock == false){
				if(g_NavigationLocked != Id && g_NavigationLocked > 0){   
					 document.getElementById('a_navigationsLinkId' + g_NavigationLocked).style.color = "#000000";
					   document.getElementById('NavigationBetweenIn' + g_NavigationLocked).style.backgroundColor = "transparent";  
                 }

			if(g_NavigationPanel != Id && Id == HauptNavID ){
						document.getElementById('NavigationBetween' + g_NavigationPanel).style.backgroundImage = "none"; 
                        document.getElementById('NavigationBetween' + g_NavigationPanel).style.paddingBottom = "10px"; 
				}
				
				if(document.getElementById('NavigationBetween' + HauptNavID) != null && currentPage != Id){
					document.getElementById('NavigationBetween' + HauptNavID).style.backgroundImage = "url('http://www.speich.ch/img/hg_navigation_offen_oben.gif')";
					document.getElementById('NavigationBetween' + HauptNavID).style.paddingBottom = "10px";
				}
				
			if(document.getElementById('NavigationBetween' + HauptNavID) != null && ISubNavID == Id && g_NavigationLocked != Id ){
					document.getElementById('NavigationBetween' + HauptNavID).style.backgroundImage = "url('http://www.speich.ch/img/hg_navigation_open_grau.gif')";
				}
				
				if(document.images['navEndImg' + EndId].src != null && Id != EndId){
					document.images['navEndImg' + EndId].src = 'http://www.speich.ch/img/hg_navigation_offen_unten.gif';
				}
				
                g_NavigationLocked = Id;
				g_NavigationPanel = ISubNavID;
            }
            
           if(EventId == "on" && g_animLock == false){	
				if(g_NavigationLocked != Id){
					document.getElementById('NavigationBetweenIn' + Id).style.backgroundColor = "#d6dbdd";
					document.getElementById('NavigationBetweenIn' + Id).style.width = "161px";
					
					 if(HauptNavID != null && ISubNavID == Id){
					  	document.getElementById('NavigationBetween' + HauptNavID).style.backgroundImage = "url('http://www.speich.ch/img/hg_navigation_open_grau.gif')"; 
                        document.getElementById('NavigationBetween' + HauptNavID).style.paddingBottom = "10px"; 
					}
					if(EndId != currentPage && Id == EndId && SpanId != 99){						
						document.images['navEndImg' + EndId].src = 'http://www.speich.ch/img/hg_navigation_offen_unten_grau.gif';
					}	
						
				}
            }
            
           if(EventId == "out" && g_animLock == false){
			   if(g_NavigationLocked != Id ){     
					document.getElementById('NavigationBetweenIn' + Id).style.backgroundColor = "transparent";
					if(document.getElementById('NavigationBetween' + HauptNavID) != null && g_NavigationLocked != ISubNavID && SpanId != 99 ){	
						document.getElementById('NavigationBetween' + HauptNavID).style.backgroundImage = "url('http://www.speich.ch/img/hg_navigation_offen_oben.gif')"; 
                    	document.getElementById('NavigationBetween' + HauptNavID).style.paddingBottom = "10px"; 	
					}
					
					if(EndId != 0 && SpanId != 99 && EndId != g_NavigationLocked && document.images['navEndImg' + EndId].src != 'http://www.speich.ch/img/hg_navigation_offen_unten.gif'){	
							document.images['navEndImg' + EndId].src = 'http://www.speich.ch/img/hg_navigation_offen_unten.gif';
					}
				}
            }
      }
      
    function mainNavigationPoser(animation,NavigationsId,Id,href, subNavId, HauptNavId, PanelId, currenPage){	
			
			g_animLock = true;
			if(animation != 99 && document.getElementById('NavigationBetween' + Id)!= null && currenPage != subNavId){
				document.getElementById('NavigationBetween' + Id).style.backgroundImage = "url('http://www.speich.ch/img/hg_navigation_offen_oben.gif')";
				document.getElementById('NavigationBetween' + Id).style.paddingBottom = "10px";
			}
			
			if( document.getElementById('NavigationBetween' + g_NavigationPanel) != null && Id != g_NavigationPanel){
				document.getElementById('NavigationBetween' + g_NavigationPanel).style.backgroundImage = "none";
				document.getElementById('NavigationBetween' + g_NavigationPanel).style.paddingBottom = "0px";
				//alert(document.getElementById('NavigationBetween' + g_NavigationPanel).style.paddingBottom);
			}
			
			
			var loc = window.location.href;
			 	g_NavigationLocked = Id;
				g_NavigationPanel = HauptNavId;
				
				if(href != loc && href != "" && href != "NULL" && href != "undefined"){
				var tempNav = NavigationsId -1
				if(loc.indexOf("default") < 0 || loc.indexOf(".asp") > 0){
						setNavigationTop(animation,NavigationsId,1,href);    
				}
			}
      }

     function changehref(href){
		 var loc = window.location.href;
		if(href != loc && href != "" && href != "NULL" && href != "undefined"){
				window.location.href = href;
		}
	 }
      
  function setNavigationTop(animation,Id,Open,href){	
     	var End  = "neutral";
		var End2 = "neutral";

	   	var loc = window.location.href;		   
		   if(Open == 1){ 
				g_NavigationHeight = 0; 
				g_NavigationHeightZero = 15; 
				
				g_clickOnUpperNode = false; 
				g_iTimeout = 100;
				g_ia = 0;
				var temploc = href.split("/");
				var lastLoc = temploc.length -1 
				var pageLength = temploc[lastLoc].length - 5
				g_pageName = temploc[lastLoc].substring(pageLength,0);
				 
				if(loc.indexOf(g_pageName) > 0){
				   g_clickOnUpperNode = true;
				   iTimeout = 0;
				   g_ia = 0;
				 }
				 
				if(Id == 'start'){
					g_ia = '1&b=1';
				}
				
				if(animation == 1){
					g_ia = 0;
				}
			}
			
		   if(Id != g_OpenNavigationId && Id != 1 && Id != 'start'){
				 if(g_NavigationHeight < 14.9){
					g_NavigationHeight = g_NavigationHeight + movePixel;
					document.getElementById("NavigationSpan" + Id).style.height = g_NavigationHeight + "px";
					g_opener = Id;
					End = "online";
				 }
				 	else
				 { 
					g_NavigationHeight = 15;
					document.getElementById("NavigationSpan" + Id).style.height = g_NavigationHeight + "px";
					End = "end";
				 }
		   }
		
		   if(g_clickOnUpperNode != true){
			   if(g_OpenNavigationId != 0){
					if(g_OpenNavigationId != Id || g_opener != g_OpenNavigationId){
						tempNavigationHeightZero = Math.floor(g_NavigationHeightZero * 10) / 10
						
						if(tempNavigationHeightZero	 >= 0.1 ){
							g_NavigationHeightZero = g_NavigationHeightZero - movePixel;
							if(g_OpenNavigationId != 1){ 
								document.getElementById("NavigationSpan" + g_OpenNavigationId).style.height = g_NavigationHeightZero + "px";
							}
							End2 = "online";	
							}else{
								g_NavigationHeightZero = 0;
								if(g_OpenNavigationId != 1){
								document.getElementById("NavigationSpan" + g_OpenNavigationId).style.height = g_NavigationHeightZero + "px";
							}
							End2 = "end";
						}
					 }
				   }
		   }else{
		   	   g_NavigationHeightZero = 0;
			   End2 = "end";
		   }

		 
		 if(End == "end"){
		 	g_opener = 0;
			g_OpenNavigationId = Id;
		 }
		 
		if(End2 == "end"){
			g_OpenNavigationId = 0;
		 }
		 
		 if(End == "online"){
		 	window.setTimeout("setNavigationTop('"+ animation +"'," + Id + ",2,'" + href + "')", 1);
		 }else{
		 	if(End2 == "online"){
					 window.setTimeout("setNavigationTop('"+ animation +"'," + Id + ",2,'" + href + "')", 1);
			 }
		 }
		 	
		
		if(End != "online" && End2 != "online" ){
				if(End == "end" && End2 == "neutral"){
					window.setTimeout("changehref('" + href + "?a=" + g_ia + "')", g_iTimeout);
				}
					 
				 if(End == "neutral" && End2 == "end"){
					window.setTimeout("changehref('" + href + "?a=" + g_ia + "')", g_iTimeout);	
				}
			 
			 	
				if(End == "end" && End2 == "end"){
					window.setTimeout("changehref('" + href + "?a=" + g_ia + "')", g_iTimeout);
				}
				
				 if(End == "neutral" && End2 == "neutral"){
					window.setTimeout("changehref('" + href + "?a=" + g_ia + "')", g_iTimeout);
				 }
			}
	}
  
	 
	 
	function setSubFooterline(px){
		hFooterline = document.getElementById('contentframe').offsetHeight - px;
		document.getElementById('subFooterLine').style.top = (hFooterline + "px");
	}
	
	function setFooter(farbe, icon){
		
		if(icon == true){
			var contentFrameHeight = document.getElementById("contentframe").offsetHeight 
			document.getElementById("footer").style.height = "139px";
			document.getElementById("footer").style.top = "-111px";
			document.getElementById("footer").style.position = "relative"
			document.getElementById("footer").style.backgroundImage = "url('/img/inhalt_bottom_" + farbe + "2.png')";
			document.getElementById('contentframe').style.height = (contentFrameHeight + "px");
			setSubFooterline(0);
		}else{
			document.getElementById("footer").style.height = "28px";
			document.getElementById("footer").style.backgroundImage = "url('/img/inhalt_bottom_" + farbe + ".png')";
			setSubFooterline(0);
		}
		
	}
	
	
	 function centerStop(page){
			var bodyClientHeight = document.body.clientHeight;
			var contentHeight = document.getElementById("contentframe").offsetHeight;
			
			if(document.body.clientWidth <= 1003)
				{
					document.getElementById("contentframe").style.left = "20px";
					document.getElementById("contentframe").style.marginLeft = "0px";
					document.getElementById("subFooterLine").style.width = "1003px";
					if(page == 'start'){
						document.getElementById("headstart").style.left = "480px";
						alert("test");
					}
				}
				else
				{
					if(bodyClientHeight < contentHeight){
							document.getElementById("contentframe").style.marginLeft = "-477px";
					}else{
						document.getElementById("contentframe").style.marginLeft = "-485px";
					}
					document.getElementById("contentframe").style.left = "50%";
					document.getElementById("subFooterLine").style.width = "auto";
					if(page == 'start'){
						document.getElementById("headstart").style.left = "50%";
					}
				}
	
				window.setTimeout(centerStop, 100);
			} 
			
		
		function verticalCenterStop(){
			hw = window.innerHeight;
			if(hw < 2){
				hw = document.body.offsetHeight;
			}
			if(hw <= 670){
				document.getElementById("startVertical").style.top = "0px";
				document.getElementById("startVertical").style.marginTop = "0px";
				
				document.getElementById("contentframe").style.top = "50px";
				document.getElementById("contentframe").style.marginTop = "0px";
				
				document.getElementById("mainFramePos").style.top = "50px";
				document.getElementById("mainFramePos").style.height = "598px";
			}else{
				document.getElementById("startVertical").style.top = "50%";
				document.getElementById("startVertical").style.marginTop = "-286px";
				
				document.getElementById("contentframe").style.top = "50%";
				document.getElementById("contentframe").style.marginTop = "-286px";
				
				document.getElementById("mainFramePos").style.top = "0px";
				document.getElementById("mainFramePos").style.height = "auto";
				document.getElementById("mainFramePos").style.bottom = "0px"
			}
			
			window.setTimeout(verticalCenterStop, 100);
		}
		
		function rndPage(){
			var ran_unrounded=Math.random()*3;
            var ran_number=Math.floor(ran_unrounded) +1;
			
			/*
				Seitenfarbe:
				1 Pink
				2 Blau
				3 Grün
			*/
			
			 switch (ran_number) {
			   	case 1:
					document.getElementById('imgsprachwahl').src = "img/pfeil_sprachwahl_start_pink.gif";
					document.getElementById('startChange').className = 'pink';
					document.getElementById("startVertical").style.backgroundImage = "url('img/start_hg_linien_pink.gif')";
					if(lang == 'de') {
						document.getElementById("startContentBox").style.backgroundImage = "url('img/start_pink.png')";
					} else {
						document.getElementById("startContentBox").style.backgroundImage = "url('img/start_pink_en.png')";
					}
				break;	
				case 2:

					document.getElementById('startChange').className = 'blau';
					document.getElementById('imgsprachwahl').src = "img/pfeil_sprachwahl_start_blau.gif";
					document.getElementById("startVertical").style.backgroundImage = "url('img/start_hg_linien_blau.gif')";
					if(lang == 'de') {
						document.getElementById("startContentBox").style.backgroundImage = "url('img/start_blau.png')";
					} else {
						document.getElementById("startContentBox").style.backgroundImage = "url('img/start_blau_en.png')";
					}
				break;
				
				case 3:
					document.getElementById('imgsprachwahl').src = "img/pfeil_sprachwahl_start_gruen.gif";
					document.getElementById('startChange').className = 'gruen';
					document.getElementById("startVertical").style.backgroundImage = "url('img/start_hg_linien_gruen.gif')";
					if(lang == 'de') {
						document.getElementById("startContentBox").style.backgroundImage = "url('img/start_gruen.png')";
					} else {
						document.getElementById("startContentBox").style.backgroundImage = "url('img/start_gruen_en.png')";
					}
				break;
				
				default:
					//document.images['pfeilTarget'].src = "img/pfeil_sprachwahl_start_gruen.gif";
					//document.getElementById("changeColor").style.style.color = "#008e4f";
					document.getElementById('startChange').className = 'gruen';
					document.getElementById("startVertical").style.backgroundImage = "url('img/start_hg_linien_gruen.gif')";
					if(lang == 'de') {
						document.getElementById("startContentBox").style.backgroundImage = "url('img/start_gruen.png')";
					} else {
						document.getElementById("startContentBox").style.backgroundImage = "url('img/start_gruen_en.png')";
					}
				break;
			}
		}
		
		function showGraphic(eventId, Id){
			if(eventId == "on"){
				if(lang == 'de') {
					document.images['icons'].src = "img/start_icons_0" + Id + "x.png"; 	
				} else {
					document.images['icons'].src = "img/start_icons_en_0" + Id + "x.png"; 	
				}
			}
			
			if(eventId == "out"){
				document.images['icons'].src = "img/start_icons.png";
			}
		}
		
		function iconEvent(e,id){
			if(e=='on'){
				document.images[id].src = '/img/inhalt_' + id + 'x.png';
			}else{
				document.images[id].src = '/img/inhalt_' + id + '.png';
			}
		}
		
		function iconEvent2(e,id){
			if(e=='on'){
				document.images['con_icon' + id].src = '/img/inhalt_icon_' + id + 'x.png';
			}else{
				document.images['con_icon' + id].src = '/img/inhalt_icon_' + id + '.png';
			}
		}
