
function popupPrint() {
    window.print();
}

function popupClose() {
    if (opener)
        opener.focus();
    window.close();
}

function popupCloseWithRedirect(location) {
    if (opener) {
        opener.location = location;
        opener.focus();
    }
    window.close();
}

/**
* Opens a popup window using standard popup template.
* Used for opening JSP files directly.
*/
function popupResizeable(url, height, width, title) {
    
    var newURL = "/mahome/pages/popupIndex.jsp?";
    if (title != null)
        newURL += "title=" + escape(title) + "&";
	newURL += "body=" + url;
	
	// Set height, width, and name if the values arent being passed in.
    if(height == null)
       height = 500;
    if(width == null)
       width = 600;
    
    var xpos = (screen.width / 2) - (width / 2);
	var ypos = (screen.height / 2) - (height / 2);

	var size     = "height=" + height + ",width=" + width;
	var position = ",left=" + xpos + ",top=" + ypos + ",screenX=" + xpos + ",screenY=" + ypos;
	var options  = ",status=no,menubar=no,scrollbars=yes, resizable=1";

	var popupWindow = window.open(newURL, "popupWindow", size + position + options);
	popupWindow.focus();
}

function popupImage(url, height, width, title) {
    
    var newURL = "/mahome/pages/popupImage.jsp?";
    if (title != null)
        newURL += "title=" + escape(title) + "&";
	newURL += "image=" + url;
	
	// Set height, width, and name if the values arent being passed in.
    if(height == null)
       height = 500;
    if(width == null)
       width = 600;
    
    var xpos = (screen.width / 2) - (width / 2);
	var ypos = (screen.height / 2) - (height / 2);

	var size     = "height=" + height + ",width=" + width;
	var position = ",left=" + xpos + ",top=" + ypos + ",screenX=" + xpos + ",screenY=" + ypos;
	var options  = ",status=no,menubar=no,scrollbars=yes, resizable=1";

	var popupWindow = window.open(newURL, "popupWindow", size + position + options);
	popupWindow.focus();
}

var generalPopupWindow = null;

/**
* Opens a popup window.
* Used for opening actions into a popup window.  Action should utilize the standard popup template.
*/
function openPopUp(location, height, width) {
	var xpos = (screen.width / 2) - (width / 2);
	var ypos = (screen.height / 2) - (height / 2);
	var size     = "height=" + height + ",width=" + width;
	var position = ",left=" + xpos + ",top=" + ypos + ",screenX=" + xpos + ",screenY=" + ypos;
	var options  = ",status=no,menubar=no,scrollbars=yes,resizable=1";
	
	generalPopupWindow = window.open(location, "generalPopupWindow", size + position + options);
	generalPopupWindow.focus();
}

function openNewPopUp(location, height, width) {
	var xpos = (screen.width / 2) - (width / 2)+60;
	var ypos = (screen.height / 2) - (height / 2);
	var size     = "height=" + height + ",width=" + width;
	var position = ",left=" + xpos + ",top=" + ypos + ",screenX=" + xpos + ",screenY=" + ypos;
	var options  = ",status=no,menubar=no,scrollbars=yes,resizable=1";
	
	generalNewPopupWindow = window.open(location, "generalNewPopupWindow", size + position + options);
	generalNewPopupWindow.focus();
}

/**
* Opens a popup window.
* Used for opening pdfs into a popup window with printing options.
*/
function popupPrintable(url, height, width, name) {

	url = "/mahome" + url;
	
	// Set height, width, and name if the values arent being passed in.
    if(height == null)
       height = 500;
    if(width == null)
       width = 600;
    if(name == null)
       name = "newWindow";
    
    var xpos = (screen.width / 2) - (width / 2);
	var ypos = (screen.height / 2) - (height / 2);

	var size     = "height=" + height + ",width=" + width;
	var position = ",left=" + xpos + ",top=" + ypos + ",screenX=" + xpos + ",screenY=" + ypos;
	var options  = ",status=no,menubar=no,scrollbars=yes, resizable=1";

	var popupWindow = window.open(url, name, size + position + options);
	popupWindow.focus();
}
