// JavaScript Document


// OPERA RESIZE FIX

function operafix ()
	{
	if(navigator.userAgent.indexOf('Opera')!=-1)
		document.location.reload();
	}


// NAVIGATION
var ActiveMenu = -1;

function toggleActiveMenu (node)
	{
	
	if (ActiveMenu == -1)
		{		
		var startpoint=document.getElementById('nav');
		if (!startpoint) return;		
		var y = startpoint.getElementsByTagName('ul');
		
		for (var i=0; i<y.length; i++)
			{
			if ((y[i].style.display == 'block') && y[i].parentNode.firstChild != node && y[i] != node)
				{
				 ActiveMenu = y[i];
				 ActiveMenu.style.display = 'none'
				}
			}
		}
	else
	{
	ActiveMenu.style.display = 'block';
	ActiveMenu = -1;
	}
	}


// BILDLEISTEN-SCROLLER
var LeisteLeftPos = 0;

function iframescroll (direction)
	{
	BrowserWidth = document.documentElement.clientWidth;	
	LeisteWidth = frames['bilderleiste'].document.getElementById('leiste').style.width;
	LeisteWidth = LeisteWidth.replace(/px/,"")
	if (direction == 'left')
		{
		LeisteLeftPos = LeisteLeftPos + BrowserWidth;
		if ( LeisteLeftPos >= 0) LeisteLeftPos = 0;
		frames['bilderleiste'].document.getElementById('leiste').style.left = LeisteLeftPos + 'px';
		// alert (LeisteLeftPos);
		}
		else /* to the right */
		{
		LeisteLeftPos = LeisteLeftPos - (251*(Math.floor(BrowserWidth/251)));
		//alert(Math.floor(BrowserWidth/251));
		//alert (LeisteLeftPos + ',LW:'+LeisteWidth + ',B: '+ BrowserWidth);
		if ((Math.abs(LeisteLeftPos)) >= (LeisteWidth - BrowserWidth)) LeisteLeftPos = - (LeisteWidth - BrowserWidth);
		frames['bilderleiste'].document.getElementById('leiste').style.left = LeisteLeftPos + 'px';		
		//frames['bilderleiste'].document.body.scrollLeft = '100px';
		}
	}


// Protect

if (window.jQuery)
	{
		$(document).ready(function() {
		$("a[href*=' ']").click(function() {
			var realemail = '';
			var email = $(this).attr("href");
			var emailArray = email.split(" ");
			for (var i=emailArray.length; i>=0; i=i-1)
				{
					if (typeof emailArray[i] != 'undefined')
					{
						if (i==2)
						{
						realemail = realemail + emailArray[i] + '@';
						}
						else
						{
						realemail = realemail + emailArray[i] + '.';
						}
					}
				}
			realemail = realemail.substring(0, realemail.length -1);
			realemail = 'mailto:' + realemail;
			$(this).attr("href", realemail);
			//alert (realemail);
			});
		});
	}