var imgWin = '';

function openPopup(url,title,width,height) {
 imgWin = window.open("","imgWin","height="+height+",width="+width+",toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes"); 
 var d = imgWin.document;
 d.open();
 d.writeln("<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.1//EN' 'http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd'>");
 d.writeln("<html xmlns='http://www.w3.org/1999/xhtml'>");
 d.writeln("<head>");
 d.writeln("<title>",title,"</title>");
 d.writeln("</head>");
 d.writeln("<body style='overflow:hidden; background:#ffffff; margin:0; padding:0'>");
 d.writeln("<div><img id='image' style='cursor : pointer' src='",url,"' alt='",title,"' height='",height,"' width='",width,"' onclick='self.close();return false;' title='click to close' /></div>");
 d.writeln("</body></html>");
 d.close();
 return false;
}

function changePopup(url,title,width,height) {
    imgWin.focus(); 
    var image=imgWin.document.getElementById('image');
    if (image) {
	image.style.visibility = 'hidden';
	image.src = url;
	image.width = width;
	image.height = height;
	imgWin.document.title = title;
	imgWin.resizeTo(width,height);
	imgWin.resizeBy(10,20);
	image.style.visibility = 'visible';
    }
}

function popitup(url,title,width,height) {
    if (imgWin.location && !imgWin.closed) {
	changePopup(url,title,width,height)
    }
    else {
	openPopup(url,title,width,height);
    }
}

function tidy() {
    if (imgWin.location && !imgWin.closed) {
	imgWin.close();
    } 
}

