/**
 *  FILENAME:  EC_CheckProdAvail.js
 *  PROJECT:   Two Harbors
 *  VERSION:      v.2.1
 *
 *  MODIFICATION HISTORY:
 *
 *  DATE     AUTHOR     DESCRIPTION
 *  ----     ------     -----------
 *  21Aug00  A HANSEN   Initial creation
 *
 *  Functions:
 *      popupTWHelpWindow(host, lang, debug)
 *
 */


/**
 * Global Variables
 */
var mmmHelpWindow = null;

/**
 * Name: popupTWHelpWindow
 * Description:
 *  Opens window with the two harbors help in it
 *  Input:
 *      host - the hostName of the box you would like
 *              to open help on, if null uses a relative link
 *      lang - the lang of help you would like to use
 *      debug - if true will display the url about to be open
 */

function popupTHHelpWindow(host, lang, debug)
{
    debug = (debug)?debug:null;
    lang = (lang)?lang:'en_us';
    host = (host)?'http://' + host:'';

    var ref = window.location.href;
    var param = null;

    // expected url = '/ordercenter/control/FrontController.jsp?command=HelpProcess
    url = host + '/ordercenter/control/FrontController.jsp?command=HelpProcess';

    if (url.indexOf("?") > -1) {
        param = "&";
    } else {
        param = "?";
    }

    // truncate the href if it's excessively long; helps
    // avoid a buffer overflow with IE
    if (ref.length >= 1500) {
        ref = ref.substring(0, 1500);
    }

    url += param + "ref=" + escape(ref);
    url += '&lang=' + escape(lang);

    if(debug) {
        alert(url);
        return false;
    }

    //close if a window exist and open the same window
    if (mmmHelpWindow && mmmHelpWindow.open && mmmHelpWindow.closed)
    { mmmHelpWindow.close(); }

    mmmHelpWindow =
        window.open(url,'mmmHelpWindow','dependent=yes,toolbar=no,location=no,directories=no,status=no'
        + ',menubar=no,resizable=yes,copyhistory=no,scrollbars=yes,innerWidth=540,innerHeight=550,width=540,height=550')
    mmmHelpWindow.focus();
}


function popupTHHelpWindowOE(url, debug)
{
    debug = (debug)?debug:null;

    // adding an extra parameter to the url passed in
    // we expect the URI /ordercenter/control/FrontController.jsp?command=HelpProcess
    // this check below is just for safety
    var param = null;
    if (url.indexOf("?") > -1) {
        param = "&";
    } else {
        param = "?";
    }

    var ref = window.location.href;

    // truncate the href if it's excessively long; helps
    // avoid a buffer overflow
    if (ref.length >= 1500) {
        ref = ref.substring(0,1500);
    }

    url += param + "ref=" + escape(ref);

    if(debug) {
        alert(url);
        return false;
    }

    //close if a window exist and open the same window
    if (mmmHelpWindow && mmmHelpWindow.open && mmmHelpWindow.closed)
    { mmmHelpWindow.close(); }

    mmmHelpWindow =
        window.open(url,'mmmHelpWindow','dependent=yes,toolbar=no,location=no,directories=no,status=no'
        + ',menubar=no,resizable=yes,copyhistory=no,scrollbars=yes,innerWidth=540,innerHeight=550,width=540,height=550')
    mmmHelpWindow.focus();
}
