// Script made by J.H. Edelbroek
//
// Adjust the following variables for your own convenience
// timeout: number of seconds after which the window will close automatically
//          set to 0, when window should not close automatically
// closeonclick: set to 1 to close the window when clicked
//               set to 0 to disable the closing when clicked
// Usage:
// Add following line in header of html-page
// <script language="JavaScript" src="viewImage.js"></script>
// Add following line in body, adjust image_name, image_width and image_height to your image
// <a onClick="viewImage('image_name',image_width,image_height)"></a> 

var timeout = 0;
var closeonclick = 1;

function viewImage(URL, WIDTH, HEIGHT) {

if (timeout != 0) HEIGHT += 20;
windowprops = "top="+(screen.height-HEIGHT)/2+",left="+(screen.width-WIDTH)/2+",width=" + WIDTH + ",height=" + HEIGHT;
TITLE = URL.substring(URL.lastIndexOf('/')+1);

text = "<html><head><title>"+TITLE+"</title></head><body leftmargin=\"0\" topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\" bgcolor=\"white\"";
if (timeout != 0) text +=" onLoad=\"setTimeout('window.close()', " + timeout*1000 + ");\"";
text += "><center>";
if (closeonclick !=0 ) text += "<A HREF='Close' onclick='self.opener=null;self.close();return false;'>";
text += "<img border=\"0\" src=\"" + URL + "\"";
if (closeonclick !=0) text += "alt=\"Klik om het venster te sluiten\"";
text += ">";
if (closeonclick !=0) text += "</a>";
if (timeout != 0) text +="<br><font face=\"arial, helvetica\" size=\"-1\">Venster sluit automatisch na " + timeout + " seconden.</font>";
text += "</center></body></html>";

preview = window.open("", "viewImage", windowprops);
preview.document.open();
preview.document.write(text);
preview.document.close();
preview.focus();
}
