// 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 offsetLeft = $( 'Mainnav' ).cumulativeOffset();

			if(this.activeArea) {			
				if( !Prototype.Browser.IE ){
					this.activeArea.style.left = (pos[0] - naviSettings.main.offsetLeft - offsetLeft[0]) +"px";
				}else{
					this.activeArea.style.marginLeft = -2+"px"
				}
				this.activeArea.style.top = (pos[1] + parentPoint.offsetHeight + naviSettings.main.offsetTop - offsetLeft[1]-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;
	}
}