


/************************************************
NavCore TO BODY
************************************************/
function NavCore() {
	/*** Start Global Configuration ***/
		this.g_timeoutTime 		= 400; 
		this.g_timeoutTimeID 	= "";
		this.g_currentNavi 		= "";	
		this.g_currentHit		= "";
		this.g_lastActivNavi	= "";
		this.g_currentBg		= "main_subnavi_holder";
		this.doc = document;		
		
		//this.ie = false;
		//this.ie7 = (this.ie && window.XMLHttpRequest);
		this.init();	
	
}


/************************************************
INIT NavCore
************************************************/
NavCore.prototype.init = function() {
		
	if (!document.getElementsByTagName) { return; }
	var anchors = (this.isFrame) ? window.parent.frames[window.name].document.getElementsByTagName('a') : document.getElementsByTagName('a');
	for (var i = 0; i < anchors.length; i++) {
		var anchor = anchors[i];	
		var relAttribute = String(anchor.getAttribute('rel'));
		if (anchor.getAttribute('href')) {
			if (relAttribute.toLowerCase().match('mnav')) {
				
				 anchor.onmouseover = function () { NavCore.overNav(this.name); return false; }	
				 anchor.onmouseout = function () { NavCore.outNav(this.name); return false; }
				 anchor.href = "#";
			}
		}
	}
	
	//todo something
					
};


/************************************************
OverNav START THE NAV
************************************************/
NavCore.prototype.overNav = function(sName) {
	
	
	if(this.g_lastActivNavi != "" && this.g_lastActivNavi != "subnavi_" + sName){
		this.EXsetNavActiv(this.g_lastActivNavi);
			//this.hideNav(this.g_lastActivNavi);
	}

	//close the old - when open
	if(this.g_currentNavi != sName){
		this.hideNav(this.g_currentNavi);
			
	}
		
	
	//vars	
	this.g_currentNavi = "subnavi_" + sName;
	this.g_currentHit = sName;
	clearTimeout(this.g_timeoutTimeID);
	
	this.setNavActFunc();
	this.setNavActiv();
    
}

/************************************************
OverNav START THE NAV
************************************************/
NavCore.prototype.setNavActiv = function(){
	
	
	var elemBg = document.getElementById(this.g_currentBg);	
	var elemOL = document.getElementById('OverLayer');	
	if(elemBg){
		elemBg.style.display = 'block';
	}
	var elemNavi = document.getElementById(this.g_currentNavi); 
	if(elemNavi){
		elemNavi.style.display = 'block';
		elemOL.style.display = 'block';
	}
	
    return true;
}
/************************************************
OverNav START THE NAV
************************************************/
NavCore.prototype.EXsetNavActiv = function(lastAc){
	
	
	var elemNavi = document.getElementById(lastAc); 
	if(elemNavi){
		elemNavi.style.display = 'block';
		elemNavi.style.display = 'none';
	}
	
    return true;
}

/************************************************
SET FUNC TO SUBLAYER
************************************************/
NavCore.prototype.setNavActFunc = function(){

	
	var elemNavi = document.getElementById(this.g_currentNavi); 
	if(elemNavi){
		elemNavi.onmouseover = function () { NavCore.overNav(NavCore.g_currentHit); return false; }	
		elemNavi.onmouseout = function () { NavCore.outNav(NavCore.g_currentHit); return false; }	
	}
	
    return true;
}

/************************************************
OUT FROM MOUSEOUT
************************************************/
NavCore.prototype.outNav = function(currentHit){
	//verzögerung zu schließen
	//echo ("out hit." + currentHit);	
	this.g_timeoutTimeID = setTimeout("NavCore.hideNav(\"" + this.g_currentNavi + "\", 1)", this.g_timeoutTime);      
	//this.g_timeoutTimeID = setTimeout("NavCore.hideNav(\"" + this.g_currentNavi + "\", \"" + currentHit + "\")", this.g_timeoutTime);                	
}

/************************************************
CLOSE - KILL TIMER
************************************************/
NavCore.prototype.hideNav = function(currentNavi, fromTimeout){
    		
		//echo ("hide " + currentNavi + " hit " + currentHit);	
		//echo ("hide hit." + currentHit);		
		clearTimeout(this.g_timeoutTimeID);
		this.g_timeoutHide = 0; 	
		if(fromTimeout == 1){
			this.g_lastActivNavi = currentNavi;
		}else{
			this.g_lastActivNavi = "";
		}
		this.hideNavActiv(currentNavi);	  
		
		//this.g_currentNavi = "";
		//this.g_currentHit = "";
}

/************************************************
CLOSE THE ELEMENTS
************************************************/
NavCore.prototype.hideNavActiv = function(currentNavi){
		
	//echo ("hideA " + currentNavi);		
	var elemBg = document.getElementById(this.g_currentBg);	      
	var elemOL = document.getElementById('OverLayer');	
	if(elemBg){
		elemBg.style.display = 'none';
		elemOL.style.display = 'none';
	}
	var elemNavi = document.getElementById(currentNavi); 
	if(elemNavi){
		elemNavi.style.display = 'none';
		elemOL.style.display = 'none';
	}
	
}


