﻿// used by versacenews_IT.swf and versacenews_IT.swf to open popup windows
// showing images
function OpenImage(imageUrl, path)
{
	var init_width = 100;
	var init_height = 100;
	var init_left = Math.floor((screen.availWidth - init_width)/2);
	var init_top = Math.floor((screen.availHeight - init_height)/2);

	var newWin = window.open(path + '/ShowImage.htm?imageUrl=' + imageUrl,
		'_new',
		'width=' + init_width + ',height=' + init_height + ',top=' + init_top + ',left=' + init_left + ',scrollbars=no,resizable=yes,status=no,location=no,toolbar=no');
}

// used by ShowImage.htm to dynamically show the images
function RenderImage()
{
	var url = document.URL;
	if(url.indexOf('?') != -1)
	{
		var queryString = url.substring(url.indexOf('?') + 1);
		var imageUrl = queryString.substring(queryString.indexOf('=') + 1);
		var img = document.getElementById('ph');
		var loading = document.getElementById('loading');
		if(loading != null) loading.style.display = 'none';

		if(img != null)
			img.src = imageUrl;
		else
			alert('An error occurred, the image cannot be shown.');
	}
	else
	{
		alert('An error occurred, the image cannot be shown.');
	}
};

// used by ShowImage.htm to dynamically adapt window size and position
// based to image size
function SetWindowSizeSize(img)
{
	var windowWidth = Math.min(img.width + 8, screen.availWidth);
	var windowHeight = Math.min(img.height + 86, screen.availHeight);
	window.resizeTo(
		windowWidth,
		windowHeight
	);
	window.moveTo(
		Math.floor((screen.availWidth - windowWidth) / 2),
		Math.floor((screen.availHeight - windowHeight) / 2)
	);
};