// initializing navi object
var navi = {
	main:{
		activeArea:		null,
		activePoint:	null,
		activeAnchor:	null,
		lock:           null,
		
		hide:		function() {
			if(this.activeArea) {
				this.activeArea.style.visibility = 'hidden';
			}
		},
		
		show: function(parentPoint, position ) {	//position => if false => no top value
		    if( !this.lock ){
			var pos = findPos(parentPoint);
			this.activeArea = document.getElementById('dropdown_' + parentPoint.id);
			this.activeAnchor = document.getElementById('link_' + parentPoint.id);
			if(this.activeArea) {
			    if( position ){
			    	this.activeArea.style.left = (pos[0] - naviSettings.main.offsetLeft) +"px";
					this.activeArea.style.top = (pos[1] + parentPoint.offsetHeight + naviSettings.main.offsetTop) +"px";
				} 
				this.activeArea.style.visibility = "visible";
			}
			naviSettings.timeout.clear();
			}
		}
	}	
}


// timeout adaptor
function startNaviTimeout() {
	naviSettings.timeout.start();
}

function stopNaviTimeout() {
	naviSettings.timeout.clear();
}



// function returns the position of the selected element
function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft;
		curtop = obj.offsetTop;
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		}
	}
	return [curleft,curtop];
}


// hiding all active navi elements
function deactivatingNavi() {
    if( !navi.main.lock ) navi.main.hide();
}

// shows the main navigation
function showMainNavi(topNaviPoint, position) { 
	deactivatingNavi();
	if( position == undefined ) position = true;
	navi.main.show(topNaviPoint, position);

}


// Switch off Opacity for Mac, because of the Flash in Background
function switchOffOpacity() {
	var allDivs = document.getElementsByTagName('div');
	for (var i=0; i<allDivs.length; i++) {
		allDivs[i].style.MozOpacity = 1;
		//allDivs[i].style.opacity = 1;
	}
}