var isO7 = ( window.opera && document.createElement ),
isMozilla = false,
isMSIE = false,
args = new Array(),
_N = " ",
INIT = 0 , UP = 1 , RIGHT = 2 , DOWN = 3 , LEFT = 4 , UNDO = 5 ,
NORTH = 1 , EAST = 2 , SOUTH = 3 , WEST = 4 ,
FORWARDS = 2 , BACKWARDS = -2 , TURNLEFT = -1 , TURNRIGHT = 1 ,
COMPASSPOINT = new Array( "" , "Norden" , "Osten" , "Süden" , "Westen" ) ,
cookiesEnabled = false , activeChapter = "weblog" ,
params , paramCounter = 0;

// **** Array ******************************************************************************
var arrayProtoTypeProperties = ",getIndex,deleteIndex,forAll,popRandom,isItem,makeRandomIndex,isEmpty,hasItems,clear,getLastChild,rotate";

Array.prototype.deleteIndex = function( v )
{   
	var T = this, i ,
  o = T[ v ];
  
	for ( i = v ; i < T.length ; i++ )
      T[ i ] = T[ i + 1 ];
    
	T.length-= 1;
	return o;
}

Array.prototype.getIndex = function( v )
{
    for (var i = 0 ; i < this.length ; i++ )
        if (this[ i ] == v ) 
           return i;
       
    return -1;
}

Array.prototype.forAll = function()
{
    for( var  i in this )
        if ( !inString( arrayProtoTypeProperties , i ) )
           if( this[ i ] , i );
}

Array.prototype.popRandom = function()
{
    var T = this;
    return T.deleteIndex( getRandom( T.length ) );
}

Array.prototype.isItem = function(v)
{
 return ( !inString( arrayProtoTypeProperties , v ) )
}

Array.prototype.makeRandomIndex = function()
{
    var randomArray = newArray();
    
    for (var i = 0 ; i < this.length ; i++ )
        randomArray.push( i );
        
    return randomArray;
}

Array.prototype.isEmpty = function()
{
 return ( this.length == 0 )
}

Array.prototype.hasItems = function()
{
 return ( this.length != 0 )
}

Array.prototype.clear = function()
{
 this.length = 0;
}

Array.prototype.getLastChild = function( v )
{
    if (v == null) 
       v = 1;
       
    if ( this.length < v ) 
       return null;
       
    return this[ this.length - v ]
};

Array.prototype.rotate = function( n )
{
     for (var i = 0 ; i < n ; i++ )
        this.push( this.shift() );
}

function validItem(i)
{
return ( !inString( arrayProtoTypeProperties , i ) )
}

function createDoubleArray( d1 , d2 )
{
    var a = new Array( d1 );
    
    for (var i = 0 ; i < d1 ; i++ )
        a[ i ] = ( d2 ) ? new Array( d2 ) : newArray();
        
    return a;
}

function newArray()
{
return new Array();
}

function splitString( o , x , d , n )
{
    o = o.split( d );
    
    if ( x != null ) 
       return o[ x ];
       
    if ( n ) 
    for (var i = 0 ; i < o.length ; i++ ) 
        o[ i ] *= 1 ;
        
    return o;
}

function splitSemicolon( o , x )
{
 return splitString( o , x , ";" );
};

function splitEqual( o , x )
{
 return splitString( o , x , "=" );
};

function splitChars( o , x )
{
 return splitString( o , x , "" );
};

function splitColon( o , x )
{
 return splitString( o , x , ":" );
};

function splitPipe( o , x )
{
 return splitString( o , x , "|" );
};

function nSplitPipe( o )
{
 return splitString( o , null , "|" , true );
};

function nSplitColon( o )
{
 return splitString( o , null , ":" , true );
};

function splitUnderScore( o , x )
{
 return splitString( o , x , "_" );
}

function splitScore( o , x )
{
 return splitString( o , x , "-" );
}

function splitComma( o , x )
{
 return splitString( o , x , "," );
}

function joinPipe( o )
{
 return o.join( "|" );
}

function joinColon( o )
{
 return o.join( ":" );
}

function joinBlank( o )
{
 return o.join( "" );
}

function check4Space( v )
{
 return ( v == " " ) ? " " : v ;
}

function getToggleText( o )
{
 return o.options[ o.selectedIndex ].text;
}

function getToggleValue( o )
{
 return o.options[ o.selectedIndex ].value;
}

function getSelectedIndex( o )
{
 return o.selectedIndex
}

function setSelectedIndex( o , v )
{
 o.selectedIndex = v;
}

function createToggleOptions( o , c , s )
{
    var start = o.options.length,
    selectedItem = -1;
    
    for (var i = 0 ; i < c.length ; i++ )
    {
        var v = splitColon( c[ i ] ),
        p = o.options[ start + i ] = new Option();
        
        if ( v.length == 1 ) 
           v[ 1 ] = v[ 0 ];
           
        p.value = v[ 0 ];
        p.text = v[ 1 ];
        
        if ( s == v[ 0 ] ) 
           selectedItem = i;
           
    };
    
    if ( selectedItem != -1 ) 
       setSelectedIndex( o , selectedItem );
};

function createNumericToggle( o , v )
{
  var  t = newArray();
  
  for ( var i = 1 ; i <= v ; i++ ) 
      t.push( i + ":" + i );
      
  createToggleOptions( o , t );
}

function getToggleIndex( o , c , x , refresh )
{
    if ( x == null ) 
       x = 0;
       
    var p = o.options;
    
    for (var i = 0 ; i < p.length ; i++ )
    {
          if ( splitColon( p[ i ].value )[ x ] == c )
          {
               if ( refresh ) 
                  o.selectedIndex = i;
                  
               return i;
          }
    };
    return -1;
};

function setIndex( o , v )
{
    if ( v == null ) 
       v = -1;
       
    o.selectedIndex = v;
};

function getIndex( o )
{
 return o.selectedIndex;
}

function setNotChecked( o )
{
 o.checked = false;
};

function setChecked( o )
{
 o.checked = true;
};

function isChecked( o )
{
 return o.checked;
};

function getRandom( m )
{
return  ( m == 1 ) ? 0 : ( getMathFloor( Math.random()*m ) );
};

function trim( s )
{
 return eval( 's.replace(/ /g,"")' );
}

function getChar( s , i )
{
 return s.charAt( i )
}

function getNumber( s , i )
{
 return 1 * s.charAt( i )
}

function getCharCode( v )
{
 return String.fromCharCode( v )
};

function getStringCode( s , v )
{
 return s.charCodeAt( v )
}


function getObj( o )
{
 return document.getElementById( o );
}

function cloneObj( o )
{
 return document.getElementById( o ).cloneNode( true );
}

function newObj( o , id , c , p )
{
    o = document.createElement( o );
    o.id = id;
    o.className = c;
    append( p , o );
    return o
};


function clone( o , v )
{
    o = o.cloneNode( true );
    
    if ( v ) 
       o.id = v;
       
    return o;
}

function getChildNodesLength( o )
{
 return o.childNodes.length;
}

function append( o1 , o2 , c )
{
    if ( c ) 
       setHTML( o1 , "" );
       
    return o1.appendChild( o2 );
}

function remove( o1 , o2 )
{
 o1.removeChild( o2 )
}

function removeChilds( o )
{
    setHTML( o );
    remove( o , o.firstChild );
}

function getFirstChild( o )
{
 return o.firstChild
}

function getLastChild( o )
{
 return o.lastChild
}

function getNextChild( o )
{
 return o.nextSibling;
}

function getChild( o , v )
{
 return o.childNodes[ v ]
}

function getParentNode( o )
{
 return o.parentNode;
}

function setWidth( o , w , r )
{
    if ( r ) 
       setDisplayNone( o );
       
    if ( w ) 
       w += "px";
        
    o.style.width = w;
    
    if ( r ) 
       setDisplayBlock( o );
}

function setWidths( v )
{
    var o = getArguments( setWidths );
    
    for (var i = 1 ; i < o.length ; i++ )
        setWidth( o[ i ] , v );
}

function setHeight( o , h )
{
    if ( h ) 
       h += "px";
       
    o.style.height = h;
}

function setHeightWidth( o , h , w )
{
    setHeight( o , h );
    setWidth( o , w );
}

function setTop( o , top )
{
    if ( hasPosTop ) 
       o.style.posTop = top;
    else	o.style.top = top + "px";
}

function setMarginTop( o , v )
{
 o.style.marginTop = v + "px";
}

function setLeft( o , l )
{
    if ( hasPosLeft ) 
       o.style.posLeft = l;
    else	o.style.left = l + "px";
}

function setTopLeft( o , t , l )
{
    var theStyle = o.style;
    
    if ( hasPosTop ) 
       theStyle.posTop = getMathFloor( t );
    else	theStyle.top = t + "px";
    
    if ( hasPosLeft ) 
       theStyle.posLeft = getMathFloor( l );
    else	theStyle.left = l + "px";
}

function setTLZ( o , t , l , z )
{
    setTopLeft( o , t , l );
    setZIndex( o , z );
};

function copyTLZ( t , s )
{
 setTLZ( t , getTop( s ) , getLeft( s ) , getZIndex( s ) );
};

function setHWTLZ( o , h , w , t , l , z )
{
    setHeightWidth( o , h , w );
    setTLZ( o , t , l , z );
};

function setNegTop( o )
{
 setTop( o , -1000 )
};

function setBorderTopWidth( o , v )
{
 o.style.borderTopWidth = v + "px";
};

function setBorderBottomWidth( o , v )
{
 o.style.borderBottomWidth = v + "px";
};

function setBorderLeftWidth( o , v )
{
 o.style.borderLeftWidth = v + "px";
};

function setBorderRightWidth( o , v )
{
 o.style.borderRightWidth = v + "px";
};

function setBorderTop( o , v )
{
 o.style.borderTop = v;
};

function setBorderBottom( o , v )
{
 o.style.borderBottom = v;
};

function setBorderLeft( o , v )
{
 o.style.borderLeft = v;
};

function setBorderRight( o , v )
{
 o.style.borderRight = v;
};

function setBorder( o , v )
{
 o.style.border = v;
}

function setBorderWidth( o , v )
{
    if ( !v ) 
       v = "0";
       
    o.style.borderWidth = v + "px";
};

function getBorderColor( o )
{
return o.style.borderColor;
}

function setBorderColor( o , v )
{
o.style.borderColor = v;
}

function getTop( o )
{
return parseInt(o.style.top);
};

function getLeft( o )
{
return parseInt(o.style.left);
};

function getWidth( o )
{
return parseInt(o.style.width);
};

function getHeight( o )
{
    var h = parseInt( o.style.height );
    
    if ( isNaN( h ) ) 
       h = "";
    
    return h;
};

function changeWidth( o , d )
{
 setWidth( o , getWidth( o ) + d )
};

function changeHeight( o , d )
{
 setHeight( o , getHeight( o ) + d )
};

function changeLeft( o , d )
{
 setLeft( o , getLeft( o ) + d )
};

function changeTop( o , d )
{
 setTop( o , getTop( o ) + d )
};


function setMarginLeft( o , v )
{
 o.style.marginLeft = v + "px";
}

function setMarginRight( o , v )
{
o.style.marginRight = v + "px";
}

function setHidden( o )
{
o.style.visibility = "hidden";
}

function setVisible( o )
{
o.style.visibility = "visible";
}

function handleVisibility( o , v )
{
    if ( v ) 
       setVisible( o ); 
    else setHidden( o );
};

function isVisible( o )
{
 return (o.style.visibility == "visible" );
}

function setDisplayNone( o )
{
 o.style.display = "none";
}

function setDisplayBlock( o )
{
 o.style.display = "block";
}

function isDisplayed( o )
{
 return o.style.display != "none"
};

function setBackgroundColor( o , v )
{
 o.style.backgroundColor = v;
};

function setColor( o , v )
{
 o.style.color = v;
};

function getColor( o )
{
 return o.style.color
};

function getBackgroundColor( o )
{
 return o.style.backgroundColor;
};

function getOffsetHeight( o )
{
 return o.offsetHeight;
};

function getOffsetWidth( o )
{
 return o.offsetWidth;
};

function setCursor( o , v )
{
    if ( !v ) 
       v="default";
       
    o.style.cursor = v
}

function setPaddingTop( o , v )
{
 o.style.paddingTop = v + "px";
}

function setPaddingLeft( o , v )
{
 o.style.paddingLeft = v + "px";
}

function setPaddingRight( o , v )
{
 o.style.paddingRight = v + "px";
}

function setPaddingTopLeft( o , t , l )
{
    setPaddingTop( o , t );
    setPaddingLeft( o , l );
}

function setPaddingLeftRight( o , l , r )
{
    setPaddingLeft( o , l );
    setPaddingRight( o , r );
}


function setImageHeightWidth( o , h , w )
{
    o.height = h;
    o.width = w;
}

function setClip( o , v )
{
    if ( !v ) 
       v = "auto auto auto auto";
       
    o.style.clip = "rect(" + v + ")";
}

function setZIndex( o , v )
{
 o.style.zIndex = v;
}

function getZIndex( o )
{
 return o.style.zIndex;
}

function setTextAlignCenter( o )
{
 o.style.textAlign = "center";
};

function setArial( o )
{
 o.style.fontFamily = "arial"
}

function setVerdana( o )
{
 o.style.fontFamily = "verdana"
}

function clearEvent( e )
{
    if ( !e ) 
       e = window.event;
       
    if ( !e ) 
       return false;
       
    if ( e.cancelBubble != null )
    {
        e.cancelBubble = true;
        e.returnValue = false;
    };
    
    if ( e.stopPropagation ) 
       e.stopPropagation();
       
    if ( e.preventDefault ) 
       e.preventDefault();
       
    return false;
}

function clearSelectEvent( o )
{
    if ( isMSIE && o )
     o.ondrag = o.onselect = o.onselectstart = clearSelectEvent;
    
    return false;
}

function getEvent()
{
 return window.event;
}

function handleVisibility( o , v )
{
 o.style.visibility = ( v ) ? "visible" : "hidden";
}

function getUpperCase( v )
{
 return v.toUpperCase();
}

function getLowerCase( v )
{
 return v.toLowerCase();
}


function disable()
{
    var o = disable.arguments;
    
    for (var i = 0 ; i < o.length ; i++ ) 
        o[ i ].disabled = true;
}

function enable()
{
    var o = enable.arguments;
    
    for (var i = 0 ; i < o.length ; i++ ) 
        o[ i ].disabled = false;
}

function isDisabled( o )
{
 return o.disabled
}

function handleEnable( o , v )
{
    if ( v ) 
       enable( o ); 
    else disable( o );
}

function setFontSize( o , v )
{
 o.style.fontSize = v + "pt";
}

function setHTML( o , v )
{
    if (v == null) 
       v = _N;
       
    o.innerHTML = v;
}

function getHTML( o )
{
 return o.innerHTML
};


function setValue( o , v )
{
    if ( isSELECT( o ) ) 
       setSelectedIndex( o , v );
    else o.value = v;
};

function getValue( o )
{
    if ( isSELECT( o ) ) 
       return getSelectedIndex( o );
       
    if ( o.type == "checkbox" ) 
       return ( o.checked ) ? 1 : 0;
       
    return o.value
}

function call( c , d )
{
    if ( !d ) 
       d=1;
       
    window.setTimeout( c , d );
};

function killTimer( v )
{
 window.clearTimeout( v );
}

function addTimer( v , d )
{
    if ( d < 0 ) 
       return null;
       
    if ( d == 0 )
    {
        eval( v );
        return null;
    };
    
    return window.setTimeout( v , d );
};


function initCrossBrowser( o )
{
    if ( !o ) 
       o = document.body;
       
    hasDocumentAll = document.all;
    hasPosTop = ( o.style.posTop != null );
    hasPosLeft = ( o.style.posLeft != null );
    isO7 = ( window.opera && document.createElement );
    isMozilla = !hasDocumentAll;
    isMSIE = !( isO7 || isMozilla );
    args = newArray();
    if ( location.search )
    {
    	var newArgs = location.search.substr( 1 ).split( "&" );
    	for (var i = 0 ; i < newArgs.length ; i++ )
    	{
    		var v = newArgs[ i ].split( "=" );
    		args[ v[ 0 ] ] = v[ 1 ];
    	}
    };
    args.debug  = true;
}

function isImageFile(n)
{
    var validTypes = "JPG,GIF,PNG,BMP";
    n = n.split( "." );
    return  (n.length == 2 && n[ 1 ].length == 3 && inString( validTypes , getUpperCase( n[ 1 ] ) ) )
}

function setImageSize( o , h , w )
{
    o.height = h;
    o.width = w;
}

function getDate()
{
 return new Date()
}

function newDate()
{
 return new Date()
};

function setFilter( o , v )
{
 o.style.filter = v;
}

function setTextDecoration( o , v )
{
 o.style.textDecoration = v
}

function setTableLayoutFixed( o )
{
 o.style.tableLayout = "fixed"
}

// ***************************************************

function getEventTarget( e )
{
    if ( !e ) 
       return null;
       
    if ( e.target ) 
       return e.target;
       
    return e.srcElement;
}

function getEventOffsetX( e )
{
    if ( isMozilla )
    {
    	if ( !e.target.pageLeft ) 
         setPageTopLeft( o );
         
    	return e.pageX - e.target.pageLeft;
    }
    else return e.offsetX
}

function getEventOffsetY( e )
{
    if ( isMozilla )
    {
    	if ( !e.target.pageLeft ) 
         setPageTopLeft( o );
         
    	return ( e.pageY - e.target.pageTop );
    }
    else return e.offsetY
}

function getEventOffset(e)
{
    var r = newArray();
    r.oX = getEventOffsetX( e );
    r.oY = getEventOffsetY( e );
    return result
}

function setPageTopLeft( o )
{
    if ( isMozilla )
    {
        var top = 0,
        left = 0,
        o = o;
        
        while ( o.offsetParent )
         {
             left += o.offsetLeft ;     
             top += o.offsetTop ;
             o = o.offsetParent ;
        };
        
        o.pageTop = top;
        o.pageLeft = left;
    }
}

function isTag( o , v )
{
 return o.tagName == v;
}

function isSPAN( o )
{
 return isTag( o , "SPAN" );
}

function isINPUT( o )
{
 return isTag( o , "INPUT" )
}

function isSELECT( o )
{
 return isTag( o , "SELECT" )
}

function isBUTTON( o )
{
return ( o.type == "button" || isTag( o , "BUTTON" ) );
}

// ************************************* Math **************************************
function getMathFloor( v )
{
return Math.floor( v )
}

function getMathAbs( v )
{
 return Math.abs( v )
}

function getMathCeil( v )
{
 return Math.ceil( v )
}

function getMathSqrt( v )
{
 return Math.sqrt( v )
}

function getMathRound( v )
{
 return Math.round( v )
}

function getMathMin( v1 , v2 )
{
 return Math.min( v1 , v2 )
}

function getNumericValue( o , a , b , d )
{
    var v = 1 * o.value;
    
    if ( isNaN( v ))
    {
         v = d;
         setValue( o , v );
    }
    else if ( !( v >= a && v <= b) )
    {
        v = d;
        setValue( o , v );
    };
    
    return v;
}

function twoDigits( v )
{
    if ( v < 10 ) 
       v = "0" + v;
       
    return v;
};

function getParam()
{
    if ( paramCounter == 0 )
    {
        params = location.search;
        
        if ( params )
           params = getUpperCase( params.substr( 1 ) ).split( "&" );
        else
        {
            paramCounter = -1;
            return null;
        }
    };
    if ( paramCounter < params.length )
    {
        var c = params[ paramCounter++ ].split( "=" );
        c.name = c[ 0 ];
        c.value = c[ 1 ];
        return c;
    }
};

function initKeyboard( f , m )
{
    var K = newArray();
    
    if ( !m )
       m = 0;
       
    switch ( m )
    {
        case 0 :
        
            K[ 40 ] = K[ 98 ] = K[ 50 ] = DOWN; 	
            K[ 37 ] = K[ 100 ] = K[ 52 ] = LEFT;	
            K[ 39 ] = K[ 102 ] = K[ 54 ] = RIGHT;	
            K[ 38 ] = K[ 104 ] = K[ 56 ] = UP;
            break;
            
        case 1:
        
            K[ 40 ] = K[ 98 ] = K[ 50 ] = BACKWARDS; 	
            K[ 37 ] = K[ 100 ] = K[ 52 ] = TURNLEFT;	
            K[ 39 ] = K[ 102 ] = K[ 54 ] = TURNRIGHT;	
            K[ 38 ] = K[ 104 ] = K[ 56 ] = FORWARDS;
            break;
    };
    
    if ( isO7 )
       document.onkeypress = f;
    else document.onkeydown = f;
    
    return K
}

function getOppositeDirection( d )
{
    switch ( d )
    {
        case NORTH :
        
        	return SOUTH;
             
        case EAST :
        	
             return WEST;
             
        case SOUTH :
        	
             return NORTH;
             
        case WEST :
        	
             return EAST;
    };
}

function createNewImage( stdImage , id , s , o , t , l , h , w , z )
{
    var n = stdImage.cloneNode( true );
    n.id = id;
    setTopLeft( n , t , l );
    
    if ( z ) 
       setZIndex( n , z );
       
    if ( s ) 
       n.src = s;
       
    o.appendChild( n );
    setImageHeightWidth( n , h , w );
    return n;
};

function preloadNewImage( o , f , s , po )
{
    o.onload = f;
    o.src = s;
    append( po , o );
}

function preloadImages( b , stdImg , c , p , n , e , callBack )
{
    if ( !stdImg )
    {
        if ( ( --preloadImages.maxImages ) == 0 )
           return eval( preloadImages.callBack );
    }
    else
    {
        n = splitPipe( n );
        preloadImages.maxImages = n.length;
        preloadImages.callBack = callBack;
        for (var i = 0 ; i < n.length ; i++ )
        {
            var m = p + n[ i ] + "." + e;
            preloadNewImage( c[ m ] = clone( stdImg ), preloadImages , m , b );
        };
    }
}

function setStatic( o )
{
 o.style.position = "static";
}

function setAbsolute( o )
{
 o.style.position = "absolute";
};

function setAttrib( o , n , v )
{
 o.setAttribute( n , v );
}

function getAttrib( o , n )
{
 return o.getAttribute( n )
}


function setMouseOver( o , v )
{
    if ( !v ) 
       v = null;
       
    o.onmouseover = v
}

function setMouseOut( o , v )
{
    if ( !v ) 
       v = null;
       
    o.onmouseout = v
}

function setMouseDown( o , v )
{
    if ( !v ) 
       v = null;
       
    o.onmousedown = v
}

function setMouseMove( o , v )
{
    if ( !v ) 
       v = null;
       
    o.onmousemove = v
}

function setMouseUp( o , v )
{
    if ( !v ) 
       v = null;
       
    o.onmouseup = v
}

function setLoad( o , v )
{
    if ( !v ) 
       v = null;
       
    o.onload = v
}

function setClick( o , v )
{
    if ( !v ) 
       v = null;
       
    o.onclick = v
}

function inString( o , s )
{
 return o.indexOf( s ) != -1;
}

function getString( o )
{
 return o.toString()
}

function getArguments( o )
{
 return o.arguments
}

// *****************************************************
function addLog( m )
{
 getObj( "debugBox" ).innerHTML += ( m + "
" ); } function activateCounter( s ) { if( 0 ) { getObj( "counterLink" ).onload = showCounter; getObj( "counterLink" ).src = s; } } function showCounter() { setVisible( getObj( "counterLabel" ) ); setVisible( getObj( "counterLink" ) ); } // ********************************************** function setCookieTime( d ) { if ( !d ) return ( new Date( 2037 , 0 , 1 )).toGMTString(); return new Date( ( new Date().getTime() + 1000 * 3600 * 24 * d ) ).toGMTString(); } function setCookie( n , v , e ) { if ( cookiesEnabled ) { if ( !e ) e = setCookieTime(); else e = setCookieTime( e ); }; var c = n + "=" + unescape( v ) + ";"; if ( e ) c += "expires=" + e + ";"; if ( cookiesEnabled ) document.cookie = c; } function getCookie() { if ( !cookiesEnabled ) return newArray(); var v = newArray() , i , p , n = splitSemicolon( document.cookie ); for ( i in n ) { if ( validItem( i ) ) { p = splitEqual( n[ i ] ); v[ eval( "p[0].replace(/^ /,'')" ) ] = p[ 1 ]; } }; return v; } function getCookieValue( n ) { var v = getCookie(); return ( v[ n ] ) ? v[ n ] : ""; } function deleteCookie( n ) { var c = n + "=;expires=" + setCookieTime( -1 ); if ( cookiesEnabled ) document.cookie = c; } // *********************************** function showChapter( chapter ) { setDisplayNone( getObj( activeChapter ) ); activeChapter = chapter; setDisplayBlock( getObj( activeChapter ) ); }