//--********************************************************************-->
//--                                                                    -->
//--   Frontier Software Pty Ltd                                        -->
//--                                                                    -->
//--   File Name     : ftrlist.js                                       -->
//--                                                                    -->
//--   History       :                                                  -->
//--   005876 - 02.07.00 - JavaScript Rewrite.                          -->
//--   008417 - 06.02.03 - Add header image for STH.                    -->
//--   008711 - 27.06.03 - Button replace manager link bar.             -->
//--   007634 - 02.07.03 - Clerical Self-Service.                       -->
//--   008890 - 15.08.03 - Button wrapping                              -->
//--   009014 - 29.08.03 - Stop over lapping of buttons on list pages   -->
//--   008972 - 03.09.03 - Apply style - CheckBox for the check boxes   -->
//--                     - Enabled the use of page comments on lst pages-->
//--   008676 - 19.09.03 - ftrListImages() removed, ftrCreateNewImage() -->
//--                       now performs image pre-loads when required.  -->
//--   009093 - 03.10.03 - Carry field value to popup search page field.-->
//--   008997 - 30.09.03 - selectTop() & listDivsDelete() fixed for     -->
//--                       rebuild problems                             -->
//--   009153 - 24.10.03 - mouseOver functions altered for XML report   -->
//--                       window                                       -->
//--   009259 - 24.11.03 - Run report links working properly            -->
//--   007335 - 12.11.03 - Tree Structure Staff List changes.           -->
//--   008858 - 15.12.03 - Button Disable moved to ftrload              -->
//--   009420 - 27.01.04 - Link buttons wrap in clerical mode correctly -->
//--   008366 - 29.01.04 - reset sDataPage correctly                    -->
//--   009195 - 12.02.04 - Allow Main Menu items (top) to be staff list -->
//--                       link buttons (lnk).                          -->
//--   009456 - 12.02.04 - listCloseSelect() reloads calling page       -->
//--   009403 - 16.02.04 - Functionality for Utility pages included     -->
//--   009286 - 27.02.04 - Introduced Review type                       -->
//--   009345 - 01.03.04 - Report print function added                  -->
//--   009091 - 04.03.04 - List rows can be links                       -->
//--   009508 - 10.03.04 - 'Select/Clear All' links now appear as       --> 
//--                        buttons. listLinkBarReport() removed.       -->
//--   009505 - 15.03.04 - Add link to WFE PHOTO in order to open staff -->
//--                       photo                                        -->
//--   009445 - 06.02.04 - Tree Structure Staff List moved.             -->
//--   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               -->
//--   009618 - 28.07.04 - Swap Heading Colours                         -->
//--   009995 - 10.08.04 - Correct Favourite Links                      -->
//--   010064 - 15.10.04 - Confirmation Prompt On Form Change           -->
//--   010097 - 09.11.04 - Correct next and previous page               -->
//--   010063 - 17.12.04 - Opera (10062) & Mozilla (10063) supported    -->
//--   010414 - 11.02.05 - Include iCurrDiv in each Row Id (unique)     -->
//--   010408 - 01.03.05 - Add new starters                             -->
//--   008834 - 22.03.05 - Force a refresh of the page after check.     -->
//--   010119 - 24.03.05 - Lookup image conforms to C21                 -->
//--   010537 - 02.08.05 - Allow the height and width of the view       -->
//--                       window to be changed.                        -->
//--   011116 - 06.09.05 - Corrected banner colour usage                -->
//--   011389 - 28.03.06 - Correct the Draft TR Election display.       -->
//--   013618 - 23.01.07 - Corrected alignment of version numbers.      -->
//--   013704 - 23.02.07 - Make TXA code available to SPI               -->
//--   013668 - 13.07.06 - New workflow option created.                 -->
//--   013668 - 02.03.07 - All times in hh:mm format                    -->
//--   013717 - 06.03.07 - Change the fav url link.                     -->
//--   013901 - 10.05.07 - loadPageCurrent function created             -->
//--   013954 - 29.05.07 - Expand Organisation Level fields             -->
//--   013827 - 25.05.07 - Split Links and Emails from Favourites       -->
//--   013976 - 04.06.07 - Correcting sheet when appendix file removed  -->
//--   013992 - 12.06.07 - Migration of STG Timesheets to c21           -->
//--   014434 - 23.10.07 - Layout & Colour Enhancements                 -->
//--   014171 - 06.08.07 - Workflow Forms Streamlined                   -->
//--   014900 - 22.04.08 - One step workflow                            -->
//--********************************************************************-->

//Storage area for all the lists within HR21
var aListContainer = new Array();

//Storage area for all the check lists within HR21
var aCheckContainer = new Array();

//Index variable pointing to the element in the aListContainer
var iList = 0;

//Selection value of the element in the aListContainer
var iListSelected = 0;

//Selection Object for the Search Facility
var aListSelected = new Array();

//Selection value of the element in the aListContainer
var bCheckLoaded = false;

//Indicates whether the list is showing a current or full history listing
var bFullHist = false;

//Indicates whether the list is showing a report from the file repository
var bViewFiles = false;

//Indicates whether the list is showing a Manager or System FAV listing
var bKioskFav = false;

//Indicates whether the list is empty or has entries
var bListEmpty = false;

// Variable set when clicking from a certain place (submenu or add button on certain pages)
// which is checked by the next page for initialisation
var bDrillMode = false;

// The manager page to return to once a member of staff has been selected
var sManPage = "";

// Array of all created data Div ID's, initialised to empty array on each list page.  
// iCurrDiv indicates which dataDiv is currently visible.
var aDivs;
var iCurrDiv;

// Holds the compiled string of HTML until it is rendered
var sListData = "";

// Document width & height
var bw, bh;

// 9093 Holds the search field value for the Select Pop-Up Windows 
var sSearchVal = "";

// 9456 - Holds the name of the page to call a pop-up window
var sCallPage = "";

// N6 - Properties (no. records, max. records, back page, which buttons) for a dataDiv
var aDivRecs = new Array();
var aDivMaxRows = new Array();
var aDivBackPage = new Array();
var aDivButtons = new Array();

// *********************************************************************
// Outgoing processing of GTR's
// *********************************************************************

// *********************************************************************
// This function sets all field terms and values for a list, if the 
// gtrContainer doesn't exist then create it.
// 010114 - bIgnoreFilter allows this function to ignore ZOF settings. This currently only
// occurs on adrlst, where filter settings can differ between staff mode and manager mode
function listGTRField(gtrContainer, bIgnoreFilter) {
    var sFilterNo = listCheckFilter(gtrContainer);
    var iFilterNo = "";
    if (sFilterNo) iFilterNo = parseInt(sFilterNo.substr(6,sFilterNo.length-6));
    for (var sFieldNumber in oDataPage.oDict) {
        if (oDataPage.oDict[sFieldNumber]["datadict"]) {
            // Append extra filters if required 
            if ((sFieldNumber.indexOf("filter") != -1)) {
                var sTempFieldNumber = sFieldNumber;
                if (sFilterNo) {
                    var sTemp = gtrContainer[sFilterNo];
                    if (sTemp.indexOf("and") == -1) {
                        var sConnect = "";
                        if ((sTemp.charAt(sTemp.length-1)) != ":") sConnect = ":";
                        gtrContainer[sFilterNo] += sConnect + "and";
                    }
                    iFilterNo++;
                    sTempFieldNumber = "filter" + (iFilterNo > 9 ? "" : "0") + iFilterNo;
                }
                if (!bIgnoreFilter) setGTRField(gtrContainer,sTempFieldNumber,oDataPage.oDict[sFieldNumber]["datadict"]);
            }
            else setGTRField(gtrContainer,sFieldNumber,oDataPage.oDict[sFieldNumber]["datadict"]);
            // Debug Window
            if (gDHTMLDebug) loadDebugPage("listGTRField:\n" + sFieldNumber + ", " + oDataPage.oDict[sFieldNumber]["datadict"] + "\n");
        }
        // Include sendfields in correct format
        else if ((sFieldNumber.indexOf("sendfields") != -1)) {
            setGTRField(gtrContainer,sFieldNumber,oDataPage.oDict[sFieldNumber]["label"]);
        } 
    }
    return;
}

// *********************************************************************
// 010114 - Return the name of the filter in the gtrContainer if one exists
function listCheckFilter(gtrContainer) {
    var sFilterNo = false;
    for (var dataDict in gtrContainer) {
        if (dataDict.indexOf("filter") != -1) sFilterNo = dataDict;
    }
    return sFilterNo;
}

// *********************************************************************
// Incoming processing of GTR's
// *********************************************************************

// *********************************************************************
function listSetSearchField() {
    for (var iIndex=0; iIndex<arguments.length; iIndex++) {
        listCloseSelect();
        aListSelected[iIndex] = arguments[iIndex].toString();	
        sSearchVal = eval("oDataPage." + aListSelected[iIndex] + ".value");
    }
    return;
}

// *********************************************************************
function listTopRowCreate() {
    var charA, charZ, argI;
    var sFieldNumber, oFieldNumber;
    var iArguments = iColumnCount = 0;
    var sArguments = arguments[0];
    // Initialise the string that will contain all the dynamic html
    sListData = "";
    // First Argument is used to set extra controls above the list header
    switch (sArguments) {
        case "Data":
        case "Staff":
		case "Review":
        case "Clerical":
            iArguments = 1; 
            sListData = linkBarLists(sArguments);
            break;
        case "Skl":
            iArguments = 1; 
            sListData = linkBarSkill();
            break;
        case "Time":
            iArguments = 1; 
            sListData = linkBarTime(); 
            sArguments = "NoCol";
            break;
        case "TimeSpc":
            iArguments = 1; 
            sListData = linkBarTime();
            break;
        case "NoCol":
            iArguments = 1;
            break;
    }
	// 009091 List rows can be links
    sListData += "<table border='0' align='left' name='listTable' cellspacing='" + ((iColumnSpacing) ? iColumnSpacing : "0") + "' cellpadding='2' width='100%'>";
    sListData += hdftHeadingCreate();
    // If nothing to the far left of screen put a space character
    if (sArguments != "NoCol") {
        sListData += "<td class='Headings'>&nbsp;</td>";
    }
    // Write heading - depending of the method being used
    if ((oDataPage.oDict) && (oDataPage.oDict["columns"])) {
        iArguments = 1;
        iColumnCount = oDataPage.oDict["columns"]["label"];
    } else {
        iColumnCount = arguments.length - 1;
    }
    // Scan through the columns building up the complete heading
    for (var i=iArguments; i<=iColumnCount; i++) {
        sListData += "<td class='Headings'";
        sFieldNumber = "field" + ((i < 10) ? "0" : "") + i;
        // Decide where to retrieve heading info from
        if ((oDataPage.oDict) && (oDataPage.oDict["columns"])) {
            oFieldNumber = eval("oDataPage.oDict['" + sFieldNumber + "']");
            argI = oFieldNumber["label"];
        } else {
            argI = arguments[i];
        }
        // Alignment all depends on the align array
        var sAlign = false;
        if ((oFieldNumber) && (oFieldNumber["align"])) sAlign = oFieldNumber["align"];
        switch (sAlign) {
            case "left":
                sListData += " align='left'";
                break;
            case "right":
                sListData += " align='right'";
                break;
            case "center":
            case "middle":
                sListData += " align='center'";
                break;
            case "justify":
                sListData += " align='justify'";
                break;
            default:
                charA = argI.charAt(0);
                charZ = argI.charAt(argI.length-1);
                // Check for align indicators with field heading string
                if (charA == " ") {
                    if (charZ == " ") { // centre the title --  special case
                        sListData += " align='center'";
                    } else {            // right-align the title
                        if (argI.toString().indexOf("Date") != -1) {
                            sListData += " align='right'";
                        } else {
                            sListData += " align='" + ((argI == " Staff Number") ? "center'" : "right'");
                        }
                    }
                }
                break;
        }
        sListData += (">" + ((argI == " ") ? "&nbsp;" : argI) + "</td>");
    }
    // Make the header look good by placing a table cell at the end
    // 14900 - One step workflow
    if (sArguments == "Workflow" && bUseHoldingStage) {
        sListData += "<td class='Headings'>&nbsp;</td>"
    }
    sListData += "</tr>";
    return;
}   

// *********************************************************************
// 9091 Set row style on mouseover
function listSetRowActive(oRow) {
    oRow.style.background = hHighlight;
    return;
}

// *********************************************************************
// 9091 Set row style on mouseup
// 9153 Allow for different colours, depending on bAlternate being passed in.
function listSetRowInactive(oRow, bAlternate) {
    if (bAlternate == true) oRow.style.background = hAlternate;
    else if (bAlternate == false) oRow.style.background = hVertBG;
    else oRow.style.background = hWindowBG;
    return;
}

// *********************************************************************
function listStaffClick(iRadioSelected,sName) {
    iListSelected = iRadioSelected;
    var oRadioButton = oDataPage.document.getElementById(sName);
    if (oRadioButton) {
        oRadioButton.checked = true;
        sEmpNo = sHoldEmpNo = validCode(oRadioButton.value);
        sEmpSurInit = sHoldEmpSurInit = validTranslation(oRadioButton.value);
        menuManSet();
        if (sManPage != "") listBackSelect(sManPage); 
    }
    return;
}

// *********************************************************************
function listRadioClick(iRadioSelected,sName) {
    iListSelected = iRadioSelected;
    var oRadioButton = oDataPage.document.getElementById(sName);
    if (oRadioButton) {
        oRadioButton.checked = true;
    }
    return;
}

// *********************************************************************
function listUtilityClick(iRadioSelected,sName) {
    iListSelected = iRadioSelected;
    var oRadioButton = oDataPage.document.getElementById(sName);
    if (oRadioButton) {
        oRadioButton.checked = true;
        oDataPage.setKeyValues();
    }
    return;
}

// *********************************************************************
// 014171: Workflow checkbox introduced
function listRowClick(evt,sZoomPage) {
    var oElementClicked, sEventId;
    // IE uses evt.srcElement, every other browser uses evt.target
    if (!evt.srcElement) oElementClicked = evt.target;
    else oElementClicked = evt.srcElement;
    sEventId = oElementClicked.id;
    // The workflow checkbox has been clicked, so we don't want to drilldown...
    if ((sEventId) && (sEventId != "") && (sEventId.length > 7) && (sEventId.toLowerCase().substr(0,8) == "workflow")) {
		return true;
    } else {
        listDrillDownSelect(sZoomPage);
    }
    return;
}

// *********************************************************************
// ZBG 9040: Enable Administrator Profile and Link View Type
// 013717: Change the url link.
// 013827: Split Links and Email Addresses from Favourites
// DFR 100057: Special handling added for IE6 click event
function listSetRowHref(oRow, bListItem) {
    var sHtml = "";
    switch (oRow["i_view"]) {
        case "true":
        case "workflow":
            sHtml += " href='javascript:void(0);' onClick='oGlob.iListSelected=" + oRow["rowCounter"] + ";oGlob.listRowClick(event,\"" + oRow["zoomPage"] + "\");" + (is.ie6 ? "if (event.srcElement.tagName != \"INPUT\") return false;" : "") + "'";
            break;
        case "click":
            sHtml += " href='javascript:void(0);' onClick='oGlob.iListSelected=" + oRow["rowCounter"] + ";oGlob.listClickSelect(\"" + oRow["zoomPage"] + "\");return false;'";
            break;
        case "open":
            sHtml += " href='javascript:void(0);' onClick='oGlob.listOpenViewSelect(\"" + oRow["zoomPage"] + "\", \"" + oRow["fr1fileid"] + "\"); oGlob.iListSelected=" + oRow["rowCounter"] + "; return false;' ";
            break;
        case "mail":
            if (bListItem) {
                sHtml += " href=mailto:'" + oRow["emladdress"] + "' alt='" + oRow["emldesc"] + "'"; 
            } else {
                sHtml += " href='javascript:void(0);' onClick='oGlob.iListSelected=" + oRow["rowCounter"] + ";oGlob.listDrillDownSelect(\"" + oRow["zoomPage"] + "\");return false;'";
            }
            break;
        case "favourites":
            if (bListItem) {
                sHtml += " href='" + oRow["favlink"] + "' alt='" + oRow["favdesc"] + "' target='_blank'"; 
            } else {
                sHtml += " href='javascript:void(0);' onClick='oGlob.iListSelected=" + oRow["rowCounter"] + ";oGlob.listDrillDownSelect(\"" + oRow["zoomPage"] + "\");return false;'";
            }
            break;
        case "link":
            if (bListItem) {
                sHtml += " href='" + oRow["lnklink"] + "' alt='" + oRow["lnkdesc"] + "' target='_blank'"; 
            } else {
                sHtml += " href='javascript:void(0);' onClick='oGlob.iListSelected=" + oRow["rowCounter"] + ";oGlob.listDrillDownSelect(\"" + oRow["zoomPage"] + "\");return false;'";
            }
            break;
        case "generate":
            if (bListItem) {
                sHtml += " href='javascript:void(0);' onClick='oGlob.iListSelected=" + oRow["rowCounter"] + ";generateClick();return true;'";
            } else {
                sHtml += " href='javascript:void(0);' onClick='oGlob.iListSelected=" + oRow["rowCounter"] + ";oGlob.listDrillDownSelect(\"" + oRow["zoomPage"] + "\");return false;'";
            }
            break;
        case "data":
        case "staff":
        case "clerical":
            sHtml += " href='javascript:void(0);' onClick='oGlob.listStaffClick(" + oRow["rowCounter"] + ",\"" + oRow["i_view"] + iCurrDiv + oRow["rowCounter"] + "\");return true;'";
            break;
        case "radio":
        case "select":
            sHtml += " href='javascript:void(0);' onClick='oGlob.listRadioClick(" + oRow["rowCounter"] + ",\"" + oRow["i_view"] + iCurrDiv + oRow["rowCounter"] + "\");return true;'";
            break;
        case "utility":
            sHtml += " href='javascript:void(0);' onClick='oGlob.listUtilityClick(" + oRow["rowCounter"] + ",\"" + oRow["i_view"] + iCurrDiv + oRow["rowCounter"] + "\");return true;'";
            break;
    }
    return sHtml;
}

// *********************************************************************
function listSetRowImage(oRow, sImage) {
    // 008676 call loadPageImage() if image pre-load is required
    if (!aImageArray[sImage]) loadPageImage(sImage); 
    var sHtml = "onMouseOver='locnImageList(\"dn\",\"" + sImage  + iCurrDiv + oRow["rowCounter"] +"\",\"" + ((oDataPage.oDict["drill"].tooltip) ? oDataPage.oDict["drill"].tooltip : "Click for action using these details") + "\");return true;' ";
    sHtml += "onMouseOut='locnImageList(\"up\",\"" + sImage  + iCurrDiv + oRow["rowCounter"] + "\",\"\");return true;'>";
    sHtml += "<img name='" + sImage  + iCurrDiv + oRow["rowCounter"] + "' src='" + loadPageResource("button") +  sImage + "_up.png' border='0' width='11' height='11' alt='" + ((oDataPage.oDict["drill"].tooltip) ? oDataPage.oDict["drill"].tooltip : "Click for action using these details") + "'>";
    return sHtml;
}

// *********************************************************************
function listRowsCreate(divObj, oRow) {
    var sFieldNumber, oFieldNumber;
    // Load up the string that contains the html
    sListData += "<tr";
    // 009091 Set mouse over for row if required
    if ((oDataPage.oDict["drill"]) && (oDataPage.oDict["drill"].labeltext == "Block")) {
        sListData += " style=";
        if ((oRow["rowCounter"] % 2) == 1) sListData += "'background:" + hAlternate + ";cursor:hand;' ";
        else sListData += "'cursor:hand;' ";
        sListData += "onMouseOver='oGlob.listSetRowActive(this);return true;' onMouseOut='oGlob.listSetRowInactive(this" + (((oRow["rowCounter"] % 2) == 1) ? ",true" : "") + ");return true;'";
        switch (oRow["i_view"]) {
            case "mail":
            case "link":
            case "generate":
            case "favourites":
                break;
            default:
                sListData += listSetRowHref(oRow);
                break;
        }
    } else {
        if ((oRow["rowCounter"] % 2) == 1) sListData += " style='background:" + hAlternate + ";' ";
    }
    sListData += ">";
    // Set the left most column for which type we require                   
    switch (oRow["i_view"]) {
        // True Drill Down
        case "true":
        case "click":
        // Workflow is drill down here and a checkbox at the end of the line
        case "workflow":
            sListData += "<td id='" + oRow["i_view"]  + iCurrDiv + oRow["rowCounter"] + "' align='center' width='5%'";
            if ((oDataPage.oDict) && (oDataPage.oDict["drill"])) {
                sListData += "><a class='HTMLLabel'" + listSetRowHref(oRow) + listSetRowImage(oRow,"view") + "</a>";
            } else {
                sListData += " height='11'>&nbsp;";
            }
            sListData += "</td>";
            break;

        // Link Facility
        case "mail":
        case "link":
        case "generate":
        case "favourites":
            sListData += "<td id='" + oRow["i_view"]  + iCurrDiv + oRow["rowCounter"] + "' align='center' width='5%'><a "
            if ((oDataPage.oDict) && (oDataPage.oDict["drill"])) sListData += " class='HTMLLabel'";
            if (bDisabledUpdate) {
                sListData += listSetRowHref(oRow, true) + listSetRowImage(oRow,"link");
            } else {
                sListData += listSetRowHref(oRow) + listSetRowImage(oRow,"view");
            }
            sListData += "</a></td>";
            break;

        // Open in New Window Facility
        case "open":
            sListData += "<td id='" + oRow["i_view"]  + iCurrDiv + oRow["rowCounter"] + "' align='center' width='5%'><a "
            if ((oDataPage.oDict) && (oDataPage.oDict["drill"])) sListData += " class='HTMLLabel'";
            sListData += listSetRowHref(oRow) + listSetRowImage(oRow,"open");
            sListData += "</a></td>";
            break;

        // Check Box for Staff Enquiry 
        case "check":
            sListData += "<td align='center' width='5%'><input type='checkbox' class='CheckBox' name='" + oRow["i_view"] + "' id='" + oRow["i_view"] + iCurrDiv + oRow["rowCounter"] + "' title='Click to select' ";
            if (aCheckContainer.length <= 0) {
                aCheckContainer = new Array();
                bCheckLoaded = false;
            }
            if ((aCheckContainer) && (aCheckContainer[oRow["rowCounter"]]) && (aCheckContainer[oRow["rowCounter"]]["checked"])) {
                sListData += "checked ";
            }
            sListData += "onClick='oGlob.aCheckContainer[" + oRow["rowCounter"] + "][\"checked\"]=this.checked; return true;' onFocus='this.blur();'></td>";
            break;

        // Radio Button for Staff List/Data Entry List/Clerical List
        case "data":
        case "staff":
        case "clerical":
            sListData += "<td align='center' width='5%'><input type='radio' name='" + oRow["i_view"] + "' id='" + oRow["i_view"] + iCurrDiv + oRow["rowCounter"] + "' value='";
            // Save the Staff Number and Name depending on which values are in the GTR
            var sTempNo = new String();
            var sTempName = new String();
            switch (oRow["cbr"]) {
                case "wfelst":
                    sTempNo = oRow["wfeempno"].replace("'","\`");
                    sTempName = oRow["wfesurinit"].replace("'","\`");
                    break;
                case "detlst":
                    sTempNo = oRow["detnumber"].replace("'","\`");
                    sTempName = oRow["detsurname"].replace("'","\`");
                    break;
            }
            sListData += sTempNo + cSeparator + sTempName + "'" + listSetRowHref(oRow);
            // Check the radio button if this element in the list array is equal to the saved staff number
            sListData += (((sTempNo == sEmpNo) ? " checked" : "") + "></td>");
            break;

        // Radio Button for Pay History and View Reports
        case "radio":
            sListData += "<td align='center' width='5%'><input type='radio' name='" + oRow["i_view"] + "' id='" + oRow["i_view"]  + iCurrDiv + oRow["rowCounter"] + "'";
            sListData += listSetRowHref(oRow);
            sListData += (((oRow["rowCounter"] == 0) ? " checked" : "") + "></td>");
            break;

        // Radio Button for Select Pop-Up Window - Enquiries Only
        case "select":
            sListData += "<td align='center' width='5%'><input type='radio' name='" + oRow["i_view"] + "' id='" + oRow["i_view"]  + iCurrDiv + oRow["rowCounter"] + "'";
            sListData += listSetRowHref(oRow);
            var bListFound = false;
            var sListValue = "";
            // 010408 - ensure null value is not referenced
            for (var i=0; i<aListSelected.length; i++) {
                sFieldNumber = "field" + (((i+1) < 10) ? "0" : "") + (i+1);
                eval("if (dataFrame." + aListSelected[i] + ") sListValue = dataFrame." + aListSelected[i] + ".value");
                if (oRow[oRow[sFieldNumber]] == sListValue) bListFound = true;
                else bListFound = false;
            }
            sListData += (((bListFound) ? " checked" : "") + "></td>");
            break;

        // 009403 - Special radio button for Utility pages 
        case "utility":
            sListData += "<td align='center' width='5%'><input type='radio' name='" + oRow["i_view"] + "' id='" + oRow["i_view"]  + iCurrDiv + oRow["rowCounter"] + "'";
            sListData += listSetRowHref(oRow);
            if (oRow["i_checked"]) sListData += (oRow["rowCounter"] == oRow["i_checked"]) ? " checked" : "";
            else sListData += (oRow["rowCounter"] == 0) ? " checked" : "";
            sListData += "></td>";
            break;

        // No Column
        case "NoCol":
            break;

        // Blank Column
        default:
            sListData += "<td align='center' width='5%' height='11'>&nbsp;</td>";
            break;
    }
    // Write data - depending of the method being used
    if ((oDataPage.oDict) && (oDataPage.oDict["columns"])) {
        if (isNaN(parseInt(oDataPage.oDict["columns"]["label"]))) alert("Error: Remember to set columns value in the configuration file for the current list page.");
        else iColumnCount = oDataPage.oDict["columns"]["label"];
    } else {
        if (isNaN(parseInt(oRow["i_maxcols"]))) {
            if (gDebug) alert("Error: Remember to set i_maxcols value in the current list page.");
        } else {
            iColumnCount = parseInt(oRow["i_maxcols"]) + 1;
        }
    }
    // Scan through the columns building up the complete row
    for (var i=1; i<=iColumnCount; i++) {
        sFieldNumber = "field" + ((i < 10) ? "0" : "") + i;
        if ((oDataPage.oDict) && (oDataPage.oDict["columns"])) {
            oFieldNumber = eval("oDataPage.oDict['" + sFieldNumber + "']");
            if (oFieldNumber["translation"]) {
                var sFieldTrans = "i_" + oFieldNumber["datadict"];
                oRow[sFieldNumber] = sFieldTrans;
                oRow[sFieldTrans] = getGTRField(oRow,oFieldNumber["datadict"] + ".trn");
            }
        }
        sListData += "<td class='Prompt' ";
        // Align is set within config.js, otherwise,
        // 
        // Types of list items are as follows;
        // 
        // Staff Number - centred
        // Positive Number - right hand justified
        // Negative Number - right hand justified
        // Time - right hand justified
        // Date - right hand justified
        // Text (default) - left hand justified
        //
        var sName = oRow[sFieldNumber];
        var sItem = "";
        if (oRow[oRow[sFieldNumber]]) {
            sItem = oRow[oRow[sFieldNumber]];
        } else {
            if (gDebug) alert("Error: " + sName + " data dictionary has no associated value in the current list page.");
        }
        var iCount = oRow["rowCounter"];
        var sType = "text";
        // First column always left justified
        if ((sFieldNumber != "field01")) {
            // 009505 Reorganise so wfephoto may be caught easily
            switch (sName) {
                case "versiontext":
                    sType = "text";
                    break;
                case "i_approve":
                case "i_decline":
                case "i_reject":
                case "i_noaction":
                    sType = "sheet";
                    break;
                case "wfephoto":
                    sType = "photo";
                    break;
                default:
                    if (sItem != "") {
                        // Align attribute set.
                        var sAlign = false;
                        if ((oFieldNumber) && (oFieldNumber["align"])) sAlign = oFieldNumber["align"];
                        if ((oDataPage.oDict) && (sAlign)) {
                            if (isNaN(sItem) && (sItem.indexOf("-") != -1)) sType = "nnum";
                            switch (oFieldNumber["align"]) {
                                case "right":
                                    sListData += "align='right' ";
                                    break;
                                case "center":
                                case "middle":
                                    sListData += "align='center' ";
                                    break;
                                case "justify":
                                    sListData += "align='justify' ";
                                    break;
                                default:
                                    sListData += "align='left' ";
                                    break;
                            }
                        } else {
                            if (sItem.charAt(0) == " ") sType = "right";
                            if (isFinite(sItem) || (sItem.indexOf("$") != -1) || (sItem.indexOf("%") != -1)) sType = "pnum";
                            if ((sName.indexOf("detnumber") != -1) || (sName.indexOf("wfeempno") != -1)) sType = "enum";
                            if (isNaN(sItem) && (sItem.indexOf("-") != -1) && (sType == "pnum")) sType = "nnum";
                            if (isNaN(sItem) && ((sName.toLowerCase().indexOf("date") != -1) || (validIsDate(sItem)))) sType = "date";
                            if (isNaN(sItem) && (sItem.indexOf(":") != -1)) sType = "i_time";
                        }
                    }
                    break;
            }
        }
        // Having decided on the type do the work needed to display data correctly
        switch (sType) {
            case "date":
            case "pnum":
            case "right":
                sListData += "align='" + ((sName == "pdtcode") ? "left" : "right") + "'";
                break;

            case "enum":
                sListData += "align='center'";
                break;

            case "nnum":
                var theRest = sItem.substring(0,sItem.length-1);
                if (isFinite(theRest)) {
                    sListData += "style='color:" + hHighlight + ";'";
                    if ((!oDataPage.oDict) || (!oDataPage.oDict["columns"])) sListData += " align='right'";
                    var iLeading = theRest.lastIndexOf(" ");
                    sItem = "-" + ((iLeading != -1) ? theRest.substr(iLeading+1) : theRest);
                }
                break;

            case "i_time":
                var colonPos = sItem.indexOf(":");
                if ((isFinite(sItem.substring(0,colonPos))) && (isFinite(sItem.substring((colonPos+1),sItem.length)))) {
                    sListData += " align='right'";
                }
                break;

            case "photo":
                sListData += "align='center' width='5%'>";
                if (sItem == "Y") {
                    sListData += "<a href='javascript:void(0);' ";
                    sListData += "onClick='oGlob.sEmpNo=\"" + oRow["wfeempno"] + "\"; oGlob.listOpenViewSelect(\"eddetvew\"); return false;' ";
                    sListData += "onMouseOver='locnImageList(\"dn\", \"photo";
                    sListData += oRow["rowCounter"];
                    sListData += "\", \"Click to view photo\"); return true;' onMouseOut='locnImageList(\"up\", \"photo";
                    sListData += oRow["rowCounter"];
                    sListData += "\", \"\"); return true;'><img name='photo"; 
                    sListData += oRow["rowCounter"];
                    sListData += "' src='" + loadPageResource("button") + "photo_up.png' border='0' width='20' height='20' alt='Click to view photo'></a>";
                } else {
                    sListData += "&nbsp;";
                }
                break;

            case "sheet":
                switch (sKskType) {
                    case "RCL":
                        sListData += "align='center'><input type='radio' name='sheet" + iCount + "' value='";
                        switch (sName) {
                            case "i_approve":
                                sListData += "Y";
                                break;
                            case "i_decline":
                                sListData += "N"; 
                                break;
                            case "i_noaction":
                                sListData += "P"; 
                                break;
                        }
                        sListData += "' onClick='oGlob.aListContainer[" + iCount + "][\"ftastatus\"]=this.value; return true;'";
                        sListData += (sName == "i_noaction") ? " checked" : "";
                        break;
                        
                    case "STG":
                    case "SPI":
                    case "TXA":
                        if ((sDataPage.indexOf("epktstxa") != -1) && (sName == "i_approve" || sName == "i_decline")) {
                            sListData += "align='center'><input type='radio' name='sheet" + iCount + "' disabled value='" + sName + "' ";
                            sListData += (sItem) ? " checked" : "";
                        } else {
                            sListData += "align='center'><input type='radio' name='sheet" + iCount + "' value='";
                            switch (sName) {
                                case "i_approve":
                                    sListData += "A"; 
                                    break;
                                case "i_decline":
                                    sListData += "D"; 
                                    break;
                                case "i_reject":
                                    sListData += "R"; 
                                    break;
                                case "i_noaction":
                                    sListData += "U"; 
                                    break;
                            }
                            sListData += "' onClick='oGlob.aListContainer[" + iCount + "][\"ktastatus\"]=this.value; return true;'";
                            sListData += (sItem) ? " checked" : "";
                            break;
                    }
                }
                break;
        }
        // Set the correct tags to complete the html
        switch (sType) {
            case "sheet":
                sListData += "></td>";
                break;
            case "photo":
                sListData += "</td>";
                break;
            default: 
                sListData += ">";
                switch (oRow["i_view"]) {
                    case "mail":
                    case "link":
                    case "generate":
                    case "favourites":
                        sListData += "<a";
                        if ((oDataPage.oDict) && (oDataPage.oDict["drill"])) sListData += " class='HTMLLabel'";
                        sListData += listSetRowHref(oRow, true) + ">";
                        sListData += ((sItem == "") ? "&nbsp;" : sItem) + "</a>";
                        break;
                    default:
                        if ((oDataPage.oDict["drill"]) && (oDataPage.oDict["drill"].labeltext == "Block")) {
                            sListData += "<a class='HTMLLabel' " + listSetRowHref(oRow, true) + ">";
                            sListData += ((sItem == "") ? "&nbsp;" : sItem) + "</a>";
                        } else {
                            sListData += ((sItem == "") ? "&nbsp;" : sItem);
                        }
                        break;
                }
                sListData += "</td>";
                break;
        }
    }
	// 13668 The following is for when there is a selection column eg Drill down at the beginning, and another 
	//       selection box (eg for submission) at the end of the line.
    switch (oRow["i_view"]) {
        // Check Box at the end of the line for all workflow application lists
        // 14900 - One step workflow
        case "workflow":
            if (bUseHoldingStage) {
                sListData += "<td align='center' width='5%'><input type='checkbox' class='CheckBox' name='" + oRow["i_view"] + "' id='" + oRow["i_view"] + oRow["rowCounter"] + "' title='Click to select' ";
                if (aCheckContainer.length <= 0) {
                    aCheckContainer = new Array();
                    bCheckLoaded = false;
                }
                if ((aCheckContainer) && (aCheckContainer[oRow["rowCounter"]]) && (aCheckContainer[oRow["rowCounter"]]["checked"])) {
                    sListData += "checked ";
                }
                sListData += "onClick='oGlob.aCheckContainer[" + oRow["rowCounter"] + "][\"checked\"]=this.checked; return true;' onFocus='this.blur();'></td>";
                iColumnCount += 1;
            }
            break;
	}
	sListData += "</tr>";
    return oRow;
}

// *********************************************************************
function listEmptyCreate(divObj, gtrContainer) {
    bListEmpty = ((getGTRField(gtrContainer,"warning01").substr(0,6) == "BRE268") || (getGTRField(gtrContainer,"info01").substr(0,6) == "BRE267")) ? true : false;
    if (divObj) {
        if (bListEmpty) {
            sListData += "</table><br><br><br>";
            sListData += "<div align='center'><img src='" + loadPageResource("misc") + "empty.png' border='0' alt=''></div>";
            // Wipe out the buttons if the list is empty
            divObj.buttons = new Array();
        } else {
            iList--;
            sListData += "</table>";
        }
        divObj.innerHTML = sListData;
        // Debug Window
        if (gDHTMLDebug) loadDebugPage("listEmptyCreate:\n" + sListData + "\n");
    }
    // Return flag indicating the file is empty 
    return bListEmpty;
}

// *********************************************************************
function listEmptyTimesheet(divObj, gtrContainer) {
    var sHtml = "";
    bListEmpty = ((getGTRField(gtrContainer,"warning01").substr(0,6) == "BRE268") || (getGTRField(gtrContainer,"info01").substr(0,6) == "BRE267")) ? true : false;
    if (divObj) {
        if (bListEmpty) {
            sHtml += "</table><br><br><br>";
            sHtml += "<div align='center'><img src='" + loadPageResource("misc") + "empty.png' border='0' alt=''></div>";
            // Wipe out the buttons if the list is empty
            divObj.buttons = new Array();
            divObj.innerHTML = sHtml;
        }
        // Debug Window
        if (gDHTMLDebug) loadDebugPage("listEmptyTimesheet:\n" + sHtml + "\n");
    }
    // Return flag indicating the file is empty 
    return bListEmpty;
}

// *********************************************************************
//8972 insert comment text to a list page
function listCommentCreate() {
    var sHtml = "<table border='0' width='100%' cellpadding='0' cellspacing='0'>";
    sHtml += hdftFieldCreate("comment","i_comment",null,0,4,"Comment"); 
    sHtml += "</table>";
    return(sHtml);
}

// *********************************************************************
// SQA20529008
function listSetDataPage() {
    oDataPage = dataFrame;
    sDataPage = dataFrame.location.href;
    return;
}

// *********************************************************************
// 010119 - Set the codes and translations from the selection window
// 013954 - Allow different field to be picked up as the translation,
// eg: sDict = "pdtnumber" and sTranslation = "pdttitle" 
function listLoadSelection(sDict,sTranslation) {
    if (aListContainer.length > 0) {
        // Find the file validated field on the data page
        var oListSelected = eval("dataFrame." + aListSelected[0]);
        if (oListSelected) oListSelected.value = aListContainer[iListSelected][sDict];
        // Load up the translation if required
        oListSelected = eval("dataFrame.document.detForm." + oListSelected.name + "_trn");
        if (oListSelected) {
            if (sTranslation == null) sTranslation = sDict + ".trn";
            oListSelected.value = aListContainer[iListSelected][sTranslation];
        }
        bModified = true;
    }
    listCloseSelect();
    return;
}

// *********************************************************************
// Starts list at top record
// 008997 Altered to allow the gtr type to be specified
function listTopSelect(sGtrType) {
    // Ensure completion is reset for the top button
    iSuccessCount = 0;
    // Set the oDataPage Object back to be the dataFrame
    if ((oVewSelWin) && (oVewSelWin.closed)) listSetDataPage();
    // Perform separate function if not in ??detlst or ??wfelst
    switch (oDataPage.oMenu.mode) {
        case "sys":
            sSelectKey = sSelectKey1 = "";
            break;
        default:
            if (oDataPage.oSearch) {
                var sTempPage = loadPageCurrent();
                switch (sTempPage) {
                    case "mrdetsel":
                        if (oDataPage.oSearch["detsurname"]) sDetNo = sDetSurname = "";
                        break;
                    case sStaffPage:
                        iEmpSeqNo = iHoldEmpSeqNo = 0;
                        sEmpNo = sHoldEmpNo = sEmpSurInit = sHoldEmpSurInit = "";
                        break;
                    default:
                        if (sGtrType == "wfeadd") {
                            iEmpSeqNo = iHoldEmpSeqNo = 0;
                            sEmpNo = sHoldEmpNo = sEmpSurInit = sHoldEmpSurInit = "";
                        }
                        break;
                }
            }
            break;
    }
    // Delete the list div and send the GTR via the original page
    listDivsDelete();
    oDataPage.sendGTR((sGtrType ? sGtrType : true));
    return; 
}

// *********************************************************************
function listPreviousSelect() {
    // Ensure completion is reset for the previous page button
    iSuccessCount = 0;
    // Set the oDataPage Object back to be the dataFrame
    if ((oVewSelWin) && (oVewSelWin.closed)) listSetDataPage();
    // Clear the buttons
    oDataPage.document.getElementById("buttDiv").innerHTML = "";
    // Set current div, then hide unneeded divs & show current
    iCurrDiv--;
    // Hide the div we have just left and then turn on the previous one
    listDivsHide(iCurrDiv);
    oDataPage.document.getElementById("dataDiv"+iCurrDiv).style.visibility = "visible";
    // Reset the buttons
    oDataPage.document.getElementById("buttDiv").innerHTML = hdftButtonLists(iCurrDiv);
    return;
}

// *********************************************************************
// Checks to see if there is a previously created div when next page is called
// Uses oGlobal var 'iCurrDiv' - which should point to the div to become visible
function listNextSelect() {
    // Ensure completion is reset for the next page button
    iSuccessCount = 0;
    // Set iCurrDiv to div we want to display
    iCurrDiv++;
    //8858 Disable the 'next' button
    loadDisableButton("next");
    // Set the oDataPage Object back to be the dataFrame
    if ((oVewSelWin) && (oVewSelWin.closed)) listSetDataPage();
    // Check for previously created divs
    if (iCurrDiv == aDivs.length) {
        // none, so send off new gtr
        oDataPage.nextPageGTR();
    } else {
        // if so, use a prev. div
        // First clear the buttons
        oDataPage.document.getElementById("buttDiv").innerHTML = "";
        // Show the correct div
        listDivsHide(iCurrDiv);
        oDataPage.document.getElementById("dataDiv"+iCurrDiv).style.visibility = "visible";
        // Reset the buttons
        oDataPage.document.getElementById("buttDiv").innerHTML = hdftButtonLists(iCurrDiv);
    }
    return;
}

// *********************************************************************
function listBackSelect(sToPage) {
    // Close Time Window
    if ((oTimeWin) && (oTimeWin != null) && (!oTimeWin.closed)) oTimeWin.close();
    // Close Calendar Window
    if ((oCalWin) && (oCalWin != null) && (!oCalWin.closed)) oCalWin.close();
    // Close View Window
    if ((oVewSelWin) && (oVewSelWin != null) && (!oVewSelWin.closed)) oVewSelWin.close();
    // Set the oDataPage Object back to be the dataFrame
    if ((oVewSelWin) && (oVewSelWin.closed)) listSetDataPage();
    // 010064 - Show a confirm message if required, then move to the selected page
    if (loadPageConfirm()) oDataPage.updatClick();
    else {
        // Set drill mode to false to indicate adding details
        bDrillMode = false;
        // Now all things are sorted we can commit to going back
        oDataPage.location.replace(loadPagePath(sToPage));
    }
    return;
}

// *********************************************************************
function listFhistSelect(sToPage) {
    // Ensure completion is reset for the top button
    iSuccessCount = 0;
    // Set the oDataPage Object back to be the dataFrame
    if ((oVewSelWin) && (oVewSelWin.closed)) listSetDataPage();
    // Clear the buttons
    oDataPage.document.getElementById("buttDiv").innerHTML = "";
    // Show the correct div
    listDivsHide(iCurrDiv);
    // Reset the buttons
    oDataPage.document.getElementById("buttDiv").innerHTML = hdftButtonLists(iCurrDiv);
    // Show opposite setting
    bFullHist = (bFullHist ? false : true);
    // Move to the selected page
    oDataPage.location.replace(loadPagePath(sToPage));
    return;
}

// *********************************************************************
function listManViewSelect(sToPage) {
    // Ensure completion is reset for the top button
    iSuccessCount = 0;
    // Set the oDataPage Object back to be the dataFrame
    if ((oVewSelWin) && (oVewSelWin.closed)) listSetDataPage();
    // Clear the buttons
    oDataPage.document.getElementById("buttDiv").innerHTML = "";
    // Show the correct div
    listDivsHide(iCurrDiv);
    // Reset the buttons
    oDataPage.document.getElementById("buttDiv").innerHTML = hdftButtonLists(iCurrDiv);
    // Show opposite setting
    bKioskFav = (bKioskFav ? false : true);
    // Move to the selected page
    oDataPage.location.replace(loadPagePath(sToPage));
    return;
}

// *********************************************************************
function listPageSelect(sToPage) {
    // Set the oDataPage Object back to be the dataFrame
    if ((oVewSelWin) && (oVewSelWin.closed)) listSetDataPage();
    // 010064 - Show a confirm message if required, then move to the selected page
    if (loadPageConfirm()) oDataPage.updatClick();
    else oDataPage.location.replace(loadPagePath(sToPage));
    return;
}

// *********************************************************************
function listPageLink(sToPage) {
    // Open to view the selected page
    if (sToPage) window.parent.open(sToPage);
    return;
}

// *********************************************************************
function listAddSelect(sToPage) {
    // Set the oDataPage Object back to be the dataFrame
    if ((oVewSelWin) && (oVewSelWin.closed)) listSetDataPage();
    // Set drill mode to false to indicate adding details
    bDrillMode = false;
    // Move to the selected page
    oDataPage.location.replace(loadPagePath(sToPage));
    return;
}

// *********************************************************************
// sToPage = oRow["zoomPage"]
function listClickSelect(sToPage) {
    // Set the oDataPage Object back to be the dataFrame
    if ((oVewSelWin) && (oVewSelWin.closed)) listSetDataPage();
    // Load up the Staff Number if it's present
    if (aListContainer[iListSelected]["wfeempno"]) sEmpNo = sHoldEmpNo = aListContainer[iListSelected]["wfeempno"];
    if (aListContainer[iListSelected]["wfesurinit"]) sEmpSurInit = sHoldEmpSurInit = aListContainer[iListSelected]["wfesurinit"];
    // Move to the selected page
    oDataPage.location.replace(loadPagePath(sToPage));
    return;
}

// *********************************************************************
// sToPage = oRow["zoomPage"]
function listDrillDownSelect(sToPage) {
    // Set the oDataPage Object back to be the dataFrame
    if ((oVewSelWin) && (oVewSelWin.closed)) listSetDataPage();
    // Set drill mode to true to indicate magnifying glass clicked
    bDrillMode = true;
    // 008009: Load up the Staff Number if it's present
    if (aListContainer[iListSelected]["detnumber"]) aDrillDownData["detnumber"] = aListContainer[iListSelected]["detnumber"];
    // Move to the selected page
    oDataPage.location.replace(loadPagePath(sToPage));
    return;
}

// *********************************************************************
// sToPage = oRow["zoomPage"], iFileId = oRow["fr1fileid"]
function listOpenViewSelect(sToPage,iFileId) {
    // 010537 - Change the height and width if entered.
    var sWindowResize = loadWindowResize(sToPage);
    // Open to view the selected page
    oVewSelWin = window.parent.open("",iFileId,sWindowResize,true);
    // Load the selected page
    oVewSelWin.location.replace(loadPagePath(sToPage));
    return;
}

// *********************************************************************
function listCloseViewSelect() {
    // 010064 - Show a confirm message if required, then move to the selected page
    if (loadPageConfirm()) oDataPage.updatClick();
    else {
        // Close the view of the selected page
        if ((oVewSelWin) && (oVewSelWin != null) && (!oVewSelWin.closed)) oVewSelWin.close();
        // Set the oDataPage Object back to be the dataFrame
        listSetDataPage();
    }
    return;
}

// *********************************************************************
function listBackViewSelect(sToPage) {
    // 010064 - Show a confirm message if required, then move to the selected page
    if (loadPageConfirm()) oDataPage.updatClick();
    else {
        // Move to the selected page
        if (oDataPage == dataFrame) {
            if ((oVewSelWin) && (oVewSelWin != null) && (!oVewSelWin.closed)) oVewSelWin.close();
        } else {
            oVewSelWin.location.replace(loadPagePath(sToPage));
        }
        // Set the oDataPage Object back to be the dataFrame
        listSetDataPage();
    }
    return;
}

// *********************************************************************
// sToPage = oRow["zoomPage"], iFileId = oRow["favurlkink"]
function listOpenSelect(sToPage, iFileId) {
    // 010537 - Change the height and width if entered.
    var sWindowResize = loadWindowResize(sToPage);
    // Open to view the selected page
    oVewSelWin = window.parent.open("",iFileId,sWindowResize,true);
    // Load the selected page
    oVewSelWin.location.replace(loadPagePath(sToPage));
    // 9456 - Set the name of the page to call the new window.
    sCallPage = loadPageCurrent();
    return;
}

// *********************************************************************
function listCloseSelect(sToPage) {
    // Close the view of the selected page
    if ((oVewSelWin) && (oVewSelWin != null) && (!oVewSelWin.closed)) oVewSelWin.close();
    // Set the oDataPage Object back to be the dataFrame
    listSetDataPage();
    // Turn off the number that was selected
    iListSelected = "NaN";
    // 9456 - Re-load the dataFrame once the window has been closed. 
    if (sToPage) {
        oDataPage.location.replace(loadPagePath(sToPage));
    }
    return;
}

// *********************************************************************
// 009345 - print function for report frames moved into scripts
// ZBG 9000: If not referencing reportFrame call the printClick function
function listPrintSelect() {
    if (oDataPage.reportFrame) {
        oDataPage.reportFrame.focus();
        if (oDataPage.reportFrame.print) oDataPage.reportFrame.print();
        else alert("Select 'File > Print' from\nyour browser to print this page.");
    } else {
        oDataPage.printClick();
    }
    return;
}

// *********************************************************************
function listCheckFound() {
    for (var i in aCheckContainer) {
        if (aCheckContainer[i]["checked"]) return true;
    }
    return false;
}

// *********************************************************************
// Lists the 'visiDiv' data divs 
function listDivs(sDiv) {
    newDiv = oDataPage.document.createElement("div");
    newDiv.setAttribute("id","dataDiv" + iCurrDiv);
    var detForm = oDataPage.document.getElementById("detForm");
    //add new div to the existing form
    detForm.appendChild(newDiv);
    listDivsConfigure(newDiv);
    listDivsHide(iCurrDiv);
    return;
}

// *********************************************************************
// Deletes all the data divs
// 8997 - Problem caused by aDivs being overwritten rectified.
// aAllDivs contains all references to divs within the document. The dataDivs are 
// retrieved and stored in aDivsToRemove, and from there can be removed as per usual.
function listDivsDelete() {
    var aDivsToRemove = new Array();
    var aAllDivs = oDataPage.document.getElementsByTagName("div");
    for (var i =0; i < aAllDivs.length; i++) {
        var sDivId = aAllDivs[i].id;
        if ((sDivId.indexOf("dataDiv") != -1) && (sDivId != "dataDiv0")) aDivsToRemove[sDivId] = sDivId;
    }
    // 010063 - fixed for all supported browsers
    for (var i in aDivsToRemove) {
        var oDiv = oDataPage.document.getElementById(aDivsToRemove[i]);
        if ((oDiv) && (oDiv.parentNode)) oDiv.parentNode.removeChild(oDiv);
    }
    aDivs.length = 1;
    iCurrDiv = 0;
    listDivsHide(iCurrDiv);
    return;
}

// *********************************************************************
// Configure new div style settings
// 009014 altered to give better div placement
// 010063 removed unnecessary mozilla branch
function listDivsConfigure(newDiv) {
    var currDiv = oDataPage.document.getElementById("dataDiv" + (iCurrDiv - 1));
    newDiv = oDataPage.document.getElementById("dataDiv" + iCurrDiv);
    newDiv.style.position = "absolute";
    newDiv.style.visibility = currDiv.style.visibility;
    newDiv.style.zIndex = currDiv.style.zIndex;
    newDiv.style.overflow = currDiv.style.overflow;
    newDiv.style.width = currDiv.style.width;
    newDiv.style.height = currDiv.style.height;
    if (oDataPage == oVewSelWin) newDiv.style.left = 20;
    else newDiv.style.left = currDiv.offsetLeft;
    switch (sKskType) {
        // ReadMe Div 
        case "ZRM":
            newDiv.style.top = "95";
            break;
        // In all other systems 
        default:
            //009014 - offsetTop attribute gives the exact value required for the placement of all divs
            newDiv.style.top = currDiv.offsetTop;
            break;
    }
    return newDiv;
}

// *********************************************************************
// Hides all the data divs except 'visiDiv'
function listDivsHide(iVisibleDiv) {
    var sCheckDiv = new String();
    var oVisibleDiv = new Object();
    var sVisibleDiv = "dataDiv" + iVisibleDiv;
    // Scan through Divs turning off visiblity for all but the right one
    for (var iIndex=0; iIndex<aDivs.length; iIndex++) {
        sCheckDiv = aDivs[iIndex];
        oVisibleDiv = oDataPage.document.getElementById(sCheckDiv);
        if (oVisibleDiv) {
            if (sVisibleDiv != sCheckDiv) oVisibleDiv.style.visibility = "hidden";
            else oVisibleDiv.style.visibility = "visible";
        }
    }
    return;
}

// *********************************************************************
