// 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)
	{
	  console.log('scroll ' + direction);
	BrowserWidth = document.documentElement.clientWidth;	
	LeisteWidth = document.getElementById('leiste').style.width;
	LeisteWidth = LeisteWidth.replace(/px/,"")
	if (direction == 'left')
		{
		LeisteLeftPos = LeisteLeftPos + BrowserWidth;
		if ( LeisteLeftPos >= 0) LeisteLeftPos = 0;
		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);
		document.getElementById('leiste').style.left = LeisteLeftPos + 'px';		
		}
	}

// bildleiste popup
function popUp(url,win,breite,hoehe) {  

    if (typeof(breite) == "undefined") 
    {
        win = window.open(url,'win',"toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=no,scrollbars=0,resizable=no,width=545,height=580"); 
    }
    else
    {
        var win_lookout;
        win_lookout ="toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=no,scrollbars=0,resizeable=no,width="+breite+",height="+hoehe
        win = window.open(url,'win',win_lookout);  
    }

    if (navigator.appName.indexOf("Netscape") != -1) win.focus();

    if (window.focus) win.focus();

    win.moveTo(10,10);

}
// Protect

if (window.jQuery) {
	$(document).ready(function() {
	  /* initialise plugins */
  	$("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);
  		});
  	});
}
