function popImage(popimg){
	windowHandle = window.open('','pop','scrollbars=no,resizable=yes,width=420,height=420');
	var tmp = windowHandle.document;
	tmp.write('<html><head><title>image</title>\n');
	tmp.write('<scr'+'ipt language="javas'+'cript">\n'); 
    tmp.write('var picUrl = "'+popimg+'"; \n');
    tmp.write('var NS = (navigator.appName=="Netscape")?true:false; \n');
    tmp.write('function FitPic() { \n');
    tmp.write('   iWidth = (NS)?window.innerWidth:document.body.clientWidth; \n');
    tmp.write('   iHeight = (NS)?window.innerHeight:document.body.clientHeight; \n');
    tmp.write('   iWidth = (document.images[0].width - iWidth)+30; \n');
    tmp.write('   iHeight = (document.images[0].height - iHeight) + 50; \n');
    tmp.write('   window.resizeBy(iWidth, iHeight); \n');
    tmp.write('   self.focus(); \n');
    tmp.write(' }; \n');
    tmp.write('</scr'+'ipt>\n'); 
	tmp.write('</head><body style="background:#fff;margin:0;padding:5;color:#fff;text-align:center;" onload="FitPic();" onblur="window.close();">');
	tmp.write('<div><img src="'+popimg+'" border="0"></div>');
	tmp.write('<button onclick="self.close();" style="margin:4px;">close</button>');
	tmp.write('</body></html>');
	tmp.close();

}
window.onload = setupThumbs;
function setupThumbs(){
	window.name = "main";
	var pagelinks=document.getElementsByTagName("a")
	for (var i=0; i<pagelinks.length; i++){ 
		if (pagelinks[i].rel == "image" ){
			pagelinks[i].onclick=function(){
				popImage(this);
				return false;
			}
		}
	}
}