var box;
var boxMinHeight = 50;
var boxMaxHeight = 0;
var moving = false;
var boxSpeed = 1;
var intervalId = 0;

function setUpBox( id )
{
	if( document.getElementById( id ) && document.getElementById( id + '_top' ) && document.getElementById( 'wrapper' ) && document.getElementById( 'footer') )
	{
		box = document.getElementById( id );
		box.style.position = 'absolute';
		box.style.height = String( boxMinHeight ) + 'px';
		
		var trigger = document.getElementById( id + '_top' );
		
		if( box.childNodes.length > 0 )
		{
			for( var i = 0; i < box.childNodes.length; i++ )
			{
				if( box.childNodes[i].offsetHeight > 0 )
				{
					boxMaxHeight += box.childNodes[i].offsetHeight;
				}
			}
		}
		
		if( window.addEventListener )
		{
			trigger.addEventListener( 'click', slide, false );
			//box.addEventListener( 'mouseover', slide, false );
			//box.addEventListener( 'mouseout', slide, false );
		}
		else
		{
			trigger.attachEvent( 'onclick', slide );
			//box.attachEvent( 'onmouseover', slide );
			//box.attachEvent( 'onmouseout', slide );
		}
		
	}
}
		
function slide()
{
	if( box )
	{
		if( moving )
		{
			return;
		}
		moving = true;
		if( box.offsetHeight < boxMaxHeight )
		{
			while( box.offsetHeight < boxMaxHeight )
			{
				stepUp();
			}
			moving = false;
		}
		else
		{
			while( box.offsetHeight > boxMinHeight )
			{
				stepDown();
			}
			moving = false;
		}
	}
}
		
function stepUp()
{
	if( box )
	{
		box.style.height = String( box.offsetHeight + 1 ) + 'px';
		box.style.top = String( box.offsetTop - 1 ) + 'px';
	}
}

function stepDown()
{
	if( box )
	{
		box.style.height = String( box.offsetHeight - 1 ) + 'px';
		box.style.top = String( box.offsetTop + 1 ) + 'px';
	}
}

function setUpWrapper()
{
	if( document.getElementById( 'wrapper' ) )
	{
		if( document.getElementById( 'wrapper' ).offsetHeight < document.documentElement.clientHeight )
		{
			document.getElementById( 'wrapper' ).style.height = String( document.documentElement.clientHeight - 105 ) + 'px';
		}
		else
		{
			document.getElementById( 'wrapper' ).style.height = '';
			if( document.getElementById( 'wrapper' ).offsetHeight < document.documentElement.clientHeight )
			{
				document.getElementById( 'wrapper' ).style.height = String( document.documentElement.clientHeight - 105 ) + 'px';
			}					
		}
	}
}
setUpBox( 'liftbox' );
setUpWrapper();
		
onresize = function(){
	setUpWrapper();
	setUpBox('lifbox');
	if( window.ddm1 )
	{
		ddm1.init();
	}
}
