// reference to the popup window
var winId

function openWindow(inURL, inWindowName, inAttributes) {
    var theWindowName = inWindowName ? inWindowName : 'Popup';
    var theAttributes = inAttributes;

    if(!theAttributes) {
        theAttributes =
        'left=50,top=50,width=800,height=600,menubar=yes,status=yes,scrollbars=yes,resizable=yes';
    }
    theWindow = open(inURL, theWindowName, theAttributes);
    theWindow.focus();
    return false;
}


// This function calls a popup window, parameteres are the hidden form 
// and the hidden command element of the hidden form.
function showPopup(form, target) {
	if (winId){
		winId.close();
	}
	features="height=470,width=425,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes";			
	winId=window.open('','popup',features); // open an empty window
    winId.focus();

	//This is an emulation of the action link on the hidden form being clicked and submitted.
	document.getElementById(form+':'+target).onclick(null);
}

function showCustomPopup(form, target, popupSizeX, popupSizeY) {
	if (winId){
		winId.close();
	}
	features="height="+popupSizeY+",width="+popupSizeX+",status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes";			
	winId=window.open('','popup',features); // open an empty window
    winId.focus();

    //This is an emulation of the action link on the hidden form being clicked and submitted.
	document.getElementById(form+':'+target).onclick(null);
}