//-----------------------------------------------------------------------------
// checkJavascript
//-----------------------------------------------------------------------------
function checkJavascript()
{
	getObject( "index_text" ).innerHTML = "loading . . .";
}

//-----------------------------------------------------------------------------
// getObject
//-----------------------------------------------------------------------------
function getObject( elem )
{
	if ( document.all )
	{
		return document.all[ elem ];
	}
	else
	{
		return document.getElementById( elem );
	}
}


//-----------------------------------------------------------------------------
// getAvailXSize / getAvailYSize
//-----------------------------------------------------------------------------
function getAvailXSize() {
	if (document.all) {
		return screen.width;
	}
	else {
		return window.innerWidth;
	}
}

function getAvailYSize() {
	if (document.all) {
		return screen.height;
	}
	else {
		return window.innerHeight;
	}
}


//-----------------------------------------------------------------------------
// centerLeftPos  / centerTopPos
//-----------------------------------------------------------------------------
function centerLeftPos(aWidth) {
	var xSize = getAvailXSize();
	return ((xSize - aWidth)/2);
}

function centerTopPos(aHeight) {
	var ySize = getAvailYSize();
	return ((ySize - aHeight)/2);
}


//-----------------------------------------------------------------------------
// centerDiv
//-----------------------------------------------------------------------------
function centerDiv(id, xSize, ySize) {
	var wrapperWidth = xSize;
	var wrapperHeight = ySize;	

	// hier die left- und top-positionierung des "mainwrapper" divbereiches anpassen
	var leftPos = centerLeftPos(wrapperWidth);
	var topPos = centerTopPos(wrapperHeight) - 30;
	
	if (document.all) { // IE
		getObject(id).style.pixelTop = topPos - 60;
		getObject(id).style.pixelLeft = leftPos;
	}	
	if (document.getElementById&&!document.all) { // NS6+
		getObject(id).style.left = leftPos+"px";
		getObject(id).style.top = topPos+"px";
	}
	if (document.layers) { // NS4+
		getObject(id).top = topPos;
		getObject(id).left = leftPos;
	} 

}


//-----------------------------------------------------------------------------
// precaching images
//-----------------------------------------------------------------------------
var imageList = [ 
[1009,610,  "images/bg.png"],
[1009,610,  "images/bg.png"],

[60,30,  "images/home.gif"],
[60,30,  "images/home_high.gif"],
[60,30,  "images/news.gif"],
[60,30,  "images/news_high.gif"],
[110,30,  "images/projectinfos.gif"],
[110,30,  "images/projectinfos_high.gif"],
[60,30,  "images/team.gif"],
[60,30,  "images/team_high.gif"],
[110,30,  "images/screenshots.gif"],
[110,30,  "images/screenshots_high.gif"],
[110,30,  "images/bewerbung.gif"],
[110,30,  "images/bewerbung_high.gif"],
[90,30,  "images/contact.gif"],
[90,30,  "images/contact_high.gif"],
[70,30,  "images/forum.gif"],
[70,30,  "images/forum_high.gif"],
[168,14,  "images/copyright.gif"],
[168,14,  "images/copyright_high.gif"],

[665,299,  "images/seemless_bg.jpg"],

[100,100,  "images/s_dwarf_sw.gif"],
[100,100,  "images/s_dwarf_sw_high.gif"],
[100,100,  "images/s_dwarf.gif"],
[100,100,  "images/s_dwarf_high.gif"],
[100,100, "images/s_amazone.gif"],
[100,100, "images/s_amazone_high.gif"],
[100,100, "images/g_oldwitch.gif"],
[100,100, "images/g_oldwitch_high.gif"]
];

var numberOfImages = imageList.length;

var loaded = new Array( numberOfImages );
for ( i = 0; i < numberOfImages; i++ )
{
  loaded[ i ] = 0;
}

var loadIndex = 0;

var progressIndent = 28;

function gotoMain()
{
	location.href = "main.html";
}

function precacheImages()
{
	if ( loadIndex >= numberOfImages )
	{
		setTimeout( "gotoMain();", 500 );
	  return;
	}

	if ( 0 == loaded[ loadIndex ] )
	{
		var imageInfo = imageList[ loadIndex ];

		var nextImage = new Image( imageInfo[ 0 ], imageInfo[ 1 ] );
		nextImage.src = imageInfo[ 2 ];

		loaded[ loadIndex ] = nextImage;
	}
	else if ( loaded[ loadIndex ].complete )
	{
		loadIndex++;
	  setProgress( loadIndex * 100 / imageList.length );
	}

	setTimeout( "precacheImages();", 10 );
}

function setProgress( percent )
{
	if ( percent < 5 )
	{
		percent = 5;
	}
	getObject( "percentage" ).innerHTML = Math.round( percent ) + " %";
}


//-----------------------------------------------------------------------------
// hilite, unhilite
//-----------------------------------------------------------------------------
var prevLink;
var actLink;

function mouseOver(name) {
	if(name != actLink) {
		hilite(name);
	}
	return true;
}

function mouseOut(name) {
	if(name != actLink) {
		unhilite(name);
	}
	return true;
}

function mouseClick(name) {
	if( name != actLink) {
		actLink = name;
		window.document.images[name].src = "images/"+name+"_high.gif";
		if(prevLink){
			unhilite(prevLink);
		}
		prevLink = name;
	}
}

function hilite(name) {
	window.document.images[name].src = "images/"+name+"_high.gif";
}

function unhilite(name) {
	window.document.images[name].src = "images/"+name+".gif";
}

//-----------------------------------------------------------------------------
// loadContent iFrame
//-----------------------------------------------------------------------------
function loadContent(name,doc) {
	parent.getObject(name).src = doc;
}

//-----------------------------------------------------------------------------
// openPopup
//-----------------------------------------------------------------------------
var win;
function openPopup(aWidth, aHeight, aDoc, aName) {
	var topPos;
	var leftPos;
	
	if(document.all) {
		topPos = ((parent.screen.height - aHeight) / 2);
		leftPos = ((parent.screen.width - aWidth) / 2);
		var parameter = "width="+aWidth+",height="+aHeight+",rezisable=no,left="+leftPos+",top="+topPos+",scrollbars=yes,dependent=yes";
	}
	else {
		topPos = ((parent.window.innerHeight - aHeight) / 2);
		leftPos = ((parent.window.innerWidth - aWidth) / 2);
		var parameter = "width="+aWidth+",height="+aHeight+",rezisable=no,screenX="+leftPos+",screenY="+topPos+",scrollbars=yes,dependent=yes";
	}
	win = window.open(aDoc, aName, parameter);
	win.focus();
}

