// initializing navi object
var navi = {
	main:{
		activeArea:		null,
		activePoint:	null,
		activeAnchor:	null,
		hide:		function() {
			if(this.activeArea) {
				this.activeArea.style.visibility = 'hidden';
			}
		},
		show:			function(parentPoint) {
			var pos = findPos(parentPoint);			
			this.activeArea = document.getElementById('dropdown_' + parentPoint.id);
			this.activeAnchor = document.getElementById('link_' + parentPoint.id);
			
			var mainnavPos = findPos( document.getElementById('Mainnav') );
			var elOffset = { left: mainnavPos[0], top: mainnavPos[1] };			
			
			if(this.activeArea) {			
				if (IE='\v'=='v') this.activeArea.style.marginLeft = -2+"px"; // if IE
				else this.activeArea.style.left = (pos[0] - naviSettings.main.offsetLeft - elOffset.left) +"px";					
				this.activeArea.style.top = (pos[1] + parentPoint.offsetHeight + naviSettings.main.offsetTop - elOffset.top-2) +"px";
				this.activeArea.style.visibility = "visible";
			}
			naviSettings.timeout.clear();
		}
	}
}


// timeout adaptor
function startNaviTimeout() {
	naviSettings.timeout.start();
}


// 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() {
	navi.main.hide();
}

// shows the main navigation
function showMainNavi(topNaviPoint) {
	deactivatingNavi();
	navi.main.show(topNaviPoint);
}


// 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;
	}
}
