

function stripPX( str )
{
	var p = str.indexOf( "px" );
	return str.substr( 0, p );
}

function switchContent( contentId )
{
	var bugYPos = stripPX( document.getElementById( 'kaefer' ).style.top );
	var newYPos = stripPX( document.getElementById( contentId ).style.top );
	if( bugYPos == "") bugYPos = 0;
	
	if( contentId.indexOf( "no_content" ) == 0 )
		location.href = "index.php?content=no_content&oldpos="+bugYPos+"&newpos="+newYPos;
	else	
		location.href = "index.php?content="+contentId+"&oldpos="+bugYPos+"&newpos="+newYPos;		
}

// ---[ BUGCONTROL ]----------------------------------------------------

function moveBug( oldPos, newPos )
{
	setBugStartupPosition( oldPos );
	new Effect.MoveBy('kaefer', newPos - oldPos, 0, { duration: 2.0 } );
	document.getElementById( 'kaefer' ).style.display = "block";
	
	if( ( newPos - oldPos ) >= 0 )
		setBugImage( "down" );
	else
		setBugImage( "up" );
}

function setBugStartupPosition( oldPos )
{
	document.getElementById( 'kaefer' ).style.display = "none";
	var bugYPos = stripPX( document.getElementById( 'kaefer' ).style.top );
	new Effect.MoveBy('kaefer', oldPos, 0, { duration: 0 } );
}

function setBugImage( direction )
{
	document.getElementById( 'bug_img' ).src = "img/set/bug_"+direction+".gif";
}

// ---[ IMG PRELOADER ]----------------------------------------------------
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
