// JavaScript Document

function MM_reloadPage(init) {  
  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 ) 
{
          
            var firstLayer = document.getElementsByTagName("div")[0];
            
            var mainDivWidth = firstLayer.offsetWidth;
            var mainDivHeight = firstLayer.offsetHeight;
 
            var bodyWidth, bodyHeight;
            if ( self.innerHeight ) 
            {
                        bodyWidth = self.innerWidth;
                        bodyHeight = self.innerHeight;
            }
            else if ( document.documentElement && document.documentElement.clientHeight )
                       
            {
                        bodyWidth = document.documentElement.clientWidth;
                        bodyHeight = document.documentElement.clientHeight;
            }
            else if ( document.body )
            {
                        bodyWidth = document.body.clientWidth;
                        bodyHeight = document.body.clientHeight;
            }
            


          
            if( ( axis == 1 ) || ( axis == 3 ) ) {
				if( bodyWidth < mainDivWidth  )
				{
							
							firstLayer.style.left = left + 'px';
							firstLayer.style.marginLeft = 0 + 'px';
				} 
				else
				{
						
							firstLayer.style.left = '50%';
							firstLayer.style.marginLeft = - ( mainDivWidth / 2 ) + 'px';
				}
			}
			
			if( ( axis == 2 ) || ( axis == 3 ) ) {
				if( bodyHeight < mainDivHeight  )
				{
							
							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];
            
           
           
            var mainDivWidth = firstLayer.offsetWidth;
            var mainDivHeight = firstLayer.offsetHeight;
 
            var bodyWidth, bodyHeight;
            if ( self.innerHeight ) 
            {
                        bodyWidth = self.innerWidth;
                        bodyHeight = self.innerHeight;
            }
            else if ( document.documentElement && document.documentElement.clientHeight )
                        
            {
                        bodyWidth = document.documentElement.clientWidth;
                        bodyHeight = document.documentElement.clientHeight;
            }
            else if ( document.body )
            {
                        bodyWidth = document.body.clientWidth;
                        bodyHeight = document.body.clientHeight;
            }
            
            if( bodyWidth < mainDivWidth  )
            {
                       
                        firstLayer.style.left = 10 + 'px';
                        firstLayer.style.marginLeft = 0 + 'px';
            } 
            else
            {
                       
                        firstLayer.style.left = '50%';
                        firstLayer.style.marginLeft = - ( mainDivWidth / 2 ) + 'px';
            }

 
            if( bodyHeight < mainDivHeight  )
            {
                       
                        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 ) {

	var layerSourceHeight = document.getElementById( layerIdSource ).offsetHeight;
	var layerSourceY = document.getElementById( layerIdSource ).offsetTop;
	var layerFooter = document.getElementById( layerIdFooter );
	
	var bodyWidth, bodyHeight;
	if ( self.innerHeight ) 
	{
				bodyWidth = self.innerWidth;
				bodyHeight = self.innerHeight;
	}
	else if ( document.documentElement && document.documentElement.clientHeight )
				
	{
				bodyWidth = document.documentElement.clientWidth;
				bodyHeight = document.documentElement.clientHeight;
	}
	else if ( document.body )
	{
				bodyWidth = document.body.clientWidth;
				bodyHeight = document.body.clientHeight;
	}
	
	if( ( layerSourceHeight >= 300 )  ) {
		layerFooter.style.top = layerSourceHeight + layerSourceY + space + 'px';
	}
	

	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 )
	{
				bodyWidth = self.innerWidth;
				bodyHeight = self.innerHeight;
	}
	else if ( document.documentElement && document.documentElement.clientHeight )
				
	{
				bodyWidth = document.documentElement.clientWidth;
				bodyHeight = document.documentElement.clientHeight;
	}
	else if ( document.body ) 
	{
				bodyWidth = document.body.clientWidth;
				bodyHeight = document.body.clientHeight;
	}
    
	if( 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' );
}


