//--********************************************************************-->
//--                                                                    -->
//--   Frontier Software Pty Ltd                                        -->
//--                                                                    -->
//--   File Name     : ftrload.js                                       -->
//--                                                                    -->
//--   History       :                                                  -->
//--   005876 - 02.07.00 - JavaScript Rewrite.                          -->
//--   008552 - 24.04.03 - Send Planner to Staff Select.                -->
//--   008830 - 29.06.03 - Fix the Page-Location routine.               -->
//--   008834 - 30.06.03 - Fix the Page-Location routine properly.      -->
//--   008846 - 04.07.03 - Increase the standard length from 150 to 170 -->
//--   007634 - 02.07.03 - Clerical Self-Service.                       -->
//--   008690 - 11.08.03 - Filter Group                                 -->
//--   008972 - 03.09.03 - Enabled the use of page comments on lst pages-->
//--   008676 - 24.09.03 - aImageArray stores all pre-loaded images.    -->
//--   009093 - 07.10.03 - New function (loadHandleKey()) to Disable any-->
//--                       action onclick of the enter key.             -->
//--   009035 - 09.09.03 - Override default List Heading colours        -->
//--   008997 - 30.09.03 - Cost Centre filter added.                    -->
//--   007335 - 12.11.03 - Tree Structure Staff List changes.           -->
//--   008983 - 28.10.03 - loadGlobals() altered for LDAP               -->
//--                       Authentication.                              -->
//--   008858 - 15.12.03 - Button Disable moved to ftrload              -->
//--   008346 - 08.01.04 - Drill down to mrexadet for EXP               -->
//--   009372 - 08.01.04 - Reset sSelectKey when entering a list or     -->
//--                       select page.                                 -->
//--   008366 - 16.01.04 - Functions for Notes facility added           -->
//--   009393 - 02.02.04 - Increased all cells in length                -->
//--   009403 - 11.02.04 - Functionality for Utility pages included     -->
//--   009345 - 01.03.04 - Staff Photos                                 -->
//--   009091 - 04.03.04 - List rows can be links                       -->
//--   009286 - 02.04.04 - Introduced rvw link type                     -->
//--   009445 - 06.02.04 - Tree Structure Staff List moved.             -->
//--   009583 - 03.05.04 - Logic to find the next review page           -->  
//--   009442 - 23.03.04 - Return to last staff list page               -->
//--   009534 - 06.04.04 - Switch between reports from the file         -->
//--                       repository and reports                       -->      
//--   009750 - 09.06.04 - Correct next and previous page               -->
//--   009743 - 18.06.04 - Store onclick events                         -->
//--   009790 - 25.06.04 - Allow for correct page message on secfgerr   -->
//--   009618 - 28.07.04 - Swap heading colours                         -->
//--   007259 - 28.07.04 - Introducing the ToolBar Window               -->
//--   009642 - 30.08.04 - Error window redesigned                      -->
//--   010105 - 02.09.04 - Corrected new password update of variable    -->
//--   009941 - 06.09.04 - Fetch the web reports setting                -->
//--   010064 - 15.10.04 - Confirmation Prompt On Form Change           -->
//--   010217 - 03.11.04 - Global variables set from PDT                -->
//--   010170 - 15.11.04 - Global variables set from SSA                -->
//--   010202 - 12.11.04 - Detemine manager based of REL                -->
//--   010327 - 01.12.04 - Staff Functions available within Clerical.   -->
//--   010063 - 17.12.04 - Opera (10062) & Mozilla (10063) supported    -->
//--   010208 - 07.12.04 - Time booking applications.                   -->
//--   007775 - 06.12.04 - Search by Pay Period                         -->
//--   010424 - 19.01.05 - Staff number removed from Notes              -->
//--   010411 - 24.02.05 - System Error Page revamped.                  -->
//--   010408 - 01.03.05 - Add new starters                             -->
//--   010177 - 27.03.05 - Set bDrillMode to true for URL link.         -->
//--   008834 - 22.03.05 - Force a refresh of the page after check.     -->
//--   010721 - 21.04.05 - Introduced New Display Only Processing       -->
//--   010119 - 24.03.05 - Lookup image conforms to C21                 -->
//--   010791 - 16.05.05 - Loading the error page corrected.            -->
//--   010698 - 01.06.05 - Layout Enhancements                          -->
//--   010947 - 12.07.05 - Notes Facility no longer adds extra lines    -->
//--   010982 - 26.07.05 - Secretary Access.                            -->
//--   010537 - 02.08.05 - Allow the height and width of the view       -->
//--                       window to be changed.                        -->
//--   011116 - 06.09.05 - Corrected banner colour usage                -->
//--   010391 - 15.09.05 - Executive Reporting Merged                   -->
//--   011171 - 05.10.05 - Corrected back button on workflow pages      -->
//--   011225 - 25.10.05 - Correctly set the sHold variables            -->
//--   010177 - 05.04.05 - Set iWfcStage from URL link                  -->
//--   011320 - 22.11.05 - Filter Group Logic Corrected                 -->
//--   011597 - 22.02.06 - Frontline Kiosk Changes                      -->
//--   011382 - 16.02.06 - Global variables set from ADR                -->
//--   011674 - 22.03.06 - Global variables set from PYD                -->
//--   011691 - 22.03.06 - Approving Manager select corrected           -->
//--   011560 - 22.02.06 - All dates in CCYY-MM-DD format               -->
//--   011389 - 28.03.06 - Correct the Draft TR Election display.       -->
//--   011498 - 27.03.06 - Carriage returns converted to \n             -->
//--   011592 - 17.03.06 - Prompt and News fields Expanded.             -->
//--   011687 - 20.03.06 - Staff tools fixed                            -->
//--   011730 - 24.04.06 - Load Applicant Number if Vacancy exists      -->
//--   011899 - 17.05.06 - Notes Corrected for multiple codes           -->
//--   011885 - 29.05.06 - Introduce themes to the banners and buttons  -->
//--   011927 - 29.05.06 - Banner page displays correctly               -->
//--   013120 - 22.08.06 - Minor fixes                                  -->
//--   013315 - 10.11.06 - Correct the standard button function         -->
//--   011154 - 30.11.06 - Enhance page title function                  -->
//--   013577 - 16.01.07 - Add Country code                             -->
//--   013619 - 24.01.07 - Set Type 16 (Date) to be 75 pixels in length -->
//--   011875 - 19.02.07 - Staff Search Enhanced based on Relationship. --> 
//--   013704 - 23.02.07 - Make TXA code available to SPI               -->
//--   013668 - 02.03.07 - All times in hh:mm format                    -->
//--   011907 - 17.01.07 - Single Sign-On                               -->
//--   013868 - 27.04.07 - Timesheet expanded to 40 codes               -->
//--   013898 - 09.05.07 - Remove Server Version                        -->
//--   013901 - 10.05.07 - Load Page Current function created           -->
//--   013946 - 22.05.07 - Various Enhancements                         -->
//--   013976 - 04.06.07 - Correcting sheet when appendix file removed  -->
//--   013903 - 12.06.07 - Increase frame size for WGO                  -->
//--   013992 - 12.06.07 - Migration of STG Timesheets to c21           -->
//--   013993 - 18.06.07 - Supports Safari Version 3                    -->
//--   014026 - 22.06.07 - Staff Explorer corrected                     -->
//--   014434 - 23.10.07 - Layout & Colour Enhancements                 -->
//--   014482 - 06.11.07 - Allow Background Banner Image in Footer      -->
//--   014171 - 06.08.07 - Workflow Forms Streamlined                   -->
//--   014439 - 18.03.08 - Warning of memo field size                   -->
//--********************************************************************-->

// *********************************************************************
// CLIENT SPECIFIC GLOBAL VARIABLES
// *********************************************************************

// *********************************************************************
var sKskTitle = "";

// Write the correct title
switch (sKskType) {
    // HR21 Guide ******************************************************
    case "ZKK":
        sKskTitle = "HR21 Installation Guide";
        break;
    // ReadMe System ***************************************************
    case "ZRM":
        sKskTitle = "ReadMe";
        break;
    // Default HR21 Systems ********************************************
    default:
        sKskTitle = sCompanyName;
        break;
}
document.writeln("<title>" + sKskTitle + "</title>");

// *********************************************************************
// HR21 LOAD VARIABLES
// *********************************************************************

// *********************************************************************
// Global Variable associated with this set of function calls
var oOptionIndex = new Array();
var oOptionIndex2 = new Array();
var aOptions = new Array();
var iDrop = 0;

// *********************************************************************
// 008676 - Global load of commonly used HR21 images, plus the buttons 
//          if required.
var aImageArray = new Array();
if (!bButtonHtml) {
    var aImages = new Array("up","down","disabled");
    for (var imageName in aImages) {
        aImageArray[aImages[imageName]] = new Image();  
        aImageArray[aImages[imageName]].src = "images/themes/" + sButtonHtml + "/" + aImages[imageName] + ".png";
    }
}

// *********************************************************************
// Sets the attributes of all pop up windows
var sDefaultWindow = "dependent=yes,titlebar=yes,alwaysraised=yes";
var sNewWindow = sDefaultWindow + ",scrollbars=yes,resizable=yes";
sNewWindow += ",left=" + ((iWindowLeft) ? iWindowLeft : 100);
sNewWindow += ",screenX=" + ((iWindowLeft) ? iWindowLeft : 100);
sNewWindow += ",top=" + ((iWindowTop) ? iWindowTop : 100);
sNewWindow += ",screenY=" + ((iWindowTop) ? iWindowTop : 100);
sNewWindow += ",menubar=" + ((bMenuBar) ? "yes" : "no");
sNewWindow += ",toolbar=" + ((bToolBar) ? "yes" : "no");
sNewWindow += ",status=" + ((bStatusBar) ? "yes" : "no");
sNewWindow += ",fullscreen=" + ((bMaximised) ? "yes" : "no");
// 010537 - The width and height must reside at the end at all times,
// so that the loadWindowResize method below, can find and change the 
// settings, if redefined for the page in the configuration file.
sNewWindow += ",width=" + ((iWindowWidth) ? iWindowWidth : 600);
sNewWindow += ",height=" + ((iWindowHeight) ? iWindowHeight : 480);

// *********************************************************************
function loadWindowResize(sToPage) {
    var oTemp = new Object();
    var sTemp = sNewWindow;
    // Set dictionary entry from configuration
    if (sToPage.indexOf("sel") != -1) oTemp = aDictList[sToPage];
    else oTemp = aDictDetail[sToPage];
    // Easy now to configure the size whether it's a select or view page
    if ((oTemp) && ((oTemp["i_width"]) || (oTemp["i_height"]))) {
        var iTemp = sNewWindow.indexOf("width");
        sTemp = sNewWindow.substring(0,iTemp-1);
        sTemp += ",width=";
        if ((oTemp["i_width"]) && (oTemp["i_width"]["label"])) sTemp += oTemp["i_width"].label;
        else sTemp += ((iWindowWidth) ? iWindowWidth : 600);
        sTemp += ",height=";
        if ((oTemp["i_height"]) && (oTemp["i_height"]["label"])) sTemp += oTemp["i_height"].label;
        else sTemp += ((iWindowHeight) ? iWindowHeight : 480);
    }
    return sTemp;
}

// *********************************************************************
// HR21 GLOBAL BUSINESS RULES ENGINE VARIABLES
// *********************************************************************

//after logon this contains the User's employee number
var sUser = "";

//8983 - after logon this contains the User's logon name
var sLoginName = "";

//after logon this contains the user password
var sPswd = "";

//after logon this contains the company site
var sSiteName = "";

//after logon this contains the user profile
var sProfile = "";

//after logon this contains the user Surname and Initials
var sMenuSurInit = "";

// After logon this contains the staff members country code
var sEmpCountry = "ZZ";

// Display Level
var iDisplayLevel = "";
var sDisplayLevel = "";

// Cost Centre Level
var iLevelToCostFor = "";
var sLevelToCostFor = "";
var sLevelToCostForCode = "";

// Filter Group
var sFilterGroup = "";

// Relationship Level found
var bRelLevelFound;

// 8997 - Filter Cost Centre
var sCostCentre = "";

// 010170 - Holds pdtorg4cd values
var sDepartment = "";

// Seqno and number of entries for Review pages
var iEvalSeqNo = 1;
// Drill mode for Review pages
var bEvalDrill = false;
// Evaluation Type
var cEvalType = false;
// Evaluation Date
var sEvalDate = new String();
// Evaluation Staff Number
var sEvalDetNumber;
// Evaluation Link Code
var sEvalLinkCode = "";

// Define variable for sequencing address page
var iAddresses = 0;
var aAddresses = false;
var bAddresses = false;
if ((aDictDetail["edadrdet"]) && (aDictDetail["edadrdet"]["i_addresses"]) && (aDictDetail["edadrdet"]["i_addresses"]["appendix"])) {
    aAddresses = aDictDetail["edadrdet"]["i_addresses"]["appendix"];
}

// 011674 - Holds pydtype value
var sPydType = "STD";
var bPydType = false;
if (aDictDetail["epktstsa"]) {
    bPydType = true;
}

// The version of the BRE currently connected to
var sBreVers = "";

// 9642 - use the keyword "ignorewarning" when resending
// a GTR after displaying warning message
var bIgnoreWarnings = false;

// *********************************************************************
// HR21 GLOBAL SYSTEM VARIABLES
// *********************************************************************

//Length of page location to be send in a GTR
var pageLocLength = 20;

// The token is used to identify the user by the backend
var sToken = "";

// The location of the current page
var sDataPage = "";
var oDataPage = null;

// The original locations before the time out by the backend
var sMenuLocn = "";
var sDataLocn = "";

// The location of the error page
var sErrorPage = "secfgerr";

// The location of the page that was to be loaded
var sLoadPage = "";

// Allows Paging to Next and Previous in a Details page that relies on a 
// Sequence number in the key
var iSeqPage = 0;

// Flag for using Html or Theme Banners
var bBannerHtml = false;
if (sBannerHtml == "true") bBannerHtml = true;

// Flag for using Html or Theme Buttons
var bButtonHtml = false;
if (sButtonHtml == "true") bButtonHtml = true;

// Economise on hard-coded frames
switch (sKskType) {
    // Set higher to cope with Staff Select requirements
    case "MEW":
        var iMaxGTRSends = 50;
        break;
    // Set high to cope with large number of GTR's being sent
    case "SPI":
    case "TXA":
    case "WGO":
    case "K77":
        var iMaxGTRSends = 250;
        break;
    // Seems Netscape 6 has an upper limit of 25
    default:
        var iMaxGTRSends = 22;
        break;
}

//is it in debug mode
var gDebug = false;

//is it in dynamic HTML debug mode
var gDHTMLDebug = false;

//Storage variable for any non-real-list drill-downs
var aDrillDownData = new Array();

// 009743 - Storage array for onclick events
var aOnClickEvents = new Array();

// 008366 - Storage object for notes data
var oNoteData = new Object();

//Only create the MSXML DOM if viewing XML reports
var bViewingXML = false;

// 009345 - store references to files (eg images and xml files) that have been written 
// to the system temp directory
var aFilesWritten = new Array();

// Create new loadBrowserSniffer object (holds browser version)
var is = new loadBrowserSniffer();

// 007259 - the zoom setting for the oDataPage
var iZoom = new Number(1);

// 010064 - indicates if a form value has been changed
var bModified = false;

// Location of HR21, watching out for a search string occurring
var aHR21Location = self.location.href.split("?");
// Check the search strings
if (aHR21Location[1]) {
    var iHR21Location = aHR21Location[0].lastIndexOf("/");
    var sHR21Location = aHR21Location[0].substr(0,iHR21Location+1);
} else {
    var iHR21Location = self.location.href.lastIndexOf("/");
    var sHR21Location = self.location.href.substr(0,iHR21Location+1);
}

// 010391 - control the posting of data to seercdet.asp
var aReport = new Array();
var aOrgCodes = new Array();
var aClickEvents = new Array();

// 011875 - Storage the staff list.
var sRelation = "";
var sRelationship = "";

// 11907 - control the sending of the logon GTR when the user's token has expired
var bSSOLogonSent = false;

// *********************************************************************
// HR21 GLOBAL SYSTEM FUNCTIONS
// *********************************************************************

// *********************************************************************
// checks browser type & version
// 010063 - updated sniffer introduced 
function loadBrowserSniffer() {
    // convert all characters to lowercase to simplify testing
    var agt = navigator.userAgent.toLowerCase();
    var appVer = navigator.appVersion.toLowerCase();

    // *** BROWSER VERSION ***
    var is_minor = parseFloat(appVer);
    var is_major = parseInt(is_minor);
    this.minor = is_minor;
    this.major = is_major;
    this.browser = "";

    var is_opera = (agt.indexOf("opera") != -1);
    var is_opera2 = (agt.indexOf("opera 2") != -1 || agt.indexOf("opera/2") != -1);
    var is_opera3 = (agt.indexOf("opera 3") != -1 || agt.indexOf("opera/3") != -1);
    var is_opera4 = (agt.indexOf("opera 4") != -1 || agt.indexOf("opera/4") != -1);
    var is_opera5 = (agt.indexOf("opera 5") != -1 || agt.indexOf("opera/5") != -1);
    var is_opera6 = (agt.indexOf("opera 6") != -1 || agt.indexOf("opera/6") != -1); 
    var is_opera7 = (agt.indexOf("opera 7") != -1 || agt.indexOf("opera/7") != -1); 
    var is_opera5up = (is_opera && !is_opera2 && !is_opera3 && !is_opera4);
    var is_opera6up = (is_opera && !is_opera2 && !is_opera3 && !is_opera4 && !is_opera5); 
    var is_opera7up = (is_opera && !is_opera2 && !is_opera3 && !is_opera4 && !is_opera5 && !is_opera6); 

    // 010063 - Set the opera properties if required
    this.opera = is_opera;
    if (this.opera) {
        this.opera7up = is_opera7up;
        this.browser = "opera";
    }
    var iePos  = appVer.indexOf('msie');
    if (iePos !=-1) {
       is_minor = parseFloat(appVer.substring(iePos+5,appVer.indexOf(';',iePos))); 
       is_major = parseInt(is_minor);
    }                    
    var is_konq = false;
    var kqPos   = agt.indexOf('konqueror');
    if (kqPos !=-1) {                 
       is_konq  = true;
       is_minor = parseFloat(agt.substring(kqPos+10,agt.indexOf(';',kqPos)));
       is_major = parseInt(is_minor);
    }                                 
    var is_safari = (agt.indexOf('safari')!=-1 && agt.indexOf('3') != -1)?true:false;
    var is_khtml  = (is_safari || is_konq);
    var is_gecko = ((!is_khtml)&&(navigator.product)&&(navigator.product.toLowerCase()=="gecko"))?true:false;
    var is_gver  = 0;
    if (is_gecko) is_gver=navigator.productSub;
    var is_moz   = ((agt.indexOf('mozilla/5')!=-1) && (agt.indexOf('spoofer')==-1) &&
                    (agt.indexOf('compatible')==-1) && (agt.indexOf('opera')==-1)  &&
                    (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1)     &&
                    (is_gecko) && 
                    ((navigator.vendor=="")||(navigator.vendor=="Mozilla")||(navigator.vendor=="Debian")));
    var is_fb = ((agt.indexOf('mozilla/5')!=-1) && (agt.indexOf('spoofer')==-1) &&
                 (agt.indexOf('compatible')==-1) && (agt.indexOf('opera')==-1)  &&
                 (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1)     &&
                 (is_gecko) && (navigator.vendor=="Firebird"));
    var is_fx = ((agt.indexOf('mozilla/5')!=-1) && (agt.indexOf('spoofer')==-1) &&
                 (agt.indexOf('compatible')==-1) && (agt.indexOf('opera')==-1)  &&
                 (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1)     &&
                 (is_gecko) && (navigator.vendor=="Firefox"));
    if ((is_moz)||(is_fb)||(is_fx)) {  
        var is_moz_ver = (navigator.vendorSub)?navigator.vendorSub:0;
        if(!(is_moz_ver)) {
            is_moz_ver = agt.indexOf('rv:');
            is_moz_ver = agt.substring(is_moz_ver+3);
            is_paren   = is_moz_ver.indexOf(')');
            is_moz_ver = is_moz_ver.substring(0,is_paren);
        }
        is_minor = is_moz_ver;
        is_major = parseInt(is_moz_ver);
    }
    var is_fb_ver = is_moz_ver;
    var is_fx_ver = is_moz_ver;

    // 010063 - Set the mozilla properties if required
    this.moz = is_moz;
    if (this.moz) {
        this.browser = "mozilla";
        this.version = is_moz_ver;
        var aTemp = this.version.split(".");
        this.moz1_7up = false;
        if ((aTemp.length) && (aTemp.length >= 2)) this.moz1_7up = (aTemp[1] >= 7);
    }

    var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1)
                && (!is_khtml) && (!(is_moz)));
    if ((navigator.vendor) &&
        ((navigator.vendor=="Netscape6")||(navigator.vendor=="Netscape")) && (is_nav)) {
        is_major = parseInt(navigator.vendorSub);
        // here we need is_minor as a valid float for testing. We'll
        // revert to the actual content before printing the result. 
        is_minor = parseFloat(navigator.vendorSub);
    }

    var is_nav2 = (is_nav && (is_major == 2));
    var is_nav3 = (is_nav && (is_major == 3));
    var is_nav4 = (is_nav && (is_major == 4));
    var is_nav4up = (is_nav && is_minor >= 4); 
    var is_navonly = (is_nav && ((agt.indexOf(";nav") != -1) || (agt.indexOf("; nav") != -1)));
    var is_nav6   = (is_nav && is_major==6);    
    var is_nav6up = (is_nav && is_minor >= 6); 
    var is_nav5   = (is_nav && is_major == 5 && !is_nav6); 
    var is_nav5up = (is_nav && is_minor >= 5);
    var is_nav7   = (is_nav && is_major == 7);
    var is_nav7up = (is_nav && is_minor >= 7);
    
    // 010063 - Set the netscape properties if required
    // In HR21 firefox and netscape are treated as mozilla, hence this.moz = true
    this.nav = is_nav;
    if (this.nav) {
        if (is_fx) {
            this.browser = "firefox";
            this.version = is_moz_ver;
            this.nav = false;
            this.moz = true;
        } else {
            this.browser = "netscape";
            this.is_nav7up = is_nav7up;
            this.moz = true;
        }
    }

    var is_ie   = ((iePos!=-1) && (!is_opera) && (!is_khtml));
    var is_ie3  = (is_ie && (is_major < 4));
    var is_ie4   = (is_ie && is_major == 4);
    var is_ie4up = (is_ie && is_minor >= 4);
    var is_ie5   = (is_ie && is_major == 5);
    var is_ie5up = (is_ie && is_minor >= 5);
    var is_ie5_5  = (is_ie && (agt.indexOf("msie 5.5") !=-1)); 
    var is_ie5_5up =(is_ie && is_minor >= 5.5);                
    var is_ie6   = (is_ie && is_major == 6);
    var is_ie6up = (is_ie && is_minor >= 6);

    // 013993 - Set the Safari explorer properties if required.
    // Safari for windows uses the Mozilla engine, so to save
    // on conditionals, we'll set this.moz to true.
    if (is_safari)
    {
        this.browser = "safari";
        this.safari3up = is_safari;
        this.moz = true;
    }
    // 010063 - Set the explorer properties if required
    // DFR 100057: Special handling added for IE6 click event
    this.ie = is_ie;
    if (this.ie) {
        this.browser = "explorer";
        this.ie5up = is_ie5up;
        this.ie5_5up = is_ie5_5up;
        this.ie6 = is_ie6;
        this.ie6up = is_ie6up;
    }
    return;
}

// *********************************************************************
// 010063 - HR21 supports:
//     Internet Explorer 5.0 and upwards
//     Mozilla 1.7 and upwards
//     Mozilla FireFox all versions
//     Netscape 7.1 and upwards
//     Opera 7.5 and upwards
// If these browsers are detected, but with an insufficient version, then a message is displayed
function loadBrowserCheck() {
    var sHtml = false;
    // BRA Communication only within Microsoft Internet Explorer
    // otherwise, notify if browser is incompatible.
    if ((navigator.appName != "Microsoft Internet Explorer") && (sComType == "BRA")) {
        sHtml = "<title>This browser is not supported for BRA Communication</title>";
        sHtml += "<body><p><b><center>This browser is not supported for BRA Communication.";
        sHtml += "<br><br>You must be running Microsoft Internet Explorer 5.0 or greater.<center><b><br><hr>";
    } else {
        var sBrowser = is.browser;
        var sReqdBrowser = "";
        switch (sBrowser) {
            case "explorer":
                if (!is.ie5up) sReqdBrowser = "Internet Explorer 5.0"
                break;
            case "firefox":
                // Firefox 1.0 is the first version, so HR21 will support all versions
                break;
            case "mozilla":
                if (!is.moz1_7up) sReqdBrowser = "Mozilla 1.7";
                break;
            case "netscape":
                if (!is.is_nav7up) sReqdBrowser = "Netscape 7.1";
                break;
            case "opera":
                if (!is.opera7up) sReqdBrowser = "Opera 7.5";
                break;
            case "safari":
                if (!is.safari3up) sReqdBrowser = "Safari 3.0";
                break;
            default:
                break;
        }
        if (sReqdBrowser) {
            sHtml = "<title>This browser is not supported</title>";
            sHtml += "<body><p><b><center>This browser is not supported.";
            sHtml += "<br><br>You must be running " + sReqdBrowser + " or greater.<center><b><br><hr>";
        }
    }
    // Write the docuemnt to the window if required
    if (sHtml) document.write(sHtml);
    return;
}

// *********************************************************************
// Returns all hidden frames to ready state.
function loadFramesCreate() {
    for (var i=2; i<frames.length; i++) {
        if (frames[i].document.forms.length < 2) {
            switch (sComType) {
                case "IIS":
                    frames[i].location = "segtrsnd.asp";
                    break;
                case "FCG":
                    frames[i].location = "segtrsnd.htm";
                    break;
            }
        }
    }
    return;
}

// *********************************************************************
// HR21 GLOBAL VARIABLES
// *********************************************************************

// Points back to this page and it's variables and functions
var oGlob = window;

// Has anyone logged on successfully yet.
var bLoggedOn = false;
   
// Staff Access only as opposed to Manager/Trainer/Administrator Access.
var bStaffOn = true;

// Web Reports Access.
var bWebReportsOn = false;

// Staff or Manager/Trainer/Administrator Access.
var bManMode = false;

// Menu Profile Access.
var sMenuProfile = false;

// 010408 - New Starters
var bNewStaff = false;
var sNewStaffNo = "";
var sNewStaffPosStart = "";
var bNewStaffAddress = false;
var bNewStaffOtherDet = false;
var sNewStaffAddressType = "";

//date variables
var sStart = "";
var dToday = new Date();
var sYear = dToday.getFullYear();
var sToday = dToday.getDate() + "/" + (dToday.getMonth() + 1) + "/" + dToday.getFullYear();
if (sZone == "USA") sToday = (dToday.getMonth() + 1) + "/" +  dToday.getDate() +  "/" + dToday.getFullYear();

//reusable copyright message to be used on all pages
var sFtrCopy = "&copy; 1983-" + sYear + " <a href='http://www.frontiersoftware.com/' target='_blank' title='Visit Frontier Software on the Web'>Frontier Software Pty Ltd</a> All Rights Reserved.";

// The " character used in the GTRs. [chr(34)]
var cDelimiter = unescape("%22");
var sDelimiter = "%22";

// The character used in the GTRs to separate code from translation. [chr(240)]
var cSeparator = unescape("%F0");
var sSeparator = "%F0";

// The character used in the GTRs when a " character is embedded. [chr(09)]
var cQuote = unescape("%09");
var sQuote = "%09";

// Get currently selected language
var sLanguage = navigator.language;

// Define the variables for the Back Page, Staff (List) Page and 
// Page Not Found (404)
var sBackPage = false;
var sStaffPage = false;
var sPageNotFound = false;

// *********************************************************************
// HR21 GLOBAL FUNCTIONS
// *********************************************************************

// *********************************************************************
function loadCommunicationType() {
    switch (sComType) {
        case "BRA":
            return FTRBra.Version;
        case "IIS":
            return "IIS Communication";
        case "FCG":
            return "FCG Communication";
        case "DEM":
            return "Demo - No Communication Involved";
        case "REL":
            return "<a href=\"../ReadMe/readme.htm?setup\" target=\"_blank\" name=\"Set Up Document\" title=\"Review Set Up documentation\">New Release - Please Set Up Communication</a>";
        default:
            return "<font style='font-weight:bold;color:red'>Unknown Communication Type</font>";
    }
}

// *********************************************************************
// Version Control notification message
function loadVersionCheck(sBreVersion, sKskReqd) {
    sBreVers = sBreVersion;
    var sMsgVers;
    // Version control logic
    if (sBreVers != "") {
        if (sBreVers < sBreReqd) {
            sMsgVers = "Warning: A problem has been detected with Business Rules Engine version " + sBreVers;
            sMsgVers += ".\n\nYou may experience problems with some aspects of HR21.\nThis is because the Business Rules Engine is incompatible with this HR21 version.\n\n";
            sMsgVers += "Compatible versions are;\n\nCurrent HR21 version:\t\t" + sKskVers + "\nRequired Business Rules Engine:\t";
            sMsgVers += (sBreReqd + " or above");
        } else if (sKskVers < sKskReqd) {
            sMsgVers = "Warning: A problem has been detected with HR21 version " + sKskVers;
            sMsgVers += ".\n\nYou may experience problems with some aspects of HR21.\nThis is because HR21 is incompatible with this Business Rules Engine version.\n\n";
            sMsgVers += "Compatible versions are;\n\nCurrent Business Rules Engine:\t" + sBreVers + "\nRequired HR21 version:\t";
            sMsgVers += (sKskReqd + " or above");
        }
    }
    // If the string has been loaded then display version control message
    if (sMsgVers) {
        alert(sMsgVers);
        return true;
    } else {
        return false;
    }
}

// *********************************************************************
// Select the appropriate pages here for a specific-page login
function loadPageFirst() {
    // Search Checking
    switch (sKskType) {
        // Other Systems ***********************************************
        case "ZRM":
        case "ZDO":
            break;
        // HR21 System ************************************************
        default:
            // Do all the menu settings first
            if (bHorizMenu) horizFrame.location.replace("sehortop.htm");
            if (bVertMenu) vertFrame.location.replace("severtop.htm");
            // Check the search strings
            if (location.search) {
                var sLink = location.search.substr(1,(location.search.length-1));
                var aFile = sLink.split("@");
                var sFile = aFile[0].toString().toLowerCase()
                switch (sFile) {
                    case "kta":
                        switch (sKskType) {
                            // For TXA & SPI Only
                            case "SPI":
                            case "TXA":
                                aDrillDownData["page"] = "mrktatxa";
                                break;
                            // For STG Only
                            case "STG":
                                aDrillDownData["page"] = "mrktastg";
                                break;
                        }
                        break;
                    default:
                        aDrillDownData["page"] = "mr" + sFile + "det";
                        break;
                }
                if (aFile[1]) {
                    var aArgs = aFile[1].split("&");
                    for (var i=0; i<aArgs.length; i++) {
                        var aPair = aArgs[i].split("=");
                        if (aPair[1]) {
                            if ((i == 0) && (aPair[0] == sUser)) {
                                aDrillDownData["page"] = sCompanyPage;
                                break;
                            } else {
                                aDrillDownData[unescape(aPair[0])] = unescape(aPair[1]);
                            }
                        }
                    }
                    switch (aDrillDownData["page"].charAt(0)) {
                        case "m":
                            aDrillDownData["bLink"] = true;
                            listPageSelect(aDrillDownData["page"]);
                            break;
                        default:
                            listPageSelect(aDrillDownData["page"]);
                            break;
                    }
                } else {
                    listPageSelect(sCompanyPage);
                }
            } else {
                listPageSelect(sCompanyPage);
            }
            break;
    }
    return;
}

// *********************************************************************
function loadGlobalsReset() {
    oGlob.bLoggedOn = false;
    oGlob.sUser = "";
    oGlob.sLoginName = "";
    oGlob.sPswd = "";
    oGlob.sProfile = "";
    oGlob.sCompanyName = "";
    oGlob.sSiteName = "";
    oGlob.iDisplayLevel = "";
    oGlob.sDisplayLevel = "";
    oGlob.iLevelToCostFor = "";
    oGlob.sLevelToCostFor = "";
    oGlob.sMenuProfile = "";
    return;
}

// *********************************************************************
// 8983 - sUser is now set according to the "userid" keyword
// If LDAP is not in use, then set sUser to "user" as usual
function loadGlobals(oContainer) {
    bLoggedOn = true;
    sUser = getGTRField(oContainer,"userid");
    sLoginName = getGTRField(oContainer,"user");
    if (sUser == "") sUser = sLoginName;
    sPswd = getGTRField(oContainer,"password");
    if (oContainer["newpass"]) sPswd = getGTRField(oContainer,"newpass");
    sProfile = getGTRField(oContainer,"securityprofile");
    sSiteName = getGTRField(oContainer,"sitename");
    iDisplayLevel = getGTRField(oContainer,"displaylevel");
    sDisplayLevel = getGTRField(oContainer,"displaylevel.trn");
    iLevelToCostFor = getGTRField(oContainer,"tocostforlevel");
    sLevelToCostFor = getGTRField(oContainer,"tocostforlevel.trn");
    if ((oContainer["relationshiplevel"]) && (oContainer["relationshiplevel"] != "RL01")) {
		bRelLevelFound = true;
		sRelationship = oContainer["relationshiplevel"];
    } else bRelLevelFound = false;
    if (oContainer["filtergroup"]) sFilterGroup = getGTRField(oContainer,"filtergroup");
    else sFilterGroup = false;
    // Set the Profile
    switch (sProfile) {
        case "KIOSK":
            sMenuProfile = "ksk";
            break;
        case "KIOSKADM":
            sMenuProfile = "adm";
            break;
        case "KIOSKCLR":
            sMenuProfile = "clr";
            break;
        case "KIOSKENT":
            sMenuProfile = "ent";
            break;
        case "KIOSKPRX":
            sMenuProfile = "prx";
            break;
        case "KIOSKSEC":
            sMenuProfile = "sec";
            break;
        case "KIOSKTRN":
            sMenuProfile = "trn";
            break;
    }
    return;
}

// *********************************************************************
function loadGlobalsStaff(oContainer) {
    sEmpNo = getGTRField(oContainer,"detnumber");
    sEmpSurInit = getGTRField(oContainer,"detnumber.trn");
    // Set Manager Number and Surname values to the same as the Staff
    sManNo = sEmpNo;
    sManSurInit = sEmpSurInit;
    // Set the country of the staff member
    sEmpCountry = getGTRField(oContainer,"detcountry");
    // Set the country of the staff member in the manager role.
    sManCountry = sEmpCountry;
    // Set the menu style for displaying staff information
    var oStyle = null;
    if (bHorizMenu) {
        oStyle = aDictDetail["sehortop"];
    } else if (bVertMenu) {
        oStyle = aDictDetail["severtop"];
    }
    // Now set the menu style string
    sMenuSurInit = sManSurInit;
    if (oStyle) {
        if (oStyle["detsurinit"]) {
            sMenuSurInit = oStyle["detsurinit"]["label"] + getGTRField(oContainer,"detnumber.trn");
        } else {
            if (oStyle["detg1name1"]) {
                sMenuSurInit = oStyle["detg1name1"]["label"] + getGTRField(oContainer,"detg1name1");
            } else if (oStyle["detprefnm"]) {
                sMenuSurInit = oStyle["detprefnm"]["label"] + getGTRField(oContainer,"detprefnm");
            } else {
                sMenuSurInit = "";
            }
            if (oStyle["detsurname"]) {
                sMenuSurInit += oStyle["detsurname"]["label"] + getGTRField(oContainer,"detsurname");
            }
        }
        if (oStyle["detnumber"]) {
            sMenuSurInit += oStyle["detnumber"]["label"] + getGTRField(oContainer,"detnumber");
        }
    }
    // Load notes variables
    // 010424 - Staff number removed from Notes
    // 011498 - Carriage returns converted to \n
    sEmpTag = sEmpSurInit + " wrote:\\n";
    sManTag = sManSurInit + " wrote:\\n";
    // It's not just a member of staff then decide on a suitable default
    // staff (list) page dependant on their profile. Additionaly make
    // sure the page is on in the global menu object.
    var oTemp = menuObjectLoad("mswfelst");
    if (oTemp) {
        sStaffPage = "mswfelst";
    } else {
        oTemp = menuObjectLoad("mswfetre");
        if (oTemp) sStaffPage = "mswfetre";
    }
    // Check for other profiles
    switch (sMenuProfile) {
        case "clr":
            oTemp = menuObjectLoad("mcdetlst");
            if (oTemp) sStaffPage = "mcdetlst";
            break;
        case "ent":
            oTemp = menuObjectLoad("mdwfelst");
            if (oTemp) sStaffPage = "mdwfelst";
            break;
        // SAW: Settings for Proxy Manager
        case "prx":
            sDetProxy = getGTRField(oContainer,"detproxy");
            break;
        case "trn":
            oTemp = menuObjectLoad("mtwfelst");
            if (oTemp) sStaffPage = "mtwfelst";
            break;
    }
    return;
}

// *********************************************************************
function loadGlobalsPosition(oContainer) {
    sPosNumber = getGTRField(oContainer,"posnumber");
    sPosTitle = getGTRField(oContainer,"posnumber.trn");
    sPosStatus = getGTRField(oContainer,"posstatus");
    sPosOverTime = getGTRField(oContainer,"poso/tpay");
    return;
}

// *********************************************************************
// 010217: picks up values from PDT
function loadGlobalsPositionCodes(oContainer) {
    sDepartment = getGTRField(oContainer,"pdtorg4cd.trn");
    // Loads up the LevelToCostForCode
    sLevelToCostForCode = eval("getGTRField(oContainer,'pdtorg" + iLevelToCostFor + "cd')");
    return;
}

// *********************************************************************
// 009442: Set the default Staff (List) Page to use
function loadGlobalsRelationship() {
    // Set the Manager Functions dependant on the Profile
    switch (sMenuProfile) {
        case "ent":
            bStaffOn = true;
            sEmpNo = "";
            sEmpSurInit = "";
            break;
         default:
            bStaffOn = false;
            break;
    }
    // For the Manager Functions load up the links
    var oTemp = menuObjectLoad("setopvew");
    if (oTemp) {
        linkCreate("Staff");
        // Check for other profiles
        switch (sMenuProfile) {
            case "clr":
                linkCreate("Clerical");
                break;
            case "ent":
                linkCreate("Data");
                break;
            case "trn":
                linkCreate("Trainer");
                break;
        }
    }
    //1: Uncomment to Debug
    //alert("loadGlobalsRelationship:\n" + sStaffPage);
    return;
}

// *********************************************************************
// 011674: picks up values from PYD
function loadGlobalsPayDetails(oContainer) {
    sPydType = getGTRField(oContainer,"pydtype");
    return;
}

// *********************************************************************
// 011730: picks up values from APD
function loadGlobalsApplicant(oContainer) {
    sApdNo = getGTRField(oContainer,"apdnumber");
    return;
}

// *********************************************************************
// 010408 - Store the newly created staff details
function loadSetNewStaff(oContainer) {
    sHoldEmpNo = sEmpNo;
    sHoldEmpSurInit = sEmpSurInit;
    sNewStaffNo = sEmpNo = getGTRField(oContainer,"detnumber");
    sEmpSurInit = getGTRField(oContainer,"detsurname") + " " + getGTRField(oContainer,"detg1name1").charAt(0);
    var sTemp = getGTRField(oContainer,"detg1name2");
    if (sTemp) sEmpSurInit += " " + sTemp.charAt(0);
    return;
}

// *********************************************************************
// 010408 - Reset staff details
function loadResetNewStaff() {
    sEmpNo = "";
    sEmpSurInit = "";
    sNewStaffNo = "";
    sNewStaffPosStart = "";
    bNewStaffOtherDet = false;
    bNewStaffAddress = false;
    sNewStaffAddressType = "";
    return;
}

// *********************************************************************
// 011907 - If the user token times out during a session and SSO is set,
// then this function handles the logging of the user back into HR21.
function loadSendLogon() {
	if (!bSSOLogonSent) {
		bSSOLogonSent = true;
		var gtrHolder = new Object();
		setGTRField(gtrHolder,"cbr","logon");
		setGTRField(gtrHolder,"logonapplication","Kiosk");
		setGTRField(gtrHolder,"showorglevel","");
		setGTRField(gtrHolder,"showtranslation","S");
		setGTRField(gtrHolder,"i_sso",true);
		sendGTR(gtrHolder,"Authenticating user...");
	}
	return;
}

// *********************************************************************
// 011907 - Refresh the logon variables and then refresh the current page
function loadProcessLogon(gtrContainer) {
	loadGlobals(gtrContainer);
	if (bLoggedOn) {
	    bSSOLogonSent = false;
	    if (oDataPage.locnInitPage) oDataPage.locnInitPage();
	    else if (oDataPage.initPage) oDataPage.initPage();
	}
    return;
}

// *********************************************************************
var sEmpTag = new String();
var sManTag = new String();

// *********************************************************************
// 008366 - iWfcStage determines the sequence number of the nte record.
// The employee entry is always set to '1', so the stage 1 manager
// should be set at '2', and stage 3 set to '3', hence the increment of
// iWfcStage when not in Employee view mode.
function loadNotesStage() {
    if (oGlob.aDrillDownData["bLink"]) {
        aDrillDownData["iWfcStage"] = parseInt(oGlob.aDrillDownData["wfcstage"]) + 1;
    } else {
        if (aListContainer[iListSelected] != null && aListContainer[iListSelected]["wfcstage"] != null)
        {
            aDrillDownData["iWfcStage"] = parseInt(aListContainer[iListSelected]["wfcstage"]) + 1;
        }
    }
    return aDrillDownData["iWfcStage"];
}

// *********************************************************************
// 008366 - Saves data required for the Notes page
// Function will receive the screen mnemonic, detnumber, then any
// number of data dictionary names followed by their corresponding values.
function loadNotesData() {
    var iIndex0 = 0;
    // Set the screen type and detnumber value
    oNoteData.screen = arguments[0];
    oNoteData.detnumber = arguments[1];
    // cycle through and pickup the data dictionary name, followed by the value
    for (var iIndex1 = 2; iIndex1 < arguments.length; iIndex1 += 2) {
        var oNoteObject = new Object();
        oNoteObject.datadict = arguments[iIndex1];
        oNoteObject.value = arguments[iIndex1+1];
        oNoteData[iIndex0++] = oNoteObject;
    }
    return;
}

// *********************************************************************
// 008366 Function accepts 3 parameters - sNote,iWfcStage,iNteSeq and 
// processes each ntetext segment from the returned nte gtrs. 
// Each nte segment will be comprised of:
// detnumber + detsurinit + ' :\n' + text.  
function loadNotesPage(sNote,iWfcStage,iNteSeq) {
    // Break the note into 2 components, the name and then the text.
    var iNoteText = sNote.indexOf("wrote:");
    if (iNoteText != -1) {
        // Get the manager comments for this stage
        if (iNteSeq == iWfcStage) {
            var sNoteText = sNote.substring((iNoteText+7),sNote.length);
            oDataPage.oForm.i_notes.value = sNoteText;
        }
    } else {
        // Get the staff comments as there is no other stage
        oDataPage.oForm.i_notes.value = sNote;
    }
    return;
}

// *********************************************************************
// Works out the correct file path for the page
function loadPagePath(sToPage) {
    var sPath = sHR21Location;
    // Temporary object to find out which menu the page is in
    var oTemp = menuObjectLoad(sToPage);
    if (oTemp) {
        sPath += oTemp["ref"];
        // Load the location into the sLoadPage
        sLoadPage = dataFrame.location.href.substr(dataFrame.location.href.length-12,8);
    }
    // couldn't find the page in the configuration, throw to the error page
    else {
        oTemp = menuObjectLoad(sErrorPage);
        if (oTemp) sPath += oTemp["ref"];
    }
    //2: Uncomment to Debug
    //alert("loadPagePath:\n" + sPath);
    return sPath;
}

// *********************************************************************
// Writes the resource path
// 010408 - Ensure cPage set correctly for non-IE browsers
function loadPageResource(sType, bRootPath) {
    var sHtml, sPrefix;
    var sTempPage = loadPageCurrent();
    var cPage = sTempPage.charAt(0);
    // If root flag set then path is hardcoded
    if (bRootPath) {
        switch (sType) {
            case "button":
            case "calendar":
            case "logo":
            case "menu":
            case "misc":
                sPrefix = "images/";
                break;
            case "styles":
                sPrefix = "";
                break;
            // images/themes/
            default:
                sPrefix = "images/themes/";
                break;
        }
        switch (sKskType) {
            case "ZRM":
                sHtml = "images/";
                break;
            default:
                sHtml = sPrefix + sType + "/";
                break;
        }
    } else {
        // Test the types of resource that is required
        switch (sType) {
            case "error":
                switch (cPage) {
                    case "s":
                        sHtml = "";
                        break;
                    default:
                        sHtml = "../";
                        break;
                }
                break;
            case "styles":
                switch (sKskType) {
                    case "ZRM":
                        sHtml = "styles/";
                        break;
                    default:
                        switch (cPage) {
                            case "s":
                                sHtml = "styles/";
                                break;
                            default:
                                sHtml = "../styles/";
                                break;
                        }
                        break;
                }
                break;
            case "button":
            case "calendar":
            case "logo":
            case "menu":
            case "misc":
                switch (sKskType) {
                    case "ZRM":
                        sHtml = "images/";
                        break;
                    default:
                        switch (cPage) {
                            case "s":
                                sHtml = "images/" + sType + "/";
                                break;
                            default:
                                sHtml = "../images/" + sType + "/";
                                break;
                        }
                        break;
                }
                break;
            // images/themes/
            default:
                switch (cPage) {
                    case "s":
                        sHtml = "images/themes/" + sType + "/";
                        break;
                    default:
                        sHtml = "../images/themes/" + sType + "/";
                        break;
                }
                break;
        }
    }
    // Debug Window
    if (gDHTMLDebug) loadDebugPage("loadPageResource:\n" + sHtml + "\n");
    return sHtml;
}

// *********************************************************************
//09093 Disable any action onclick of the enter key for all textboxes
function loadHandleKey() {
    var sEvt = " onKeyPress='var charCode = (oGlob.is.moz) ? event.which : event.keyCode; if (charCode == 13) return false; else return true;' ";
    return sEvt;
}

// *********************************************************************
// 008676 - create a new globally held image
function loadPageImage(sImage) {
    aImageArray[sImage] = true;
    aImageArray[sImage + "_up"] = new Image();
    aImageArray[sImage + "_up"].src = "images/button/" + sImage + "_up.png";
    aImageArray[sImage + "_dn"] = new Image();
    aImageArray[sImage + "_dn"].src = "images/button/" + sImage + "_dn.png";
    if (is.moz) loadCheckImgSrc(sImage);
    return;
}

// *********************************************************************
// 010063 - Function checks the src attribute of pre-loaded images. Mozilla doesn't treat
// relative pathing the same way that IE and Opera do, so if problems with the src attribute
// are found then they are corrected.
function loadCheckImgSrc(sImage) {
    var sTemp = oDataPage.location.toString();
    var iIndex = sTemp.lastIndexOf("/");
    var sPath = sTemp.substr(0,iIndex);
    var sImgSrc = aImageArray[sImage + "_up"].src;
    if (sImgSrc.indexOf(sPath) != -1) {
        aImageArray[sImage + "_up"].src = "../images/button/" + sImage + "_up.png";
        aImageArray[sImage + "_dn"].src = "../images/button/" + sImage + "_dn.png";
    }
    return;
}

// *********************************************************************
// 009345 - store a reference to files stored in the system temp directory
function loadStoreFileRef(sFileId,sSrc) {
    aFilesWritten[sFileId] = new Object();
    aFilesWritten[sFileId].src = sSrc;
    return;
}

// *********************************************************************
// Writes the stylesheet link depending on user's browser
function loadPageStyles() {
    var sHtml = "";
    var sCssOverride = bRootPath = false;
    if (arguments[0]) sCssOverride = arguments[0];
    if (arguments[1]) bRootPath = arguments[1];
    var sLink = "<link rel='stylesheet' type='text/css' href='";
    // Load common style sheet
    if (sCssStyle) {
        sHtml = sLink;
        sHtml += loadPageResource("styles",bRootPath);
        sHtml += sCssStyle + ".css'>";
        if (sCssOverride) {
            sHtml += sLink;
            sHtml += loadPageResource("styles",bRootPath);
            sHtml += sCssStyle + "." + sCssOverride + ".css'>";
        }
    } else {
        sHtml = sLink;
        sHtml += loadPageResource("styles",bRootPath);
        sHtml += "std.css'>";
    }
    // Additional Style Sheet for Setup System
    switch (sKskType) {
        case "ZKK":
        case "ZRM":
            sHtml += "<link rel='stylesheet' type='text/css' href='styles/generic.css'>";
            break;
        default:
            // Standard Defintion of all heading colours.
            var hHeadColor = (bHorizMenu) ? hHorizInactive : hVertInactive;
            var hHeadHover = (bHorizMenu) ? hHorizBG : hVertBG;
            var hHeadBackground = (bHorizMenu) ? hHorizActive : hVertActive;
            // If swapping colours then ensure colour and background are swapped
            // Otherwise set non-standard colours found within the configuration file
            if (bSwapHeading) {
                hHeadColor = (bHorizMenu) ? hHorizActive : hVertActive;
                hHeadHover = (bHorizMenu) ? hHorizBG : hVertBG;
                hHeadBackground = (bHorizMenu) ? hHorizInactive : hVertInactive;
            } else {
                if (oGlob.hHeadingColor) hHeadColor = oGlob.hHeadingColor;
                if (oGlob.hHeadingHover) hHeadHover = oGlob.hHeadingHover;
                if (oGlob.hHeadingBackground) hHeadBackground = oGlob.hHeadingBackground;
            }
            // Final check to make sure that all colours are different
            if (hHeadHover == hHeadBackground) {
                hHeadHover = hHeadColor;
                hHeadColor = (bHorizMenu) ? hHorizBG : hVertBG;
            }
            // Build the new style colours for the heading class
            sHtml += "<style>";
            sHtml += ".Headings{color:" + hHeadColor + ";background-color:" + hHeadBackground + ";text-decoration:none;} ";
            sHtml += "a.Headings:hover{color:" + hHeadHover  + ";background-color:" + hHeadBackground + ";text-decoration:none;}";
            // 009091 - Add in styles for active rows
            sHtml += "a.HTMLLabel{color:" + hPrompt + ";text-decoration:none;} ";
            sHtml += "a.HTMLLabel:hover{color:" + hPrompt + ";text-decoration:none;} ";
            // Add styles for the employee calendar and leave planner
            var sTempPage = loadPageCurrent();
            if (sTempPage == "ecempcal" || "melvecal" || "melvepln") {
                for (var sIndex in aDictDetail[sTempPage]) {
                    if (aDictDetail[sTempPage][sIndex] && aDictDetail[sTempPage][sIndex]["title"] && aDictDetail[sTempPage][sIndex]["appendix"] && aDictDetail[sTempPage][sIndex]["appendix"][0]) {
                        sHtml += " ." + aDictDetail[sTempPage][sIndex]["label"] + " {background-color:" + aDictDetail[sTempPage][sIndex]["appendix"][0] + ";} "; 
                    }
                }
            }
            // Fix an HTML button problem for Netscape 6
            if (bButtonHtml == true) sHtml += " .HTMLbutton{text-decoration:none;height:25px;width:100px;color:" + ((bHorizMenu) ? hHorizInactive : hVertInactive) + ";background-color:" + ((bHorizMenu) ? hHorizBG : hVertBG) + ";}";
            sHtml += "</style>";
            // 007259 - set the zoom property, for IE only
            if ((is.ie) && (aDictMenu["setopvew"])) {
                if (oDataPage == dataFrame) dataFrame.document.body.style.zoom = iZoom;
                else {
                    if (oDataPage.frames.length > 0) {
                        if (oDataPage.frames[0].document.body) oDataPage.frames[0].document.body.style.zoom = iZoom;
                    }
                    else if (oDataPage.document) oDataPage.document.body.style.zoom = iZoom;
                }
            }
            break;
    }
    //3: Uncomment to Debug
    //alert("loadPageStyles:\n" + sHtml);
    return sHtml;
}

// *********************************************************************
// 9403 - new sTypePage 'U' Added for utility pages
function loadPageType(sUrl) {
    var sPageType = sUrl.toString().substr(sUrl.length-7,3);
    // Set to Details Page if same as Type
    switch (sPageType) {
        case "dfa":
        case "txa":
        case "tre":
            break;
        default:
            if (sPageType == sKskType.toLowerCase()) {
                sPageType = "det";
            }
            break;
    }
    // Special cases for the various pages including the message window, 
    // calendar window, and time picker window
    var sPageName = loadPageFromURL(sUrl);
    switch (sPageName) {
        case "seerrvew":
        case "sedrivew":
        case "setimvew":
            sPageType = "misc";
            break;
    }
    // Return a character to indicate the page type
    switch (sPageType) {
        // Heavily Customised pages
        case "txa":
            return "C";
        // Numerous different Details pages, see test above
        case "ban":
        case "chg":
        case "cal":
        case "det":
        case "err":
        case "pas":
        case "pln":
        case "rpt":
            return "D";
        case "lst":
        case "pro":
            return "L";
        case "tre":
            return "T";
        case "sel":
        case "dfa":
            return "S";
        case "utl":
            return "U";
        case "vew":
            return "V";
        case "msg":
            return "E";
        // Initial Logon Menu pages
        case "log":
            var sMenuPage = sUrl.toString().substr(sUrl.length-10,3);
            switch (sMenuPage) {
                case "ver":
                case "hor":
                case "sht":
                    return "M";
                default:
                    return "D";
            }
            break;
        // All Other Menu Pages
        default:
            return false;
    }
}

// *********************************************************************
var bDisabledUpdate = false;

// *********************************************************************
// ZBG 7081: Allow Manager fields to be accessed
// ZBG 9040: Enable Administrator Profile and Link View Type
function loadPageDisabled() {
    // Check the configuration is correct otherwise return true
    if (!oDataPage.oDict) {
        if (gDebug) alert(oDataPage.oMenu["title"] + ": Check there is a Configuration entry on Details or Lists form.");
        return true;
    }
    // If defined sort out the setting, otherwise return default setting
    var bPageDisabled = false;
    // Check the profile settings
    var sProfile = "";
    if (oDataPage.oDict["profile"]) sProfile = oDataPage.oDict["profile"]["labeltext"];
    // Find dictionary entry from configuration file
    switch (sProfile) {
        case "all":
            break;
        case "adm":
            if (sMenuProfile != "adm") bPageDisabled = true;
            break;
        case "clr":
            if ((sMenuProfile != "clr") && (!bManMode)) bPageDisabled = true;
            break;
        case "ent":
            if ((sMenuProfile != "ent") && (bManMode)) bPageDisabled = true;
            break;
        case "man":
            if ((sMenuProfile == "clr") || (sMenuProfile == "ent") || (!bManMode)) bPageDisabled = true;
            break;
        case "none":
            bPageDisabled = true;
            break;
        default:
            switch (oDataPage.oMenu["mode"]) {
                case "adm":
                case "man":
                case "rvw":
                case "sec":
                case "sys":
                    break;
                default:
                    if (bManMode) bPageDisabled = true;
                    break;
            }
            break;
    }
    return bPageDisabled;
}

// *********************************************************************
// 010064 - Alert the user if changes have been made to the form.
function loadPageConfirm() {
    var bConfirm = false;
    if ((bModified) && (oDataPage.document.getElementById("updat"))) {
        bModified = false;
        var sMsg = "Do you want to " + oDataPage.oDict["updat"]["labeltext"] + " the changes you made to " + oDataPage.oMenu["title"] + " ?"; 
        bConfirm = oDataPage.confirm(sMsg);
    }
    return bConfirm;
}

// *********************************************************************
function loadPageTitle() {
    var sHtml = "<title>";
    // Set title string from configuration
    if (arguments.length != 0) {
        sHtml += arguments[0];
    } else if ((oDataPage) && (oDataPage.oMenu) && (oDataPage.oMenu.title)) {
        sHtml += oDataPage.oMenu["title"];
    }
    sHtml += "</title>";
    // Debug Window
    if (gDHTMLDebug) loadDebugPage("loadPageTitle:\n" + sHtml + "\n");
    return sHtml;
}

// *********************************************************************
// Introduced for 2.06.00
function loadFormField(oContainer, sName, sDict, iDecimals) {
    if (!sDict) sDict = sName;
    var oTemp = eval("oDataPage.oForm." + sName);
    if (oTemp) {
        if (oTemp.tagName.toLowerCase() == "select") {
            oTemp.value = optnsGet(oContainer,sDict,sName);
        } else {
            if (isNaN(iDecimals)) {
                oTemp.value = getGTRField(oContainer,sDict);
            } else {
                oTemp.value = oGlob.validNumber(getGTRField(oContainer,sDict),iDecimals);
            }
        }
    }
    // Process the extra field for translations
    oTemp = eval("oDataPage.oForm." + sName + "_trn");
    if (oTemp && findGTRField(oContainer,sDict + ".trn")) {
        oTemp.value = getGTRField(oContainer,sDict + '.trn');
    }
    // Init the field count
    oTemp = eval("oDataPage.oForm." + sName + "_count");
    if (oTemp) {
        var iHeight = (oDataPage.oDict[sName]["height"]) ? oDataPage.oDict[sName]["height"] : 5;
        var iLength = (oDataPage.oDict[sName]["length"]) ? oDataPage.oDict[sName]["length"] : 40;
        var iMaxLength = parseInt(iHeight * iLength);
        var iTextlength = parseInt(getGTRField(oContainer,sDict).length);
        iMaxlength = iMaxLength - iTextlength;
        oTemp.value = iMaxlength;
    }
    return;
}

// *********************************************************************
// Introduced for 2.06.00
function loadClearFields() {
    var oElement;
    for (var iIndex=0; iIndex<oDataPage.oForm.length; iIndex++) {
        oElement = oDataPage.oForm[iIndex];
        // If the style indicates that this is a key field, then do not
        // blank out the value
        if (oElement.className == "Key") {
            return;
        }
        // Check each element type and rest as required
        switch (oElement.type) {
            case "button":
                break;
            case "checkbox":
                oElement.checked = false;
                break;
            case "radio":
                if (loadPageType(oDataPage.location.href) != "U") {
                    oElement.checked = false;
                }
                break;
            case "text":
                if ((oElement.name.indexOf("laclvetype") == -1) && (!oElement.getAttribute("clear"))) {
                    oElement.value = "";
                }
                break;
            case "select":
            case "password":
            case "textarea":
                oElement.value = "";
                break;
            default:
                if (oElement.tagName.toLowerCase() == "select") {
                    oElement.value = "";
                }
                break;
        }
    }
    return;
}

// *********************************************************************
// Introduced for 2.06.00
// Accepts 2 parameters, the name of the form item and a boolean indicating whether to enable or disable
function loadDisableField(sName, bDisable) {
    var oFormItem = eval("oDataPage.document.detForm." + sName + "_trn");
    if (oFormItem) oFormItem.disabled = bDisable;
    oFormItem = eval("oDataPage.document.detForm." + sName);
    if (oFormItem) oFormItem.disabled = bDisable;
    return;
}

// *********************************************************************
// Called by any page.  Initialises focus to first editable field in form.
function loadPageFocus() {
    // If the ToolBar Window is open don't bother with focus
    if ((oGlob.oToolWin) && (!oGlob.oToolWin.closed)) return;
    // Scan for the first avaiable field to take focus
    // SQA issue 20528006
    // A problem occurs here in the mozilla based browsers. The normal procedure
    // for a details page is to apply focus to the first editable field, then load in values
    // from the GTR (if there are any). In mozilla, this causes the onchange event to 
    // fire. This is incorrect, as onchange is designed only to fire if a user changes the
    // contents of an input element, then tabs away from that element. To get around 
    // this, we are not applying focus to the form element in mozilla based browsers
    if (!is.moz) {
        for (var i=0; i<oDataPage.oForm.length; i++) {
            if (!oDataPage.oForm[i].disabled && oDataPage.oForm[i].style.visibility != "hidden") {
                switch (oDataPage.oForm[i].type) {
                    case "checkbox":
                    case "password":
                    case "radio":
                    case "text":
                    case "textarea":
                        oDataPage.oForm[i].select();
                        oDataPage.oForm[i].focus();
                        break;
                    default:
                        oDataPage.oForm[i].focus();
                        break;
                }
                break;
            }
        }
    }
    // 010064 - Set the onchange event if required
    // SQA issue 20528006
    // function call moved to loadPageFocus() because in non-IE browsers the document
    // doesn't exist when hdftCheckModifyAlert is called from hdftFooterCreate, and so
    // the onchange events do not get set correctly
    hdftCheckModifyAlert();
    return;
}

// *********************************************************************
var iSuccessCount = 0;      // counts the number of gtr's being processed

// *********************************************************************
// Called by any click function in the page.
function loadPageClick(bPageInitial) {
    // Reset the count for the number of gtr's being processed
    iSuccessCount = 0;
    // Indicates that entries may be found on a list
    bListEmpty = false;
    // Reset bModified
    if (!bPageInitial) bModified = false;
    return;
}

// *********************************************************************
function loadPageLists() {
    // 014439 - Store some key values before resetting the list variables
    if (aListContainer[iListSelected] != null) loadStoreListValues();
    iList = 0;
    iCurrDiv = 0;
    sListData = "";
    // 009372 Reset sSelectKey when entering a list or select page
    sSelectKey = "";
    aDivs = new Array();
    aListContainer = new Array();
    iListSelected = 0;
    bDrillMode = false;
    return;
}

// *********************************************************************
// 014439 - Store various drilldown values required in the Performance Management chain
function loadStoreListValues() {
    if (aListContainer[iListSelected]["wfcstartdt"] != null) sEvalDate = aListContainer[iListSelected]["wfcstartdt"];
    if (aListContainer[iListSelected]["wfccode"] != null) cEvalType = aListContainer[iListSelected]["wfccode"];
    if (aListContainer[iListSelected]["kpidate"] != null) dEvalDate = aListContainer[iListSelected]["kpidate"];
    if (aListContainer[iListSelected]["detnumber"] != null) sEvalDetNumber = aListContainer[iListSelected]["detnumber"];
    if (aListContainer[iListSelected]["detnumber.trn"] != null) sEvalDetName = aListContainer[iListSelected]["detnumber.trn"];
    return;
}

// *********************************************************************
// Clear the array and other variables
function loadPageTrees() {
    iEmpSeqNo = 1;
    iTree = iCurrDiv = iTreeSelected = iTreeTotal = 0;
    sTreeData = sTreeState = "";
    aDivs = new Array();
    aTreeContainer = new Array();
    bDrillMode = false;
    aTreeList = new Array();
    return;
}

// *********************************************************************
// 013901: Created to have one central location for finding out the
// location page name that is being used. Ensuring page string is set 
// correctly for non-IE browsers.
function loadPageLocation() {
    var sTempPage = sDataPage.substr((sDataPage.length - pageLocLength),pageLocLength);
    return sTempPage;
}

// *********************************************************************
// 013901: Created to have one central location for finding out the
// current page name that is being used. Ensuring page string is set 
// correctly for non-IE browsers.
function loadPageCurrent() {
    var sTempPage = (sDataPage.length > 8 ? sDataPage.substr(sDataPage.length-12,8) : sDataPage);
    return sTempPage;
}

// *********************************************************************
function loadPageCurrentPrefix() {
    var sTempPage = (sDataPage.length > 8 ? sDataPage.substr(sDataPage.length-12,2) : sDataPage.substr(0,2));
    return sTempPage;
}

// *********************************************************************
// 013901: Created to have one central location for finding out the
// page name that exists in the URL passed in. Ensuring page string is set 
// correctly for non-IE browsers.
function loadPageFromURL(sURL) {
    var sTempPage = (sURL.length > 8 ? sURL.substr(sURL.length-12,8) : sURL);
    return sTempPage;
}

// *********************************************************************
// Called by any page.  Initialises all required oGlobal variables.
// 009403 - sType 'U' Added for utility pages
// 009442 - Added separate processing for Back and Staff Pages
// 010408 - Ensure sTempPage set correctly for non-IE browsers
function loadPageInitial(sGoingToPage, sBackToPage) {
    var sTempPage = sType = null;
    // Reset the global page variables
    loadPageClick(true);
    // Clear up any Debug Windows that may be open
    loadDebugClose();
    // Test string containing the menu page and the current data page
    if (sGoingToPage) {
        // Set the data page variable to the destination page
        sDataPage = sGoingToPage;
        // Set the Staff Page when a recognised Staff List is encountered
        sTempPage = loadPageCurrent();
        // Discover what type of page this is
        sType = loadPageType(sDataPage);
        // Set dictionary entry from configuration
        switch (sType) {
            case "L":
            case "T":
                oDataPage = dataFrame;
                break;
            case "S":
                oDataPage = oVewSelWin;
                break;
            case "U":
                oDataPage = dataFrame;
                break;
            case "V":
                oDataPage = oVewSelWin;
                break;
            default:
                oDataPage = dataFrame;
                break;
        }
        // Set up the oMenu for the page
        oDataPage.oMenu = menuObjectLoad(sTempPage);
        // If no menu entry then show configuration error page
        if ((oDataPage.oMenu == null) || (!oDataPage.oMenu)) {
            sPageNotFound = sTempPage;
            if (gDebug) alert("Warning: Menu page is not defined in Configuration File.");
            listPageSelect(sErrorPage);
        } else {
            // Debug Window, Open Up here...
            if (gDHTMLDebug) loadDebugOpen(oDataPage.oMenu["title"]);
            // Set Back Page in a configurable way to be used at all times
            if (!arguments[1]) sBackToPage = "";
            switch (sTempPage) {
                case "mcdetlst":    // Clerical
                case "mdwfelst":    // Data Entry
                case "mswfelst":    // Staff List
                case "mswfetre":    // Staff Tree
                case "mwwfelst":    // Salary Review
                    sStaffPage = sTempPage;
                    break;
                default:
                    var sBackTemp = sTempPage;
                    var sTemp = sTempPage.substr(5,3);
                    var oTemp = new Object();
                    // Before going back make sure workflow page is in the menu configuration
                    var bWorkflowPage = ((sTempPage.substr(0,2) == "mr") && (sLoadPage.substr(2,3) != "wfc") && (sLoadPage.substr(2,2) != "kp") && (sTemp != "lst") && (sTemp != "sel"));
                    if (bWorkflowPage) {
                        sBackTemp = sTempPage.replace(sTemp,"lst");
                        oTemp = menuObjectLoad(sBackTemp);
                        if (!oTemp) sBackToPage = "mrwfclst";
                        else sBackToPage = sBackTemp;
                    }
                    // Check the value of sBackToPage
                    if (sBackToPage == "") {
                        if (sTemp != "lst") sBackTemp = sTempPage.replace(sTemp,"lst");
                        oTemp = menuObjectLoad(sBackTemp);
                        if (oTemp) sBackToPage = sBackTemp;
                        else sBackToPage = sBackPage;
                    }
                    sBackPage = sBackToPage;
                    break;
            }
            // Set dictionary entry from configuration
            switch (sType) {
                case "C":
                case "L":
                case "T":
                    // 010064 - Reset the bModified flag.
                    bModified = false;
                    oDataPage.oDict = aDictList[sTempPage];
                    break;
                case "S":
                    oDataPage.oDict = aDictList[sTempPage];
                    break;
                case "U":
                    // 010064 - Reset the bModified flag.
                    bModified = false;
                    oDataPage.oDict = aDictList[sTempPage];
                    oDataPage.oDictUtl = aDictDetail[sTempPage];
                    break;
                case "V":
                    oDataPage.oDict = aDictDetail[sTempPage];
                    break;
                default:
                    // 010064 - Reset the bModified flag.
                    bModified = false;
                    oDataPage.oDict = aDictDetail[sTempPage];
                    break;
            }
            // Set up the oSearch for the page
            oDataPage.oSearch = aDictSearch[sTempPage];
            // Set up the oForm for the page
            oDataPage.oForm = oDataPage.document["detForm"];
            // Set up the disabled update flag for the page
            if (sType) bDisabledUpdate = loadPageDisabled();
            // Set up a banner on all pages with no repeat
            switch (sKskType) {
                case "EAY":
                    break;
                default:
                    // Only include banner if page setup for it and not a pop-up page type
                    if ((oDataPage.document.body) && (sBannerBG) && (!bBannerBGFooter) && (sType != "S") && (sType != "V")) {
                        oDataPage.document.body.style.backgroundRepeat = "no-repeat";
                        oDataPage.document.body.background = loadPageResource("logo") + sBannerBG;
                    }
                    break;
            }
            // Clears innerHTML if the error window has been displayed
            if (oDataPage.document.getElementById("errSpan") != null) {
                oDataPage.document.getElementById("errSpan").innerHTML = "";
            }
            // Reset variables depending on the type of page being loaded
            switch (sType) {
                case "L":
                case "S":
                    loadPageLists();
                    break;
                case "T":
                    loadPageTrees();
                    break;
                case "V":
                    break;
                case "U":
                    iTab = 0;
                    loadPageLists();
                    break;
                default:
                    iTab = 0;
                    if (!bDrillMode) {
                        aListContainer = new Array();
                    }
                    break;
            }
        }
    }
    return;
}

// *********************************************************************
// Scan through setting the standard length's
// 9393: increase larger sizes by 1.5
// 013619: Set Type 16 (Date) fields to be 40 pixels in length
function loadFieldLength(iLength, sDataType) {
    if ((arguments.length == 2) && (sDataType == "16")) {
        return "75";
    } else {
        if (isNaN(iLength) || ((iLength >= 0) && (iLength < 5))) {
            return "50";
        } else if ((iLength >= 5) && (iLength < 10)) {
            return "80";
        } else if ((iLength >= 10) && (iLength < 15)) {
            return "135";
        } else if ((iLength >= 15) && (iLength < 20)) {
            return "180";
        } else if ((iLength >= 20) && (iLength < 30)) {
            return "270";
        } else if ((iLength >= 30) && (iLength < 40)) {
            return "305";
        } else if ((iLength >= 40) && (iLength < 50)) {
            return "375";
        } else {
            return "450";
        }
    }
}

// *********************************************************************
// Returns link to manager page otherwise standard error
function loadPageManager() {
    // Set a variable to equal the page name
    var sToPage = loadPageCurrent();
    // Extra Manager Mode processing required
    if ((sKskType == "STG") && (sToPage == "mrktalst")) bManMode = true;
    // Set the Manager Mode global variables
    menuManMode(false);
    // If the page for the manager view has been defined then load it
    switch (oDataPage.oMenu["mode"]) {
        case "adm":
        case "sys":
            return true;
            break;
        case "man":
            // 011687 - Throw to staff list for terminations
            var cSysPage = sToPage.charAt(0);
            var cManPage = sToPage.charAt(1);
            // 011927 - Don't redirect if going to a banner page
            // 013946 - or system page
            if (!listCheckFound()) {
                if ((cSysPage != "s") && (cManPage == "e") && (sToPage != "mewfelst") && (sToPage.substr(5,3) != "ban")) {
                    return listPageSelect("mewfelst");
                } else {
                    return true;
                }
            } else if ((sToPage == "moterdet") && (sEmpNo == "")) {
                return listPageSelect(sStaffPage);
            } else {
                return true;
            }
            break;
        case "sec":
            // Check the profile and only give access to the pages that match
            switch (sMenuProfile) {
                case "sec":
                    if ((sEmpNo == "") && (sToPage != "mswfelst")) {
                        sManPage = sToPage;
                        return listPageSelect(sStaffPage);
                    } else {
                        return true;
                    }
                    break;
                default:
                    if ((bManMode) && (sToPage != "mswfelst")) {
                        return listPageSelect(sErrorPage);
                    } else {
                        return true;
                    }
                    break;
            }
            break;
        case "all":
            if (bManMode) {
                return listPageSelect(sErrorPage);
            } else {
                return true;
            }
            break;
        case "clr":
        case "rvw":
            if (sEmpNo == "") {
                sManPage = sToPage;
                return listPageSelect(sStaffPage);
            } else {
                return true;
            }
            break;
        case "ent":
            if ((sEmpNo == "") && (sToPage != "mdwfelst")) {
                sManPage = sToPage;
                return listPageSelect(sStaffPage);
            } else {
                return true;
            }
            break;
        case "lnk":
        case "vew":
            // Check the profile and only give access to the pages that match
            switch (sMenuProfile) {
                case "clr":
                case "sec":
                    if (bManMode) {
                        return listPageSelect(sErrorPage);
                    } else {
                        return true;
                    }
                    break;
                default:
                    if (sEmpNo == "") {
                        sManPage = sToPage;
                        return listPageSelect(sStaffPage);
                    } else {
                        return true;
                    }
                    break;
            }
            break;
        default:
            return listPageSelect(sErrorPage);
            break;
    }
}

// *********************************************************************
// Returns the correct string for the tool tip on the button
function loadPageBack() {
    // Temporary storage of text if this is a particular type of page
    var sTemp = "";
    var oTemp = new Object();
    // Load the tool tip
    oTemp = menuObjectLoad(sBackPage);
    if (oTemp) sTemp = "Back to " + oTemp["title"];
    // Check that sTemp is no longer an empty string
    if (sTemp != "") {
        return sTemp;
    } else {
        return "Back to originating page" + ((bDebug) ? (" : " + sBackPage) : "");
    }
}

// *********************************************************************
//  Calculates page dimensions.  
//  Used by loadDivsCreate to calc. dimensions of dynamic divs for list pages.
//  Takes input - what = w or h, returns appropriate reading.
function loadPageDimensions(what) {
    var tf = oDataPage;
    var d = tf.document;
    var b = d.body;
    // Check for Mozilla
    if (is.moz) {
        return ((what == "w") ? tf.innerWidth : tf.innerHeight);
    } else {
        return ((what == "w") ? b.offsetWidth : b.offsetHeight);
    }
}

// *********************************************************************
// Constructor function for loadDivsDynamic objects.  
//          (Dynamic Divs = divs used in list pages)
//           4 types of Divs:       head, data, butt, foot
// 010063 - Adjusted some settings to suit all supported browsers
function loadDivsDynamic(divname, divType, divPosition) {
    var sTempPage = loadPageCurrent();
    // Check for full screen mode (fsm)
    var bw = loadPageDimensions("w");
    var bh = loadPageDimensions("h");
    fsm = (bh >= 550);
    // Set as many common values as possible
    this.name = divname;
    this.id = divname;
    switch (sKskType) {
        // ReadMe Div is 100% Page Width and in Left by 0
        case "ZRM":
            this.width = bw;
            this.left = 0;
            break;
        // In all other systems Div is 90% Page Width and in Left by 10
        default:
            this.width = 0.9 * bw;
            this.left = 10;
            break;
    }
    // Set the background color and visiblity
    this.bgcol = "";
    this.vis = "visible";
    // Pick the Div type and set the prototype values
    switch (divType) {
        case "head":        
            this.width = bw; // This is the exception
            this.left = 0; 
            this.height = 0.15 * bh;
            this.top = 0;
            this.overflow = "visible";
            this.align = "center";
            this.pos = "relative";
            this.clip = "auto";
            // try giving everything a proper z-index
            this.zindex = "z-index:0; ";
            this.extra = "";
            break;
        case "data":
            // 9403 - dataDiv position should be 'relative'
            switch (divPosition) {
                case "relative":
                    this.height = 0; 
                    this.pos = "relative";
                    break;
                case "absolute":
                    this.height = 0; 
                    this.pos = "absolute";
                    break;
                default:
                    this.height = 0.5 * bh;
                    this.pos = (aDivs.length == 0) ? "relative" : "absolute";
                    break;
            }
            this.overflow = (is.moz) ? "clip" : "visible";
            this.align = "center"
            switch (sKskType) {
                // ReadMe Div 
                case "ZRM":
                    this.top = (aDivs.length == 0) ? 0 : 102;
                    break;
                // In all other systems 
                default:
                    this.top = (aDivs.length == 0) ? 0 : 62;
                    break;
            }
            // Give data divs a z-index
            this.zindex = ("z-index:" + iCurrDiv + "; ");
            // Add all dataDiv's to the aDivs
            aDivs[aDivs.length] = divname;
            break;
        case "butt":
            this.height = 0.06 * bh;
            this.top = (bButtonHtml ? 20 : 30);
            this.overflow = "visible";
            this.align = "center";
            this.clip = "auto";
            this.pos = "relative";
            break;
        case "foot":
            this.height = 0.12 * bh;
            this.top = 5;
            this.overflow = "visible";
            this.align = "left";
            this.clip = "auto";
            this.pos = "relative";
            this.extra = "";
            break;
        case "cal":
            this.height = 0.64 * bh;
            this.overflow = "visible";
            this.clip = "rect(0 100 100 0)";
            this.align = "center"
            this.pos = "relative";
            this.top = 0;
            // Give data divs a negative z-index so that submenus are always above them
            this.zindex = "z-index:" + iCurrDiv + "; ";
            break;
        case "legend":
            this.top = 40;
            this.left = 300;
            this.width = 160;
            this.height = 250;
            this.vis = "hidden";
            this.align = "center";
            this.pos = "absolute";
            this.bgcol = "white";
            // Give data divs a negative z-index so that submenus are always above them
            this.zindex = "z-index:100; ";
            this.border = "2px solid; padding:5px;";
            this.action = "onClick='oGlob.calenLegendHide(); return false;'";
            break;
        case "comment":
            this.height = 0.05 * bh;
            this.top = 25;
            this.overflow = "visible";
            this.align = "left";
            this.clip = "auto";
            this.pos = "relative";
            this.extra = "";
            break;
    }
    return;
}   

// *********************************************************************
// 9403 - a 3rd argument is passed in from the utility pages
function loadDivsCreate(divName, divType, divPosition) {
    var bw = loadPageDimensions("w");
    var bh = loadPageDimensions("h");
    // create new div obj & add it to div object array
    var divNm = new loadDivsDynamic(divName,divType,divPosition);
    // write the div HTML
    var sHtml = "<div align='" + divNm.align + "' id='" + divNm.id + "' style='position:" + divNm.pos + "; visibility:" + divNm.vis + "; ";
    sHtml += (divNm.extra) ? divNm.extra : "";
    sHtml += (divNm.zindex) ? divNm.zindex : "";
    sHtml += (divNm.bgcol) ? ("background-color:" + divNm.bgcol + "; ") : "";
    sHtml += (divNm.border) ? ("border:" + divNm.border + "; ") : "";
    sHtml += (divNm.padd) ? ("padding:" + divNm.padd + "; ") : "";
    sHtml += "overflow:" + divNm.overflow + "; ";
    sHtml += "left:" + divNm.left + "px; top:" + divNm.top + "px; ";
    sHtml += "width:" + divNm.width + "px; height:" + divNm.height + "px;'";
    sHtml += (divNm.action) ? (divNm.action) : "";
    sHtml += ">";
    if (divType == "legend") sHtml += calenLegend();
    if (divType == "comment") sHtml += listCommentCreate();
    sHtml += "</div>";
    //4: Uncomment to Debug
    //alert("loadDivsCreate:\n" + sHtml);
    return(sHtml);
}

// *********************************************************************
// 10063 - Mozilla/Opera
// The divs on the list pages need to be adjusted so that they aren't
// bunched up and overlap.
function loadDivsAlign() { 
    var aDivs = new Array("dataDiv" + iCurrDiv,"comDiv","buttDiv","footDiv");
    for (var iIndex = 0; iIndex < aDivs.length; iIndex++) {
        // Find the first div, and calculate its absolute top position, and also its height
        var oFirstDiv = oDataPage.document.getElementById(aDivs[iIndex]);
        if (oFirstDiv) {
            oFirstDiv.style.border = "0.02cm solid " + (oDataPage.document.bgColor == "" ? hWindowBG : oDataPage.document.bgColor);
            var iHeight = 0;
            for (var i = 0; i < oFirstDiv.childNodes.length; i++) iHeight = iHeight + oFirstDiv.childNodes[i].offsetHeight;
            var iFirstTop = loadGetVerticalPos(oFirstDiv);
            // Find the following div, and calculate its absolute top position, and also its height
            // If the 2nd div top position is less than the height of the 1st div, then grow the 1st div
            var oSecondDiv = oDataPage.document.getElementById(aDivs[iIndex+1]);
            if (oSecondDiv) {
                var iSecondTop = loadGetVerticalPos(oSecondDiv);
                if ((iFirstTop + iHeight) > iSecondTop) oFirstDiv.style.height = iHeight;                
            }
        }
    }
    return;
}

// *********************************************************************
// SQA 20528005: Need to grow the div dimensions to prevent overlap with other page Divs
function loadGrowDiv(sName) {
    var oDiv = oDataPage.document.getElementById(sName);
    if (oDiv) {
        var iHeight = 0;
        for (var i = 0; i < oDiv.childNodes.length; i++) iHeight = iHeight + oDiv.childNodes[i].offsetHeight; 
        if (parseInt(iHeight) > parseInt(oDiv.style.height)) oDiv.style.height = iHeight + 15;
    }
    return;
}

// *********************************************************************
// 009742 - used in sefrirpt.htm to create the org chart, but can be used anywhere.
// Pass in a html form element, and these functions will return an integer value for 
// the left (x) position, or top (y) position, depending on which function you call.
// 010063 - moved to ftrload.js from ftrmisc.js
// *********************************************************************
function loadGetHorizontalPos(oElement) {
    var iLeftPos = oElement.offsetLeft;         
    var oParElement = oElement.offsetParent;
    while (oParElement != null) {
        iLeftPos += oParElement.offsetLeft;
        oParElement = oParElement.offsetParent;
    }
    return iLeftPos;
}

// *********************************************************************
// 010063 - moved to ftrload.js from ftrmisc.js
function loadGetVerticalPos(oElement) {
    var iTopPos = oElement.offsetTop;
    var oParElement = oElement.offsetParent;
    while (oParElement != null) {
        iTopPos += oParElement.offsetTop;
        oParElement = oParElement.offsetParent;
    }
    return iTopPos;
}

// *********************************************************************
function loadEnableButton(sButtonNm) {
    for (var i=0; i<arguments.length; i++) {
        var sButtonNm = arguments[i];
        if (oDataPage.oDict[sButtonNm] || sButtonNm == "next") {
            if (bButtonHtml) oDataPage.document.getElementById(sButtonNm).disabled = false;
            else {
                if (aClickEvents.length != 0) {
                    var oTemp = oDataPage.document.getElementById(sButtonNm + iCurrDiv);
                    if (oTemp) {
                        oTemp.src = aImageArray["up"].src;
                        oTemp.onclick = aClickEvents[sButtonNm].onclick;
                        oTemp.onmouseover = aClickEvents[sButtonNm].onmouseover;
                        oTemp.onmouseout = aClickEvents[sButtonNm].onmouseout;
                        oTemp.style.cursor = "hand";
                    }
                    oTemp = oDataPage.document.getElementById("label" + sButtonNm + iCurrDiv);
                    if (oTemp) {
                        oTemp.onclick = aClickEvents["label" + sButtonNm].onclick;
                        oTemp.onmouseover = aClickEvents["label" + sButtonNm].onmouseover;
                        oTemp.onmouseout = aClickEvents["label" + sButtonNm].onmouseout;
                        oTemp.style.cursor = "hand";
                    }
                    aClickEvents = new Array();
                }
            }
        }
    }
    return;
}

// *********************************************************************
// 8858 Disables the page button(s) as specified by the arguments. 
// Either the html button will be disabled, or the graphical button will be replaced by a blank one.
// 010063 - Fixed for all supported browsers
function loadDisableButton(sButtonNm) {
    var oTemp = null;
    for (var i=0; i<arguments.length; i++) {
        var sButtonNm = arguments[i];
        if (oDataPage.oDict[sButtonNm] || sButtonNm == "next") {
            if (bButtonHtml) {
                oTemp = oDataPage.document.getElementById(sButtonNm);
                if (oTemp) oTemp.disabled = true;
            }
            else {
                oTemp = oDataPage.document.getElementById(sButtonNm + iCurrDiv);
                if (oTemp) {
                    if (oTemp.onclick != null) {
                        var oTempObject = new Object();
                        oTempObject.onclick = oTemp.onclick;
                        oTempObject.onmouseover = oTemp.onmouseover;
                        oTempObject.onmouseout = oTemp.onmouseout;
                        aClickEvents[sButtonNm] = oTempObject;
                    }
                    oTemp.src = aImageArray["disabled"].src;
                    oTemp.onclick = null;
                    oTemp.onmouseover = null;
                    oTemp.onmouseout = null;
                    oTemp.style.cursor = "arrow";
                }
                oTemp = oDataPage.document.getElementById("label" + sButtonNm + iCurrDiv);
                if (oTemp) {
                    if (oTemp.onclick != null) {
                        var oTempObject = new Object();
                        oTempObject.onclick = oTemp.onclick;
                        oTempObject.onmouseover = oTemp.onmouseover;
                        oTempObject.onmouseout = oTemp.onmouseout;
                        aClickEvents["label" + sButtonNm] = oTempObject;
                    }
                    oTemp.onclick = null;
                    oTemp.onmouseover = null;
                    oTemp.onmouseout = null;
                    oTemp.style.cursor = "arrow";
                }
            }
        }
    }
    return;
}

// *********************************************************************
function loadButtonFocus(sButtonNm) {
    var sID = sButtonNm;
    if (!bButtonHtml) sID += iCurrDiv;
    var oButton = oDataPage.document.getElementById(sID);
    if (oButton) oButton.focus();
    return;
}

// *********************************************************************
// 010698 - Line up the detail table with the list div
function loadUtlPageStyles(sDivId,sTableId) {
    var oDataDiv = oDataPage.document.getElementById(sDivId);
    var oDetailTable = oDataPage.document.getElementById(sTableId);
    if (oDataDiv && oDetailTable) {
        oDetailTable.style.left = oDataDiv.style.left;
        oDetailTable.style.width = oDataDiv.style.width;
        oDetailTable.style.position = oDataDiv.style.position;
    }
    return;
}

// *********************************************************************
// 010698 - Configure the divider div
function loadConfigureDivider() {
    if (oDataPage.oDict["i_divider"]) {
        var oDiv = oDataPage.document.getElementById("divider");
        var oTable = new Object();
        // Find the table that houses the divider div
        if (is.moz) oTable = oDiv.nextSibling;
        else oTable = oDiv.parentNode.parentNode.parentNode;
        // Calculate the table height and top
        var iTableHeight = oTable.offsetHeight;
        var iTableTop = loadGetVerticalPos(oTable);
        // Find the second table cell containing a heading
        var oCell = new Object();
        var aTemp = oDataPage.document.getElementsByTagName("td");
        for (var i = 0; i < aTemp.length; i++) {
            if (aTemp[i].className == "Headings") oCell = aTemp[i];
        }
        // Find the position of the table cell
        var iHoriz = loadGetHorizontalPos(oCell)
        var iVert = loadGetVerticalPos(oCell);
        // In order to calculate the height of the div, check if there is a comment present
        var oComment = oDataPage.document.getElementById("i_comment");
        var iDividerHeight = 0;
        if (oComment) {
            var iCommentTop = loadGetVerticalPos(oComment);
            iDividerHeight = iCommentTop - iVert; 
        } else {      
            if (is.moz) {
                iDividerHeight = iVert - iTableTop;
                iDividerHeight = iTableHeight - iDividerHeight;
            } else {
                var iLastChildTop = loadGetVerticalPos(oTable.lastChild);
                iDividerHeight = iLastChildTop - iVert; 
            }
        }
        // Configure the divider div
        oDiv.style.top = iVert;
        oDiv.style.height = iDividerHeight;
        oDiv.style.width = '1px';
        oDiv.style.left = iHoriz;
        oDiv.style.backgroundColor = hdftGetBgColour();
        oDiv.style.position = "absolute";
    }
    return;
}

// *********************************************************************
// HR21 DEBUG WINDOW 
// *********************************************************************

// *********************************************************************
var oDebugWin = null;

// *********************************************************************
function loadDebugOpen(sTitle) {
    oDebugWin = window.open("","DebugWindow","toolbar,status,menubar,scrollbars,resizable,height=400,width=600");
    if (oDebugWin) {
        oDebugWin.document.write("<html><head><title>Debug Window - " + sTitle + "</title>");
        oDebugWin.document.write("<body><div id='codeDiv'></div></body></html>");
    }
    return;
}

// *********************************************************************
function loadDebugPage(sDebug) {
    if (oDebugWin) {
        sDebug = sDebug.replace(/</g,"&lt;");
        sDebug = sDebug.replace(/>/g,"&gt;");
        sDebug = sDebug.replace(/\n/g,"<br>");
        oDebugWin.document.getElementById("codeDiv").innerHTML += sDebug;
    }
    return;
}

// *********************************************************************
function loadDebugClose() {
    if (oDebugWin && (!oDebugWin.closed)) oDebugWin.close();
    oDebugWin = null;
    return;
}

// *********************************************************************
// HR21 SECTIONS PERFORMED ONLOAD 
// *********************************************************************

// Time Window
var oTimeWin = null;

// Calendar Window
var oCalWin = null;

// Help Window
var oHelpWin = null;

// Message Window
var oMessWin = null;
var bMessWin = false;

// Server Side Error Window
var oServerWin = null;

// View Opened Window
var oVewSelWin = null;

// variable for determining whether a sub-menu always gets a plus-sign
// regardless of whether it holds another sub-menu or not
var bSubsGetPlus = false;

// Whether you want an open sub-menu to close automagically
// when another sub-menu is opened.  'true' means auto-close
var bSubsAutoClose = true;
        
// Initialise various variables dependant on the System Type
switch (sKskType) {
    // Other Systems ***************************************************
    case "ZKK":
    case "ZRM":
        break;
    // HR21 Systems ****************************************************
    default:
        // Variable set for the Back page and the Staff List page
        sBackPage = sCompanyPage;
        // Initially set the Staff Page to be the same as the Back Page
        // But processing in the loadGlobals function will pick the correct
        // Staff List for the type of HR21 avaiable to the manager
        sStaffPage = sBackPage;
        // For certain clients set certain variables        
        switch (sKskType) {
            // DHS - Department of Human Services
            case "DHS":
                // 007482 - DHS - For Salay pay frequency - stores Pay Interval for determining periodical amount
                var sPayFrequency = "";
                // 007482 - DHS - For Medicare page - determines page number for medicare
                var bSeqNum = false;
                break;
            // SAW - SA Water Corporation
            case "SAW":
                var sDetProxy = "";
                var iRecords = 10;
                var sName = "";
                var sDetNumber = "";
                var sTitle = "";
                var sSearchNo = "";
                var sSearchName = "";
                var sDirName = sHR21Location;
                break;
        }
        break;
}

// *********************************************************************

