function MIN(a,b){return(a<b)?a:b;};
function ConcatURL(baseURL,concatURL)
{
	var res = String(baseURL), toConcat=String(concatURL);
	if(toConcat.length>0 && toConcat!="" && toConcat!="undefined") {
		var app_sign = (res.indexOf("?")!=-1) ? "&" : "?";
		if ((toConcat.charAt(0) == "?") || (toConcat.charAt(0) == '&'))
			toConcat = toConcat.substring(1,toConcat.length);

		res += app_sign + toConcat;
	};
	return res;
};

function ShowPopupImage(filename,w,h)
{
	var url = ConcatURL("/inc/popup.php",'src=/content/images/'+filename+'&w='+w+'&h='+h);
	var width = Math.floor(MIN(w+80,window.screen.availWidth/1.5));
	var height = Math.floor(MIN(h+90,window.screen.availHeight-40));
	var left = Math.floor(((window.screen.availWidth-width)/2-40));
	var top = Math.floor(((window.screen.availHeight-height)/2-40));
	var sFeatures = "height="+height+",resizable=no,scrollbars=1,toolbar=0,width="+width+",left="+left+",top="+top;
	var oWnd = window.open(url,"image_popup",sFeatures);
	oWnd.focus();
};
