function f(s)
{
	if (navigator.appName.indexOf("Microsoft") != -1) return window[s];
	else return document[s];
}

function handleScroll()
{
	f("website").sendToActionScript(window.pageYOffset);
}

function handleIEScroll()
{
	f("website").sendToActionScript(document.documentElement.scrollTop);
}

function addEvent(element, eventName, callback)
{	
	element = document.getElementById(element);
	if(element.addEventListener)
	{
		if(eventName == 'mousewheel') element.addEventListener('DOMMouseScroll', callback, false);
		element.addEventListener(eventName, callback, false);
	}
	else if(element.attachEvent)
	{
		element.attachEvent("on" + eventName, callback);
	}
}

function cancelEvent(e)
{
	e = e ? e : window.event;
	if(e.stopPropagation) e.stopPropagation();
	if(e.preventDefault) e.preventDefault();
	e.cancelBubble = true;
	e.cancel = true;
	e.returnValue = false;
	return false;
}

function printInfo(e)
{
	e = e ? e : window.event;
	var normal = e.detail ? e.detail * -1 : e.wheelDelta / 10;
	f("wrapper").scrollTop = f("wrapper").scrollTop - normal;
	f("website").sendToActionScript(f("wrapper").scrollTop);
	cancelEvent(e);
}

function neuAufbau(h)
{
	$('#website').css("width", (document.body.offsetWidth - 17) + "px");
}
			
function setWrapperHeight(h)
{
	$('#inhalt').css("height", h + "px");
	
	if (navigator.appVersion.indexOf("MSIE 6.0") == -1)
	{
		if (navigator.appName.indexOf("Microsoft") != -1)
			window.onscroll = handleIEScroll;
		else
			return window.onscroll = handleScroll;
	}
	else
	{
		$('#website').css("width", (document.body.offsetWidth - 17) + "px");
		addEvent('website', 'mousewheel', printInfo);
		window.onresize = neuAufbau;
	}
}

function gotoTop()
{
	if (navigator.appVersion.indexOf("MSIE 6.0") == -1)
	{
		window.scrollTo(0, 0);
	}
	else
	{
		f("wrapper").scrollTop = 0;
	}
}

function gotoBottom()
{
	if (navigator.appVersion.indexOf("MSIE 6.0") == -1)
	{
		window.scrollTo(0, 5000);
	}
	else
	{
		f("wrapper").scrollTop = 5000;
	}
}

function scrollToY(topMargin)
{
	if($.browser.opera)
	{
		$('html').animate({
		scrollTop: topMargin + 290
		}, 1000);
	}
	else
	{
		$('html, body').animate({
			scrollTop: topMargin + 290
		}, 1000);
	}
}

function callAlert(s)
{
	alert(s);
}

function callPopup(s)
{
	$.fancybox({
	    'width': 'auto',
        'height': 'auto',
        'autoScale': true,
        'transitionIn': 'fade',
        'transitionOut': 'fade',
        'type': 'image',
        'href': s,
        'onclose': function()
        {
        	$('#website').focus();
        }
    });
}
