var myImgUrl = '';
var myWinAlert = '';
var imgWin = '';
var imgSheet = '';
var myTitle = '';
var myDescription = '';

function displaySheet(urlImg, itemTitle, itenDescription) {
	myImgUrl = urlImg; 
	if(itemTitle) {myTitle = itemTitle; }
        if(itenDescription) { myDescription = itenDescription; }
	imgSheet = new Image();
	imgSheet.onload = displayImages;
	imgSheet.onerror = displayDoc;
	myWinAlert = window.open('', 'ALERT', 'width=200,height=40,toolbar=no,location=no,menubar=no,resizable=yes');
	myWinAlert.document.open();
	myWinAlert.document.writeln('<html><body>Loading</body></html>');
	myWinAlert.document.close();
	myWinAlert.focus();
	imgSheet.src = urlImg;
	return; 
}

function displayImages () {
	var htmlWidth = imgSheet.width + 100;
	var htmlHeight = imgSheet.height + 200;
	var npw = 'width=' + htmlWidth + ',height=' + htmlHeight + ',toolbar=no,location=no,menubar=no,resizable=yes';
	if(imgWin) {
		imgWin.close();
	}	
	imgWin = window.open('', "MACRINIGROUP", npw);
	imgWin.document.open();
	imgWin.document.writeln('<html><head><title>' + myTitle + '</title><link href="../include/macrini_popup.css" type="text/css" rel="stylesheet"></head><body><center><div class="popup"> ' + myTitle + ' </div><span class="popup_img"><img src="' + myImgUrl + '"><br>' + myDescription + '</span></center></body></html>');
	imgWin.document.close();
	imgWin.resizeTo(htmlWidth, htmlHeight);
	myWinAlert.close();
	imgWin.focus();
	return;
}

function displayDoc () {

	var htmlWidth = 500;
	var htmlHeight = 400;
	var npw = 'width=' + htmlWidth + ',height=' + htmlHeight + ',toolbar=no,location=no,menubar=no,resizable=yes';
	imgWin = window.open(myImgUrl, "MACRINIGROUP", npw).focus(); 
	myWinAlert.close();
	return;
}
