function isdefined( variable){
    return (typeof(window[variable]) == "undefined")?  false: true;
}

function viewImage(imageUrl, width, height, title, downloadUrl, downloadTitle)
{
	var widthVar;
	var heightVar;
	if (width == null || width == "0" || width == "null")
	{
        widthVar = 500;
	}
    else {
        widthVar = parseInt(width)+25;
    }

	if (height == null || height == "0" || height == "null"){
	    heightVar = 500;
	}
    else {
		heightVar = parseInt(height) + 55;
    }

	var popupOptions = "width="+widthVar+",height="+heightVar+",menubar=no,location=no,resizable=yes,scrollbars=no,status=yes";
    popup = window.open(imageUrl, "ProductImage", popupOptions);


    popup.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' + "\n");
	popup.document.write('<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs" lang="cs">' + "\n");
	popup.document.write('<head>' + "\n");
	popup.document.write('<link rel="stylesheet" type="text/css" href="/css/main.css" media="screen"/>' + "\n");
	popup.document.write('<title>' + title + '&gt; BaSys</title>' + "\n");
	popup.document.write('</head>' + "\n");
    popup.document.write('<body style="background: white; margin: 0; padding: 0;">' + "\n");
    popup.document.write('<div align="center">' + "\n");
    popup.document.write('<img src="' + imageUrl + '" widht="'+ width +'" height="' + height + '" title="' + title + '" alt="' + title + '" onclick="window.close();" /><br />' + "\n");
    popup.document.write('<a href="#" onclick="window.close();">[x] ' + title + '</a>' + "\n");
    if (isdefined(downloadUrl) && downloadUrl != ''&& isdefined(downloadTitle) && downloadTitle != '')
	    popup.document.write('<br /><a href="' + downloadUrl + '">[ ' + downloadTitle + ' ]</a>' + "\n");
    popup.document.write('</div>' + "\n");
    popup.document.write("</body>" + "\n");
    popup.document.write("</html>" + "\n");


}
