// PopUp.js
// libreria di funzioni generiche per la gestione delle finestre PopUp

function fnPopUp (psUrl, psWindowName, pnWidth, pnHeight,  psOption) {
	var vnTop;
	var vnLeft;
	var vsDim;
	var obWindow;

	vnTop = Math.floor((screen.height - pnHeight) / 2) - 15;
	vnLeft = Math.floor((screen.width - pnWidth) / 2) - 4;
	//vsDim = "width=" + pnWidth + ",height=" + pnHeight + ",";
	vsDim = "width=" + pnWidth + ",height=" + pnHeight + ",top=" + vnTop + ",left=" + vnLeft + ",";
	if (psOption == "") {
		vsOption = "scrollbars=no,resizable=no,status=no,location=no,toolbar=no,status=0";
	} else {
		vsOption = psOption;
	}
	
	obWindow = window.open(psUrl, psWindowName, vsDim + vsOption);
	//obWindow.moveBy(vnLeft, vnTop)
	obWindow.focus();
	
	return obWindow;
}


function fnShowModal (psUrl, psArguments, pnWidth, pnHeight,  psOption) {
	var vsFeatures;
	if(psOption == ""){
		vsFeatures = vsFeatures + " " + "dialogHeight: " + pnHeight + "px;"; 
		vsFeatures = vsFeatures + " " + "dialogWidth: " + pnWidth + "px;";
		vsFeatures = vsFeatures + " " + "center: Yes;"; 
		vsFeatures = vsFeatures + " " + "help: No;"; 
		vsFeatures = vsFeatures + " " + "resizable: No;"; 
		vsFeatures = vsFeatures + " " + "status: No;"; 
		vsFeatures = vsFeatures + " " + "scroll: No;" ;
	}
	else{
		vsFeatures = vsFeatures + " " + "dialogHeight: " + pnHeight + "px;"; 
		vsFeatures = vsFeatures + " " + "dialogWidth: " + pnWidth + "px;";
		vsFeatures = vsFeatures + " " + "center: Yes;"; 
		vsFeatures = vsFeatures + " " + psOption;
	}

	obWindow = window.showModalDialog(psUrl,psArguments,vsFeatures);
	return obWindow;
}
