// initializing navi object
var navi = {
	main:{
		activeArea:		null,
		activePoint:	null,
		activeAnchor:	null,
		hide:		function() {
			blockMenu( false );
			if(this.activeArea) {
				this.activeArea.style.visibility = 'hidden';
				if(this.activeAnchor) this.activeAnchor.style.color = naviSettings.main.linkColor;
			}
		},
		show:			function(parentPoint) {
			blockMenu( true );
			var pos = findPos(parentPoint);
			var id = parentPoint.id.split( "_" );
			this.activeArea = document.getElementById('dropdown_' + id[1]);
			this.activeAnchor = document.getElementById('link_' + id[1]);
			if ( this.activeAnchor ) this.activeAnchor.style.color = naviSettings.main.linkColorOver;
			if(this.activeArea) {
				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 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;
	}
}

function blockMenu( state ){
	var movie = swfobject.getObjectById("IntroAnimation");
	if( movie ) movie.blockmenue( state );
}