//--********************************************************************-->
//--                                                                    -->
//--   Frontier Software Pty Ltd                                        -->
//--                                                                    -->
//--   File Name     : ftrhdft.js                                       -->
//--                                                                    -->
//--   History       :                                                  -->
//--   005876 - 02.07.00 - JavaScript Rewrite.                          -->
//--   007198 - 20.03.02 - Buttons created on fly.                      -->
//--   007911 - 20.09.02 - Allow two fields in one cell.                -->
//--   008417 - 06.02.03 - Add header image for STH.                    -->
//--   008711 - 27.05.03 - Button replace manager link bar.             -->
//--   008780 - 01.07.03 - Colours for Messages set in Configuration.   -->
//--   007634 - 02.07.03 - Clerical Self-Service.                       -->
//--   008890 - 15.08.03 - Button wrapping.                             -->
//--   008972 - 03.09.03 - Apply style - CheckBox for the check boxes.  -->
//--   008676 - 22.09.03 - parameters passed to imgSwap() in lower case.-->
//--   009093 - 03.10.03 - Carry field value to popup search page field.-->
//--   009093 - 07.10.03 - Disable any action onclick of the enter key. -->
//--   009145 - 04.11.03 - Allow for multiple occurrences of same image -->
//--                       in search fields.                            -->
//--   009228 - 09.09.03 - Cost Centre filter for wfe & wfc pages.      -->
//--   008366 - 16.01.04 - Functions for Notes facility added           -->
//--   009389 - 26.01.04 - Allows for list table search fields          -->
//--   009349 - 29.01.04 - Dimensions of pop-up calendar changed        -->
//--   009387 - 04.02.04 - Change Password re-located                   -->
//--   009403 - 16.02.04 - Functionality for Utility pages included     -->
//--   009345 - 01.03.04 - 'print' added to Button Load method          -->
//--   009347 - 26.04.04 - Day added to date search                     -->
//--   009507 - 10.03.04 - staff number & name now configurable         -->
//--   009445 - 06.02.04 - Tree Structure Staff List moved.             -->
//--   009442 - 23.03.04 - Return to last staff list page               -->
//--   009693 - 14.05.04 - allow action on enter click for laccalcrun   -->
//--   009455 - 31.05.04 - Disable popup cal when hidden                -->
//--   009550 - 08.06.04 - Link to workflow notes viewer                -->
//--   009743 - 18.06.04 - Store onclick events                         -->
//--   009618 - 28.07.04 - Swap Heading Colours                         -->
//--   009973 - 02.08.04 - Utitlity Pages correctly show Staff Details  -->
//--   007259 - 28.07.04 - Allow for styles for the toolbar             -->
//--   009940 - 19.08.04 - Allow page title to be configured            -->
//--   009642 - 30.08.04 - Error window redesigned                      -->
//--   010172 - 13.10.04 - Self Service Authorisation Rules             -->
//--   010064 - 15.10.04 - Confirmation Prompt On Form Change           -->
//--   010217 - 30.10.04 - Calendar dimensions controlled via config    -->
//--   010063 - 17.12.04 - Opera (10062) & Mozilla (10063) supported    -->
//--   007775 - 06.12.04 - Search by Pay Period                         -->
//--   010411 - 24.02.05 - System Error Page revamped.                  -->
//--   010554 - 18.02.05 - Re-Alignment of the timesheet grid           -->
//--   010408 - 01.03.05 - Add new starters                             -->
//--   009745 - 22.02.05 - Introduced translation                       -->
//--   010721 - 21.04.05 - Introduced New Display Only Processing       -->
//--   010730 - 29.04.05 - Introduced New Button Width                  -->
//--   009997 - 12.04.05 - Mandatory indicator on fields                -->
//--   010119 - 24.03.05 - Lookup image conforms to C21                 -->
//--   010698 - 19.04.05 - Layout Enhancements                          -->
//--   010982 - 26.07.05 - Secretary Access.                            -->
//--   011044 - 15.08.05 - Corrected format of buttons                  -->
//--   011116 - 06.09.05 - Corrected banner colour usage                -->
//--   011171 - 05.10.05 - Corrected back button on workflow pages      -->
//--   011225 - 25.10.05 - Correctly set the sHold variables            -->
//--   011214 - 03.11.05 - Corrected notes button on appraisal pages    -->
//--   011389 - 28.03.06 - Correct the Draft TR Election display.       -->
//--   011885 - 10.05.06 - Introduce themes to the banners and buttons  -->
//--   011967 - 11.09.06 - Add i_powered and move the comments area     -->
//--   013169 - 23.10.06 - Stop update message, when no change made.    -->
//--   013315 - 10.11.06 - Correct the Image button.                    -->
//--   013481 - 29.11.06 - Notes and Comments placed in separate table. -->
//--   011154 - 30.11.06 - Enhance page title function                  -->
//--   013619 - 24.01.07 - Set Type 16 (Date) to be 75 pixels in length -->
//--   011904 - 20.06.06 - Added new skill code search.                 -->
//--   013685 - 14.02.07 - Radio and Check Box use disabled at all times-->
//--   013668 - 02.03.07 - All times in hh:mm format                    -->
//--   013901 - 10.05.07 - New banner style for Company News            -->
//--   013929 - 23.06.07 - Memo field height added.                     -->
//--   010643 - 04.05.07 - Correct the setting of Organisation Level    -->
//--   014434 - 23.10.07 - Layout & Colour Enhancements                 -->
//--   014482 - 06.11.07 - Allow Background Banner Image in Footer      -->
//--   014439 - 18.03.08 - Warning of memo field size                   -->
//--********************************************************************-->

// *********************************************************************
function hdftVertBannerLoad() {
    var hColorBG = hWindowBG;
    // Turn off the banner when bBreadCrumb has been enabled
    if (bBreadCrumb) return "";
    // Initialise html string for use in this function
    var sHtml = "";
    // Offset for the banner unless a pop-up page type
    var sType = loadPageType(sDataPage);
    if ((sBannerBG) && (!bBannerBGFooter)) {
        if ((iBannerOffset) && (sType != "S") && (sType != "V")) {
            sHtml += "<div width='100%' style='height:" + iBannerOffset + "px;'>&nbsp;</div>";
        }
    }
    // Initialise the banner arrays for use in this function
    var aBanner = new Array(oDataPage.oMenu["title"]);
    // Set any additional logo images to the left of the header
    switch (sKskType) {
        case "IBM":
            sHtml += "<img align='left' src='" + loadPageResource("logo") + "ibm_ban.png'>"
            break;
        case "EAY":
            if ((sBannerBG) && (!bBannerBGFooter) && (sType != "S") && (sType != "V")) {
                sHtml += "<div id='banner' style='position:absolute;top:0;left:-10;z-index:1;'><table width='101%' border='0' align='center' cellpadding='0' cellspacing='0'><tr><td height='37' style='background-color:" + hVertBG + ";'>&nbsp;</td><td align='right' rowspan='3' width='206'><img src='" + loadPageResource("logo") + sBannerBG + "'></td></tr><tr style='background-color:black;'><td height='26'></td></tr><tr><td height='17'>&nbsp;</td></tr></table></div><br><br><br><br><br><br>";
            }
            break;
    }
    // If a style has been set then we need to do a bit of preliminary work on the title string
    if (bBannerLower) {
        aBanner[0] = aBanner[0].toLowerCase();
    } else if (bBannerSplit) {
        var iBanner = aBanner[0].indexOf(" ");
        if (iBanner > 0) {
            aBanner[1] = aBanner[0].substring(iBanner+1,aBanner[0].length).toLowerCase();
            aBanner[0] = aBanner[0].substring(0,iBanner);
        } else {
            aBanner[1] = null;
        }
    }
    // Place the banner in the alignment specified
    sHtml += "<table border='0' cellpadding='0' cellspacing='0'";
    switch (sBannerAlign) {
        case "center":
            sHtml += " align='center'";
            break;
        default:
            sHtml += " width='100%'";
            break;
    }
    sHtml += ">";
    // Place the menu image next to the banner if displaying images on the menu
    sHtml += "<tr align='" + ((sBannerAlign) ? sBannerAlign : "center") + "'>";
    if (bBannerHtml) {
        var sTempClass = "HTMLBanner";
        switch (sTempPage) {
            case "cocfclst":
                sTempClass = "CfcBanner";
                break;
        }
        if ((bBannerSplit) && (aBanner[1])) {
            sHtml += "<td rowspan='4' width='5px;'>&nbsp;</td>";
        } else {
            sHtml += "<td rowspan='2' width='5px;'>&nbsp;</td>";
        }
    }
    // Store the current page name
    var sTempPage = loadPageCurrent();
    // Sort out the banner string
    if (bBannerHtml) {
        sHtml += "<td class='" + sTempClass + "'";
        if ((bBannerSplit) && (aBanner[1])) {
            switch (sBannerAlign) {
                case "left":
                    sHtml += " rowspan='2' align='left' style='padding-top:0px;padding-bottom:0px;'";
                    break;
                case "right":
                    sHtml += " rowspan='2' align='right' width='100%' style='padding-top:0px;padding-bottom:0px;'";
                    break;
                default:
                    sHtml += " rowspan='2' align='right' width='50%' style='padding-top:0px;padding-bottom:0px;'";
                    break;
            }
        }
        sHtml += ">";
    } else {
        sHtml += "<td class='" + sTempClass + "' valign='top'>";
    }
    // Sort out the banner graphic
    if ((oDataPage.oMenu["graphic"]) && ((bBannerImage == true) || (bBannerImage == "vert"))) {
        // If Logon then load an alternative logo image
        switch (sTempPage) {
            case "seusrlog":
                sHtml += "<img valign='center' src='" + loadPageResource("logo") + oDataPage.oMenu["graphic"] + ".png'></td></tr></table>";
                return sHtml;
            default:
                sHtml += "<img valign='center' width='24' src='" + loadPageResource("menu") + oDataPage.oMenu["graphic"] + ".png'>";
                sHtml += "&nbsp;&nbsp;";
                break;
        }
    }
    // Sort out the banner string
    if (bBannerHtml) {
        sHtml += "<font class='" + sTempClass + "' style='color:";
        // If a banner image is set it is probably the same colour as the menu background so use active colour
        if (sBannerBG) {
            hColorBG = (bHorizMenu) ? hHorizInactive : hVertInactive;
            if (hColorBG == hWindowBG) sHtml += (bHorizMenu) ? hHorizBG : hVertBG;
            else sHtml += hColorBG;
        } else {
            hColorBG = (bHorizMenu) ? hHorizBG : hVertBG;
            if (hColorBG == hWindowBG) sHtml += (bHorizMenu) ? hHorizActive : hVertActive;
            else sHtml += hColorBG;
        }
        sHtml += ";'>" + aBanner[0] + "</font></td>";
        if ((bBannerSplit) && (aBanner[1])) {
            sHtml += "<td class='" + sTempClass + "' style='padding-top:0px;padding-bottom:0px;font-size:0px;'>&nbsp;</td></tr>";
            sHtml += "<tr><td class='" + sTempClass + "' ";
            switch (sBannerAlign) {
                case "left":
                    sHtml += "rowspan='2' align='left' width='100%' style='padding-top:0px;padding-bottom:0px;'";
                    break;
                case "right":
                    sHtml += "rowspan='2' align='right' style='padding-top:0px;padding-bottom:0px;'";
                    break;
                default:
                    sHtml += "rowspan='2' align='left' width='50%' style='padding-top:0px;padding-bottom:0px;'";
                    break;
            }
            sHtml += "><font class='" + sTempClass + "' style='color:";
            // If a banner image is set it is probably the same colour as the menu background so use active colour
            if (sBannerBG) {
                hColorBG = (bHorizMenu) ? hHorizInactive : hVertInactive;
                if (hColorBG == hWindowBG) sHtml += (bHorizMenu) ? hHorizBG : hVertBG;
                else sHtml += hColorBG;
            } else {
                hColorBG = (bHorizMenu) ? hHorizBG : hVertBG;
                if (hColorBG == hWindowBG) sHtml += (bHorizMenu) ? hHorizActive : hVertActive;
                else sHtml += hColorBG;
            }
            sHtml += ";'>" + aBanner[1] + "</font></td></tr>";
            sHtml += "<tr><td class='" + sTempClass + "' style='padding-top:0px;padding-bottom:0px;font-size:0px;'>&nbsp;</td></tr>";
        } else {
            sHtml += "</tr>";
        }
        if (sBannerBG) {
            if (bBannerUnderline) {
                sHtml += "<tr><td colspan='3' align='center' valign='center'>";
                sHtml += "<hr width='100%'>";
                sHtml += "</td></tr>";
            }
        }
        sHtml += "</table>"; 
    } else {
        switch (sKskType) {
            case "SAW":
                if (oDataPage.oMenu["ref"].indexOf("ban.htm") != -1) {
                    if (oDataPage.oMenu["title"].indexOf(" Menu") == -1) aBanner[0] = oDataPage.oMenu["title"] + " Menu";
                    else aBanner[0] = oDataPage.oMenu["title"];
                }
                break;
        }
        for (var i=0; i<aBanner[0].length; i++) {
            if (aBanner[0].charAt(i)) {
                sHtml += "<td valign='top'><img src='" + loadPageResource(sBannerHtml);
                switch (aBanner[0].charAt(i)) {
                    case " ":
                        sHtml += "space";
                        break;
                    case ".":
                        sHtml += "f_stop";
                        break;      
                    case "\\":
                        sHtml += "b_stroke";
                        break;      
                    case "/":
                        sHtml += "f_stroke";
                        break;      
                    case "'":
                        sHtml += "apost";
                        break;      
                    case "-":
                        sHtml += "dash";
                        break;      
                    case "&":
                        sHtml += "and";
                        break; 
                    case "@":
                        sHtml += "at";
                        break;
                    case "*":
                       sHtml += "ast";
                        break;
                    case ":":
                        sHtml += "colon";
                        break;
                    case ";":
                        sHtml += "s_colon";
                        break;
                    case "?":
                        sHtml += "question";
                        break;
                    case "(":
                        sHtml += "left_par";
                         break;
                    case ")":
                        sHtml += "righ_par";
                        break;
                    default:
                        if (aBanner[0].charAt(i).toLowerCase() == aBanner[0].charAt(i)) {
                            sHtml += "lower_" + aBanner[0].charAt(i);
                        } else {
                            sHtml += "upper_" + aBanner[0].charAt(i).toLowerCase();
                        }
                        break;
                }
                sHtml += ".png'></td>";
            }
        }
        // Closing off the Vertical Banner Table
        if (bBannerUnderline) {
            sHtml += "</tr><table border='0' valign='center' align='center' cellpadding='0' cellspacing='0'><tr><td colspan=" + aBanner[0].length + "><img src='" + loadPageResource(sBannerHtml) + "underline.png' width=" + (aBanner[0].length * 26) + " height='11px'></td></tr></table>";
        } else {
            sHtml += "</tr></table>"; 
        }
    }
    return sHtml;
}

// *********************************************************************
function hdftHorizBannerLoad() {
    // Turn off the banner when bBreadCrumb has been enabled
    if (bBreadCrumb) return "";
    // Initialise html string for use in this function
    var sHtml = "";
    // Initialise the banner arrays for use in this function
    var aBanner = new Array(oDataPage.oMenu["title"]);
    return sHtml;
}

// *********************************************************************
// 007776 - Breadcrumbs
function hdftCrumbSpawn(expr, qty, reversed) {
    var spawnee = [expr];
    for (var s=1; s<qty; s++) {
        spawnee[s] = expr + spawnee[s-1];
    }
    if (reversed) {
        return spawnee.reverse();
    } else {
        return spawnee;
    }
}

// *********************************************************************
// 007776 - Breadcrumbs
function hdftCrumbLoad(divider) {
    if (!divider) divider = "&nbsp;>>&nbsp;";
    var sTitle = dataFrame.document.title;
    var sTemp = dataFrame.location.toString(), sHtml = "<td width='45%' class='BreadCrumbs'>";
    sTemp = sTemp.substring(sTemp.indexOf(sMainPage + "/") - 1);
    sTemp = sTemp.split("/");
    switch (sKskType) {
        case "ZRM":
            var howmany = hdftCrumbSpawn("../",sTemp.length,true);
            if (sTemp[1].toLowerCase().indexOf("readme/") != -1) {
                sTemp[1] = "Home";
                howmany[1] = "index.htm";
            }
            break;
        default:
            var howmany = hdftCrumbSpawn("",sTemp.length,true);
            if (sTemp[1].toLowerCase().indexOf("hr21/") != -1) {
                sTemp[1] = "Home";
                if (bStaffOn) howmany[1] = sCompanyPage + ".htm";
                else howmany[1] = "Staff/mswfelst.htm";
            }
            break;
    }
    // Set different limits depending on system being used
    switch (sKskType) {
        case "ZRM":
            var iLength = sTemp.length-2;
            var iIndex = 1;
            break;
        default:
            if (bLoggedOn) {
                var iLength = sTemp.length-1;
                var iIndex = 1;
            } else {
                var iLength = sTemp.length-2;
                var iIndex = 2;
            }
            break;
    }
    // Scan through and create bread crumbs
    for (var i=iIndex; i<iLength; i++) {
        sHtml += "<a href='";
        switch (sKskType) {
            case "ZRM":
                sHtml += howmany[i+2];
                if (i == 1) sHtml += "' target='_parent";
                break;
            default:
                if (i == 1) {
                    if (iLength == 2) sHtml += howmany[i];
                    else sHtml += "../" + howmany[i];
                } else sHtml += sTemp[i].toLowerCase();
                sHtml += "' target='dataFrame";
                break;
        }
        sHtml += "'>" + unescape(sTemp[i] + "</a>" + divider);
    }
    sHtml += sTitle + "</td><td width='5%'>&nbsp;</td>";
    return sHtml;
}

// *********************************************************************
// 9093 Loads previously selected value in page search field
function hdftGetPrevSelect(sFieldSelect){
    var sSearchValue = "";
    // Staff Based Searching
    switch (sFieldSelect) {
        case "wfesurinit":
            sSearchValue = sEmpSurInit;
            break;
        case "detsurinit":
            sSearchValue = sDetSurname;
            break;
        case "detsurname":
            sSearchValue = sEmpSurInit;
            break;
        case "wfeempno":
            sSearchValue = sEmpNo;
            break;
        case "detnumber":
            sSearchValue = sDetNo;
            break;
        case "wfecostctr":
        case "wfccostctr":
            sSearchValue = sCostCentre;
            break;
        // Popup Window Based Searching
        case "bsbcode":
        case "skicode":
        case "ptacode":
        case "gnaorgcode":
        case "lrccode":
        case "loccode":
        case "awdclass":
        case "code":
            sSearchValue = sSearchVal;
            break;
        case "csdscecode":
        case "pdtcode":
        case "paabusunit":
            sSearchValue = "";
            break;	
        // The Rest of Searching
        default:
            sSearchValue = "";
            break;
    }
    return sSearchValue;
}

// *********************************************************************
// Writes the HTML for the search table elements
// 09093 calling loadHandleKey() Disables any action onclick of the enter key
// 010119 - Lookup image conforms to C21
function hdftSearchField(sSearchField) {
    var sHtml = "";
    if (oDataPage.oSearch[sSearchField]["label"]) {
        sHtml += "<td class='Prompt' style='color:" + hPrompt + ";'>";
        sHtml += oDataPage.oSearch[sSearchField]["label"] + "</td>";
    }
    // 9347 - Add Day to the date search
    if (sSearchField == 'i_date') sHtml += "<td>" + calenGetMonthSelect(dToday.getMonth(), dToday.getDate()) + "</td>"; 
    // 9389 allow for drop down search tables
    switch (oDataPage.oSearch[sSearchField]["datatype"]) {
        case 9:
            sHtml += "<td><select";
            break;
        default:
            sHtml += "<td><input type='text'";
            break;
    }
    sHtml += " name='" + sSearchField + "' id='" + sSearchField + "' value='" + hdftGetPrevSelect(sSearchField) + "' class='Search' ";
    sHtml += "maxlength='" + oDataPage.oSearch[sSearchField]["length"];
    sHtml += "' style='width:" + loadFieldLength(oDataPage.oSearch[sSearchField]["length"],oDataPage.oSearch[sSearchField]["datatype"]) + "px;background-color:" + hSearch + ";' ";
    sHtml += loadHandleKey() + " title='" + oDataPage.oSearch[sSearchField]["title"] + "' clear='false'></td>"; 
    if (oDataPage.oSearch[sSearchField]["graphic"]) {
        // 9145 - Allow for multiple occurrences of same image in search fields
        // 10063 - 'detForm' added to path
        sHtml += "<td>";
        if (!bButtonHtml) sHtml += "<a href='javascript:void(0);' ";
        else sHtml += "<input type='button' value='' tabindex='-1' class='goButton' title='Search for these Staff details' style='background:url(" + loadPageResource("button") + validStripUnderScore(oDataPage.oSearch[sSearchField]["graphic"]) + "_up.png);background-color:#D4D0C8;background-position:center;background-repeat:no-repeat;' ";
        sHtml += " onClick='oGlob.lkupSearch(\"" + sSearchField + "\",detForm." + sSearchField + ".value); return true;' ";
        if (!bButtonHtml) {
            sHtml += "onMouseOver='locnImageSwap(\"dn\", \"" + oDataPage.oSearch[sSearchField]["graphic"] + "\", \"" + oDataPage.oSearch[sSearchField]["title"] + "\"); return true;' onMouseOut='locnImageSwap(\"up\", \"" + oDataPage.oSearch[sSearchField]["graphic"] + "\", \"\"); return true;'>";
            sHtml += "<img name='" + oDataPage.oSearch[sSearchField]["graphic"] + "' alt='" + oDataPage.oSearch[sSearchField]["title"] + "' border='0' src='" + loadPageResource("button") + validStripUnderScore(oDataPage.oSearch[sSearchField]["graphic"]) + "_up.png' tabindex='-1'></a>";
        }
        else sHtml += ">"; 
        sHtml += "</td><td><img src='" + loadPageResource("menu") + "pixel.png' width='5' height='1' alt=''></td>";
    }
    return sHtml;
}

// *********************************************************************
// Writes the HTML for the search table elements
function hdftSearchCreate(sSearchCreate) {
    var sHtml = "";
    if (oDataPage.oSearch[sSearchCreate]) {
        switch (oDataPage.oSearch[sSearchCreate].mode) {
            case "clr":
            case "ent":
                if ((bManMode) || (sMenuProfile == oDataPage.oSearch[sSearchCreate].mode)) {
                    sHtml += hdftSearchField(sSearchCreate);
                }
                break;
            case "sec":
                var sTempPage = loadPageCurrent();
                if ((bManMode) && (sMenuProfile == oDataPage.oSearch[sSearchCreate].mode)) {
                    sHtml += hdftSearchField(sSearchCreate);
                } else if (sTempPage == "mswfelst") {
                    sHtml += hdftSearchField(sSearchCreate);
                }
                break;
            case "man":
            case "sys":
                sHtml += hdftSearchField(sSearchCreate);
                break;
            case "all":
                if ((sMenuProfile != "clr") && (sMenuProfile != "ent") && (sMenuProfile != "sec")) {
                    sHtml += hdftSearchField(sSearchCreate);
                }
                break;
            default:
                if ((bManMode) && (sMenuProfile != "clr") && (sMenuProfile != "ent")) {
                    sHtml += hdftSearchField(sSearchCreate);
                }
                break;
        }
    }
    return sHtml;
}

// *********************************************************************
// Writes the HTML for header section of all pages.
function hdftSearchLoad() {
    var sHtml = "<div id='searchDiv' style='position:relative;left:5px;top:0px;'>";
    sHtml += "<table border='0' cellpadding='0' cellspacing='0'><tr>";
    // Output the bread crumb string
    if (bBreadCrumb) sHtml += hdftCrumbLoad();
    // Produce nothing if oSearch not defined in configuration
    if (!oDataPage.oSearch) {
        // Debug Window
        if (gDHTMLDebug) loadDebugPage("hdftSearchLoad:\nSearch page is not defined in Configuration File.\n");
        // Add extra space to compensate for no Search objects
        sHtml += "</tr></table></div>";
        return sHtml;
    }
    // Scan the Object within the configuration
    for (var sSearchLoad in oDataPage.oSearch) {
        // Sort out what we are going to be searching on
        switch (sSearchLoad) {
            // Staff Based Searching
            case "wfesurinit":
            case "wfeempno":
            case "detsurinit":
            case "detnumber":
                switch (oDataPage.oSearch[sSearchLoad].mode) {
                    case "ent":
                    case "man":
                    case "sec":
                        sHtml += hdftSearchCreate(sSearchLoad);
                        break;
                    default: 
                        if (bManMode) sHtml += hdftSearchCreate(sSearchLoad);
                        else sHtml += "<td height='22px'>&nbsp;</td>";
                        break;
                }
                break;
            // The Rest of Searching
            default:
                sHtml += hdftSearchCreate(sSearchLoad);
                break;
        }
        // Debug Window
        if (gDHTMLDebug) loadDebugPage("hdftSearchCreate:\nBuilding Search for: " + sSearchLoad + "\n");
    }
    sHtml += "</tr></table></div>";
    return sHtml;
}

// *********************************************************************
// Writes the HTML for header section of all pages.
// 009940 - Allow page title to be configured
function hdftHeaderCreate() {
    var sHtml = "";
    // Build up the htmp needed to create the header
    // On demand create banner heading and/or breadcrumb trail
    sHtml += "<div id='headDiv' style='width:100%;position:relative;left:0px;top:0px;'>";
    if (bVertMenu) sHtml += hdftVertBannerLoad();
    sHtml += "</div>";
    // Output the search code string
    sHtml += hdftSearchLoad();
    // Debug Window
    if (gDHTMLDebug) loadDebugPage("hdftHeaderCreate:\n" + sHtml + "\n");
    return sHtml;
}

// *********************************************************************
// 009507 - detnumber & detsurinit have been made configurable
// 009973 - detnumber & detsurinit objects cater for utility pages
// *********************************************************************
// Note:
// The setting of clear='false' is required by the loadClearFields method
// so that the values loaded into the Staff Number and Name fields when in
// Manager Mode are not cleared.
function hdftStaffDetails() {
    // Create some temporary objects and strings
    var oTemp = null;
    var sHtml = "";
    // If a search has been defined on the page for the fields then leave
    if ((oDataPage.oSearch) && ((oDataPage.oSearch["wfesurinit"]) || (oDataPage.oSearch["wfeempno"]))) {
        if (gDebug) alert("Warning: Search on page has been defined in Configuration File.");
        sHtml += "<td colspan='4'><div id='staffDiv'><table border='0' width='100%' cellpadding='0' cellspacing='0'><tr>";
        sHtml += "<td>&nbsp;</td></tr></table></div>";
        return sHtml;
    } else {
        sHtml += "<td colspan='4'><div id='staffDiv' class='StaffSearch' style='background-color:" + ((hSearchBG) ? hSearchBG : hWindowBG) + ";'>";
        sHtml += "<table border='0' width='100%' cellpadding='0' cellspacing='0'><tr>";
    }
    // Test the Staff Surname and Intials field
    if ((oDataPage.oDict) && (oDataPage.oDict["detsurinit"])) oTemp = oDataPage.oDict["detsurinit"];
    else if ((oDataPage.oDictUtl) && (oDataPage.oDictUtl["detsurinit"])) oTemp = oDataPage.oDictUtl["detsurinit"];
    if (oTemp) {
        sHtml += "<td class='Prompt' style='color:" + hPrompt + ";' valign='middle'>" + ((oTemp["label"] == "") ? "Staff Name" : oTemp["label"]) + "</td>";
        sHtml += "<td valign='middle'><input type='text' name='detsurinit' id='detsurinit' maxlength='24' style='width:140px' value='" + sEmpSurInit + "' clear='false' " + hdftDisplayOnly(true) + " style='background-color:" + ((hSearchBG) ? hSearchBG : hWindowBG) + ";'></td>";
    }
    // Test the Staff Number field
    oTemp = null;
    if ((oDataPage.oDict) && (oDataPage.oDict["detnumber"])) oTemp = oDataPage.oDict["detnumber"];
    else if ((oDataPage.oDictUtl) && (oDataPage.oDictUtl["detnumber"])) oTemp = oDataPage.oDictUtl["detnumber"];
    if (oTemp) {
        sHtml += "<td class='Prompt' style='color:" + hPrompt + ";' valign='middle' nowrap>" + ((oTemp["label"] == "") ? "Number" : oTemp["label"]) + "</td>";
        sHtml += "<td valign='middle'><input type='text' name='detnumber' id='detnumber' maxlength='7' style='width:70px' value='" + sEmpNo + "' clear='false' " + hdftDisplayOnly(true) + " style='background-color:" + ((hSearchBG) ? hSearchBG : hWindowBG) + ";'></td>";
    }
    sHtml += "</tr></table></div></td>";
    return sHtml;
}
    
// *********************************************************************
// 010408 - set temp page correctly for non-IE browsers
function hdftStaffHeader(iRows) {
    // Setup the text string for the html
    var sHtml = "";
    var sTempPage = loadPageCurrent();
    // load the text string for the html
    sHtml += "<tr height='22px'><td rowspan='" + iRows + "' width='10'>&nbsp;</td>";
    // start at box 
    switch (sTempPage.substr(0,2)) {
        case "md":
            sHtml += hdftStaffDetails();
            break;
        case "mr":
            if (sTempPage.indexOf("mrpfrdet") == -1) sHtml += hdftStaffDetails();
            else if (bManMode) sHtml += hdftStaffDetails();
            break;
        case "me":
            sHtml += "<td>&nbsp;</td>";
            break;
        default:
            if ((bManMode || bNewStaff) && (sTempPage.indexOf("detdet") == -1)) sHtml += hdftStaffDetails();
            else sHtml += "<td>&nbsp;</td>";
            break;
    }
    sHtml += "</tr>";
    // Debug Window
    if (gDHTMLDebug) loadDebugPage("hdftStaffHeader:\n" + sHtml + "\n");
    return sHtml;
}

// *********************************************************************
// 009349 - HR21: POP-UP CALENDAR REVAMPED
// 013668 - All times in hh:mm format
//  Determines the screen co-ordinates of the mouse click and opens the new window 
//  according to those co-ordinates.
function hdftSetCoOrds(eFormClick,sWindow) {
    iPosX = eFormClick.clientX;
    iPosY = eFormClick.clientY + 103;
    var iHeight = 180;
    var iWidth = 200;
    // 10217 - dimensions can be set via config
    switch (sWindow) {
        case "Time":
            if (aDictDetail["setimvew"]["i_height"]) iHeight = aDictDetail["setimvew"]["i_height"].label;
            else iHeight = 280;
            if (aDictDetail["setimvew"]["i_width"]) iWidth  = aDictDetail["setimvew"]["i_width"].label;
            else iWidth = 260;
            break;
        default:
            if (aDictDetail["sedrivew"]["i_height"]) iHeight = aDictDetail["sedrivew"]["i_height"].label;
            if (aDictDetail["sedrivew"]["i_width"]) iWidth  = aDictDetail["sedrivew"]["i_width"].label;
            break;
    }
    var bw = loadPageDimensions("w");
    // Position window to the left or right of the icon
    if ((iPosX + iWidth) > bw) iPosX -= 55;
    else iPosX += 142;
    // 010063 - ensure path is correct for Mozilla
    var sWindowParameter = "width=" + iWidth + ",height=" + iHeight + ",screenX=" + iPosX + ",left=" + iPosX + ",screenY=" + iPosY + ",top=" + iPosY + sDefaultWindow;
    switch (sWindow) {
        case "Time":
            oTimeWin = window.parent.open(loadPagePath("setimvew"),"TimePicker",sWindowParameter,true);
            break;
        default:
            oCalWin = window.parent.open(loadPagePath("sedrivew"),"CalendarPicker",sWindowParameter,true);
            break;
    }
    return;
}

// *********************************************************************
// 013668 - All times in hh:mm format
function hdftTime(imgName, formPath, sClass) {
    var iImgName = 0, sHtml = sImgName = "";
    if (!bButtonHtml) {       
        if ((iImgName = imgName.indexOf("_")) != -1) sImgName = imgName.substr(0, iImgName);
        else sImgName = imgName;
        sHtml = "<a name='a" + imgName + "' id='" + imgName + "' href='javascript:void(0);' onMouseOver='locnImageSwap(\"dn\", \"" + imgName + "\", \"Select a time\"); return true;' onMouseOut='locnImageSwap(\"up\", \"" + imgName + "\", \"\"); return true;' tabindex='-1' ";
    }
    else sHtml = "<input name='a" + imgName + "' id='" + imgName + "' type='button' value='' tabindex='-1' class='timButton' title='Select a time' ";
    // Disable popup calendar when it's not on the page
    if (sClass == "Key") sHtml += "onClick='if (!oGlob.bDrillMode) { oGlob.timeSetField(" + formPath + "); oGlob.hdftSetCoOrds(event,\"Time\"); return true; }'>";
    else sHtml += "onClick='oGlob.timeSetField(" + formPath + "); oGlob.hdftSetCoOrds(event,\"Time\"); return true;'>";
    if (!bButtonHtml) sHtml += "<img name='" + imgName + "' src='" + loadPageResource("button") + sImgName + "_up.png' alt='Select a time' border='0' align='top'></a>";
    // Debug Window
    if (gDHTMLDebug) loadDebugPage("hdftTime:\n" + sHtml + "\n");
    return sHtml;
}

// *********************************************************************
// 009349 - HR21: POP-UP CALENDAR REVAMPED
// 009743 - id of link set according to the image name
// 010119 - Lookup image conforms to C21
function hdftCalendar(imgName, formPath, sClass) {
    var iImgName = 0, sHtml = sImgName = "";
    if (!bButtonHtml) {       
        if ((iImgName = imgName.indexOf("_")) != -1) sImgName = imgName.substr(0, iImgName);
        else sImgName = imgName;
        sHtml = "<a name='a" + imgName + "' id='" + imgName + "' href='javascript:void(0);' onMouseOver='locnImageSwap(\"dn\", \"" + imgName + "\", \"Search for a specific date\"); return true;' onMouseOut='locnImageSwap(\"up\", \"" + imgName + "\", \"\"); return true;' tabindex='-1' ";
    }
    else sHtml = "<input name='a" + imgName + "' id='" + imgName + "' type='button' value='' tabindex='-1' class='calButton' title='Search for a specific date' ";
    // 009455  Disable popup calendar when it's not on the page
    if (sClass == "Key") sHtml += "onClick='if (!oGlob.bDrillMode) { oGlob.calenSetDateField(" + formPath + "); oGlob.hdftSetCoOrds(event); return true;}'>";
    else sHtml += "onClick='oGlob.calenSetDateField(" + formPath + "); oGlob.hdftSetCoOrds(event); return true;'>";
    if (!bButtonHtml) sHtml += "<img name='" + imgName + "' src='" + loadPageResource("button") + sImgName + "_up.png' alt='Search for a specific date' border='0' align='top'></a>";
    // Debug Window
    if (gDHTMLDebug) loadDebugPage("hdftCalendar:\n" + sHtml + "\n");
    return sHtml;
}

// *********************************************************************
// 010119 - Lookup image conforms to C21
// 011214 - Introduce the Sequence Number for use by the Apprisal pages
function hdftNotes(imgName, iSeqNumber, sType) {
    var iImgName = 0, sHtml = "";
    if (!bButtonHtml) sHtml = "<a href='javascript:void(0);' onMouseOver='locnImageSwap(\"dn\", \"nte\", \"Use this facility to view all notes entered\"); return true;' onMouseOut='locnImageSwap(\"up\", \"nte\", \"\"); return true;' tabindex='-1'";
    else sHtml = "<input name='nte' id='nte' type='button' value='' tabindex='-1' class='noteButton' title='Use this facility to view all notes entered'";
    sHtml += " onClick='";
    if (iSeqNumber) sHtml += "notesClick(" + iSeqNumber + ((sType) ? (",\"" + sType + "\"") : "") + ");";
    else sHtml += "oGlob.listOpenViewSelect(\"sentevew\");";
    sHtml += " return true;'>";
    if (!bButtonHtml) sHtml += "<img name='nte' src='" + loadPageResource("button") + "nte" + "_up.png' alt='Use this facility to view all notes entered' border='0'></a>";
    // Debug Window
    if (gDHTMLDebug) loadDebugPage("hdftNotes:\n" + sHtml + "\n");
    return sHtml;
}

// *********************************************************************
// 009743 - id of link set according to the image name
// 010119 - Lookup image conforms to C21
function hdftSelect(imgName, fileName) {
    var iImgName = 0;
    var sHtml = sImgName = "";
    // Strip out the index of the image if required
    if ((iImgName = imgName.indexOf("_")) != -1) {
        sImgName = imgName.substr(0,iImgName);
    } else {
        sImgName = imgName;
    }
    // Decide if using the standard three dot button or the toggling graphic
    if (bButtonHtml) {
        sHtml = "<input id='" + imgName + "' type='button' value='...' tabindex='-1' class='stdButton' title='Search for a specific entry'";
    } else {
        sHtml = "<a id='" + imgName + "' href='javascript:void(0);' onMouseOver='locnImageSwap(\"dn\", \"" + imgName + "\", \"Search for a specific entry\"); return true;' onMouseOut='locnImageSwap(\"up\", \"" + imgName + "\", \"\"); return true;' tabindex='-1' ";
    }
    // If the file name has been set then load up the search field parameters and call the select opening faciltiy,
    // Otherwise this is called from a click function on the calling page
    if (fileName) {
        sHtml += "onClick='oGlob.listSetSearchField(";
        for (var i=2; i<arguments.length; i++) {
            sHtml += "\"" + arguments[i] + "\"";
            var j = i + 1;
            if (j != arguments.length) sHtml += ",";
        }
        sHtml += "); oGlob.listOpenSelect(\"" + fileName + "\", \"SearchFacility\"); return true;'>";
    } else {
        sHtml += "onClick='window.parent.parent." + imgName + "Click(); return true;'>";
    }
    if (!bButtonHtml) sHtml += "<img name='" + imgName + "' src='" + loadPageResource("button") + sImgName + "_up.png' alt='Search for a specific entry' border='0' align='top' style='margin:0px 5px 0px 2px;'></a>";
    // Debug Window
    if (gDHTMLDebug) loadDebugPage("hdftSelect:\n" + sHtml + "\n");
    return sHtml;
}

// *********************************************************************
// Note: Though we have given clients the ability to pick, readonly will
// only work in IE
//
// 010721 - Output standard display only HTML when required
function hdftDisplayOnly(bDisplayOnly) {
    var sHtml = "";
    if (bDisplayOnly) {
        sHtml += " tabindex='-1' class='Display' ";
        if (is.ie) {
            sHtml += sDisplayOnly;
        } else {
            sHtml += "disabled";
        }
    }
    return sHtml;
}

// *********************************************************************
// 9743 - hdftSetOnClickEvent() accepts two parameters: the name of the 
//        form element, and a boolean to indicate whether the element 
//        should be disabled or not. If it is to be disabled, then the 
//        onclick event is stored in aOnClickEvents[], so then it can 
//        reinstated later if required.
function hdftSetOnClickEvent(sFormElement, bDisable) {
    var oFormElement = oDataPage.document.getElementById(sFormElement);
    var sTempPage = loadPageCurrent();
    var sEvent = sTempPage + "_" + sFormElement;
    if (oFormElement) {
        if (bDisable) {
            aOnClickEvents[sEvent] = oFormElement.onClick;
            oFormElement.onClick = null;
            oFormElement.disabled = true;
            oFormElement.style.cursor = "default";
            oFormElement.style.visibility = "hidden";
        }
        else {
            if (aOnClickEvents[sEvent]) oFormElement.onClick = aOnClickEvents[sEvent];
            oFormElement.disabled = false;
            oFormElement.style.cursor = "hand";
            oFormElement.style.visibility = "visible";
        }
    }
    return;
}

// *********************************************************************
// 009618 Swap Heading Colours
// 010698 Layout enhancements
function hdftHeadingCreate() {
    var sHtml = "<tr style='background-color:" + hdftGetBgColour() + ";'>";
    return sHtml;
}

// *********************************************************************
// 010698 Return the appropriate colour hex code
function hdftGetBgColour() {
    var hBgColour = "";
    if (bSwapHeading) {
        hBgColour = ((bHorizMenu) ? hHorizActive : hVertInactive);
    } else {
        hBgColour = ((bHorizMenu) ? hHorizInactive : hVertActive)
    }
    return hBgColour;
}

// *********************************************************************
// 10208 Creates a table cell containing an input cell based on the 
// dictionary field name passed in, alternatively will create a cell 
// containing the html string that is passed in
function hdftCreateCell(oRow,sDict,sValue,sId,sHtml) {
    var oCell = oRow.insertCell(oRow.cells.length);
    var sAlign = "left";
    if ((oDataPage) && (oDataPage.oDict[sDict]) && (oDataPage.oDict[sDict]["align"])) sAlign = oDataPage.oDict[sDict]["align"];
    oCell.align = sAlign; 
    if (!sHtml) {
        var sHtml = "<input id='" + sId + "' name='" + sId + "' type='text' style='text-align:" + sAlign + ";' maxlength='" + oDataPage.oDict[sDict]["length"] + "' size='" + (oDataPage.oDict[sDict]["length"] * 1.7) + "' value='" + sValue + "'";
        if (oDataPage.oDict[sDict]["display"]) sHtml += " " + oGlob.hdftDisplayOnly(true);
        sHtml += ">";
    }
    oCell.innerHTML = sHtml; 
    return oCell;
}

// *********************************************************************
function hdftHeadingColumnCreate(sName) {
    var sHtml = "";
    var oTemp = new Object();
    // Set the data dictionary for a utility page if required
    if (oDataPage.oDictUtl) oTemp = oDataPage.oDictUtl;
    else if (oDataPage.oDict) oTemp = oDataPage.oDict;
    // If the entry exists in the configuration
    if (oTemp[sName]) {
        sHtml += "<th class='Headings' style='text-align:";
        if (oTemp[sName]["align"]) {
            sHtml += oTemp[sName]["align"];
        } else {
            sHtml += "left";
        }
        sHtml += ";'>";
        if (oTemp[sName]["label"]) {
            sHtml += oTemp[sName]["label"];
        }
        sHtml += "</th>";
    }
    // Debug Window
    if (gDHTMLDebug) loadDebugPage("hdftHeadingColumnCreate:\n" + sHtml + "\n");
    return sHtml;
}

// *********************************************************************
// 013929: Global function used to load events on a textarea to limit
//         them to a specific number of characters.
function hdftMemoEvents(iMaxLength) {
    var sHtml = "onKeyDown='oGlob.hdftMemoMaxLength(this," + iMaxLength.toString() + ");' ";
    sHtml += "onKeyUp='oGlob.hdftMemoMaxLength(this," + iMaxLength.toString() + ");' ";
    return sHtml;
}

// *********************************************************************
// 013929: Global function used when creating type 36 objects (textarea) 
//         and limit them to specific number of characters.
function hdftMemoMaxLength(oTextArea, iMaxLength) {
    // If no maximum length supplied default to 200
	if (!iMaxLength) {
        iMaxLength = 200;
    }
    // Check the length, if gone too far, go warning colour and change tool 
    // tip to indicate that chopping is occuring
	if (oTextArea.value.length > iMaxLength) {
        oTextArea.style.backgroundColor = hError ? hError : "#00FF00";
		oTextArea.title = "Maximum number of characters has been exceeded.";
		oTextArea.value = oTextArea.value.substring(0, iMaxLength);
    } else if (oTextArea.value.length > iMaxLength - 10) {
        oTextArea.style.backgroundColor = hWarning ? hWarning : "#FF964A";
        oTextArea.title = "";
	} else {
        oTextArea.style.backgroundColor = "#FFFFFF";
        oTextArea.title = "";
    }
	return;
}

// *********************************************************************
// 014439: Some extra magic for GBS only.
function hdftCountMemoMaxLength(sName, oTextArea, iMaxLength) {
    var sNameCount = sName + "_count";
    var oInputCount = oDataPage.document.getElementById(sNameCount);
    // If no maximum length supplied default to 200
	if (!iMaxLength) {
        iMaxLength = 200;
    }
    // Check the length, if gone too far simply alert
	if (oTextArea.value.length > iMaxLength) {
		alert("Maximum number of characters has been exceeded.");
		oTextArea.value = oTextArea.value.substring(0, iMaxLength);
		if (oInputCount) oInputCount.value = "0";
	} else {
        if (oInputCount) {
            oInputCount.value = iMaxLength - oTextArea.value.length;
        }
        oTextArea.title = "";
    }
	return;
}

// *********************************************************************
var iTab = 0;

// *********************************************************************
// Generator Supplied Appendix Breakdown by Object Type:
//
// calen: [0] = Image Rollover Reference
//        [1] = Flag to include onBlur event, included when false
//
// 010119 - Lookup image conforms to C21 
// 013668 - Added a type for dynamically doing arrays on a page
function hdftFieldCreate(iName, sName, cNewLine, iTabIndex, iColSpan, sClass, aAppendix) {
    var oTemp = new Object();
    var cTestLine = cTestLine2 = sHtml = sTemp = sDataType = "";
    // 009403 - Set the data dictionary for a utility page if required
    if (oDataPage.oDictUtl) oTemp = oDataPage.oDictUtl;
    else if (oDataPage.oDict) oTemp = oDataPage.oDict;
    if (oTemp[sName] && oTemp[sName].datatype) sDataType = oTemp[sName].datatype;
    var bElementName = ((isNaN(iName)) ? false : true);
    var sElementName = sName + ((bElementName) ? iName : "");
    // Argument 2: Taking care of number of objects to a table row
    if ((arguments[2]) && (isNaN(arguments[2]))) {
        cTestLine = cNewLine.toString().charAt(0).toLowerCase();
        cTestLine2 = cNewLine.toString().charAt(1).toLowerCase();
    } else {
        // If the value is numeric do a pixel rowspan to indent objects
        if ((arguments[2]) && (!isNaN(arguments[2]))) {
            sHtml += "<tr><td ";
            if (arguments[2] != true) sHtml += "rowspan='" + arguments[2] + "' width='10'>&nbsp;</td><td ";
            sHtml += "height='22px'>&nbsp;</td></tr>"
            // Debug Window
            if (gDHTMLDebug) loadDebugPage("hdftFieldCreate - numeric[0]:\n" + sHtml + "\n");
            return sHtml;
        }
    }
    // Temporary Variable for starting the row
    switch (sClass) {
        case "Headings":
            sTemp = hdftHeadingCreate();
            break;
        case "Divider":
            // 10698 - create a divider div
            if (oDataPage.oDict["i_divider"]) sTemp = "<div id='divider'></div>";
            return sTemp;
            break;
        default:
            sTemp = "<tr>";
            break;
    }
    // 007911: Taking care of opening and/or closing the row
    switch (cTestLine) {
        case "a":
            break;
        case "l":
        case "s":
            if ((cTestLine2 == "") || (cTestLine2 == "f")) sHtml += sTemp;
            break;
        case "":
        case "t":
        case null:
            sHtml += sTemp;
            break;
        case "r":
            if ((cTestLine2 == "") || (cTestLine2 == "f")) sHtml += sTemp + "<td colspan='2'>&nbsp;</td>";
            break;
    }
    // 007911: Taking care of whether to create the object or not
    if (!oTemp[sName]) {
        switch (cTestLine) {
            case "a":
                break;
            case "":
            case null:
                sHtml += "</tr>";
                break;
            case "e":
            case "l":
            case "r":
                if ((cTestLine2 == "") || (cTestLine2 == "l")) sHtml += "</tr>";
                break;
            case "s":
                if (cTestLine2 == "l") sHtml += "<td colspan='2'>&nbsp;</td>";
                break;
            case "t":
                sHtml += "<td>&nbsp;</td></tr>";
                break;
        }
        // Debug Window
        if (gDHTMLDebug) loadDebugPage("hdftFieldCreate:\nNot creating " + sElementName + " field. Adding: " + sHtml + "\n");
        return sHtml;
    }
    // Initialise prompt dependant on object type
    switch (sClass) {
        case "Comment":
        case "Headings":
            sHtml += "<td id='" + sElementName + "' name='" + sElementName + "' valign='middle' class='" + sClass + "'";
            if ((arguments[4]) && (!isNaN(iColSpan)) && (iColSpan > 0)) sHtml += " colspan='" + iColSpan + "'";
            // Take care of alignment and border style settings
            sHtml += " style='text-align:";
            if (oTemp[sName]["align"]) sHtml += oTemp[sName]["align"];
            else sHtml += "left";
            //008780: Set colours and text
            switch (sClass) {
                case "Headings":
                    sHtml += ";'>" + oTemp[sName]["label"];
                    break;
                case "Comment":
                    sHtml += ";color:" + oTemp[sName]["colour"] + ";'>" + oTemp[sName]["comment"];
                    break;
            }
            break;
        default:
            if (cTestLine == "a") {
                sHtml += "<td valign='middle'";
                if ((arguments[4]) && (!isNaN(iColSpan)) && (iColSpan > 0)) sHtml += " colspan='" + iColSpan + "'";
                if (sDataType != 37) {
                    sHtml += ">";
                }
            } else if ((cTestLine2 == "") || (cTestLine2 == "f")) {
                // Argument 4: Taking care of column spanning
                if (sElementName == "") {
                    sHtml += "<td valign='middle'";
                    if ((arguments[4]) && (!isNaN(iColSpan)) && (iColSpan > 0)) sHtml += " colspan='" + iColSpan + "'";
                    sHtml += ">&nbsp;</td>";
                } else {
                    if (bElementName) {
                        if (cTestLine == "e") sHtml += "<td>&nbsp;</td>";
                    } else {
                        sHtml += "<td id='" + sElementName + "' name='" + sElementName + "' valign='middle' class='Prompt' style='color:" + hPrompt + ";";
                        if (oDataPage.oDict["i_divider"] && cNewLine == "e") sHtml += "padding-left:5px;";
                        sHtml += "'";
                        if ((arguments[4]) && (!isNaN(iColSpan)) && (iColSpan > 0)) sHtml += " colspan='" + iColSpan + "'";
                        sHtml += ">" + oTemp[sName]["label"];  
                        if (oTemp[sName]["mandatory"]) sHtml += "&nbsp;<font style='color:" + hError + ";font:bold;'>*</font>";
                        sHtml += "</td>";
                    }
                }
                // Argument 6: Taking care of alignment
                sHtml += "<td valign='middle' align=";
                if (oDataPage.oDict["i_divider"]) {
                    sHtml += "'right' valign='middle'";
                    sHtml += " style='text-align=\"" + oTemp[sName].align + "\";";
                    if (cNewLine == "s") sHtml += "padding-right:5px;";
                    sHtml += "' ";
                } else {
                    sHtml += "'" + ((oTemp[sName] && oTemp[sName]["align"]) ? oTemp[sName]["align"] : "left") + "' ";
                }
                // Only do this if object is not going to be a radio type, ie datatype 37
                if (sDataType != 37) {
                    if ((arguments[4]) && (!isNaN(iColSpan)) && (iColSpan < 0)) sHtml += " colspan='" + Math.abs(iColSpan) + "'";
                    else if (oTemp[sName]["length"] >= 50) sHtml += " colspan='3'";
                    sHtml += ">";
                }
            }
            // datatype 37 is a radio button
            if (sDataType != 37) {
                switch (sDataType) {
                    // time
                    case 3:
                        sHtml += "<input type='text' name='" + sElementName;
                        sHtml += "' " + ((oTemp[sName]["appendix"] != "enter") ? loadHandleKey() : "") + " maxlength='" + ((oTemp[sName]["length"]) ? oTemp[sName]["length"] : "30") + "' ";
                        break;
                    // select
                    case 9:
                        if (bDisabledUpdate) {
                            sHtml += "<input type='text' name='" + sElementName; 
                            if (oTemp[sName].trans) sHtml += "_trn";
                            sHtml += "' maxlength='" + ((oTemp[sName]["length"]) ? oTemp[sName]["length"] : "30") + "'";
                        }
                        else sHtml += "<select name='" + sElementName + "' size='1' onFocus='if (selectedIndex == -1) selectedIndex=0; return true;'";
                        break;
                    // text (and passwords)
                    case 10:
                        if (sClass == "Password") sHtml += "<input type='password' name='" + sName + "'" + loadHandleKey() + " maxlength='" + ((oTemp[sName]["length"]) ? oTemp[sName]["length"] : "20") + "'";
                        else {
                            sHtml += "<input type='text' name='" + sElementName;
                            if (oTemp[sName].trans) sHtml += "_trn";
                            sHtml += "' " + ((oTemp[sName]["appendix"] != "enter") ? loadHandleKey() : "") + " maxlength='" + ((oTemp[sName]["length"]) ? oTemp[sName]["length"] : "30") + "' ";
                        }
                        break;
                    // button
                    case 32:
                        break;
                    // checkbox
                    case 35:
                        sHtml += "<input type='checkbox' class ='CheckBox ' name='" + sElementName + "'";
                        break;
                    // textarea
                    case 36:
                        // 13929: limit textarea to specific number of characters.
                        var iHeight = (oTemp[sName]["height"]) ? oTemp[sName]["height"] : 5;
                        var iLength = (oTemp[sName]["length"]) ? oTemp[sName]["length"] : 40;
                        var iMaxLength = iHeight * iLength;
                        sHtml += "<textarea name='" + sElementName + "' wrap='soft' "
                        sHtml += "rows='" + iHeight.toString() + "' cols='" + iLength.toString() + "' ";
                        // 014439: Some extra magic for GBS only.
                        if ((oTemp[sName]["appendix"]) && (oTemp[sName]["appendix"][0]) && (oTemp[sName]["appendix"][0] == "true")) {
                            sHtml += "onKeyDown='oGlob.hdftCountMemoMaxLength(\"" + sElementName + "\",this," + iMaxLength.toString() + ");' ";
                            sHtml += "onKeyUp='oGlob.hdftCountMemoMaxLength(\"" + sElementName + "\",this," + iMaxLength.toString() + ");' ";
                        } else {
                            sHtml += "onKeyDown='oGlob.hdftMemoMaxLength(this," + iMaxLength.toString() + ");' "
                            sHtml += "onKeyUp='oGlob.hdftMemoMaxLength(this," + iMaxLength.toString() + ");' ";
                        }
                        break;
                    default:
                        if (sClass == "Password") sHtml += "<input type='password' name='" + sElementName + "'" + loadHandleKey();
                        else sHtml += "<input type='text' name='" + sElementName + "'" + ((oTemp[sName]["appendix"] != "enter") ? loadHandleKey() : "");
                        sHtml += " maxlength='" + ((oTemp[sName]["length"]) ? oTemp[sName]["length"] : "30") + "' ";
                        break;
                }
                // Do not worry about styles if data type 32 or 35
                switch (sDataType) {
                    case 32:
                    case 35:
                        break;
                    default:
                        sHtml += " style='width:" + loadFieldLength(oTemp[sName]["length"],sDataType) + "px;";
                        switch (sClass) {
                            case "Key":
                                sHtml += "background-color:" + hKey + ";";
                                break;
                            case "Search":
                                sHtml += "background-color:" + hSearch + ";";
                                break;
                            case "Default":
                                sHtml += "background-color:" + hDefault + ";";
                                break;
                            default:
                                sHtml += "background-color:" + hWindowBG + ";";
                                break;
                        }
                        // Take care of alignment and border style settings
                        sHtml += "text-align:";
                        if (oTemp[sName]["align"]) sHtml += oTemp[sName]["align"];
                        else sHtml += "left";
                        sHtml += ";'";
                        break;
                }
            }
            // Do not worry about adding HTML if data type 32
            switch (sDataType) {
                case 32:
                    break;
                default:
                    // Take care of tool tip creation via the title contents
                    if (oTemp[sName]["title"]) sHtml += " title='" + oTemp[sName]["title"] + "' ";
                    // Argument 5: Taking care of class setting, remember if Key class then disable if drilling down
                    if ((arguments[5]) || (oTemp[sName]["display"]) || (bDisabledUpdate)) {
                        if (((oTemp[sName]["display"]) || (bDisabledUpdate)) && (sClass != "Key")) sClass = "Display"; 
                        // datatype 36 is a textarea
                        if (sDataType != 36) sHtml += " class='" + sClass + "' ";
                        // 13685: Object does not recognise readonly therefore set to disabled at all times.
                        if ((sClass == "Key") && (bDrillMode)) {
                            switch (sDataType) {
                                case 35:
                                case 37:
                                    sHtml += " disabled";
                                    break;
                                default:
                                    sHtml += " " + sDisplayOnly;
                                    break;
                            }
                        }
                    }
                    // Take care of tab index creation via the global count for each page
                    sHtml += " tabindex='";
                    // 13685: Object does not recognise readonly therefore set to disabled at all times.
                    if (((oTemp[sName]["display"]) || (bDisabledUpdate)) && (sClass != "Key")) {
                        sHtml += "0'";
                        switch (sDataType) {
                            case 35:
                            case 37:
                                sHtml += " disabled";
                                break;
                            default:
                                sHtml += " " + sDisplayOnly;
                                break;
                        }
                    } else if (isNaN(iTabIndex)) {
                        sHtml += iTab++ + "'";
                    } else {
                        sHtml += iTabIndex + "'";
                        iTab = iTabIndex + 1;
                    }
                    break;
            }
            break;
    }
    // Argument 6: Add on the options
    if (arguments[6]) sHtml += " " + aAppendix;
    // Finish off the closing tags for the object being created
    switch (sDataType) {
        // time
        case 3:
            if ((!oTemp[sName]["display"]) && (!bDisabledUpdate)) {
                sHtml += ">";
                if ((!oTemp[sName]["appendix"]) || (isNaN(oTemp[sName]["appendix"][0]))) sHtml += hdftTime("tim","document.detForm." + sElementName,sClass);
                else sHtml += hdftTime("tim_" + oTemp[sName]["appendix"][0],"document.detForm." + sElementName,sClass);
            } else {
                sHtml += ">";
            }
            break;
        // organisation validated
        case 7:
            sHtml += ">";
            if ((!oTemp[sName]["display"]) && (!bDisabledUpdate)) {
                // Set the Organisation Level that field is validated against.
                if ((!oTemp[sName]["appendix"]) || (isNaN(oTemp[sName]["appendix"][0]))) sHtml += hdftSelect("gna","esgnasel","document.detForm." + sElementName);
                else sHtml += hdftSelect("gna_" + oTemp[sName]["appendix"][0],"esgnasel","document.detForm." + sElementName);    
            }
            if (oTemp[sName].trans) sHtml += "<input type='text' name='" + sElementName + "_trn' maxlength='24' style='width:140px' " + hdftDisplayOnly(true) + ">";
            break;
        // select
        case 9:
            if (oTemp[sName]["appendix"]) sHtml += " id='" + sName + oTemp[sName]["appendix"][0] + "' name='" + sName + oTemp[sName]["appendix"][0] + "'";
            if ((bDisabledUpdate) || (oTemp[sName]["datatype"] != 9)) sHtml += ">";
            else sHtml += "><option>&nbsp;</option><option>&nbsp;</option><option>&nbsp;</option><option>&nbsp;</option><option>&nbsp;</option><option>&nbsp;</option></select>";
            break;
        // text
        case 10:
            if (sClass != "Comment" && sClass != "Headings") {
                if (oTemp[sName]["appendix"]) sHtml += " id='" + sName + oTemp[sName]["appendix"][0] + "' name='" + sName + oTemp[sName]["appendix"][0] + "'";
                sHtml += ">";
            }
            break;
        // file validated
        case 11:
            if (oTemp[sName]["appendix"]) sHtml += " id='" + sName + oTemp[sName]["appendix"][0] + "' name='" + sName + oTemp[sName]["appendix"][0] + "'";
            sHtml += ">";
            // if Display Only then no need for any lookup just show the code or translation
            if ((!oTemp[sName]["display"]) && (!bDisabledUpdate)) {
                // 010119 - Find the file that this field is validated against, 
                // eg. pydbsbnum is validated against PYBSB, so we want to throw to esbsbsel.htm
                var sSearchType = oTemp[sName].dataval.toLowerCase(); 
                sSearchType = sSearchType.substr(sSearchType.length-3, 3);
                var sPrefix = (sSearchType == "det" ? "mr" : "es");
                if ((!bDisabledUpdate) || (sSearchType == "ssa")) {
                    if ((!oTemp[sName]["appendix"]) || (isNaN(oTemp[sName]["appendix"][0]))) sHtml += hdftSelect(sSearchType,sPrefix + sSearchType + "sel","document.detForm." + sName);
                    else sHtml += hdftSelect(sSearchType + "_" + oTemp[sName]["appendix"][0], sPrefix + sSearchType + "sel","document.detForm." + sName);
                }
            }
            if (oTemp[sName].trans) {
                sHtml += "<input type='text' name='" + sElementName + "_trn' maxlength='30' style='width:320px' " + hdftDisplayOnly(true) + ">";
            }
            break;
        // calendar
        case 16:
            if ((!oTemp[sName]["display"]) && (!bDisabledUpdate)) {
                if ((!oTemp[sName]["appendix"]) || (!oTemp[sName]["appendix"][1])) sHtml += " onBlur='if (this.value == \"\") this.value=oGlob.sToday; return true;'>";
                else sHtml += ">";
                if ((!oTemp[sName]["appendix"]) || (isNaN(oTemp[sName]["appendix"][0]))) sHtml += hdftCalendar("cal","document.detForm." + sElementName,sClass);
                else sHtml += hdftCalendar("cal_" + oTemp[sName]["appendix"][0],"document.detForm." + sElementName,sClass);
            } else {
                sHtml += ">";
            }
            break;
        // buttons
        case 32:
            switch (sName) {
                case "i_notes":
                    sHtml += hdftNotes();
                    break;
            }
            break;
        // checkbox
        case 35:
            sHtml += ">";
            break;
        // textarea
        case 36:
            sHtml += "></textarea>";
            switch (sName) {
                case "i_notes":
                    if (oTemp[sName].trans) sHtml += hdftNotes();
                    break;
            }
            // 014439: Some extra magic for GBS only.
            if ((oTemp[sName]["appendix"]) && (oTemp[sName]["appendix"][0]) && (oTemp[sName]["appendix"][0] == "true")) {
                var iHeight = (oTemp[sName]["height"]) ? oTemp[sName]["height"] : 5;
                var iLength = (oTemp[sName]["length"]) ? oTemp[sName]["length"] : 40;
                var iMaxLength = iHeight * iLength;
                sHtml += "<br><input type='text' id='" + sName + "_count' name='" + sName + "_count' value='" + iMaxLength + "' style='width:50px;' maxlength='3' " + hdftDisplayOnly(false) + ">";
            }
            break;
        // radio
        case 37:
            sHtml += ">";
            // 010408 - work out if char(0) or the whole string should be used for the radio ID
            var bUseString = hdftCheckRadio(oTemp,sName);
            var sRadioId = "";
            for (var i=0; i<oTemp[sName]["appendix"].length; i++) {
                sRadioId = bUseString ? oTemp[sName]["appendix"][i] : oTemp[sName]["appendix"][i].charAt(0);
                sHtml += "<font class='Prompt' style='color:" + hPrompt + ";'>" + oTemp[sName]["appendix"][i] + "</font>";
                sHtml += "&nbsp;<input type='radio' name='" + sElementName + "' id='" + sElementName + sRadioId + "' value='" + sRadioId + "'";
                // 13685: Object does not recognise readonly therefore set to disabled at all times.
                if (((oTemp[sName]["display"]) || (bDisabledUpdate)) && (sClass != "Key")) sHtml += " disabled";
                sHtml += ">&nbsp;";
            }
            break;
        default:
            if (sClass != "Comment" && sClass != "Headings") {
                if (oTemp[sName]["appendix"]) sHtml += " id='" + oTemp[sName]["appendix"][0] + "' name='" + oTemp[sName]["appendix"][0] + "'";
                sHtml += ">";
            }
            break;
    }
    // Argument 2: Taking care of number of objects to a table row
    if ((cTestLine2 == "") || (cTestLine2 == "l")) sHtml += "</td>";
    switch (cTestLine) {
        case "a":
            break;
        case "":
        case null:
            sHtml += "</tr>";
            break;
        case "e":
        case "l":
        case "r":
            if ((cTestLine2 == "") || (cTestLine2 == "l")) sHtml += "</tr>";
            break;
    }
    // Debug Window
    if (gDHTMLDebug) loadDebugPage("hdftFieldCreate:\n" + sHtml + "\n");
    return sHtml;
}

// *********************************************************************
// 010408 - Introduced to avoid id clashes in radio buttons
// If any of the first characters of the aAppendix elements
// are not unique then false is returned.
function hdftCheckRadio(oTemp,sName) {
    var sTemp = "";
    var aTemp = new Array();
    for (var i in oTemp[sName]["appendix"]) sTemp += oTemp[sName]["appendix"][i].charAt(0);
    for (var i = 0; i < sTemp.length; i++) {
        var cChar = sTemp.charAt(i);
        aTemp = eval("sTemp.match(/" + cChar + "/g);");
        if (aTemp.length && aTemp.length > 1) return true;
    }
    return false;
}

// *********************************************************************
// 8366 - Creates the HTML for the the workflow notes page
// 9550 - Readonly mode for historical notes viewer
function hdftNotesCreate() {
    var bViewOnly = false;
    var iMaxLength = iLength = iHeight = 0;
    if ((dataFrame.oDict["i_notes"].datatype == 32) && (dataFrame.oDict["i_notes"].display)) {
        bViewOnly = true;
    }
    var sHtml = "<table><tr><td class='Prompt'>" + ((aDictDetail["sentevew"]["i_allnotes"]["label"]) ? aDictDetail["sentevew"]["i_allnotes"]["label"] : "") + "</td></tr>";
    sHtml += "<tr><td>";
    sHtml += "<textarea id='i_allnotes' name='i_allnotes' title='" + ((aDictDetail["sentevew"]["i_allnotes"]["title"]) ? aDictDetail["sentevew"]["i_allnotes"]["title"] : "") + "' ";
    iLength = aDictDetail["sentevew"]["i_allnotes"]["length"];
    iHeight = aDictDetail["sentevew"]["i_allnotes"]["height"];
    iMaxLength = iLength * iHeight;
    sHtml += "rows='" + iHeight.toString() + "' cols='" + iLength.toString() + "' ";
    sHtml += "style='width:550px;height:150px;background-color:"+ hAlternate + ";' onKeyPress='return false;' " + ((bViewOnly) ? sDisplayOnly : "onClick='i_mannotes.focus();'" ) + "></textarea>";
    sHtml += "</td></tr>";
    if ((!bViewOnly) && (aDictDetail["sentevew"]["i_mannotes"])) {
        sHtml += "<tr><td class='Prompt'>" + ((aDictDetail["sentevew"]["i_mannotes"]["label"]) ? aDictDetail["sentevew"]["i_mannotes"]["label"] : "") + "</td></tr>";
        sHtml += "<tr><td>";
        sHtml += "<textarea id='i_mannotes' name='i_mannotes' title='" + ((aDictDetail["sentevew"]["i_mannotes"]["title"]) ? aDictDetail["sentevew"]["i_mannotes"]["title"] : "") + "' "
        iLength = aDictDetail["sentevew"]["i_mannotes"]["length"];
        iHeight = aDictDetail["sentevew"]["i_mannotes"]["height"];
        iMaxLength = iLength * iHeight;
        sHtml += "rows='" + iHeight.toString() + "' cols='" + iLength.toString() + "' ";
        sHtml += "onKeyDown='oGlob.hdftMemoMaxLength(this," + iMaxLength.toString() + ");' "
        sHtml += "onKeyUp='oGlob.hdftMemoMaxLength(this," + iMaxLength.toString() + ");' ";
        sHtml += "style='width:550px;height:150px;'></textarea>";
        sHtml += "</td></tr>";
    } else {
        oVewSelWin.resizeBy(0, -150);
    }
    sHtml += "</table>";
    // Debug Window
    if (gDHTMLDebug) loadDebugPage("hdftNotesCreate:\n" + sHtml + "\n");
    return sHtml;
}

// *********************************************************************
function hdftButtonLoad(sImage, sToolTip, sLabelText, sHref) {
    // 008890: sCurrDiv has been introduced to help with the unique naming 
    // of buttons in lists, especially in mswfelst where there are link buttons.
    var sTemp, sCurrDiv = iCurrDiv ? iCurrDiv : 0;   
    // Only load up the extra string for the Click command if on a detail
    // page at the moment. Pop-Up pages should not load this string.
    var sClick = (oDataPage == dataFrame) ? "oGlob.oDataPage=oGlob.dataFrame; " : "";
    // Set any out of the ordinary cases, before doing the default
    switch (sImage) {
        case "staff":
            var oTemp = menuObjectLoad(sStaffPage);
            if (oTemp) sToolTip = "Back to " + oTemp["title"];
            sClick += "oGlob.listPageSelect(\"" + sStaffPage + "\"); return false;";
            break;
        case "back":
            sClick += sImage + "Click(); return false;'";
            break;
        case "del":
            sClick += "if (confirm(\"";
            sClick += ((sDataPage.indexOf("padetdet") != -1) ? "Do not delete staff with totals in the current Year to Date.\\nCurrent Year to Date values are required for Payment Summaries.\\n\\n" : "");
            sClick += "Do you wish to delete your " + oDataPage.oMenu["title"] + " information ?\",\"Delete Staff Information\")) { delClick(); } return false;'";
            break;
        case "del_co":
            sImage = "del";
            sClick += "delClick(); return false;'";
            break;
        case "end":
        case "next_emp":
            if (sImage == "next_emp") sImage = "next";
            sClick += "updatClick(); return false;'";
            break;
        case "curr":
            sClick += "fhistClick(); return false;'";
            break;
        case "sysvw":
            sClick += "manvwClick(); return false;'";
            break;
        case "next":
            sClick += "oGlob.listNextSelect(); return true;'"; 
            break;
        case "prev":
            sClick += "oGlob.listPreviousSelect(); return true;'"; 
            break;
        case "print":
	    	// 009345 - print function for report frames moved into scripts
            sClick += "oGlob.listPrintSelect(); return true;'"; 
            break;
        case "top":
            sClick += "oGlob.listTopSelect(); return true;' target='oDataPage'"; 
            break;
        default:
            // 008711: Reworked for buttons on link bar
            if (sImage.indexOf("lnk_") != -1) {
                sClick += "if (!(oGlob.bListEmpty)) { oGlob.listPageSelect(\"" + sHref + "\"); } this.blur();";
            } else {
                sClick += sImage + "Click(";
                // If the sHref attribute is a link, send it to the click function on the page
                if (arguments[3]) sClick += "\"" + sHref + "\"";
                sClick += ");";
            }
            sClick += " return false;'";
            break;
    }
    // Set up some temporary variables before proceeding
    sTemp = "<td align='" + ((sImage.indexOf("lnk_") != -1) ? "left" : "right") + "'>";
    if (isNaN(iButtonWidth)) {
        iButtonWidth = 100;
    }
    var sTempOffset = "";
    switch (sButtonAlign) {
        case "left":
        case "right":
            sTempOffset = sButtonAlign + ":" + iButtonOffset + ";";
            break;
    }
    var sTempForeUp = ((bHorizMenu) ? hHorizInactive : hVertInactive);
    var sTempBackUp = ((bHorizMenu) ? hHorizBG : hVertBG);
    var sTempForeDown = ((bHorizMenu) ? hHorizBG : hVertBG);
    var sTempBackDown = ((bHorizMenu) ? hHorizActive : hVertActive);
    // Use Html or Graphical Buttons
    if (bButtonHtml) {
        // 010063 - HTML re-arranged for multi browser support
        sTemp += "<input type='button' id='" + sImage + "' class='HTMLbutton' style='color:" + sTempForeUp + ";width:" + iButtonWidth + ";text-align:" + ((sButtonAlign) ? sButtonAlign : "center") + ";background-color:" + sTempBackUp + "' name='" + sImage + "' value='" + sLabelText + "' onClick='" + sClick + "' ";
        sTemp += "onMouseOver=\"this.style.background='" + sTempBackDown + "';this.style.color='" + sTempForeDown + "';window.status=\'" + sToolTip + "\';return true;\" onMouseOut=\"this.style.background='" + sTempBackUp + "';this.style.color='" + sTempForeUp + "';window.status=\'" + window.defaultStatus + "\';return true;\" title='" + sToolTip + "' tabindex='100'></td>";
    } else {
        if (sButtonHtml == "arrows") {
            sTempForeUp = ((bHorizMenu) ? hHorizBG : hVertBG);
            sTempForeDown = ((bHorizMenu) ? hHorizInactive : hVertInactive);
        }
        // 008890: sCurrDiv is used to keep the naming of graphics buttons unique.
        sTemp += "<img id='" + sImage + sCurrDiv + "' name='" + sImage + sCurrDiv + "' alt='" + sToolTip + "' border='0' href='javascript:void(0);' src='" + loadPageResource(sButtonHtml, (sHref == true ? true : null)) + "up.png' onMouseOver=\"this.src='" + loadPageResource(sButtonHtml, (sHref == true ? true : null)) + "down.png';return true;\" onMouseOut=\"this.src='" + loadPageResource(sButtonHtml, (sHref == true ? true : null)) + "up.png';return true;\" onClick='" + sClick + "' width='" + iButtonWidth + "' tabindex='-1'>";
        sTemp += "<div href='javascript:void(0);' name='label" + sImage + sCurrDiv + "' id='label" + sImage + sCurrDiv + "' title='" + sToolTip + "' style='color:" + sTempForeUp + ";position:relative;top:-22;" + sTempOffset + "width:" + iButtonWidth + ";z-index:1;' align='" + ((sButtonAlign) ? sButtonAlign : "center") + "' onMouseOver=\"window.status=\'" + sToolTip + "\';" + sImage + sCurrDiv + ".src='" + loadPageResource(sButtonHtml, (sHref == true ? true : null)) + "down.png';this.style.cursor='hand';this.style.color='" + sTempForeDown + "';return true;\" onClick='" + sClick + "' onMouseOut=\"window.status=\'" + window.defaultStatus + "\';" + sImage + sCurrDiv + ".src='" + loadPageResource(sButtonHtml, (sHref == true ? true : null)) + "up.png';this.style.color='" + sTempForeUp + "';return true;\" tabindex='-1' class='HTMLLabel'>" + sLabelText + "</div>";
    }
    sTemp += "</td>";
    return sTemp;
}

// *********************************************************************
// 010063 - Appearance of buttons fixed for all supported browsers
function hdftButtonDetail(aButtons, bNoDiv) {
    var oButtons, sHtml = "";
    // Fixing bug in 010063 where the aButtons array could be null.
    if ((!oDataPage.oDict) || (aButtons == null)) return sHtml;
    var iWidth = aButtons.length;
    iWidth = iWidth * 10;
    if (!bNoDiv) sHtml += "<div id='buttDiv' style='position:relative;left:10px;top:" + ((bButtonHtml) ? ((is.ie) ? 7 : 0) : ((is.ie) ? 20 : 0)) + "px;width:97%;height:30px;'>";
    sHtml += "<table border='0' cellpadding='0' cellspacing='0' align='right'>";
    sHtml += "<tr height='30' valign='middle'><td align='right'></td>";
    // Make sure the array is not null
    if (aButtons != null) {
        // Scan through button array and set the various buttons
        for (var iIndex=0; iIndex<aButtons.length; iIndex++) {
            // Check to see if this button is defined
            oButtons = eval("oDataPage.oDict['" + aButtons[iIndex] + "']");
            if ((!oButtons) || (oButtons == null)) {
                // do nothing
            } else {
                switch (aButtons[iIndex]) {
                    case null:
                    case true:
                        break;
                    case "staff":
                        if (bManMode) sHtml += hdftButtonLoad(aButtons[iIndex],oButtons["tooltip"],oButtons["labeltext"],oButtons["href"]);
                        break;
                    case "back":
                        sHtml += hdftButtonLoad("back",loadPageBack(),oButtons["labeltext"],oButtons["href"]);
                        break;
                    // Used on the Postion Details page
                    case "cost":
                    case "subsidiary":
                        if ((bDrillMode) && (bManMode)) {
                            sHtml += hdftButtonLoad(aButtons[iIndex],oButtons["tooltip"],oButtons["labeltext"],oButtons["href"]);
                        }
                        break;
                    // IBM: Two Customised Buttons for address functions
                    case "prev_em":
                        sHtml += hdftButtonLoad("next","Previous page required","Previous");
                        break;
                    case "next_em":
                        sHtml += hdftButtonLoad("next","Next page required","Next");
                        break;
                    case "dpre":
                    case "dnex":
                    case "dprt":
                        sHtml += hdftButtonLoad(aButtons[iIndex],oButtons["tooltip"],oButtons["labeltext"],oButtons["href"]);
                        break;
                    default:
                        if (!bDisabledUpdate) sHtml += hdftButtonLoad(aButtons[iIndex],oButtons["tooltip"],oButtons["labeltext"],oButtons["href"]);
                        break;
                }
                sHtml += "<td width='10'>&nbsp;</td>";
            }
        }
    }
    // space at the end of buttons
    sHtml += "</tr></table>";
    if (!bNoDiv) sHtml += "</div>";
    return sHtml;
}

// *********************************************************************
// 010063 - Removed unnecessary table cell
function hdftButtonLists(iDivId) {
    // Get the right div Object from the correct frame
    var oDivObj = oDataPage.document.getElementById("dataDiv" + iDivId);
    // Properties (no. records, max. records, back page, which buttons) for a dataDiv
    var divRecs, divMaxRows, divBackPage, divButtons, divButtonLength;
    // Indicate whether or not to load up buttons from the array
    var bUseArray = false;
    // Set properties for a dataDiv
    if (oDivObj.records >= 0) {
        divRecs = oDivObj.records;
        aDivRecs[iDivId] = divRecs;
    } else {
        divRecs = aDivRecs[iDivId];
    }
    if (oDivObj.maxRows) {
        divMaxRows = ((iDivId + 1) * oDivObj.maxRows) - (iDivId + 1);
        aDivMaxRows[iDivId] = divMaxRows;
    } else {
        divMaxRows = aDivMaxRows[iDivId];
    }
    if (oDivObj.buttons) {
        divButtons = oDivObj.buttons;
        aDivButtons[iDivId] = divButtons;
        divButtonLength = oDivObj.buttons.length;
    } else {
        divButtons = aDivButtons[iDivId];
        divButtonLength = aDivButtons.length;
        bUseArray = true;
    }
    //Indicates if a button was produced at all
    var bNoButt = false;
    var sHtml = "<table border='0' cellpadding='0' cellspacing='0' align='right'><tr height='30'>";
    sHtml += "<td align='right'></td>";
    // Make sure the array is not null
    if (divButtons != null) {
        // Scan through button array and set the various buttons
        for (var iIndex=0; iIndex<divButtonLength; iIndex++) {
            // Check to see if this button is defined
            if (bUseArray) oButtons = eval("oDataPage.oDict['" + aDivButtons[iIndex] + "']");
            else oButtons = eval("oDataPage.oDict['" + divButtons[iIndex] + "']");
            if ((!oButtons) || (oButtons == null)) {
                // do nothing
            } else {
                var sButtons = (bUseArray)? aDivButtons[iIndex] : divButtons[iIndex];
                switch (sButtons) {
                    case null:
                    case true:
                        break;
                    case "staff":
                        if (bManMode) sHtml += hdftButtonLoad(sButtons,oButtons["tooltip"],oButtons["labeltext"],oButtons["href"]);
                        break;
                    case "back":
                        sHtml += hdftButtonLoad("back",loadPageBack(),oButtons["labeltext"],oButtons["href"]);
                        break;
                    case "curr":
                        // ZBG 9432: When both buttons don't exist prevent curr being output
                        if ((oDataPage.oDict["fhist"]) && (oDataPage.oDict["curr"]) && (bFullHist)) {
                            sHtml += hdftButtonLoad(sButtons,oButtons["tooltip"],oButtons["labeltext"],oButtons["href"]);
                        }
                        break;
                    case "fhist":
                        // ZBG 9432: When both buttons don't exist prevent fhist being output
                        if ((oDataPage.oDict["fhist"]) && (oDataPage.oDict["curr"]) && (!bFullHist)) {
                            sHtml += hdftButtonLoad(sButtons,oButtons["tooltip"],oButtons["labeltext"],oButtons["href"]);
                        }
                        break;
                    case "sysvw":
                        if (!bKioskFav) sHtml += hdftButtonLoad(sButtons,oButtons["tooltip"],oButtons["labeltext"],oButtons["href"]);
                        break;
                    case "manvw":
                        if (bKioskFav) sHtml += hdftButtonLoad(sButtons,oButtons["tooltip"],oButtons["labeltext"],oButtons["href"]);
                        break;
                    default:
                        if (!bDisabledUpdate) sHtml += hdftButtonLoad(sButtons,oButtons["tooltip"],oButtons["labeltext"],oButtons["href"]);
                        break;
                }
                sHtml += "<td width='10'>&nbsp;</td>";
            }
        }
    }
    // This set of buttons always appears on lists without being defined
    // As long as the list is not empty otherwise skip this process
    //
    // ZBG #7518: Add the ability to turn off top, next & previous buttons.
    // This is done by setting the records object to false in the list page.
    // DFR20603010: Don't output these buttons for utilities pages.
    if ((!bListEmpty) && (oDivObj.records) && (loadPageType(sDataPage) != "U")) {
        var sTemp = "";
        // Top Button
        if ((sDataPage.indexOf("detsel") != -1) || (sDataPage.indexOf("wfelst") != -1) || (sDataPage.indexOf("pdtlst") != -1) || (iDivId > 1)) {
            sTemp = "Top of " + oDataPage.oMenu["title"];
            sHtml += hdftButtonLoad("top", sTemp, "Top");
            sHtml += "<td width='10'>&nbsp;</td>";
        }
        // Prev Page Button
        if (iDivId != 0) {
            sTemp = "Previous page of " + oDataPage.oMenu["title"];
            sHtml += hdftButtonLoad("prev", sTemp, "Previous");
            sHtml += "<td width='10'>&nbsp;</td>";
        }
        // Next Page Button
        if (divRecs >= divMaxRows) {
            sTemp = "Next page of " + oDataPage.oMenu["title"];
            sHtml += hdftButtonLoad("next", sTemp, "Next");
            sHtml += "<td width='10'>&nbsp;</td>";
        }
    }
    // End of buttons
    sHtml += "</tr></table>";
    return sHtml;
}

// *********************************************************************
// Writes HTML for buttons on all Pages.
// 011044 Added "U" to the case statement and changed Generator to 
// output only the buttons on the list page for buttons
function hdftButtonCreate(oButtons, bNoDiv) {
    var sHtml = "";
    // Decide which sort of page this is
    var sType = loadPageType(sDataPage);
    switch (sType) {
        case "L":
        case "S":
        case "T":
        case "U":
            sHtml = hdftButtonLists(oButtons);
            break;
        default:
            sHtml = hdftButtonDetail(oButtons, bNoDiv);
            break;
    }
    // Debug Window
    if (gDHTMLDebug) loadDebugPage("hdftButtonCreate:\n" + sHtml + "\n");
    return sHtml;
}

// *********************************************************************
// 009387 - Remove special footer text from seusrdet
// 010063 - Set footDiv Top and Height according to page type
// 014482 - Allow Background Banner Image in Footer
// Writes HTML for footer on all Pages.
function hdftFooterCreate() {
    var iTop = (loadPageType(sDataPage) == "D") ? 5 : 20;
    var sHtml = "<div id='footDiv' style='position:relative;left:10px;top:" + iTop + "px;height:35px;margin-bottom:" + iTop + "px;'>";
    sHtml += "<hr noshade size='1' style='margin:2px;'>";
    sHtml += "<span id='messageBox' class='Display' style='margin-top:2px;margin-bottom:2px;'></span>";
    sHtml += "</div>";
    // Output a banner at the foot of the page
    if ((bBannerBGFooter) && (sType != "S") && (sType != "V")) {
        sHtml += "<div id='footImgDiv' style='position:relative;'>";
        sHtml += "<img src='" + loadPageResource("logo") + sBannerBG + "'>";
        sHtml += "</div>";
    }
    // Debug Window
    if (gDHTMLDebug) loadDebugPage("hdftFooterCreate:\n" + sHtml + "\n");
    return sHtml;
}

// *********************************************************************
// 010064 - Check to see if the onchange event needs to be set
function hdftCheckModifyAlert() {
    if ((bModifyAlert) && (oDataPage.document.getElementById("updat"))) {
        hdftSetOnChange();
    }
    return;
}

// *********************************************************************
// 010064 - Collects all of the input and select html elements and sets
// an onchage event that will control the bModified flag.
function hdftSetOnChange() {
    var aInput = oDataPage.document.getElementsByTagName("input");
    for (var i=0; i < aInput.length; i++) {
        // 13169 - stop the popup message, when no change occurs.
        if (aInput[i].type == "checkbox") aInput[i].onclick = function() {oGlob.bModified = true;}
        else aInput[i].onchange = function() {oGlob.bModified = true;}
    }
    aInput = oDataPage.document.getElementsByTagName("select");
    for (var i=0; i < aInput.length; i++) aInput[i].onchange = function() {oGlob.bModified = true;}
    aInput = oDataPage.document.getElementsByTagName("textarea");
    for (var i=0; i < aInput.length; i++) aInput[i].onchange = function() {oGlob.bModified = true;}
    return;
}

// *********************************************************************
// Writes HTML for Powered By.
// 011967 - Add i_powered support
function hdftPoweredByCreate(sPoweredBy) {
    var sHtml = "";
    var bFullVersion = true;
    if (oDataPage.oDict["i_copyright"]) {
        bFullVersion = (oDataPage.oDict["i_copyright"]["appendix"] && oDataPage.oDict["i_copyright"]["appendix"][0]);
    }
    if (bFullVersion) {
        sHtml += "<tr><td colspan='2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>";
        sHtml += "<td style='color:" + hPrompt + ";' align='right' valign='top'>";
        sHtml += (sPoweredBy) ? sPoweredBy : "Powered by:";
        sHtml += "</td>";
        sHtml += "<td colspan='2'><img src='" + loadPageResource("logo", true) + "chris21.png' width='160' height='160'></td>";
        sHtml += "</tr><tr><td colspan='5' height='15'>&nbsp;</td></tr>";
    }
    // Debug Window
    if (gDHTMLDebug) loadDebugPage("hdftPoweredByCreate:\n" + sHtml + "\n");
    return sHtml;
}

// *********************************************************************
// Writes HTML for copyright.
function hdftCopyrightCreate() {
    var sHtml = "<table border='0' width='100%' cellspacing='0' cellpadding='0'><tr><td rowspan='5' width='10'>&nbsp;</td></tr>";
    var sVersion = "Version " + sKskVers + ((sLibraryVersion) ? sLibraryVersion : "");
    var bFullVersion = true;
    var sAlign = "left";
    if (oDataPage.oDict["i_copyright"]) {
        bFullVersion = (oDataPage.oDict["i_copyright"]["appendix"] && oDataPage.oDict["i_copyright"]["appendix"][0]);
        sAlign = oDataPage.oDict["i_copyright"]["align"];
    }
    if (bFullVersion) {
        sHtml += "<tr><td align='" + sAlign + "'>" + sFtrCopy + "</td></tr>";
    }
    sHtml += "<tr><td align='" + sAlign + "'>" + sVersion + " - " + loadCommunicationType() + "</td></tr>";
    sHtml += "</table>";
    // Debug Window
    if (gDHTMLDebug) loadDebugPage("hdftCopyrightCreate:\n" + sHtml + "\n");
    return sHtml;
}

// *********************************************************************
