﻿/***********************\
*                       *
* Window Pop-up Control *
*                       *
*      Version 1.0      *
*                       *
\***********************/

var popWindow = null;

function PopTheEmailWindow(strEmailRec) {
    popTheWindow(657, 420, "ShowEmailJob", "/ChoiceHomes/Popup/EmailJob.aspx", "to=" + strEmailRec);
}

function popTheWindow(intWidth, intHeight, strWindowName, strURL, strQueryParams)
{
    popTheWindow(intWidth, intHeight, strWindowName, strURL, strQueryParams, false)
}

function popTheWindow(intWidth, intHeight, strWindowName, strURL, strQueryParams, bNewWindow)
{
    var strWindowChrome;

    if (intWidth == null)
    {
        intWidth = 640;
    }

    if (intHeight == null)
    {
        intHeight = 480;
    }

    if (strWindowName == null)
    {
        strWindowName = "myPopWindow";
    }

    strWindowChrome = "height=" + String(intHeight) + ",";
    strWindowChrome += "menubar=0,"
    strWindowChrome += "location=0,"
    strWindowChrome += "resizable=1,"
    strWindowChrome += "scrollbars=1,"
    strWindowChrome += "status=0,"
    strWindowChrome += "toolbar=0,"
    strWindowChrome += "width=" + String(intWidth);

    if (strURL == null)
    {
        alert("No popup window URL specified!");
    }
    else
    {

        if (strQueryParams.length != 0)
        {
            strURL += "?" + strQueryParams;
        }

        if (!bNewWindow && popWindow != null)
        {

            if (popWindow.open)
            {
                popWindow.close();
            }
            popWindow = null;
        }

        popWindow = window.open(strURL, strWindowName, strWindowChrome);
    }
}
