
// begining of generic code
var x = 0;
var y = 0;

STATUS_OK = 1;
STATUS_DISABLED = 2;
STATUS_HIDDEN = 3;
STATUS_NAPRICES = 4;

PIC_THUMBNAIL = 1;
PIC_PHOTO = 2;
PIC_UPDATE = 3;
PIC_DELTALINE = 4;
PIC_DELTAPHOTO = 5;

var bConfigComplete;
var SeriesID;
var LargeThumbnail;

function GetLeftPos(control) {
    var xPos = 0;

    if (control.offsetParent) {
        xPos = GetLeftPos(control.offsetParent);
    }

    return control.offsetLeft + xPos;
}

function GetTopPos(control) {

    var xPos = 0;

    if (control.offsetParent) {
        xPos = GetTopPos(control.offsetParent);
    }

    return control.offsetTop + xPos;

}
function ShowRelated() {

    //alert("ShowRelated");
    //  add this functionality to the "*" for hidden options - better pop-up  -NN  Jan 20/2003
//    if (document.all) {
//        document.all["RelatedPopup"].innerHTML = Related;
//        if (document.all.RelatedPopup.style.pixelLeft) {
//            document.all.RelatedPopup.style.pixelLeft = GetLeftPos(document.all.RELATEDLINK) - 150;
//        }
//        else {
//            document.all.RelatedPopup.style.left = GetLeftPos(document.all.RELATEDLINK) - 150;
//        }
//        if (document.all.RelatedPopup.style.posTop) {
//            document.all.RelatedPopup.style.posTop = GetTopPos(document.all.RELATEDLINK);
//        }
//        else {
//            document.all.RelatedPopup.style.top = GetTopPos(document.all.RELATEDLINK);
//        }
//        document.all.RelatedPopup.style.pixelWidth = 150;
//        document.all.RelatedPopup.style.visibility = "visible";

//    }
//    else if (document.layers) {
//        var nets = document.layers["RelatedPopup"];
//        nets.document.open();
//        nets.document.write("<table border=1 cellpadding=0 cellspacing=0 BGCOLOR='#FFFFC3'><tr><td valign=top><font color='#000000'>" + text + "</font></td></tr></table>");
//        document.RelatedPopup.left = x - 150;
//        document.RelatedPopup.top = y + 10;
//        nets.visibility = "show";
//        document.close();

//        // the color #FFFFC3

//    }
//    else {
        var RelatedPopup = document.getElementById("RelatedPopup")
        var RelatedLink = document.getElementById("RELATEDLINK")

        RelatedPopup.innerHTML = Related;

        if (RelatedPopup.style.pixelLeft) {
            RelatedPopup.style.pixelLeft = GetLeftPos(RelatedLink) - 190;
        }
        else {
            RelatedPopup.style.left = GetLeftPos(RelatedLink) - 190;
        }
        if (RelatedPopup.style.posTop) {
            RelatedPopup.style.posTop = GetTopPos(RelatedLink);
        }
        else {
            RelatedPopup.style.top = GetTopPos(RelatedLink) - RelatedPopup.style.height;
        }

        RelatedPopup.style.pixelWidth = RelatedPopup.style.width;
        RelatedPopup.style.visibility = "visible";
    //}

    return false;
}


function ShowDocumentsPopup(zInnerHTML, zContainerId, zLinkId, bChildMenu) {

    //alert("ShowRelated");
    //add this functionality to the "*" for hidden options - better pop-up  -NN  Jan 20/2003
    if (document.all) {
        document.all[zContainerId].innerHTML = zInnerHTML;
        var Container = document.all[zContainerId];
        var LinkObj = document.all[zLinkId];
        if (Container.style.pixelLeft) {
            Container.style.pixelLeft = GetLeftPos(LinkObj) - 150;
        }
        else {
            Container.style.left = GetLeftPos(LinkObj) - 150;
        }
        if (Container.style.posTop) {
            Container.style.posTop = GetTopPos(LinkObj);
        }
        else {
            Container.style.top = GetTopPos(LinkObj);
        }
        Container.style.pixelWidth = 150;
        Container.style.visibility = "visible";


    }
    else if (document.layers) {
        var nets = document.layers[zContainerId];
        nets.document.open();
        nets.document.write("<table border=1 cellpadding=0 cellspacing=0 BGCOLOR='#FFFFC3'><tr><td valign=top><font color='#000000'>" + text + "</font></td></tr></table>");
        var TableObj = eval('document.' + zContainerId);
        TableObj.left = x - 150;
        TableObj.top = y + 10;
        nets.visibility = "show";
        document.close();
        // the color #FFFFC3


    }
    else {
        var Container = document.getElementById(zContainerId);
        var LinkObj = document.getElementById(zLinkId);

        Container.innerHTML = zInnerHTML;

        if (Container.style.pixelLeft) {
            Container.style.pixelLeft = GetLeftPos(LinkObj) - 150;

        }
        else {
            Container.style.left = GetLeftPos(LinkObj) - 150;
        }

        if (Container.style.posTop) {
            Container.style.posTop = GetTopPos(LinkObj);
        }
        else {
            Container.style.top = GetTopPos(LinkObj);
        }

        Container.style.pixelWidth = 150;

        Container.style.visibility = "visible";



    }

    if (bChildMenu == true) {
        document.getElementById(zContainerId).style.left = 0 //parseInt(document.getElementById(zContainerId).style.left) / 2 + "px"
        document.getElementById(zContainerId).style.top = 0 //parseInt(document.getElementById(zContainerId).style.top) / 2 + "px"
    }

    return false;
}

function SwapPopupMenus(zOrigionalPopupId, zNewPopupId, zNewPopupContent, zNewPopupParentLinkId, bChildofOrigional) {
    HideDocumentsPopup(zOrigionalPopupId);
    ShowDocumentsPopup(zNewPopupContent, zNewPopupId, zNewPopupParentLinkId, bChildofOrigional);
}

function HideDocumentsPopup(zContainer) {
    try {
        if (document.all) {
            var ContainerObj = eval('document.all.' + zContainer);
            ContainerObj.style.visibility = "hidden";
        }
        else if (document.layers) {
            var nets = eval('document.layers[' + zContainer + ']');
            nets.visibility = "hidden";
            //document.RelatedPopup.visibility = "hidden"; 
        }
        else {
            if (document.getElementById(zContainer)) {
                var ContainerObj = document.getElementById(zContainer);
                ContainerObj.style.visibility = "hidden";
            }
        }
    } catch (e) {
        //alert(e.message)
    }
}

function ShowMaintenanceSheets() {

    //alert("ShowRelated");
    //  add this functionality to the "*" for hidden options - better pop-up  -NN  Jan 20/2003
    if (document.all) {
        document.all["MaintenanceSheets"].innerHTML = Maintenance;
        if (document.all.MaintenanceSheets.style.pixelLeft) {
            document.all.MaintenanceSheets.style.pixelLeft = GetLeftPos(document.all.MAINTENANCELINK) - 150;
        }
        else {
            document.all.MaintenanceSheets.style.left = GetLeftPos(document.all.MAINTENANCELINK) - 150;
        }
        if (document.all.MaintenanceSheets.style.posTop) {
            document.all.MaintenanceSheets.style.posTop = GetTopPos(document.all.MAINTENANCELINK);
        }
        else {
            document.all.MaintenanceSheets.style.top = GetTopPos(document.all.MAINTENANCELINK);
        }
        document.all.MaintenanceSheets.style.pixelWidth = 150;
        document.all.MaintenanceSheets.style.visibility = "visible";

    }
    else if (document.layers) {
        var nets = document.layers["MaintenanceSheets"];
        nets.document.open();
        nets.document.write("<table border=1 cellpadding=0 cellspacing=0 BGCOLOR='#FFFFC3'><tr><td valign=top><font color='#000000'>" + text + "</font></td></tr></table>");
        document.MaintenanceSheets.left = x - 150;
        document.MaintenanceSheets.top = y + 10;
        nets.visibility = "show";
        document.close();
        // the color #FFFFC3

    }
    else {
        var MaintenanceSheets = document.getElementById("MaintenanceSheets")
        var MaintenanceLink = document.getElementById("MAINTENANCELINK")

        MaintenanceSheets.innerHTML = Maintenance;

        if (MaintenanceSheets.style.pixelLeft) {
            MaintenanceSheets.style.pixelLeft = GetLeftPos(MaintenanceLink) - 150;
        }
        else {
            MaintenanceSheets.style.left = GetLeftPos(MaintenanceLink) - 150;
        }
        if (MaintenanceSheets.style.posTop) {
            MaintenanceSheets.style.posTop = GetTopPos(MaintenanceLink);
        }
        else {
            MaintenanceSheets.style.top = GetTopPos(MaintenanceLink);
        }

        MaintenanceSheets.style.pixelWidth = 150;
        MaintenanceSheets.style.visibility = "visible";
    }

    return false;
}

function HideMIWindow(event) {
    try {
        if (document.all) {
            document.all.MaintenanceSheets.style.visibility = "hidden";
        }
        else if (document.layers) {
            var nets = document.layers["MaintenanceSheets"];
            nets.visibility = "hidden";
            //document.RelatedPopup.visibility = "hidden"; 
        }
        else {
            document.getElementById("MaintenanceSheets").style.visibility = "hidden";
        }
    } catch (e) {

    }
}

function ShowSpecSheets() {

    alert("bleh")
    //alert("ShowRelated");
    //  add this functionality to the "*" for hidden options - better pop-up  -NN  Jan 20/2003
    if (document.all) {
        document.all["SpecSheets"].innerHTML = Spec;

        if (document.all.SpecSheets.style.pixelLeft) {
            document.all.SpecSheets.style.pixelLeft = GetLeftPos(document.all.SPECLINK) - 150;
        }
        else {
            document.all.SpecSheets.style.left = GetLeftPos(document.all.SPECLINK) - 150;
        }

        if (document.all.SpecSheets.style.posTop) {
            document.all.SpecSheets.style.posTop = GetTopPos(document.all.SPECLINK);
        }
        else {
            document.all.SpecSheets.style.top = GetTopPos(document.all.SPECLINK);
        }

        document.all.SpecSheets.style.pixelWidth = 150;
        document.all.SpecSheets.style.visibility = "visible";

    }
    else if (document.layers) {
        var nets = document.layers["SpecSheets"];
        nets.document.open();
        nets.document.write("<table border=1 cellpadding=0 cellspacing=0 BGCOLOR='#FFFFC3'><tr><td valign=top><font color='#000000'>" + text + "</font></td></tr></table>");
        document.SpecSheets.left = x - 150;
        document.SpecSheets.top = y + 10;
        nets.visibility = "show";
        document.close();
        // the color #FFFFC3
    }
    else {

        var SpecSheets = document.getElementById("SpecSheets")
        var SpecLink = document.getElementById("SPECLINK")

        SpecSheets.innerHTML = Spec;


        if (SpecSheets.style.pixelLeft) {
            SpecSheets.style.pixelLeft = GetLeftPos(SpecLink) - 150;
        }
        else {
            SpecSheets.style.left = GetLeftPos(SpecLink) - 150;
        }

        if (SpecSheets.style.posTop) {
            SpecSheets.style.posTop = GetTopPos(SpecLink);
        }
        else {
            SpecSheets.style.top = GetTopPos(SpecLink);
        }

        SpecSheets.style.pixelWidth = 150;
        SpecSheets.style.visibility = "visible";
    }

    return false;
}

function HideSpecWindow(event) {
    try {
        if (document.all) {
            document.all.SpecSheets.style.visibility = "hidden";
        }
        else if (document.layers) {
            var nets = document.layers["SpecSheets"];
            nets.visibility = "hidden";
            //document.RelatedPopup.visibility = "hidden"; 
        }
        else {
            document.getElementById("SpecSheets").style.visibility = "hidden";
        }
    } catch (e) {

    }
}

function HideWindow(event) {
    try {

        if (document.all) {

            document.all.RelatedPopup.style.visibility = "hidden";
            HideDocumentsPopup('MaintenanceSheets');
            HideDocumentsPopup('OPTIONMaintenanceSheets');
            HideDocumentsPopup('SpecSheets');
            HideDocumentsPopup('RelatedDocsOther');
            HideDocumentsPopup('ArchiveDocs');
            HideDocumentsPopup('BulletinsTable');

        }
        else if (document.layers) {
            var nets = document.layers["RelatedPopup"];
            nets.visibility = "hidden";
            var nets = document.layers["MaintenanceSheets"];
            nets.visibility = "hidden";
            var nets = document.layers["RelatedDocsOther"];
            nets.visibility = "hidden";

            //document.RelatedPopup.visibility = "hidden"; 
        }
        else {
            var RelatedPopup = document.getElementById("RelatedPopup")

            RelatedPopup.style.visibility = "hidden";

            HideDocumentsPopup('MaintenanceSheets');
            HideDocumentsPopup('OPTIONMaintenanceSheets');
            HideDocumentsPopup('SpecSheets');
            HideDocumentsPopup('RelatedDocsOther');
            HideDocumentsPopup('ArchiveDocs');
            HideDocumentsPopup('Bulletins');
        }

    } catch (e) {

    }
}

function SetImage(ImageID, Type) {
    if (document.all) {
        document.all[ImageID].src = BaseURL + '?Page=' + Type + '&ProductLineID=' + ProductLine.ProductLineID + '&BaseID=' + SelectedBaseID + '&ConfigInfo=' + GetConfigInfo();
    }
    else {
        document.getElementById(ImageID).src = BaseURL + '?Page=' + Type + '&ProductLineID=' + ProductLine.ProductLineID + '&BaseID=' + SelectedBaseID + '&ConfigInfo=' + GetConfigInfo();
    }
}

function ClearPrice() {
    if (document.all['PRICE']) {
        setInnerHTML("PRICE", "<b>Price:</b> <A href='#' onClick='ShowPrice();return false;'>Show Price</A>");
    }
    else if (document.getElementById("PRICE")) {
        setInnerHTML("PRICE", "<b>Price:</b> <A href='#' onClick='ShowPrice();return false;'>Show Price</A>");
    }
}
function ShowPicture(Type) {

    var PictureHTML;
    var CaptionHTML;


    try {

        LargeThumbnail = "LargeThumbnail";

        PicMode = Type;


        switch (Type) {
            case PIC_THUMBNAIL:

                if (ConfigComplete() == true) {
                    PictureHTML = "<table style='width:275px;border-collapse:collapse;border-width:0'><tr><td ><IMG src='" + BaseURL + "?Page=" + "Thumbnail" + "&ProductLineID=" + ProductLine.ProductLineID + "&BaseID=" + SelectedBaseID + "&ConfigInfo=" + GetConfigInfo() + "&PartNum=" + GetPartNumber() + "'></td></tr></table>";
                } else {
                    PictureHTML = "<table style='width:277px;border-collapse:collapse;border-width:0'><tr><td style='text-align:center'>Selection Required</td></tr></table>";
                }

                CaptionHTML = "<a href='#' onClick='JumpToNewWindow(\"LargeThumbnail\",\"New=1\");return false;'>Show Large Thumbnail</a>";

                break;

            case PIC_PHOTO:

                PictureHTML = "<table style='width:275px;border-collapse:collapse;border-width:0'><tr><td ><IMG src='" + BaseURL + "?Page=" + "PRODPIC" + "&ProductLineID=" + ProductLine.ProductLineID + "&BaseID=" + SelectedBaseID + "&ConfigInfo=" + GetConfigInfo() + "' alt='" + SelectedBaseID + "' height=170 width=275></td></tr></table>";
                CaptionHTML = ''; //"<a href='#' onClick='ShowPicture(PIC_THUMBNAIL);return false'>Show Thumbnail Drawing</a>";

                break;

            case PIC_UPDATE:

                if (ConfigComplete() == true) {

                    PictureHTML = "<table style='width:277px;border-collapse:collapse;border-width:0'><tr><td style='text-align:center'><a href='#' onClick='ShowPicture(PIC_THUMBNAIL);return false;'>Click To Update Drawing</a></td></tr></table>";

                } else {
                    PictureHTML = "<table style='width:277px;border-collapse:collapse;border-width:0'><tr><td style='text-align:center'>Selection Required</td></tr></table>";
                }

                CaptionHTML = ''; //"<a href='#' onClick='ShowPicture(PIC_PHOTO);return false;'>Show Photo</a>";

                break;

            case PIC_DELTALINE:

                PictureHTML = "<table style='width:275px;border-collapse:collapse;border-width:0'><tr><td><IMG src='" + BaseURL + "?Page=" + "LINEART" + "&ProductLineID=" + ProductLine.ProductLineID + "&BaseID=" + SelectedBaseID + "&ConfigInfo=" + GetConfigInfo() + "' height=170 width=275></td></tr></table>";

                CaptionHTML = ''; //"<a href='#' onClick='ShowPicture(PIC_DELTAPHOTO);return false;'>Show Photo</a>";

                break;

            case PIC_DELTAPHOTO:

                //	PictureHTML = "<IMG src='" + BaseURL + "?Page=" + "PRODPIC" + "&ProductLineID=" + ProductLine.ProductLineID + "&BaseID=" + SelectedBaseID + "&ConfigInfo=" + GetConfigInfo() + "' height=170 width=275>";
                //	CaptionHTML = '' //"<a href='#' onClick='ShowPicture(PIC_DELTALINE);return false;'>Show Line Art</a>";
                //	break;					

                PictureHTML = "<table style='width:275px;border-collapse:collapse;border-width:0'><tr><td ><IMG src='" + BaseURL + "?Page=" + "LINEART" + "&ProductLineID=" + ProductLine.ProductLineID + "&BaseID=" + SelectedBaseID + "&ConfigInfo=" + GetConfigInfo() + "' height=170 width=275></td></tr></table>";

                CaptionHTML = ''; //"<a href='#' onClick='ShowPicture(PIC_DELTAPHOTO);return false;'>Show Photo</a>";

                break;

            default:

                PictureHTML = "No Picture Available";
                CaptionHTML = '';

                break;
        }

        setInnerHTML('PICTURE', PictureHTML);
        setInnerHTML('PICCAPTION', CaptionHTML);

    } catch (e) {
        alert("Error in Show Picture: " + e.description);
        //do nothing
    }

}

function JumpToPage(PageID, Other, OldConfigInfo, bHistory) {


    if (PageID == 'DWG') {
        if (!ConfigComplete()) {
            alert("Please make all required selections");
            return;
        }
    }

    if (Other == null) {
        Other = '';
    }

    if (PageID != '' && zSelectedLHPID != null) {
        Other += "&LHPHANDLE=" + zSelectedLHPID;

    }

    if (PageID != '' && zSelectedLHPID2 != null) {
        Other += "&LHPHANDLE2=" + zSelectedLHPID2;
    }

    if (zSelectedFINISHID != '' && zSelectedFINISHID != null) {
        Other += "&LHPFINISH=" + zSelectedFINISHID;
    }

    if (zSelectedFINISHID2 != '' && zSelectedFINISHID2 != null) {
        Other += "&LHPFINISH2=" + zSelectedFINISHID2;
    }

    if (zSelectedAccentID != '' && zSelectedAccentID != null) {
        Other += "&LHPACCENT=" + zSelectedAccentID;
    }

    if (zSelectedAccentID2 != '' && zSelectedAccentID2 != null) {
        Other += "&LHPACCENT2=" + zSelectedAccentID2;
    }

    if (OldConfigInfo == '' || OldConfigInfo == null) {
        zConfigInfo = GetConfigInfo();
        //alert("New zConfigInfo=" + zConfigInfo);
    } else {
        //alert("OldConfigInfo=" + OldConfigInfo);
        zConfigInfo = OldConfigInfo;
    }

    if (bHistory == null) {
        bHistory = true;
    }

    document.clear();

    //alert("ConfigInfo=" + zConfigInfo);

    if (self.location.protocol == 'file:') {
        self.location.href = BaseURL + '@Page=' + PageID + '&ProductLineID=' + ProductLine.ProductLineID + '&BaseID=' + SelectedBaseID + '&ConfigInfo=' + zConfigInfo + "&SeriesID=" + SeriesID + "&PartNum=" + GetPartNumber() + "&" + Other;

    } else {
        if (bHistory) {
            self.location.href = BaseURL + '?Page=' + PageID + '&ProductLineID=' + ProductLine.ProductLineID + '&BaseID=' + SelectedBaseID + '&ConfigInfo=' + zConfigInfo + "&SeriesID=" + SeriesID + "&PartNum=" + GetPartNumber() + Other;
        } else {
            self.location.replace(BaseURL + '?Page=' + PageID + '&ProductLineID=' + ProductLine.ProductLineID + '&BaseID=' + SelectedBaseID + '&ConfigInfo=' + zConfigInfo + "&SeriesID=" + SeriesID + "&PartNum=" + GetPartNumber() + Other);
        }
    }

}

function RebuildPrice() {

    if (OldConfigInfo == '' || OldConfigInfo == null) {
        zConfigInfo = GetConfigInfo();
    } else {
        zConfigInfo = OldConfigInfo;
    }
    self.location.href = BaseURL + '?Page=Price&ProductLineID=' + ProductLine.ProductLineID + '&BaseID=' + SelectedBaseID + "&SeriesID=" + SeriesID + '&ConfigInfo=' + zConfigInfo + "&PartNum=" + GetPartNumber() + "&BasePartNum=" + GetPartNumber(true);
}

function ShowPrice() {
    OldConfigInfo = '';
    Other = '';

    if (OldConfigInfo == '' || OldConfigInfo == null) {
        zConfigInfo = GetConfigInfo();
    } else {
        zConfigInfo = OldConfigInfo;
    }

    if (typeof BaseNAPricing !== 'undefined') {
        if (BaseNAPricing == true) {
            //alert("NA Pricing=True");
            setInnerHTML(0);

        } else {
            if (ConfigComplete()) {
                var Part;
                var Price;

                Part = 'P' + GetPartNumber(false, false);

                Part = Part.replace(/-/g, "_");
                Part = Part.replace(/ /g, "_");
                var pat = new RegExp("/", "g");
                Part = Part.replace(pat, "_");

                try {
                    Price = Prices[Part];
                    Price = Price.substr(1);

                    if (Price != null && Price > 0) {
                        if (bLHPproduct == true) {

                            if (CompleteHandlePrice != '') {
                                Price = parseFloat(Price) + parseFloat(CompleteHandlePrice);
                                Price = parseFloat(Price);
                                Price = Price.toFixed(2);

                                if (CompleteHandle2Price != null && CompleteHandle2Price != '') {
                                    Price = parseFloat(Price) + parseFloat(CompleteHandle2Price);
                                    Price = parseFloat(Price);
                                    Price = Price.toFixed(2);

                                }

                                setInnerHTML("PRICE", "<b>Price: $" + Price + "</b>");

                            } else {
                                if (CompleteHandle2Price != null && CompleteHandle2Price != '') {
                                    Price = parseFloat(Price) + parseFloat(CompleteHandle2Price);
                                    Price = parseFloat(Price);
                                    Price = Price.toFixed(2);
                                    setInnerHTML("PRICE", "<b>Price: $" + Price + "</b>");
                                } else {
                                    Price = parseFloat(Price);
                                    Price.toFixed(2);

                                    setInnerHTML("PRICE", "<b><font color=blue>Base Only: $" + formatCurrency(Price) + "</font></b>");
                                }
                            }
                        }
                        else {

                            setInnerHTML("PRICE", "<b>Price: $" + Price + "</b>");
                        }

                    } else {
                        if (Price == "-555") {
                            setInnerHTML("PRICE", "<b>Price: N/A</b>");
                        } else {
                            setInnerHTML("PRICE", "<b>Price: POR</b>");
                        }
                    }

                } catch (e) {
                    //alert("Error=" + e.description);
                    setInnerHTML("PRICE", "<b>Price: POR</b>");
                }
            } else {
                setInnerHTML("PRICE", "<b>Price: </b>");
            }
        }

    }
}

function ShowLHPpagePrice() {

    var Handle;
    var HandlePrice;
    var AccentPrice;
    var CompleteHandlePrice;
    var zNewHandlePrice;

    if (CompGroupID == "LHP2") {
        if (bAllLHPHandles == true) {
            Handle = AllLHP[zSelectedLHPID2];
        }
        else {
            Handle = LHP[zSelectedLHPID2];
        }
    }
    else {
        if (bAllLHPHandles == true) {
            Handle = AllLHP[zSelectedLHPID];
        }
        else {
            Handle = LHP[zSelectedLHPID];
        }
    }
    if (Handle.FINISH != null) {
        /*for (FinishID in handle.FINISH)
        {
        zSelectedFINISHID=handle.FINISH[FinishID].FINISHID;
        break;
        }*/
        HandlePrice = Handle.Price;

    }
    if (Handle.ACCENT != null) {
        /*for (AccentID in handle.ACCENT)
        {
        zSelectedAccentID=handle.ACCENT[AccentID].FINISHID;	
        break;
        }*/
        //AccentPrice=Handle.ACCENT[zSelectedAccentID].Price
        //alert("AccentPrice=" + AccentPrice);
    }

    CompleteHandlePrice = parseFloat(HandlePrice); //+ parseFloat(AccentPrice);
    CompleteHandlePrice = parseFloat(CompleteHandlePrice);
    CompleteHandlePrice = CompleteHandlePrice.toFixed(2);
    zNewHandlePrice = "<b>&nbsp;Price:&nbsp;$" + CompleteHandlePrice + "</b>";

    return (zNewHandlePrice);

}

function ShowProductFeatures(pfURL) {
    var winSize = 0.95;
    var WinWidth = 0.75;
    var WinHeight = 0.80;

    //alert("ShowProductFeatures");

    var windowSettings = "height=" + WinHeight + ",width=" + WinWidth;
    
    windowSettings += ",resizable";
    windowSettings += ",scrollbars=yes,menubar=yes,toolbar=yes";

    NewWindow = window.open(pfURL, "ProductFeatures", windowSettings);

    NewWindow.moveTo((1 - winSize) / 2 * screen.availWidth, (1 - winSize) / 2 * screen.availHeight);
    NewWindow.focus();

}
function JumpToNewWindow(PageID, Other, OldConfigInfo) {
    var winSize = 0.95;
    var WinWidth;
    var WinHeight;
    var Format = "";

    switch (PageID) {
        case "SpecApprovals":
            if (!ConfigComplete()) {
                alert("Please make all required selections");
                return;
            }
            WinWidth = "600";
            WinHeight = "400";
            Format = "&Format=bullet"
            break;

        case "Submittal":
            if (!ConfigComplete()) {
                alert("Please make all required selections");
                return;
            }
            WinWidth = screen.availWidth * winSize;
            WinHeight = screen.availHeight * winSize;
            break;

        case "Graph":

            WinWidth = "640";
            WinHeight = "480";
            break;

        case "Pictures":

            WinWidth = "600";
            WinHeight = "520";
            break;

        case "AllPictures":

            WinWidth = "600";
            WinHeight = "520";
            break;

        case "LargeThumbnail":

            WinWidth = "640";
            WinHeight = "480";
            break;

        case "BYOF":

            WinWidth = "620";
            WinHeight = "590";
            break;

        case "Drawing":
        case "DWG":

            if (!ConfigComplete()) {
                alert("Please make all required selections");
                return;
            }
            WinWidth = screen.availWidth * winSize;
            WinHeight = screen.availHeight * winSize;
            break;
        default:

            WinWidth = screen.availWidth * winSize;
            WinHeight = screen.availHeight * winSize;
            break;
    }
    
    var windowSettings = "height=" + WinHeight + ",width=" + WinWidth;

    windowSettings += ",resizable";
    windowSettings += ",scrollbars=yes";

    if (Other == null) {
        Other = '';
    }
    if (OldConfigInfo == '' || OldConfigInfo == null) {
        zConfigInfo = GetConfigInfo();
    } else {
        zConfigInfo = OldConfigInfo;
    }

    if (self.location.protocol == 'file:') {
        self.location.href = BaseURL + '@Page=' + PageID + '&ProductLineID=' + ProductLine.ProductLineID + '&BaseID=' + SelectedBaseID + '&ConfigInfo=' + zConfigInfo + "&PartNum=" + GetPartNumber() + "&" + Other;

    } else {

        NewWindow = window.open(BaseURL + '?Page=' + PageID + '&ProductLineID=' + ProductLine.ProductLineID + '&BaseID=' + SelectedBaseID + Format + '&ConfigInfo=' + zConfigInfo + "&PartNum=" + GetPartNumber() + "&" + Other, PageID, windowSettings);

        NewWindow.moveTo((1 - winSize) / 2 * screen.availWidth, (1 - winSize) / 2 * screen.availHeight);
        NewWindow.focus();

    }
}


function ConfigComplete() {
    //NN-added check to see if an LHP product has been selected.
    for (grp in Product.OptionGroups) {
        group = Product.OptionGroups[grp];
        if (group.GroupID == "LHP" || group.GroupID == "LHP1" || group.GroupID == "LHP2") {

        }
        else {
            if (group.Required == 1 && group.selected == null && group.status == STATUS_OK) {

                bConfigComplete = false;
                return false;
            }
        }
    }
    bConfigComplete = true;

    return true;

}

function InitOptions() {
    for (grp in Product.OptionGroups) {
        group = Product.OptionGroups[grp];
        group.status = STATUS_OK;
        group.selected = null;
        for (opt in group.Options) {
            option = group.Options[opt];
            //option.status=STATUS_OK;
            if (option.Default == true) {
                group.selected = option;

            }
        }
    }
    if (ConfigInfo != null) {
        ParseConfigInfo();
    }

    var iCount = 0;
    do {
        ProcessRules();
        iCount++;
    } while (GroupRules() == true && iCount < 4);

    //SetSelectedOption(GroupID);
}

function ParseConfigInfo() {
    var OptionID = '';
    ConfigInfo = ConfigInfo.replace(/-/g, "_");
    Items = ConfigInfo.split(';');

    for (var i = 0; i <= Items.length - 1; i++) {
        SubItems = Items[i].split('=');
        GroupID = SubItems[0];
        OptionID = SubItems[1];

        if (Product.OptionGroups[GroupID]) {
            group = Product.OptionGroups[GroupID];
            if (group != null) {
                if (group.Options) {
                    if (group.Options['O' + OptionID] != null) {
                        group.selected = group.Options['O' + OptionID];
                        // not sure if we need to do this.
                        //ProcessEvents('O' + OptionID);
                    }
                }
            }
        }
    }

}

function OptionClicked(GroupID, OptionID, bSetValue) {
    value = true;
    group = Product.OptionGroups[GroupID];

    if (group.selected != null) {
        if ((group.AllowNoSel == 1 || group.Required == 0) && group.selected.OptioncompID == OptionID) {
            value = false;
        }
    }

    if (bSetValue != null) {
        value = bSetValue;

    }
    SetOption(GroupID, OptionID, value);
    iCount = 0;

    do {
        ProcessRules();
        iCount++;
    } while (GroupRules() == true && iCount < 4);
    ProcessEvents(Product.OptionGroups[GroupID]);
    if (iCount > 3) {

        alert('An error has occurred while processing');
    }


    RenderOptionsHTML();


    //ClearPrice();
    ShowPrice();
    try {
        if (PicMode == PIC_THUMBNAIL) {
            ShowPicture(PIC_UPDATE);
        }
    } catch (e) {
        //do nothing
    }

}

function formatCurrency(num) {
    var cents;
    var sign;

    num = num.toString().replace(/\$|\,/g, '');
    if (isNaN(num)) {
        num = "0";
        sign = (num == (num = Math.abs(num)));
        num = Math.floor(num * 100 + 0.50000000001);
        cents = num % 100;
        num = Math.floor(num / 100).toString();
    }
    if (cents < 10) {
        cents = cent(num);
        cents = "0" + cents;
    }
    else {
        cents = cent(num);
    }
    /*for (var i = 0; i < Math.floor((num.length-(1+i))/3);i++)
    {
		
		num = num.substring(0,num.length-(4*i+3)) + num.substring(num.length-(4*i+3));
    }
    alert(num);
    if(cents!=null)
    {
    return (((sign)?'':'') + num + '.' + cents);
    }
    else
    {
    return (((sign)?'':'') + num);
    }*/
    return (cents);
}
function cent(amount) {
    // returns the amount in the .99 format
    return (amount == Math.floor(amount)) ? amount + '.00' : ((amount * 10 == Math.floor(amount * 10)) ? amount + '0' : amount);
}

function SetOption(GroupID, OptionID, value) {
    //alert("SetOption");
    try {
        if (value == null) {
            value = true;
        }

        group = Product.OptionGroups[GroupID];

        if (value == false) {
            group.selected = null;
        } else {
            if (group.status == STATUS_OK && group.Options["O" + OptionID].status == STATUS_OK) {
                group.selected = group.Options["O" + OptionID];
            }
        }
    } catch (e) {
        //alert("Error Setting OptionGroup:" + GroupID);
    }
    // now process the change

}

function Disable(GroupID, OptionID) {
    //alert("Disable");
    if (OptionID == '') {
        Product.OptionGroups[GroupID].status = STATUS_DISABLED;
        Product.OptionGroups[GroupID].selected = null;
    } else {
        Product.OptionGroups[GroupID].Options["O" + OptionID].status = STATUS_DISABLED;
        if (Product.OptionGroups[GroupID].selected != null) {
            if (Product.OptionGroups[GroupID].selected.OptioncompID == OptionID) {
                Product.OptionGroups[GroupID].selected = null;
            }
        }
    }
}

function Hide(GroupID, OptionID) {


    if (OptionID == '' || OptionID == 'undefined') {
        Product.OptionGroups[GroupID].status = STATUS_HIDDEN;
        Product.OptionGroups[GroupID].selected = null;
    } else {
        Product.OptionGroups[GroupID].Options["O" + OptionID].status = STATUS_HIDDEN;

        if (Product.OptionGroups[GroupID].selected != null) {
            if (Product.OptionGroups[GroupID].selected.OptioncompID == OptionID) {
                Product.OptionGroups[GroupID].selected = null;
            }
        }
    }


}

function HideSpoutSubTypes(SubTypes) {
    SubTypeArray = SubTypes.split(",");
    for (grp in Product.OptionGroups) {
        group = Product.OptionGroups[grp];
        if (group.GroupID.search("SPOUT") != -1) {
            for (opt in group.Options) {
                option = group.Options[opt];

                for (var i = 0; i < SubTypeArray.length; i++) {
                    if (option.SubType != null) {
                        if (option.SubType == SubTypeArray[i]) {
                            option.status = STATUS_HIDDEN;
                        }
                    }
                }
            }
        }
    }
}

function SetNAPricing(zBaseID) {

    alert("SetNAPricing - BaseID = " + zBaseID);
    /*if (OptionID=='')
    {
    Product.OptionGroups[GroupID].status = STATUS_DISABLED;
    Product.OptionGroups[GroupID].selected = null;
    } else
    {
    Product.OptionGroups[GroupID].Options["O" + OptionID].status = STATUS_DISABLED;
    if (Product.OptionGroups[GroupID].selected!=null)
    {
    if (Product.OptionGroups[GroupID].selected.OptioncompID==OptionID)
    {
    Product.OptionGroups[GroupID].selected=null;
    }
    }
    }
    */
}

function SetGroupDefault(group) {
    //alert("SetGroupDefault");
    group.selected = null;

    for (opt in group.Options) {
        option = group.Options[opt];
        if (option.Default == 1 && option.status == STATUS_OK) {
            group.selected = option;
        }
    }

    if (group.selected == null) {
        for (opt in group.Options) {
            option = group.Options[opt];
            if (option.Standard == 1 && option.status == STATUS_OK) {
                group.selected = option;
            }
        }
    }

    if (group.selected == null) {
        for (opt in group.Options) {
            option = group.Options[opt];
            if (option.status == STATUS_OK) {
                group.selected = option;
            }
        }
    }
}

// Support functions for Accessories

function IsSelected(OptionID) {
    // returns true if the option is selected in any option group
    for (OG in Product.OptionGroups) {
        group = Product.OptionGroups[OG];
        if (group.selected != null) {
            if (group.selected.OptioncompID == OptionID) {
                return true;
            }
        }
    }
    return false;
}


function IsAnySelected() {
    group = Product.OptionGroups[arguments[0]];
    if (group != null) {
        if (group.selected != null) {

            for (var i = 1; i <= arguments.length; i++) {
                if (group.selected.OptioncompID == arguments[i]) {
                    return true;
                }

            }
        }
    }
    return false;
}

function HandleRequiresService(GroupID) {

    handlegroup = Product.OptionGroups[GroupID];
    ServiceGroup = Product.OptionGroups.SERVICE;
    if (ServiceGroup != null) {
        if (ServiceGroup.selected != null) {
            SID = ";" + ServiceGroup.selected.OptioncompID + ";";
            for (Opt in handlegroup.Options) {
                O = handlegroup.Options[Opt];
                if (O.Data != null) {
                    zData = O.Data;
                } else {
                    zData = "";
                }
                zData = zData.replace(/-/g, "_");
                if (zData != null) {
                    if (zData.search(SID) < 0) {
                        O.status = STATUS_DISABLED;
                    }
                } else {
                    O.status = STATUS_DISABLED;
                }
            }
        } else {
            handlegroup.status = STATUS_DISABLED;
        }
    } else {
        handlegroup.status = STATUS_DISABLED; ;
    }
}

function GetSelected(GroupID) {
    // returns the selected optionID for the group
    // returns '' if no selection

    if (Product.OptionGroups[GroupID] != null) {
        if (Product.OptionGroups[GroupID].selected != null) {

            return (Product.OptionGroups[GroupID].selected.OptioncompID) + '';
        } else {

            return '';
        }
    } else {

        return '';   // nothing selected

    }
}

function GetOption(GroupID, OptionID) {
    //alert("GetOption");
    option = Product.OptionGroups[GroupID].Options["O" + OptionID];
    return option;
}

function SetOptionAsSTD(GroupID, OptionID) {
    //alert("SetOptionAsSTD");
    for (opt in Product.OptionGroups[GroupID].Options) {
        Product.OptionGroups[GroupID].Options[opt].Standard = 0;
    }
    option = Product.OptionGroups[GroupID].Options["O" + OptionID];
    option.Standard = 1;
}

function NoAdd(GroupID, OptionID) {
    //alert("NoAdd Function - GroupID = " + GroupID + " and OptionID = " + OptionID);

    if (OptionID == "") {
        group = Product.OptionGroups[GroupID];
        group.AddMode = 0;
    }
    else {
        option = Product.OptionGroups[GroupID].Options["O" + OptionID];
        option.AddMode = 0;
    }
}

// End Support functions
/*function Add(GroupID,OptionID)
{
if(OptionID=="")
{
group=Product.OptionGroups[GroupID];
group.AddMode=group.OldAddMode;
}
else
{	
option= Product.OptionGroups[GroupID].Options["O" + OptionID];
option.AddMode=option.OldAddMode;
}	
}*/

function GroupRules() {
    bChanged = false;
    for (OG in Product.OptionGroups) {
        group = Product.OptionGroups[OG];
        if (group.status != STATUS_OK) {
            group.selected = null;
        } else {
            if (group.Required == 1) {

                if (group.AllowNoSel == 0 && group.selected == null) {
                    SetGroupDefault(group);
                    bChanged = true;
                }
                if (group.selected != null) {

                    if (group.selected.status != STATUS_OK) {
                        SetGroupDefault(group);
                        bChanged = true;
                    }
                }
            } else {
                if (group.selected != null) {
                    if (group.selected.status != STATUS_OK) {
                        //SetGroupDefault(group);
                        group.selected = null;
                        bChanged = true;
                    }
                }
            }
        }
    }
    return bChanged;
}

function ProcessRules() {
    for (grp in Product.OptionGroups) {
        group = Product.OptionGroups[grp];
        group.status = STATUS_OK;
        for (opt in group.Options) {

            if (group.Options[opt].Discontinued == 1) {
                group.Options[opt].status = STATUS_DISABLED;
            } else {
                group.Options[opt].status = STATUS_OK;
                group.Options[opt].AddMode = group.Options[opt].OldAddMode;
            }
        }
    }

    ProductRules();

}

/*function SetSelectedOption(GroupID)
{
try
{
// selected the standard option in a group
if (Product.OptionGroups[GroupID].status==STATUS_OK)
{
for (opt in Product.OptionGroups[GroupID].Options)
{

option = Product.OptionGroups[GroupID].Options[opt]
if (option.Standard==1 && option.status==STATUS_OK)
{
Product.OptionGroups[GroupID].selected = option;
}
}
}
}
catch(e)
{
alert("An error occurred in SetSelectedOption - " + e.description);
}	
}*/

function SetSTDOption(GroupID) {

    try {
        // selecte the standard option in a group
        if (Product.OptionGroups[GroupID].status == STATUS_OK) {

            for (opt in Product.OptionGroups[GroupID].Options) {

                option = Product.OptionGroups[GroupID].Options[opt];


                if (option.Standard == 1) {
                    if (option.status == STATUS_OK) {

                        Product.OptionGroups[GroupID].selected = option;
                    }
                }
            }
        }
    }
    catch (e) {
        alert("An error occurred in SetSTDOption - " + e.description);


    }
}
function GetConfigInfo() {
    zConfig = "";
    for (OG in Product.OptionGroups) {
        group = Product.OptionGroups[OG];
        if (group) {
            if (group.selected != null) {
                zConfig += group.GroupID + "=" + group.selected.OptioncompID + ";";
            }
        }
    }
    return zConfig;
}

function GetVal(str) {
    var zTemp = "";

    p = str.search(/\d/);
    if (p >= 0) {
        zTemp = str.substr(p, str.length - p);
    }
    Val = parseInt(zTemp);
    if (Val.toString() == 'NaN') {
        Val = 0;
    }
    return Val;
}

function IsNumeric(str) {
    Val = parseInt(str);
    if (Val.toString() == 'NaN') {
        return false;
    } else return true;
}

function IsOptionalSpoutSelected() {
    for (OG in Product.OptionGroups) {
        group = Product.OptionGroups[OG];

        if (group.GroupID.search("OSPOUT") != -1) {
            if (group.selected != null) {
                return true;
            }
        }
    }

    return false;
}

function GetPartNumber(bBaseOnly, bLHP) {

    var i;
    var j;
    var Service1, Service2, zServices;
    var CompleteLHP;
    var CompleteLHP2;

    CompleteLHP = "";
    CompleteLHP2 = "";

    try {
        zPart = new String(Product.PartNumFormat);
        if (Product.PartNumFormat == null || Product.PartNumFormat == '') {
            return Product.PartNum;
        }
        zPart = zPart.replace(/\[/g, "<");
        zPart = zPart.replace(/\]/g, ">");

        zOptions = new String("");
        zAccys = "";

        for (i = 0; i <= 5; i++) {

            for (OG in Product.OptionGroups) {
                group = Product.OptionGroups[OG];

                if ((group.selected != null) && ((group.BaseOption == 1 && bBaseOnly == true) || (bBaseOnly != true))) {

                    if (group.selected.AddOrder == i) {

                        zOptNum = group.selected.PartNum;
                        if (group.selected.Standard == 1) {
                            zOptNum = "";
                        }
                        if (group.GroupID.search('OSPOUT') != -1) {
                            pat = new RegExp("<OSPOUT>");
                        } else {
                            pat = new RegExp("<" + group.GroupID + ">");
                        }


                        switch (group.selected.AddMode) {
                            case 0: // do not add
                                //alert(group.selected.GroupID + " AddMode= " + group.selected.AddMode);
                                zPart = zPart.replace(pat, '');
                                break;
                            case 1: // place holder
                                //alert("zPart=" + zPart + " and zOptNum=" + zOptNum);
                                zPart = zPart.replace(pat, zOptNum);
                                zPart = zPart.replace(pat, zOptNum);
                                break;
                            case 2: //append	
                                //alert("zOptions=" + zOptions + " and zOptNum=" + zOptNum);
                                zOptions += zOptNum;
                                break;

                            case 6: // sum with first digit of options
                                if (GetVal(zOptions) > 0 || zOptions == '') {
                                    if (zOptions == '') {
                                        zOptions = '   ';
                                    }
                                    if (group.selected.AddPos == 0) {
                                        pos = 0;
                                    } else {

                                        pos = group.selected.AddPos - 1;

                                    }
                                    Digit = GetVal(zOptions.substr(pos, 1));

                                    Digit = Digit + parseInt(zOptNum);

                                    NewOption = "";
                                    for (j = 0; j <= zOptions.length - 1; j++) {
                                        if (j == pos) {

                                            NewOption += Digit.toString();
                                        } else {
                                            NewOption += zOptions.substr(j, 1);
                                        }
                                    }
                                    zOptions = NewOption;
                                } else {

                                    zOptions += zOptNum;
                                }
                                break;
                            case 7:

                                if (zOptions == '') {
                                    zOptions += '-' + zOptNum;
                                }
                                else {
                                    zOptions += zOptNum;
                                }
                                break;



                            case 8:
                                //8 - append suffix with dash, unless optional spout is selected, then use no dash

                                if (IsOptionalSpoutSelected() == true) {
                                    zPart += zOptNum;
                                } else {
                                    zPart += '-' + zOptNum;
                                }
                                break;

                            case 99:
                                if (zAccys.length > 0) {
                                    zAccys += ", ";
                                }
                                zAccys += zOptNum;
                                break;
                            default:
                                //alert("Default=" + zOptNum);
                                //alert(group.selected.GroupID + " AddMode= " + group.selected.AddMode);
                                zPart = zPart.replace(pat, zOptNum);

                                break;

                        }
                    }
                }
            }
        }
        zOptions = zOptions.replace(/ /g, '');
        //zPart = zPart.replace('<OPTIONS>','-' + zOptions);
        zPart = zPart.replace('<OPTIONS>', zOptions);
        if (zPart.search('<OPTIONSFINISH>') > 0) {
            if (Product.OptionGroups.FINISH.selected != null) {

                if (Product.OptionGroups.FINISH.selected.AddMode != 0 && Product.OptionGroups.FINISH.selected.Standard == 0) {
                    var FinishPartNum = Product.OptionGroups.FINISH.selected.PartNum;

                    if (IsNumeric(FinishPartNum)) {
                        NewVal = GetVal(zOptions) + GetVal(FinishPartNum);
                        zPart = zPart.replace('<OPTIONSFINISH>', "-" + NewVal.toString());
                    } else {

                        if ((zOptions != null && zOptions != '') && IsNumeric(zOptions.substr(0, 1))) {
                            zOptions = '-' + zOptions;
                        }
                        zPart = zPart.replace('<OPTIONSFINISH>', zOptions + FinishPartNum);
                    }

                } else {
                    if ((zOptions != null && zOptions != '') && IsNumeric(zOptions.substr(0, 1))) {
                        zOptions = '-' + zOptions;
                    }
                    zPart = zPart.replace('<OPTIONSFINISH>', zOptions);
                }
            } else {
                zPart = zPart.replace('<OPTIONSFINISH>', zOptions);
            }
        }
        //alert(zPart);
        if ((zPart.search('<ALLSERVICES>') > 0) && bBaseOnly != true) {
            try {
                Service1 = Product.OptionGroups.SERVICE1.selected;
                Service2 = Product.OptionGroups.SERVICE2.selected;

                if (Service1.PartNum < Service2.PartNum) {
                    zServices = Service1.PartNum + "/" + Service2.PartNum;
                } else {
                    zServices = Service2.PartNum + "/" + Service1.PartNum;
                }
            } catch (e) {
                zServices = '';

                if (Service1 != null) {
                    zServices = Service1.PartNum;
                }
                if (Service2 != null) {
                    zServices = Service2.PartNum;
                }

            }
            zPart = zPart.replace('<ALLSERVICES>', zServices);
        }


        if ((zPart.search('<SHOWEROPTIONS3>') > 0) && bBaseOnly != true) {
            var p1 = 0;
            var p2 = 0;
            var p3 = 0;
            for (OG in Product.OptionGroups) {
                group = Product.OptionGroups[OG];

                // add options to an array (if they are selected) when they are found
                if (group.selected != null) {
                    
                        if (group.GroupID.search('HOSE') != -1) {
                            
                            p1 = parseFloat('0' + group.selected.PartNum) * 100;
                            
                        }
                        if (group.GroupID.search('BARS') != -1) {
                            
                            p2 = parseFloat('0' + group.selected.PartNum) * 10;
                            
                        }
                        if (group.GroupID.search('SHOWERHEADS') != -1) {
                            
                            p3 = parseFloat('0' + group.selected.PartNum);
                            
                        }

                       
                    
                }
            }
            var showerpart = "";

            
            if (p3 > 0) {
                showerpart = pad(p1 + p2 + p3,3);
            } else {

                showerpart = pad((p1 + p2)/10,2);

            }
            
            
            if ((showerpart == '00') || (showerpart=='000')) {
                showerpart = '';
            }
            
            zPart = zPart.replace('<SHOWEROPTIONS3>', showerpart);
                     
                            
        }
        
        if ((zPart.search('<SHOWEROPTIONS>') > 0) && bBaseOnly != true) {
            var zShowerOptionArray = new Array();
            var zShowerOptionPartNum;
            var i = 0;

            // loop through all options looking for OSPOUT, SPOUT, HOSE, BARS
            try {
                for (OG in Product.OptionGroups) {
                    group = Product.OptionGroups[OG];
                    // add options to an array (if they are selected) when they are found
                    if (group.selected != null) {
                        if (group.selected.AddMode != 0) {
                            if (group.GroupID.search('OSPOUT') != -1) {
                                //add to array
                                zShowerOptionArray[i] = group.selected.CompPartNum;
                                i++;
                            }
                            if (group.GroupID.search('SPOUT') != -1) {

                                //add to array
                                zShowerOptionArray[i] = group.selected.CompPartNum;
                                i++;
                            }
                            if (group.GroupID.search('HOSE') != -1) {

                                //add to array
                                zShowerOptionArray[i] = group.selected.CompPartNum;
                                i++;
                            }
                            if (group.GroupID.search('BARS') != -1) {

                                //add to array
                                zShowerOptionArray[i] = group.selected.CompPartNum;
                                i++;
                            }
                            if (group.GroupID.search('MISC') != -1) {

                                //add to array
                                zShowerOptionArray[i] = group.selected.CompPartNum;
                                i++;
                            }
                        }
                    }
                }

                //if ((ProductLine.ProductLineID == "105015") || (ProductLine.ProductLineID == "105016")) {
                    zShowerOptionPartNum = BuildShowerPartNumWithoutAO(zShowerOptionArray);
                //} else {
                //    zShowerOptionPartNum = BuildShowerPartNum(zShowerOptionArray);
                //}
            }
            catch (e) {
                alert("Error occurred in GetPartNumber - " + e.description);
            }

            // pass the array in to a function to build the new part number

            // replace the tag with the new part number

            zPart = zPart.replace('<SHOWEROPTIONS>', zShowerOptionPartNum);

        }

        zPart = zPart.replace('<BASE>', Product.PartNum);

        zPart = zPart.replace('--', '-');
        zPart = zPart.replace('--', '-');

        zPart = zPart.replace(/<\w*>/g, "");

        zPart = zPart.replace('--', '-');
        zPart = zPart.replace('--', '-');

        zPart = zPart.replace(/\B-|-\B/g, "");

        if (zAccys.length > 0) {
            zPart += (" w/ " + zAccys);
        }

    } catch (er) {

        zPart = 'Error'; //er.description;
    }

    if (bLHPproduct == true && bLHP != false) {
        var Handle;
        var HandleAndFinish;
        var Accent;

        Accent = "";

        if (zSelectedLHPID != '' || zSelectedLHPID2 != '') {
            zPart = zPart + " w/ ";
        }

        if (zSelectedLHPID != '') {
            Handle = LHP[zSelectedLHPID];
            if (Handle != null) {
                if (Handle.FINISH != null) {
                    if (Handle.FINISH[zSelectedFINISHID].AddMode == '1') {
                        HandleAndFinish = LHP[zSelectedLHPID].PartNum + Handle.FINISH[zSelectedFINISHID].OptionPartNum;
                        //alert("zSelectedFINISHID=" + zSelectedFINISHID);
                        //alert("HandleAndFinish=" + HandleAndFinish);
                    }
                    else {
                        HandleAndFinish = LHP[zSelectedLHPID].PartNum;
                    }

                    if (Handle.ACCENT != null) {
                        Accent = Handle.ACCENT[zSelectedAccentID].OptionPartNum;
                    }
                    else {
                        zSelectedAccentID = '';
                    }
                    if (Accent != "") {
                        CompleteLHP += HandleAndFinish + ", " + Accent;
                    }
                    else {
                        CompleteLHP += HandleAndFinish;
                    }
                }
                else {
                    CompleteLHP += LHP[zSelectedLHPID].PartNum;
                }
            }
        }
        if (CompleteLHP != "") {
            zPart = zPart + CompleteLHP;
        }

        if (zSelectedLHPID2 != '') //&& zSelectedLHPID!='')
        {
            Handle = LHP[zSelectedLHPID2];
            if (Handle != null) {
                if (Handle.FINISH[zSelectedFINISHID2].AddMode == '1') {
                    HandleAndFinish = LHP[zSelectedLHPID2].PartNum + Handle.FINISH[zSelectedFINISHID2].OptionPartNum;
                }
                else {
                    HandleAndFinish = LHP[zSelectedLHPID2].PartNum;
                }

                if (Handle.ACCENT != null) {

                    Accent = Handle.ACCENT[zSelectedAccentID2].OptionPartNum;
                }
                else {
                    Accent = '';
                    zSelectedAccentID2 = '';
                }
                if (Accent != "") {

                    if (zSelectedLHPID != '') {
                        CompleteLHP2 = ", " + HandleAndFinish + ", " + Accent;
                    }
                    else {
                        CompleteLHP2 = HandleAndFinish + ", " + Accent;
                    }
                }
                else {
                    if (zSelectedLHPID != '') {
                        CompleteLHP2 = ", " + HandleAndFinish;
                    }
                    else {
                        CompleteLHP2 = HandleAndFinish;
                    }
                }
                if (CompleteLHP2 != "") {
                    zPart = zPart + CompleteLHP2;
                }
            }
        }
    }
    //alert("zPart=" + zPart);
    zPart = zPart.replace("~", "&nbsp;");
    zPart = zPart.replace("~", "&nbsp;");
    zPart = zPart.replace("~", "&nbsp;");

    zPart = zPart.replace("~", "&nbsp;");
    //alert("zPart=" + zPart);
    return zPart;
}

function pad(number, length){
   var str = "" + number;
   while(str.length<length){
      str = '0'+str;
   }
   return str;
}

function BuildShowerPartNum(zShowerOptionArray) {
    // Date created:  27 October, 2002
    // Arguments:  An array of shower options 
    // Returns:  A new part number created based on part numbers passed in
    // Author:  NN

    var zNewPartNum = new Array();
    var iLength;
    var iloopCounter;
    var i;
    var zCompletePart = "";

    iLength = zShowerOptionArray.length - 1;

    zNewPartNum[0] = "A";

    // Loop through array of selected shower part numbers

    for (iLoopCounter = iLength; iLoopCounter >= 0; iLoopCounter--) {
        for (i = 1; i < zShowerOptionArray[iLoopCounter].length; i++) {
            if (zShowerOptionArray[iLoopCounter].substring(i, i + 1) != 0) {
                // loop through each column of characters in part numbers

                zNewPartNum[i] = zShowerOptionArray[iLoopCounter].substring(i, i + 1);
            }
            else {
                if (zNewPartNum[i] == null) {
                    zNewPartNum[i] = "0";
                }
            }
        }
    }

    for (i = 0; i < zNewPartNum.length; i++) {
        if (zNewPartNum[i] == null) {
            zNewPartNum[i] = "0";
        }
        zCompletePart = zCompletePart + zNewPartNum[i];
    }

    if (zCompletePart != "A") {
        return zCompletePart;
    }
    else {
        return "";
    }
}
function BuildShowerPartNumWithoutAO(zShowerOptionArray) {
    // Date created:  26 March, 2006
    // Arguments:  An array of shower options 
    // Returns:  A new part number created based on part numbers passed in
    // Author:  NN

    var zNewPartNum = new Array();
    var iLength;
    var iloopCounter;
    var i;
    var zCompletePart = "";

    iLength = zShowerOptionArray.length - 1;

    zNewPartNum[0] = "A";

    // Loop through array of selected shower part numbers

    for (iLoopCounter = iLength; iLoopCounter >= 0; iLoopCounter--) {
        for (i = 1; i < zShowerOptionArray[iLoopCounter].length; i++) {
            if (zShowerOptionArray[iLoopCounter].substring(i, i + 1) != 0) {
                // loop through each column of characters in part numbers

                zNewPartNum[i] = zShowerOptionArray[iLoopCounter].substring(i, i + 1);
            }
            else {
                if (zNewPartNum[i] == null) {
                    zNewPartNum[i] = "0";
                }
            }
        }
    }

    for (i = 0; i < zNewPartNum.length; i++) {
        if (zNewPartNum[i] == null) {
            zNewPartNum[i] = "0";
        }
        zCompletePart = zCompletePart + zNewPartNum[i];
    }

    if (zCompletePart != "A") {
        zCompletePart = zCompletePart.substr(2, 2);
        return zCompletePart;
    }
    else {
        return "";
    }
}
function SelectedListValue(list) {

    return list.options[list.selectedIndex].value;
}

function GetPicURL(zPic) {
    return "images/pics/" + zPic + ".jpg"
}

function GetImageTag(zPic) {
    if (zPic != "" && zPic != 'none' && zPic != null) {
        return "<img src='" + GetPicURL(zPic) + "' class='smallAdaImage' />"
    } else {
        return '';
    }
}


function setInnerHTML(ElementID, HTML) {
    var Element;

    try {
        if (navigator.userAgent.indexOf('Netscape') != -1) {
            Element = document.getElementById(ElementID);
            Element.innerHTML = HTML;
        }
        else if (document.all) {
            Element = document.all[ElementID];
            Element.innerHTML = HTML;
        }
        else {
            Element = document.getElementById(ElementID);
            Element.innerHTML = HTML;
        }
    } catch (e) {
        //alert("Error:" + e.message);
        //alert(ElementID + "Test");
    }
}


function RenderDropList(group) {
    HTML = "<p><b>" + group.GroupName + ":</b><br>";

    HTML += "<select size=1 name='LIST" + group.GroupID + "'";
    HTML += " onChange=OptionClicked('" + group.GroupID + "',SelectedListValue(LIST" + group.GroupID + "))";
    HTML += ">";

    if (group.Required == 0) {
        HTML += "<option value=''>No Selection</Option>";
    }
    if (group.Required == 1 && group.selected == null) {
        HTML += "<option value='' selected>Must Select</Option>";
    }
    for (option in group.Options) {
        opt = group.Options[option];

        if (opt.status == STATUS_OK) {

            HTML += "<Option";
            if (group.selected == opt) {
                HTML += " selected";
            }
            HTML += " value='" + opt.OptioncompID + "'>";

            desc = opt.Description;

            if (opt.Discontinued == true) {
                desc = "[Discontinued]" + desc;
            }

            if (opt.status == STATUS_OK) {
                HTML += desc;
            } else {
                HTML += "<font color='color='#C0C0C0'>" + desc + "</font>"
            }
            HTML += "</option>";
        }
    }
    HTML += "</select>";

    return HTML;
}
function ChangePage(zCompID) {
    parent.self.location.href = BaseURL + "?Page=XREF&CompetitorID=" + SelectedID.value + "&zCompPartID=" + zCompID;
}
function RenderOptionList(group) {
    HTML = "<table height=4 border=0 cellpadding=0 cellspacing=0><tr><td height=4 style='font-size: 1px'>&nbsp;</td></tr></table>";
    if (group.status == STATUS_HIDDEN) {
        return "";
    }

    if (group.status == STATUS_DISABLED) {
        //HTML = "<p><b>" + group.GroupName + ":</b><br><hr color=#FF0000>";
        HTML += "<table width='100%' border=0 cellspacing=0 style='border-bottom-style: solid; border-bottom-width: 1; border-bottom-color:#AC0535; border-bottom-width: 1px; font-family:Arial, sans-serif'><tr><td>";
        HTML += "<b>" + group.GroupName + ":</b>";
        HTML += "</td></tr></table>";
    } else {

        //HTML = "<p><b>" + group.GroupName + ":</b><br><hr color=#FF0000>";
    HTML += "<table width='100%' border=0 cellspacing=0 style='border-bottom-style: solid; border-bottom-width: 1; border-bottom-color:#AC0535; border-bottom-width: 1px; font-family:Arial, sans-serif'><tr><td>";
        HTML += "<b>" + group.GroupName + ":</b>";
        HTML += "</td></tr></table>";
        for (option in group.Options) {
            opt = group.Options[option];

            if (opt.status != STATUS_HIDDEN) {

                HTML += "<input size=50 type=checkbox name='" + group.GroupID + "' onClick=OptionClicked('" + group.GroupID + "','" + opt.OptioncompID + "')";


                if (group.selected == opt) {
                    HTML += " checked";
                }

                HTML += ">";

                desc = opt.Description;

                if (opt.Discontinued == 1) {
                    desc = "[Discontinued]" + desc;
                }

                if (opt.status == STATUS_OK) {
                    HTML += desc;
                } else {
                    HTML += "<font color='#606060'>" + desc + "</font>"
                }
                // if option group ID = finish
                if (group.GroupID == "FINISH") {
                    try {
                        if (FinishPics[opt.OptioncompID] != null) {
                            //alert ("<a href='#' onClick='SetFinishPicture(\"" + opt.OptioncompID + "\")'>Show Photo</a>");
                            //HTML += "&nbsp;<a href='#' onClick='SetFinishPicture(\"" + opt.OptioncompID + "\");return false;'>[Show Photo]</a>";
                            HTML += "&nbsp;<a href='#' onClick='SetFinishPicture(\"" + opt.OptioncompID + "\");return false;'>[Show Photo]</a>";
                        }
                    } catch (e) {
                        alert("Error in specselect.js (RenderOptionList) - " + e.description);
                    }
                }

                HTML += "<br>";
            }
        }
    }


    return HTML;
}

function GetLargeADAPicture() {
    var zIMGsource;
    if (Product.CSA == "1") {

        if (Product.ADA == "1") {
            //do nothing, both pictures will show up together
        }
        else {
            zIMGSource = "images/pics/adamed.jpg";

            if (Product.ADA == "1") {
                setInnerHTML('LargeADA', '<IMG src=' + zIMGSource + '>');
            }
        }
    }
    else {

        zIMGSource = "images/pics/adamed.jpg";

        if (Product.ADA == "1") {
            setInnerHTML('LargeADA', '<IMG src=' + zIMGSource + '>');
        }
    }
}
function GetLargeCSAPicture() {
    var zIMGsource;
    if (Product.CSA == "1") {
        if (Product.ADA == "1") {
            // do nothing, both pictures will show up together
        }
        else {
            zIMGSource = "images/pics/csamed.jpg";
            if (Product.CSA == "1") {
                setInnerHTML('LargeADA', '<IMG src=' + zIMGSource + '>');
            }
        }
    }
}
function GetBothADACSAPicture() {
    var zIMGsource;
    if (Product.CSA == "1") {
        if (Product.ADA == "1") {
            zIMGSource = "images/pics/adacsamed.jpg";
            setInnerHTML('LargeADA', '<IMG src=' + zIMGSource + '>');
        }
        else {
            // do nothing, one of the pictures is hidden
        }
    }
}
function SetFinishPicture(FinishID) {

    JumpToNewWindow("Pictures", "FinishClicked=" + FinishID);
}

function ShowAllPhotos() {
    JumpToNewWindow("AllPictures");
}

function GetGroupNoSelText(group) {
    var zGroupRules;

    if (group.Required == 1) {
        if (group.GroupRules != null) {
            zGroupRules = group.GroupRules;
            if (zGroupRules.search(/REQUIRES\(SERVICE\)/) == "-1") {
                if (zGroupRules.search(/BLANKONNOSELECTION/) == "-1") {
                    HTML = " style='color: #FF0000; font-size: 8pt;' value='Required Selection' size=50";
                }
                else {
                    HTML = "value=''";
                    //HTML = " style='color: #FF0000' value='Required Selection'";
                }
                //HTML = " style='color: #FF0000' value='Required Selection'";
            }
            else {
                HTML = "style='font-size: 8pt;' value='Must Select Service Index First' size=50";
            }
        }
        else {
            HTML = " style='color: #FF0000' value='Required Selection'";
        }
    } else {

        if (group.GroupID.search('OSPOUT') >= 0 && Product.OptionGroups["SPOUT"] != null) {
            DefaultSpout = Product.OptionGroups["SPOUT"];
            if (DefaultSpout.selected != null) {
                HTML = "style='color: #0000FF' value ='[Standard] " + DefaultSpout.selected.CompPartNum + "'";
            } else {
                HTML = " style='color: #000000' value='<No Selection>'";
            }
        } else {

            HTML = " style='color: #000000' value='<No Selection>'";
        }
    }

    return HTML;
}

function GetParentSpout() {
    if (Product.OptionGroups["SPOUT"] != null) {
        return (Product.OptionGroups["SPOUT"].selected);

    }
}

function RenderLHPSelection(group) {
    //Check if zSelectedLHPID is anything
    //If it is, get the selected handle, finish(if there is one), and accent(if there is one)
    //Show the selected handle as a link on the products page (also 'edit' link)

    // If the handle program exists but there is not a selected handle
    // show the below html on the products page.

    var Handle;
    var HandleAndFinish;
    var HandleAndFinishDesc;

    if (group == 'LHP2') {

        if (zSelectedLHPID2 != '' && zSelectedLHPID2 != null) {

            HTML = "<table height=4 border=0 cellpadding=0 cellspacing=0><tr><td height=4 style='font-size: 1px'>&nbsp;</td></tr></table>";
            HTML += "<table width='100%' border=0 cellspacing=0 style='border-bottom-style: solid; border-bottom-width: 1; border-bottom-color:#FF0000; font-family:Arial, sans-serif; font-size:8pt'><tr><td colspan=2>";
            HTML += "<b>Diverter:</b></td></tr></table><table border=0>";

            /*		alert("zSelectedLHPID2=" + zSelectedLHPID2);
            alert("zSelectedFINISHID2=" + zSelectedFINISHID2);
            alert("zSelectedAccentID2=" + zSelectedAccentID2);
            */
            //alert("Group.GroupID=" + group.GroupID);

            Handle = LHP[zSelectedLHPID2];
            //WORK_TO_DO  - check here if Finish = ''  -NN
            try {
                if (Handle.FINISH != null) {
                    if (Handle.FINISH[zSelectedFINISHID2].AddMode == '1') {

                        HandleAndFinish = LHP[zSelectedLHPID2].PartNum + Handle.FINISH[zSelectedFINISHID2].OptionPartNum;
                        HandleAndFinishDesc = LHP[zSelectedLHPID2].Description + ", " + Handle.FINISH[zSelectedFINISHID2].Description;
                    }
                    else {

                        HandleAndFinish = LHP[zSelectedLHPID2].PartNum;
                        HandleAndFinishDesc = LHP[zSelectedLHPID2].Description + ", " + Handle.FINISH[zSelectedFINISHID2].Description;
                    }
                }
                else {
                    HandleAndFinish = LHP[zSelectedLHPID2].PartNum;
                    HandleAndFinishDesc = LHP[zSelectedLHPID2].Description + ", " + Handle.FINISH[zSelectedFINISHID2].Description;
                }

                HTML += "<tr><td width='20'><a href=# onClick='JumpToPage(\"LHP\",\"Group=LHP2\");return false;'><IMG SRC='images/Pics/" + LHP[zSelectedLHPID2].SmallPicture + ".jpg' border='0'></a></td><td><table border=0><tr><td align='left'><a href=# onClick='JumpToPage(\"LHP\",\"Group=LHP2\");return false;'>" + HandleAndFinish + "</a></td><td> - " + HandleAndFinishDesc + "</td></tr>";

            }
            catch (e) {
                alert("Error occurred in RenderLHPSelection" + e.description);
            }
            if (Handle.ACCENT != null) {

                HTML += "<tr><td><a href=# onClick='JumpToPage(\"LHP\",\"Group=LHP2\");return false;'>" + Handle.ACCENT[zSelectedAccentID2].OptionPartNum + "</a></td><td> - " + Handle.ACCENT[zSelectedAccentID2].Description + "</td></tr></table></td></tr>";

            }
            else {
                HTML += "</table></td></tr>";
                zSelectedAccentID2 = '';
            }
            HTML += "<tr><td colspan=2><a href=# onClick='JumpToPage(\"LHP\",\"Group=LHP2\");return false;'>Edit Current Handle Selection</a></td></tr></table>";

        }
        else {
            HTML = "<table height=4 border=0 cellpadding=0 cellspacing=0><tr><td height=4 style='font-size: 1px'>&nbsp;</td></tr></table>";
            HTML += "<table width='100%' cellspacing=0 class='productOptionUnderline' style='font-family:Arial, sans-serif; font-size:8pt'><tr><td>";
            HTML += "<b>Diverter:</b></td></tr></table><table>";
            HTML += "<tr><td><a href=# onClick='JumpToPage(\"LHP\",\"Group=LHP2\");return false;'>Select a handle...</a></td><td> </td></tr></table>";
        }
    }
    else {
        if (zSelectedLHPID != '') {

            HTML = "<table height=4 border=0 cellpadding=0 cellspacing=0><tr><td height=4 style='font-size: 1px'>&nbsp;</td></tr></table>";
            HTML += "<table width='100%' cellspacing=0 class='productOptionUnderline' style='font-family:Arial, sans-serif; font-size:8pt'><tr><td colspan=2>";
            //HTML += "<b>" + group.GroupName + "</b></td></tr></table><table border=0>";
            if (bLHPproduct2 == true) {
                HTML += "<b>Hot and Cold Handles:</b></td></tr></table><table border=0>";
            }
            else {
                HTML += "<b>Less Handle Program:</b></td></tr></table><table border=0>";
            }
            if (zSelectedLHPID == '') {
                //Handle = LHP[group.
            }
            else {
                //alert("test1");
                Handle = LHP[zSelectedLHPID];  //- is this the problem line?
                //alert("test2");
            }
            //WORK_TO_DO  - check here if Finish = ''  -NN
            if (Handle.FINISH != null) {

                if (Handle.FINISH[zSelectedFINISHID].AddMode == '1') {

                    HandleAndFinish = LHP[zSelectedLHPID].PartNum + Handle.FINISH[zSelectedFINISHID].OptionPartNum;
                    HandleAndFinishDesc = LHP[zSelectedLHPID].Description + ", " + Handle.FINISH[zSelectedFINISHID].Description;
                }
                else {
                    HandleAndFinish = LHP[zSelectedLHPID].PartNum;
                    HandleAndFinishDesc = LHP[zSelectedLHPID].Description + ", " + Handle.FINISH[zSelectedFINISHID].Description;
                }
            }
            else {
                HandleAndFinish = LHP[zSelectedLHPID].PartNum;
                HandleAndFinishDesc = LHP[zSelectedLHPID].Description;
            }

            //HTML += "<tr><td width='20'><a href=# onClick='JumpToPage(\"LHP\",\"Group=" + group.GroupID + "\");return false;'><IMG SRC='images/Pics/" + LHP[zSelectedLHPID].SmallPicture + ".jpg' border='0'></a></td><td><table border=0><tr><td align='left'><a href=# onClick='JumpToPage(\"LHP\",\"Group=" + group.GroupID + "\");return false;'>" + HandleAndFinish + "</a></td><td> - " + HandleAndFinishDesc + "</td></tr>";
            HTML += "<tr><td width='20'><a href=# onClick='JumpToPage(\"LHP\",\"Group=LHP\");return false;'><IMG SRC='images/Pics/" + LHP[zSelectedLHPID].SmallPicture + ".jpg' border='0'></a></td><td><table border=0><tr><td align='left'><a href=# onClick='JumpToPage(\"LHP\",\"Group=LHP\");return false;'>" + HandleAndFinish + "</a></td><td> - " + HandleAndFinishDesc + "</td></tr>";

            if (Handle.ACCENT != null) {

                HTML += "<tr><td><a href=# onClick='JumpToPage(\"LHP\",\"Group=LHP\");return false;'>" + Handle.ACCENT[zSelectedAccentID].OptionPartNum + "</a></td><td> - " + Handle.ACCENT[zSelectedAccentID].Description + "</td></tr></table></td></tr>";

            }
            else {
                HTML += "</table></td></tr>";
                zSelectedAccentID = '';
            }
            //HTML += "<tr><td colspan=2><a href=# onClick='JumpToPage(\"LHP\",\"Group=" + group.GroupID + "\");return false;'>Edit Current Handle Selection</a></td></tr></table>";
            HTML += "<tr><td colspan=2><a href=# onClick='JumpToPage(\"LHP\",\"Group=LHP\");return false;'>Edit Current Handle Selection</a></td></tr></table>";

        }
        else {
            HTML = "<table height=4 border=0 cellpadding=0 cellspacing=0><tr><td height=4 style='font-size: 1px'>&nbsp;</td></tr></table>";
            HTML += "<table width='100%' border=0 cellspacing=0 style='border-bottom-style: solid; border-bottom-width: 1; border-bottom-color:#FF0000; font-family:Arial, sans-serif; font-size:8pt'><tr><td>";
            if (bLHPproduct2 == true) {
                HTML += "<b>Hot and Cold Handles:</b></td></tr></table><table border=0>";
            }
            else {
                HTML += "<b>Less Handle Program:</b></td></tr></table><table>";
            }
            //HTML += "<tr><td><a href=# onClick='JumpToPage(\"LHP\",\"Group=" + group.GroupID + "\");return false;'>Select a handle...</a></td><td>&nbsp;&nbsp;&nbsp;&nbsp;<a href=# onClick='JumpToNewWindow(\"BYOF\");return false;'>Build Your Own Faucet</a></td></tr></table>";
            HTML += "<tr><td><a href=# onClick='JumpToPage(\"LHP\",\"Group=LHP\");return false;'>Select a handle...</a></td></tr></table>";
        }
    }


    return HTML;
    //alert(zSelectedLHPID);

    //If there is no selected handle, show a link to the LHP page
}

function RenderSelectBox(group) {

    //HTML = "<br>";
    HTML = "<table height=4 border=0 cellpadding=0 cellspacing=0><tr><td height=4 style='font-size: 1px'>&nbsp;</td></tr></table>";
    //HTML +="<b>" + group.GroupName + ":</b><br><hr color=#FF0000>";
    HTML += "<table width='100%' border=0 cellspacing=0 ><tr><td>";
    HTML += "<b>" + group.GroupName + ":</b>";
    HTML += "</td></tr></table>";
    HTML += "<input type='text' size=50 name='" + group.GroupID + "'";
    if (group.selected == null) {
        HTML += GetGroupNoSelText(group);
    } else {
        if (group.selected.Standard == 1) {
            HTML += "style='font-size: 8pt; color: #0000FF;' value='[Standard]" + group.selected.PartNum + "-" + group.selected.Description + "'";
        } else {
            HTML += " style='font-size: 8pt;' value='" + group.selected.PartNum + "-" + group.selected.Description + "'";
        }
    }
    HTML += ">";
    if (group.status == STATUS_OK) {
        HTML += "<input size=50 type='button' value='...' name='" + group.GroupID + "'";

        HTML += " onClick=JumpToPage('PRODUCT','Group=" + group.GroupID + "')";
        HTML += ">";
    }

    //HTML += "<br>";

    return HTML;

}

function RenderTableList(group) {
    //HTML = "<br><b>" + group.GroupName + ":</b><br><hr color=#FF0000>";
    var HTML;
    var opt;
    var option;
    var group;
    var forecolor;
    var desc;


    HTML = "<Table border=1 cellpadding=0 cellspacing=0 width=100%>";
    HTML += "<tr><td colspan=2 align=center><b>" + group.GroupName + ":</b></td></tr>";
    HTML += "<tr bgcolor=#c0c0c0><td>Description</td><td>Part</td></tr>";
    for (opt in group.Options) {
        option = group.Options[opt];
        if (option.status != STATUS_HIDDEN) {
            HTML += "<tr";
            if (group.selected == option) {
                forecolor = '#FFFFFF';
                HTML += " bgcolor=#000000";
            } else {
                if (option.Standard == 1) {
                    forecolor = '#0000FF';
                } else {
                    forecolor = '#000000';
                }
            }


            if (option.status == STATUS_DISABLED || group.status == STATUS_DISABLED) {
                forecolor = '#C0C0C0';
            } else {
                HTML += " onClick=OptionClicked('" + group.GroupID + "','" + option.OptioncompID + "')";
            }

            desc = option.Description;

            if (option.Discontinued == true) {
                desc = "[Discontinued]" + desc;
            }


            HTML += ">";
            //HTML += "<td height=50px><a href=''><font color=" + forecolor + ">" + GetImageTag(option.SmallPicture) + "</font></a></td>"
            HTML += "<td height=50px><font color=" + forecolor + ">" + desc + "</font></td>";
            HTML += "<td valign=top><font color=" + forecolor + ">" + option.PartNum + "</font></td>";
            HTML += "</tr>";
        }
    }
    HTML += "</Table>";




    return HTML;
}


function RenderFrameTableList(group) {

    var HTML;
    var opt;
    var option;
    var group;
    var forecolor;
    var bgcolor;
    var desc;
    var FirstRow;
    var Row;
    var currentRowClass;
    var Rows;

    
    HTML = "<table class='optionGrid'>";
    
    FirstRow = "";
    Rows = "";

    for (opt in group.Options) {

        Row = "";
        currentRowClass = "";
        
        option = group.Options[opt];

        if (option.status == STATUS_HIDDEN) {
            continue;       
        }

        //Build the current row
        
        //Open row tag <tr>
        Row = "<tr id='P" + option.OptioncompID + "'";

        //Set the background color based on whether if the row is selected
        if (group.selected == option) {
            currentRowClass = 'selectedRow regularRow';
        }
        else {
            if (option.Standard == 1) {
                currentRowClass = 'selectedStandardRow regularRow';
            }
        }

        //Set Disabled
        if (option.status == STATUS_DISABLED || group.status == STATUS_DISABLED) {
            currentRowClass = 'disabledRow';
        } else {
            Row += " onclick=\"parent.OptionClicked('" + group.GroupID + "','" + option.OptioncompID + "')\"";
        }
        
        //Ninja in the class name for the entire Row
        Row += " class='" + currentRowClass + "'"

        Row += ">";

        desc = option.Description;

        if (option.Discontinued == true) {
            desc = "[Discontinued]" + desc;
        }
        
        //Create the cells
        Row += "<td class='imageColumn'>"
        
        //Add Small Product Image
        // Row += "<a href='' class='smallProductImage'>" + GetImageTag(option.SmallPicture);
        Row +=  GetImageTag(option.SmallPicture);

        //Small ADA Image
        if (option.ADA == true) {
            Row += GetImageTag('smallada');
        }
        
        //Close the Image Cell
        //Row += "</a></td>";
        Row += "</td>";

        //Create the Description Cell
        Row += "<td class='descriptionCell'>" + desc + "</td>";
        
        //Start the Part Number Cell
        Row += "<td class='partNumberCell'>" + option.PartNum;

        //Add a more link to open an information window depending on the Option
        if (option.OptionTag == '*') {
            Row += "<br /><a href='#' onclick='OpenNewWindow();return false;'>More...</a>";
        }
        
        //Clost the cell tag
        Row += "</td>";
        
        //Close the row tag
        Row += "</tr>";

        Rows += Row;
        
    }
    
    //Combine the opening table tag with the rows
    HTML += FirstRow + Rows +  "</div>";
    
    return HTML;
}

function ApplyMultipliers() {

    //This function is used by the Edit Price page
    //Apply all changes to the multiplier fields that have been made
    //Any that have been changed from 1.000 will affect the future prices

    //Start by listing all of the values in the multiplier boxes (to be sure they are accessable.

    var allInputBoxes;
    var allInputBoxesForFuturePriceChange;
    var zTempName;
    var iNewFuturePrice;
    var i;
    var j;
    var cCurrentPrice;
    var cFuturePrice;
    var objPriceText;


    allInputBoxes = document.forms[0].elements;
    //alert(allInputBoxes[1].name);
    //alert(allInputBoxes[1].value);
    allInputBoxesForFuturePriceChange = document.forms[0].elements;





    for (i = 0; i <= allInputBoxes.length; i++) {
        //alert(allInputBoxes[i].name);
        if (allInputBoxes[i]) {
            if (allInputBoxes[i].value != "1.000") {
                if (allInputBoxes[i].name.indexOf("MULTI") != -1) {
                    zTempName = allInputBoxes[i].name.substring(11, allInputBoxes[i].name.length);
                    for (j = 0; j <= allInputBoxesForFuturePriceChange.length; j++) {
                        //	alert("zInputBoxName=" + allInputBoxes[i].name);
                        //	alert("InputBox.value="+ allInputBoxes[i].value);
                        //alert("allInputBoxesForFuturePriceChange.length=" + allInputBoxesForFuturePriceChange.length);

                        //					alert("allInputBoxesForFuturePriceChange[j].value=" + allInputBoxesForFuturePriceChange[j].value);
                        //					alert("zTempName=" + zTempName);

                        if (allInputBoxesForFuturePriceChange[j]) {
                            if (allInputBoxesForFuturePriceChange[j].name.indexOf(zTempName) != -1) {
                                if (allInputBoxesForFuturePriceChange[j].name.indexOf("MULTI") == -1) {
                                    //alert("allInputBoxesForFuturePriceChange[j].value=" + allInputBoxesForFuturePriceChange[j].value);
                                    //alert("allInputBoxes[i].value=" + allInputBoxes[i].value);
                                    cCurrentPrice = allInputBoxesForFuturePriceChange[j].value
                                    //Remove the $ sign
                                    if (cCurrentPrice.substring(0, 1) == "$") {
                                        cCurrentPrice = cCurrentPrice.substring(1, allInputBoxesForFuturePriceChange[j].value.length);
                                    }

                                    //Remove any commas
                                    var commapos = cCurrentPrice.indexOf(",");
                                    while (commapos >= 0) {
                                        cCurrentPrice = cCurrentPrice.substring(0, commapos) + cCurrentPrice.substring(commapos + 1, cCurrentPrice.length);
                                        commapos = cCurrentPrice.indexOf(",");
                                    }
                                    cFuturePrice = (cCurrentPrice * allInputBoxes[i].value);
                                    //alert("New Future Price = " + cFuturePrice);

                                    allInputBoxesForFuturePriceChange[j].value = dollarize(cFuturePrice);
                                }
                            }
                        }
                    }
                }
            }
        }
    }

}

function ApplyBaseMultiplier(mult) {
    var allInputBoxes;
    var i;
    var cCurrentPrice;
    var cFuturePrice;
    var objPriceText;
    var currentspantag;


    allInputBoxes = document.forms[0].elements;
    for (i = 0; i <= allInputBoxes.length; i++) {

        if (allInputBoxes[i]) {

            if (allInputBoxes[i].name.substring(0, 4) == 'BASE' || allInputBoxes[i].name.substring(0, 4) == 'PART') {

                Currentspantag = document.getElementById('Current|' + allInputBoxes[i].name);
                if (Currentspantag) {
                    cCurrentPrice = Currentspantag.innerHTML;
                    //Remove the $ sign
                    if (cCurrentPrice.substring(0, 1) == '$') {
                        cCurrentPrice = cCurrentPrice.substring(1, cCurrentPrice.length);
                    }
                    cFuturePrice = (cCurrentPrice * mult);
                    if (isNaN(cFuturePrice) == false) {

                        allInputBoxes[i].value = dollarize(cFuturePrice);
                    }
                }
            }
        }
    }
}

function dollarize(cPrice) {
    return "$" + format(cPrice, 2);

}

function format(num, decplaces) {


    if (isNaN(parseInt(num))) {
        return NaN;
    }


    return formatCurrency(Math.ceil(eval(num) / 0.05) * 5 / 100);


    //all this was replaced with the above function which fixed a rounding problem

    /* var newNumStr = num;
    //Format correct decimal places
    //Multiply by decimal places to the power of ten
    //Round to get rid of unneeded decimals
    newNumStr = "" + Math.round(eval(newNumStr) * Math.pow(10, decplaces));
    
    //Pad small numbers with 0s
    while(newNumStr.length <= decplaces)
    {
    newNumStr = "0" + newNumStr;
    }
    var iDecimalPos = newNumStr.length - decplaces;
    
    //assemble decimals
    newNumStr = newNumStr.substring(0,iDecimalPos) + "." + newNumStr.substring(iDecimalPos,newNumStr.length);
    
    //Add comma for formatting
    //start at the decimal point and work toward the beginning decrementing by 3 place values each time
    
    if(num > 1000)
    {
    //
    var iPos = newNumStr.indexOf(".");
    if(iPos < 0)
    {
    iPos = newNumStr.length;
    }
    iPos -=3;
        
    while(iPos >=1)
    {
    newNumStr = newNumStr.substring(0,iPos) + "," + newNumStr.substring(iPos, newNumStr.length);
    iPos -=3;
    }
    }
    
    
    
    newNumStr = jsNearestNickle(newNumStr);
    return newNumStr*/



}

//obsolete
function jsNearestNickle(newNumStr) {
    // var varValue = "123456.30";   // simulated parameter 
    var varValue = newNumStr
    // note that all $ signs and commas must be removed! 

    var dVal = parseInt(varValue);                    //dollar value 
    var cVal = parseInt((varValue * 100) - (dVal * 100));   //cent value 
    var pVal = parseInt(cVal - (parseInt(cVal / 10) * 10)); //penny value 
    var tVal = cVal - pVal;                             //ten cent value 

    //alert(dVal); alert(cVal); alert(pVal); alert(tVal); 

    if (pVal <= 2) {
        pVal = 0;      // nearest nickle is .00 down so tens don't change 
    } else {
        if (pVal <= 6) {
            pVal = 5;     // nearest nickle is .05 so tens don't change 
        } else {
            pVal = 0;     // nearest nickle is .10 up so nickle 0 tens increase 
            tVal += 10;
        }
    }

    //alert(dVal + "." + (tVal+pVal)); 

    return (dVal + "." + (tVal + pVal));

}
function writeFrame(zID, zHTML, zSelected) {
    var zID;
    var zHTML;
    var zSelected;

    try {
    
        document.getElementById(zID).innerHTML = zHTML
        
    } catch (e) {
        alert("Error 1 in writeFrame - " + e.description);
    }

//    if (zSelected != null && zSelected != "") {
//        try {

//            if (document.getElementById("P" + zSelected) != null) {
//                document.getElementById("P" + zSelected).scrollIntoView();
//            }
//            
//        } catch (e) {
//            alert("Error 2 in writeFrame - " + e.description); // do nothing
//        }
//    }
    
    return;

}