var scrollInterval;
var lastY		= 0;
var maxInterval	= 50;
var scrollCount;
function scroll_to_top()
{
	clearInterval(scrollInterval);
	var coords		= getScrollXY();
	lastY			= coords[1];
	scrollCount		= 0;
	scrollInterval	= setInterval(scrollIt, 20);
}
function scrollIt()
{
	var coords	= getScrollXY();
	if(coords[1] > 2 && scrollCount < maxInterval && lastY >= coords[1])
	{
		window.scrollTo(0,coords[1]-coords[1]/4);
		scrollCount++;
		lastY	= coords[1];
	}
	else
	{
		window.scrollTo(0,0);
		clearInterval(scrollInterval);
		scrollCount	= 0;
	}
}
function resize(height)
{
	var winHeight	= $(window).height();
	var winWidth	= $(window).width();
	height			= ( height < winHeight ? winHeight : height );
	updateFlash(winWidth, height);
}
window.onresize = function()
{
	if(typeof myFlashObject != 'undefined')
	{
		var winWidth	= $(window).width();
		var winHeight	= $(window).height();
		height			= ( myFlashObject.height < winHeight ? winHeight : myFlashObject.height );
		updateFlash(winWidth, height);
	}
}
function updateFlash(w,h)
{
	/*
	DEPRECATED, Makes the Flash movie "Blink" in Firefox
	var fObj	= document.getElementById(SWFAddress.getId());
	if(fObj)
	{
		fObj.width	= w;
		fObj.height	= h;
	}
	*/
	$('#canvas').css('height', h);
}
function getScrollXY() 
{
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}
function getMiddlePage()
{
	var coords		= getScrollXY();
	var winHeight	= $(window).height();
	var fObj		= document.getElementById(SWFAddress.getId());
	if(fObj)
	{
		fObj.getMiddlePage(coords[1] + winHeight/2);
	}
}
