var nowH = 100;
var tagH;
var timerID;
var easing = 0.2;
var ffPositionTop = document.getElementById( 'ff' ).offsetTop;
var siPositionTop = document.getElementById( 'site-image' ).offsetTop;
var oldIE = false;


if( navigator.userAgent.indexOf( 'MSIE' ) != -1 )
{
	var IEVersion = parseInt( ( navigator.userAgent ).substr( ( navigator.userAgent.indexOf( 'MSIE' ) + 5 ), 3 ) );
	oldIE = IEVersion < 7;
}


function changeHeight( h )
{
	tagH = h;
	clearInterval( timerID );
	timerID = setInterval( "changeHeigthHandler()", 1000 / 30 );
	window.focus();
}


function changeHeigthHandler()
{
	if ( document.getElementById )
	{
		ffPositionTop = ( ( tagH - nowH ) * easing ) + ffPositionTop;
		siPositionTop = ( ( tagH - nowH ) * easing ) + siPositionTop;
		nowH = ( ( tagH - nowH ) * easing ) + nowH;
		document.getElementById( "flashContent" ).style.height = nowH + "px";
		if( oldIE )
		{
			document.getElementById( "loader" ).style.height = nowH + "px";
			document.getElementById( 'ff' ).style.top = ffPositionTop + 'px';
			document.getElementById( 'site-image' ).style.top = siPositionTop + 'px';
		}

		if ( Math.abs( tagH - nowH ) <= 1 )
		{
			document.getElementById( "flashContent" ).style.height = tagH + "px";
			if( oldIE )
			{
				document.getElementById( "loader" ).style.height = tagH + "px";
				document.getElementById( 'ff' ).style.top = 'auto';
				document.getElementById( 'ff' ).style.bottom = '-1px';
				document.getElementById( 'site-image' ).style.top = 'auto';
				document.getElementById( 'site-image' ).style.bottom = '40px';
			}
			clearInterval( timerID );
		}
	}
	else if ( document.all )
	{
		ffPositionTop = ( ( tagH - nowH ) * easing ) + ffPositionTop;
		nowH = ( ( tagH - nowH ) * easing ) + nowH;
		document.all( "flashContent" ).style.height = nowH + "px";
		if( oldIE )
		{
			document.all( "loader" ).style.height = nowH + "px";
			document.all( 'ff' ).style.top = ffPositionTop + 'px';
			document.all( 'site-image' ).style.top = siPositionTop + 'px';
		}		

		if ( Math.abs( tagH - nowH ) <= 1 )
		{
			document.all( "flashContent" ).style.height = tagH + "px";
			if( oldIE )
			{
				document.all( "loader" ).style.height = tagH + "px";
				document.all( 'ff' ).style.top = 'auto';
				document.all( 'ff' ).style.bottom = '-1px';
				document.all( 'site-image' ).style.top = 'auto';
				document.all( 'site-image' ).style.bottom = '40px';
			}
			clearInterval( timerID );
		}
	}
}
