var w3c = (typeof(document.getElementById) != 'undefined') ? 1 : 0;
var ie5plus = ((typeof(document.getElementById) != 'undefined') && (document.all)) ? 1 : 0;
var ns6 = ((navigator.userAgent.indexOf('Netscape6') != -1) && (typeof(document.getElementById) != 'undefined')) ? 1 : 0;
var ns7 = ((navigator.userAgent.indexOf('Netscape7') != -1) && (typeof(document.getElementById) != 'undefined')) ? 1 : 0;
var moz = ((navigator.userAgent.indexOf('Gecko') != -1) && (typeof(document.getElementById) != 'undefined')) ? 1 : 0;
var ie4 = (document.all) ? 1 : 0;
var ns4 = (document.layers) ? 1 : 0;
var opera = (navigator.userAgent.indexOf('Opera') != -1) ? 1 : 0;

// -------------------------------------------------------------------------------------------------

function BodyOnLoad()
{
	ShowTicker();
	ImgPreload();
	window.defaultStatus = ' ';
}

function BodyOnResize()
{
	MainWidth = document.body.offsetWidth;
	MenuWidth = GetElemRef("MainMenue").offsetWidth;
	SpaceWidth = (MainWidth - MenuWidth) / 2;
	
	if (SpaceWidth < 83)
		GetElemRef("FSLogoDiv").style.visibility = 'hidden';
	else
		GetElemRef("FSLogoDiv").style.visibility = 'visible';
}

function ShowTour(URL, Width, Height, EventObj)
{
	X = (screen.width - Width) / 2 - 15;
	Y = (screen.height - Height) / 2 - 15;
	if (URL.substr(0, 4).toLowerCase() != 'http')
		window.open('touren/' + URL, 'Tour', 'height=' + Height + ',left=' + X + ',top=' + Y + ',width=' + Width);
	else
		window.open(URL, 'Tour', 'height=' + Height + ',left=' + X + ',top=' + Y + ',width=' + Width);
	
	if (EventObj) StopEvent(EventObj);
}

function ShowBigShot(URL, Width, Height, EventObj)
{
	X = (screen.width - Width) / 2 - 10;
	Y = (screen.height - Height) / 2 - 15;
	SS = window.open('about:blank', 'Screenshot', 'Height=' + Height + ',left=' + X + ',top=' + Y + ',Width=' + Width);
	
	HTML = '<html><head><title>Vergr&ouml;ßerter Screenshot</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>'
	HTML += '<body style="margin: 0px;"><img src="' + URL + '" onClick="self.close()" style="cursor: pointer; cursor: hand;" galleryimg="no" alt="Klicken um das Fenster zu schließen..."></body></html>'
	
	SS.document.write(HTML);
	SS.document.close();

	StopEvent(EventObj);	
}

function Redirect(ID)
{
	switch (ID)
	{
		case 1: window.location.replace('service_start.asp');
		case 2: window.location.replace('service_login.asp');
	}
}

function StopEvent(EventObj)
{
	if (document.addEventListener)
	{
		EventObj.stopPropagation();
		EventObj.preventDefault();
	}
	else
	{
		EventObj.cancelBubble = true;
		EventObj.returnValue = false;
	}
}

function GetElemRef(ElemString)
{
	if (w3c) return document.getElementById(ElemString);
	if (ie4) return document.all[ElemString];
}

function ImgReplace(ImageName, ImageURL)
{
	if (document.images[ImageName]) document.images[ImageName].src = ImageURL;
}

function Hov(EventObj)
{
	window.defaultStatus = ' ';
	window.status = ' ';
	StopEvent(EventObj);
	return true;
}

function CursorH(Obj)
{
	!ie4 ? Obj.href = '#' : GetElemRef('StartGra').style.cursor = 'hand';
	return true;
}

function CursorNoH(Obj)
{
	!ie4 ? Obj.href = '' : GetElemRef('StartGra').style.cursor = 'default';
	return true;
}

function Preloader(BaseDir, Files)
{
	var Imgs = new Array();
	
	for (var i = 0; i < Files.length; i++)
	{
		if (Files[i] != '')
		{
			Imgs[i] = new Image();
			Imgs[i].src = BaseDir + Files[i];
		}
	}
}

function SetMainContentsHeight()
{
	if (GetElemRef('Ueberschrift'))
	{
		UeberschriftHeight = GetElemRef('Ueberschrift').style.height;
		MainMenuHeight = GetElemRef('MainMenue').style.height;
		LogoandNameHeight = GetElemRef('LogoandName').style.height;
		FooterHeight = GetElemRef('Footer').style.height;
	}
	else
	{		
		UeberschriftHeight = 3;
		MainMenuHeight = GetElemRef('MainMenue').style.height;
		LogoandNameHeight = GetElemRef('LogoandName').style.height;
		FooterHeight = GetElemRef('Footer').style.height;
	}
	
	if (document.body.clientHeight)
		TDHeight = document.body.clientHeight - parseInt(UeberschriftHeight) - parseInt(MainMenuHeight) - parseInt(LogoandNameHeight) - parseInt(FooterHeight) - 2;
	else 
	{
		if (window.innerHeight)	TDHeight = window.innerHeight - parseInt(UeberschriftHeight) - parseInt(LogoandNameHeight) - parseInt(FooterHeight) - 2;
	}

	GetElemRef('MainContents').style.height = TDHeight + 'px';
}
