var PopWindow = null;

function popImg(img) {
	cw = screen.availWidth;
	ch = screen.availHeight;

	img1=new Image();
	
	img1.src=(img);

	sw = img1.width;
	sh = img1.height;
	
//	alert(img+"\r\n "+img1.src+' sw:'+sw+' sh:'+sh);

	if(sw == 0) {
		sw = img1.width;
	}	

	if(sh == 0) {
		sh = img1.height;
	}

	ml = (cw - sw) / 2;
	mt = (ch - sh) / 2;
	
	var url = "../web/popup/imgView.jsp?img=" + img1.src + "&w=" + sw + "&h=" + sh;
	PopWindow = window.open(url, 'pop', 'width=' + sw + ',height=' + sh + ',top=' + mt + ',left=' + ml + ',toolbar=no,scrollbars=yes,menubar=no,status=no ,directories=no, titlebar=0,location=0,channelmode=0,resizable=0,target=_blank');
	
/*
	img = document.body.appendChild(document.createElement('img'));
    img.src = id.src;
    var w = img.offsetWidth; 
    var h = img.offsetHeight; 
    document.body.removeChild(img); 
	sw = w;
	sh = h;
	if(sh == 0) {
		sh = 500;
	}

	ml = (cw - sw) / 2;
	mt = (ch - sh) / 2;
	
	if(PopWindow != null) {
		PopWindow.close();
	}
	//popimg = "win"+parseInt(Math.random() * 1000);
	//parent.savePopObj = PopWindow =window.open(url,'pop','width='+sw+',height='+sh+',top='+mt+',left='+ml+',toolbar=no,scrollbars=yes,menubar=no,status=no ,directories=no, titlebar=0,location=0,channelmode=0,resizable=0,target=_blank');
	//alert(url + ' sw:' + sw + ' sh:' + sh);
	if(imgs == undefined) {
		PopWindow = window.open(url,'pop','width='+sw+',height='+sh+',top='+mt+',left='+ml+',toolbar=no,scrollbars=yes,menubar=no,status=no ,directories=no, titlebar=0,location=0,channelmode=0,resizable=0,target=_blank');
	}else if(imgs == 1) {
		PopWindow = window.open(url + '&w=' + w + '&h=' + h, 'pop', 'width=' + sw + ',height=' + sh + ',top=' + mt + ',left=' + ml + ',toolbar=no,scrollbars=yes,menubar=no,status=no ,directories=no, titlebar=0,location=0,channelmode=0,resizable=0,target=_blank');
	}
	*/
}

function popUp(url, w, h, param) {
	cw=screen.availWidth;
	ch=screen.availHeight;
	sw = w;
	sh = h;
	
	if (sh == 0) {
		sh = 500;
	}
	
	ml = (cw-sw) / 2;
	mt = (ch-sh) / 2;
	
	if (PopWindow != null) {
		PopWindow.close();
	}
	
	if (param != "") {
		url = url + "?" + param;
	}
	
	PopWindow =window.open(url,'pop','width='+sw+',height='+sh+',top='+mt+',left='+ml+',toolbar=no,scrollbars=yes,menubar=no,status=yes ,directories=no, titlebar=0,location=0,channelmode=0,resizable=0,target=_blank');
}
