// NEWS

function ShowNews( id )
{
	document.getElementById(id).style.display = 'block';
	document.getElementById('teasers').style.display = 'none';
}

function HideNews( id )
{
	document.getElementById(id).style.display = 'none';
	document.getElementById('teasers').style.display = 'block';
}

// PHOTO PREVIEW

function ShowPreview( url, aspect )
{
	HidePreview();
	
	var id = ( aspect == 0 ) ? 'preview' : 'preview2';
	document.getElementById(id).style.display = 'block';
	document.getElementById(id).style.backgroundImage = 'url(' + url + ')';
}

function HidePreview()
{
	document.getElementById('preview').style.display = 'none';
	document.getElementById('preview2').style.display = 'none';
}

// NAVIGATION

function GetPosition( element )
{
	var Position = { x: 0, y: 0 };
	
	do
	{
		Position.x += element.offsetLeft;
		Position.y += element.offsetTop;
	}
	while( element = element.offsetParent );
	
	return Position;
}

var arVersion = navigator.appVersion.split("MSIE");
var version = parseFloat(arVersion[1]);

var last_x = 0;
function SlideCursor( ereignis )
{
	// get menu's position
	var MenuPosition = GetPosition( document.getElementById("menu") );
	
	var y = 0;
	var x = 0;
	
	// get mouse position
	x = document.all ? window.event.clientX : ereignis.pageX;
	y = document.all ? window.event.clientY : ereignis.pageY;
	
	x -= 22;
	
	// check if mouse hovers over the menu
	if( y > MenuPosition.y && y < (MenuPosition.y+33) )
	{
		// get cursor
		var cursor = document.getElementById("cursor");
		var image = document.getElementById("cursor_image");
		
		if( version < 7.0 ) // ie6
		{
			if( x > last_x ) cursor.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader( src='png/cursor2.png' )";
			else cursor.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader( src='png/cursor.png' )";
		}
		else // others
		{
			if( x > last_x ) cursor.style.backgroundImage = "url(png/cursor2.png)";
			else cursor.style.backgroundImage = "url(png/cursor.png)";
		}
		
		// prevent cursor from going off
		if( x < (MenuPosition.x+2) ) x = MenuPosition.x+2;
		if( x > (MenuPosition.x+378) ) x = MenuPosition.x+378;
		
		// update cursor's position
		cursor.style.left = x + "px";
		
		//window.status = "x: " + x;
	}
	
	// save position
	last_x = x;
}

document.onmousemove = SlideCursor;
