
// (c) 2003 by Frank P. Baumgartner, baumgartner@motune.com


function sxy(i,x,y) 
{
	if ( document.layers ) 
	{
		eval('document.'+i+'.top ='+y);
    eval('document.'+i+'.left='+x);
	}
	else if ( document.all ) 
	{
		eval('document.all.'+i+'.style.pixelLeft='+x);
		eval('document.all.'+i+'.style.pixelTop ='+y); 
	} 
	else if ( document.getElementById ) 
	{  
		document.getElementById(i).style.left=x;
		document.getElementById(i).style.top=y; 
	}
}


function s(i,v) 
{
	b = (v>0) ? '"visible";' : '"hidden";';

	if (document.layers) 
	{
		eval("document."+i+".visibility="+b );
	}
	else if (document.all) 
	{
		eval("document.all."+i+".style.visibility="+b );
	} 
	else if (document.getElementById) 
	{
		eval("document.getElementById(i).style.visibility="+b );
	}
}



function layerWrite(id,nestref,text) 
{
	if ( navigator.appName.indexOf("Internet Explorer") != -1 ) 
	{
		document.all[id].innerHTML = text;
	}
	else if ( document.getElementById )
	{
		var lyr = document.getElementById(id);
		lyr.innerHTML = text;
	} 
	else 
	{ 
		var lyr = (nestref) ? eval('document.'+nestref+'.document.'+id+'.document') : document.layers[id].document;
		lyr.open();
		lyr.write(text);
		lyr.close();
	}
}


// get the true offset of anything on NS4, IE4/5 & NS6, even if it's in a table!
function getAbsX(elt) { return (elt.x) ? elt.x : getAbsPos(elt,"Left"); }
function getAbsY(elt) { return (elt.y) ? elt.y : getAbsPos(elt,"Top"); }
function getAbsPos(elt, which) 
{
 iPos = 0;
 while (elt != null) 
 {
  iPos += elt["offset" + which];
  elt = elt.offsetParent;
 }
 return iPos;
}

var x,y;
var browserOK = false;
var mie = false;
var aver = parseInt(navigator.appVersion.substring(0,1));
var aname = navigator.appName;

	if (aname.indexOf("Internet Explorer")!=-1) 
	{
		if (aver>=4) 
		{
			browserOK = navigator.javaEnabled();
		}
		mie = true;
	}

	if (aname.indexOf("Netscape")!=-1) 
	{
		if (aver>=4) 
		{
			browserOK = navigator.javaEnabled();
		}
	}


// --- get the center ---

function checkbrowserOK() 
{
		if(!mie) 
		{
			pageX=window.pageXOffset;
			pageW=window.innerWidth-20;
			pageY=window.pageYOffset;
			pageH=window.innerHeight-20;
		} 
		else 
			{
			pageX=window.document.body.scrollLeft;
			pageW=window.document.body.offsetWidth-20;
			pageY=window.document.body.scrollTop;
			pageH=window.document.body.offsetHeight-20;
		} 
}


function imagesLoaded() 
{
	if ( !document.images ) 
	{
		return false;
	}
	
	if ( document.images.length <= 0 || !document.images.length ) 
	{
		return false;
	}

	for ( i=0; i<document.images.length; i++ ) {

		if ( !document.images[i] ) 
		{
			return false;
		}

		if ( navigator.appName.indexOf("Internet Explorer") != -1 && !document.images[i].complete ) 
		{
			return false;
		}
	}
	return true;
}

function Fensterweite()
{
 if (window.innerWidth) return window.innerWidth;
 else if (document.body && document.body.offsetWidth) return document.body.offsetWidth;
 else return 0;
}

function Fensterhoehe()
{
 if (window.innerHeight) return window.innerHeight;
 else if (document.body && document.body.offsetHeight) return document.body.offsetHeight;
 else return 0;
}


function neuAufbau()
{
// if (Weite != Fensterweite() || Hoehe != Fensterhoehe())
// window.history.go(0);

	if ( document.all.opel && document.all.kanister ) 
	{
		x = getAbsX( document.images["advtrans"] );
		y = getAbsY( document.images["advtrans"] );
		sxy( "opel", x, y );
		sxy( "strahl", x + 435, y + 27 );
		y2 = y + 27;

		x += 405;
		y = Fensterhoehe() - 220;
		sxy( "kanister", x, y );

		h = y - y2 + 75;

		layerWrite( "strahl", null, '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" WIDTH="75" HEIGHT="' + h + '" id="strahlswf" ALIGN=""> <PARAM NAME=scale VALUE=exactfit> <PARAM NAME=movie VALUE="strahl.swf"> <PARAM NAME=quality VALUE=high> <PARAM NAME=wmode VALUE=transparent> <PARAM NAME=bgcolor VALUE=#FFFFFF> <EMBED src="strahl.swf" quality=high wmode=transparent bgcolor=#FFFFFF  WIDTH="75" HEIGHT="' + h + '" NAME="strahlswf" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT>' );
		var mc = mie ? window.strahlswf : window.document.strahlswf;
		mc.TPlay( "/" );

	}
//	setTimeout( "neuAufbau()", 300 );
}


if ( navigator.appName.indexOf("Internet Explorer") != -1 || document.layers ) 
{
	/*Überwachung von Netscape initialisieren*/
	if(!window.Weite && window.innerWidth)
	 {
	   window.onresize = neuAufbau;
	   Weite = Fensterweite();
	   Hoehe = Fensterhoehe();
	 }

	/*Überwachung von MS Internet Explorer initialisieren*/
	 if(!window.Weite && document.body && document.body.offsetWidth)
	 {
	   window.onresize = neuAufbau;
	   Weite = Fensterweite();
	   Hoehe = Fensterhoehe();
	 }
}


function updRockPos()
{	
	try
	{
			var marker = document.getElementById('marker');
			var	rock = document.getElementById('goldenrock');
			
			var Xpos = getAbsX(marker);
			var Ypos = getAbsY(marker);
			// alert(Xpos );
			
			if ( mie ) Xpos += 20;
		
			sxy( 'goldenrock', Xpos - 245, Ypos - 340 );
	}
	catch (err)
	{
	}
}

setInterval( "updRockPos()", 20 );

