
function openDownloadDialog()
{
	if( parseInt( $( 'main' ).viewportOffset().top ) > 0 ) //avoid the ispace, but don't scroll up
		$( 'main' ).scrollTo();
//	else if( parseInt( $( 'other_layouts_list' ).viewportOffset().top ) < 0 ) //avoid the ispace, but don't scroll up
//		$( 'other_layouts_list' ).scrollTo();
		
//	preloadLayoutImage();

	var fun = function() {
		loadDownloadDialog();
		showBox();
	};
	
//	if( Prototype.Browser.IE )
//		setTimeout( fun, 2000 );
//	else
		fun();
}

function preloadLayoutImage()
{
	var src = linkprefix+'...';
	if( src )
		preloadImage( src );
}

function preloadImage( src )
{
	$( 'preload_img' ).src = src;
}

function loadDownloadDialog()
{
	$('box').update( $('download_dialog').innerHTML );
}

function closePreview()
{
	//$('box').update('');
	hideBox();
//	$('preload_img').src = '';
}

Event.observe( window, 'load', function() {
	$( 'main' ).scrollTo();
	if( document.location.href.match( /download_/ ) )
		openDownloadDialog();
});