//--********************************************************************-->
//--                                                                    -->
//--   Frontier Software Pty Ltd                                        -->
//--                                                                    -->
//--   File Name     : ftrhelp.js                                       -->
//--                                                                    -->
//--   History       :                                                  -->
//--   005876 - 02.07.00 - JavaScript Rewrite.                          -->
//--   009509 - 01.06.04 - eRecruitment.                                -->
//--********************************************************************-->

// *********************************************************************
// opens the popup help window
function helpPageCreate(url) {
    oHelpWin = window.parent.open("","HelpWindow",sNewWindow,true);
    if (oHelpWin) {
        // Various processing for different client help files
        switch (sKskType) {
            // ********************************************************* eR21
            case "eR21":
                oHelpWin.location.replace(helpPageER21(url));
                break;
            // ********************************************************* HR21
            default:
                oHelpWin.location.replace(helpPageLoad(url));
                break;
        }
        oHelpWin.focus();
    }
    return;
}

// *********************************************************************
// 9509 - Returns the correct path for the eRecruitment help.
function helpPageER21(url) {
    var sHref = window.location.href;
    var sDataSource = "";
    // Determine if it is a query string or not. If not then just return the
    // default help page -> intro.htm
    var iQuestion = sHref.lastIndexOf("?");
    if (iQuestion > -1) {
        var sTemp = sHref.substr(0,iQuestion);
        var iSlash = sTemp.lastIndexOf("/") + 1;
        sTemp = sHref.substring(iSlash,iQuestion);
        var iDot = sTemp.lastIndexOf(".");
        sDataSource = sTemp.substring(0,iDot);
    } 
    else sDataSource = "intro";
    url += ("#" + sDataSource + ".htm");
    return url;
}

// *********************************************************************
function helpPageLoad(url) {
    var sPrefix = sDataSource = sMenuSource = sMenuPage = "";
    // index of last slash and the length
    var iSlash = dataFrame.location.href.lastIndexOf("/") + 1;
    var iLength = dataFrame.location.href.length;
    // Set menu string based on menu type used
    if (bHorizMenu) sMenuPage = horizFrame.location.href;
    if (bVertMenu) sMenuPage = vertFrame.location.href;
    if ((!sMenuPage) || (sMenuPage == null)) sMenuSource = "";
    else sMenuSource = sMenuPage.substr(sMenuPage.length-12,8);
    // Various processing for different client help files
    switch (sKskType) {
        // ************************************************************* OCR
        case "OCR":
            sDataSource = dataFrame.location.href.substring((iSlash+2),iLength);
            switch (sMenuSource) {
                // ***************************************************** Logon
                case "severlog":
                case "sehorlog":
                    sDataSource = "";
                    break;
                // ***************************************************** HR21
                case "severtop":
                case "sehortop":
                    if (bManMode) {
                        sPrefix = (sDataSource == "cfclst.htm") ? "dh" : "dm";
                    } else {
                        sPrefix = (sDataSource == "cfclst.htm") ? "dh" : "de";
                        var sHistPg = sDataSource.substr(3,1);
                        if (sHistPg == "h") sDataSource = sDataSource.substr(0,3) + "lst.htm";
                    }
                    break;
            }
            break;
        // ************************************************************* ANO/IBM
        case "ANO":
        case "IBM":
            switch (sMenuSource) {
                // ***************************************************** Logon
                case "severlog":
                case "sehorlog":
                    sDataSource = "";
                    break;
                // ***************************************************** HR21
                case "severtop":
                case "sehortop":
                    if (bManMode) {
                        sPrefix = (sDataSource == "cfclst.htm") ? "he" : "hm";
                    } else {
                        sPrefix = "he";
                    }
                    break;
            }
            break;
        // ************************************************************* Other Systems
        case "ZFI":
        case "ZRM":
            sDataSource = "";
            break;
        // ************************************************************* Standard
        default:
            sDataSource = dataFrame.location.href.substring(iSlash,iLength);
            var aDataSource = sDataSource.split(".");
            if (aDataSource.length && aDataSource.length > 0) sDataSource = aDataSource[0] + ".htm";
            break;
    }
    // If nothing then take no action otherwise load up the prefixs change
    if (sDataSource == "") return url;
    else {
        url += ("#" + sPrefix + sDataSource);
        return url;
    }
}

// *********************************************************************
