// JavaScript Document

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

///////////////////////////////////////////////////////////////////////////////////////////////////

function SD_AutoOffSetFirstLayer( axis, left, top ) // 1 == only Width, 2 == only Height, 3 == both
{
            //var firstLayer = document.getElementsByTagName("div")[0].firstChild;
            var firstLayer = document.getElementsByTagName("div")[0];
            //alert( firstLayer.data);
           
            //var mainDivWidth = document.getElementById('mainLayer').offsetWidth;
            var mainDivWidth = firstLayer.offsetWidth;
            var mainDivHeight = firstLayer.offsetHeight;
 
            var bodyWidth, bodyHeight;
            if ( self.innerHeight ) // all except Explorer
            {
                        bodyWidth = self.innerWidth;
                        bodyHeight = self.innerHeight;
            }
            else if ( document.documentElement && document.documentElement.clientHeight )
                        // Explorer 6 Strict Mode
            {
                        bodyWidth = document.documentElement.clientWidth;
                        bodyHeight = document.documentElement.clientHeight;
            }
            else if ( document.body ) // other Explorers
            {
                        bodyWidth = document.body.clientWidth;
                        bodyHeight = document.body.clientHeight;
            }
            //alert( 'bodyWidth: ' +  bodyWidth + ', bodyHeight: ' + bodyHeight + ' // mainDivWidth: ' + mainDivWidth + ', mainDivHeight: ' + mainDivHeight );


            //if( document.body.offsetWidth < mainDivWidth  )
            if( ( axis == 1 ) || ( axis == 3 ) ) {
				if( bodyWidth < mainDivWidth  )
				{
							//alert('bodyWidth: ' +  bodyWidth);
							firstLayer.style.left = left + 'px';
							firstLayer.style.marginLeft = 0 + 'px';
				} 
				else
				{
							//alert(document.body.offsetWidth);
							firstLayer.style.left = '50%';
							firstLayer.style.marginLeft = - ( mainDivWidth / 2 ) + 'px';
				}
			}
			
			if( ( axis == 2 ) || ( axis == 3 ) ) {
				if( bodyHeight < mainDivHeight  )
				{
							//alert('bodyHeight: ' + bodyHeight);
							firstLayer.style.top = top + 'px';
							firstLayer.style.marginTop = 0 +'px';
				} 
				else
				{
							firstLayer.style.top = '50%';
							firstLayer.style.marginTop = - ( mainDivHeight / 2 ) + 'px';
				}
			}
}

function SD_Jump()
{
            //var firstLayer = document.getElementsByTagName("div")[0].firstChild;
            var firstLayer = document.getElementsByTagName("div")[0];
            //alert( firstLayer.data);
           
            //var mainDivWidth = document.getElementById('mainLayer').offsetWidth;
            var mainDivWidth = firstLayer.offsetWidth;
            var mainDivHeight = firstLayer.offsetHeight;
 
            var bodyWidth, bodyHeight;
            if ( self.innerHeight ) // all except Explorer
            {
                        bodyWidth = self.innerWidth;
                        bodyHeight = self.innerHeight;
            }
            else if ( document.documentElement && document.documentElement.clientHeight )
                        // Explorer 6 Strict Mode
            {
                        bodyWidth = document.documentElement.clientWidth;
                        bodyHeight = document.documentElement.clientHeight;
            }
            else if ( document.body ) // other Explorers
            {
                        bodyWidth = document.body.clientWidth;
                        bodyHeight = document.body.clientHeight;
            }
            //alert( 'bodyWidth: ' +  bodyWidth + ', bodyHeight: ' + bodyHeight + ' // mainDivWidth: ' + mainDivWidth + ', mainDivHeight: ' + mainDivHeight );


            //if( document.body.offsetWidth < mainDivWidth  )
            if( bodyWidth < mainDivWidth  )
            {
                        //alert('bodyWidth: ' +  bodyWidth);
                        firstLayer.style.left = 10 + 'px';
                        firstLayer.style.marginLeft = 0 + 'px';
            } 
            else
            {
                        //alert(document.body.offsetWidth);
                        firstLayer.style.left = '50%';
                        firstLayer.style.marginLeft = - ( mainDivWidth / 2 ) + 'px';
            }

 
            if( bodyHeight < mainDivHeight  )
            {
                        //alert('bodyHeight: ' + bodyHeight);
                        firstLayer.style.top = 10 + 'px';
                        firstLayer.style.marginTop = 0 +'px';
            } 
            else
            {
                        firstLayer.style.top = '50%';
                        firstLayer.style.marginTop = - ( mainDivHeight / 2 ) + 'px';
            }
}

function SD_SetFooter( layerIdSource, layerIdFooter, space, footerZIndex ) {
	//alert(layerName);	
	var layerSourceHeight = document.getElementById( layerIdSource ).offsetHeight;
	var layerSourceY = document.getElementById( layerIdSource ).offsetTop;
	var layerFooter = document.getElementById( layerIdFooter );
	
	var bodyWidth, bodyHeight;
	if ( self.innerHeight ) // all except Explorer
	{
				bodyWidth = self.innerWidth;
				bodyHeight = self.innerHeight;
	}
	else if ( document.documentElement && document.documentElement.clientHeight )
				// Explorer 6 Strict Mode
	{
				bodyWidth = document.documentElement.clientWidth;
				bodyHeight = document.documentElement.clientHeight;
	}
	else if ( document.body ) // other Explorers
	{
				bodyWidth = document.body.clientWidth;
				bodyHeight = document.body.clientHeight;
	}
	
	if( ( layerSourceHeight >= 300 )  ) {
		layerFooter.style.top = layerSourceHeight + layerSourceY + space + 'px';
	}
	
	/*	set footer z-index (if javascript is enabled, the footer could get another z-index. If javascript ist disabled, 
	  	the footer could not clash with content, if the footer z-index is lower than the footer z-index of the main layer by default  */
	layerFooter.style.zIndex = footerZIndex;
}

function SD_SetSameHeightThanBody( targetDiv ) {
	var layer = document.getElementById( targetDiv );
	var mainDivWidth = layer.offsetWidth;
	var mainDivHeight = layer.offsetHeight;	
	var bodyWidth, bodyHeight;
	
	if ( self.innerHeight ) // all except Explorer
	{
				bodyWidth = self.innerWidth;
				bodyHeight = self.innerHeight;
	}
	else if ( document.documentElement && document.documentElement.clientHeight )
				// Explorer 6 Strict Mode
	{
				bodyWidth = document.documentElement.clientWidth;
				bodyHeight = document.documentElement.clientHeight;
	}
	else if ( document.body ) // other Explorers
	{
				bodyWidth = document.body.clientWidth;
				bodyHeight = document.body.clientHeight;
	}
    
	if( bodyHeight > mainDivHeight  ) {	
		//alert( "bodyHeight > mainDivHeight" );
		layer.style.height = bodyHeight + 'px';
	}
}

function SD_TheOnLoad() { 
	SD_AutoOffSetFirstLayer( 1, 0, 0 ); 
	SD_SetSameHeightThanBody( 'mainDiv' );
}

function SD_TheOnResize() {
	SD_AutoOffSetFirstLayer( 1, 0, 0 ); 
	SD_SetSameHeightThanBody( 'mainDiv' );
}


