function showPopupImgWindow(im,w,h,alt){
	if(window.screen 
		&& window.screen.height 
		&& window.screen.height > (h+50) 
		&& window.screen.width 
		&& window.screen.width > (w+120)
	){
		var imgwindow = window.open('',"_blank","resizable=no,menubar=no,status=no,top=30,left=100,scrollbars=no,width="+w+",height="+h);
	}else{
		var w2 = (window.screen.width > (w+120)) ? (w+25) : (window.screen.width-120) ;
		var h2 = (window.screen.height > (h+50)) ? (h+25) : (window.screen.height-50) ;
		var imgwindow = window.open('',"_blank","resizable=yes,menubar=no,status=no,top=30,left=100,scrollbars=yes,width="+w2+",height="+h2);
	}
	imgwindow.document.open("text/html");
	imgwindow.document.writeln('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title>'+alt+'<\/title><style type="text/css" title="">* {padding:0;margin:0;background:#fff;}<\/style><\/head>');
	imgwindow.document.writeln('<body onBlur="self.close()"><div onclick="self.close();"><img src="'+im+'" width="'+w+'" height="'+h+'" alt="'+alt+'" border="0" align="left" \/><\/div><\/body><\/html>');
	imgwindow.document.close();
	imgwindow.focus();
}

function showPopupWindow(path,w,h){
	win = window.open(path,"_blank","resize=yes,resizable=yes,menubar=no,status=no,top=30,left=100,scrollbars=yes,width="+w+",height="+h);
	win.focus();
}

function getElementbyClass(ro, cln){
var tmp=new Array();
var inc=0;
for (i=0; i<ro.length; i++){
	if (ro[i].className==cln) tmp[inc++]=ro[i]}return tmp
}

window.onload = function() {
	if (!document.getElementsByTagName) return false;
	var elms = document.getElementsByTagName('a');
	cl=getElementbyClass(elms, 'popup');
	for (var i = 0; i < cl.length; i++) {
		cl[i].onclick = function() {showPopupImgWindow(this.getAttribute("href"),this.getAttribute("w"),this.getAttribute("h"));return false;}
	}
}
