
function getObj(f) {
        comma = ",";
        this.oForm = f;
        this.oElm = f.elements;
        this.oUppht = f.upperheight;
        this.oSets = f.sets;
        this.oPun = f.punct;
        this.oEsp = f.espanol;
        this.oFont = f.font;
        this.oBq = f.lqty;
        this.oUpPrice = f.UpPrice;
        this.oPanel = f.panel;
        this.oColor = f.color;
        this.oPgTotal = f.s_pgTotal;
        this.oQty = f.qty;
        this.oAcc = f.pTotal;
        this.oTotal = f.totl;
        this.di = document.images;
        return this, resetForm(), data(), doFont(), doSize(3), tot_cook();
    };


    function data() {
        var siz = oUppht.selectedIndex;
        siz = siz == -1 ? 0 : siz;
        this.dStr = dArr[getFont()][siz];
        var t = 0, bt = 0;
        var hex = oColor.value == "White" ? "#ffffff" : oColor.value == "Black" ? "#000000" : oColor.value == "Red" ? "#ff0000" : oColor.value == "Blue" ? "#003399" : "#339900";
        for (var e = 7; e < 72; e++) {
            t = parseFloat(oElm[e].value);
            if (isNaN(t)) {
                t = 0;
            };
            oElm[e].style.backgroundColor = oElm[e].value > 0 ? "#dafb95" : "#ffffff";
            bt += t;
        };
        oBq.value = bt;
        t = bt < 150 ? dStr[7] : bt < 200 ? dStr[8] : bt < 400 ? dStr[9] : bt < 800 ? dStr[10] : dStr[11];
        oUpPrice.value = oForm.price_each.value = fixP(t);
        oPanel.value = dStr[1];
        analysis();
    };


    function analysis() {
        oPgTotal.value = "0.00";
        var t = 0, tot = 0, tr1 = 0, bt = 0;
        bt = parseFloat(oBq.value);
        t = parseFloat(oUpPrice.value);
        t = t * bt;
        oPgTotal.value = fixP(t);
        oTotal.value = fixP(t + tot);
    };


    function checkBoxes(obj) {
        if (isNaN(obj.value)) {
            obj.value = 0;
        };
        if (obj.value == "") {
            obj.value = 0;
        };
        data();
    };


    function getFont() {
        fon = oFont.selectedIndex;
        fon = fon == -1 ? 0 : fon;
        return fon;
    };


    function doFont() {
        var fArr = new Array;
        fArr = F.split("/");
        var faLen = fArr.length;
        for (var i = 0; i < faLen; i++) {
            var fFont = fArr[i].split("~");
            oFont.options[i] = new Option(fFont[0], fFont[1]);
        };
        oFont.selectedIndex = 0;
    };


    function doSize() {
        var daLen = dArr[getFont()].length;
        for (var j = oUppht.options.length - 1; j > 0; j--) {
            oUppht.options[j] = null;
        };
        for (var k = 0; k < daLen; k++) {
            if (dArr[fon][k][0] == 89) {
                oUppht.options[k] = new Option("8\" on 9\"", dArr[fon][k][0]);
            } else {
                oUppht.options[k] = new Option(dArr[fon][k][0] + "\"", dArr[fon][k][0]);
            };
        };
        oUppht.selectedIndex = 0;
        di.imgF.src = "gImages/changeable/styles/" + oFont.value.toLowerCase() + ".jpg";
        doColor(oUppht[oUppht.selectedIndex].value);
    };


    function getPunct() {
        var c = 0;
        var set = oPun.selectedIndex;
        set = set == -1 ? 0 : set;
        var s = parseFloat(oSets[oSets.selectedIndex].value);
        this.iStr = iArr[1];
        this.sStr = pArr[0][set];
        for (var e = 43; e < 59; e++) {
            if (e > 54 && e < 57) {
                oElm[e].value = s + sStr[iStr[c]];
            } else {
                oElm[e].value = sStr[iStr[c]];
            };
            c++;
        };
        data();
    };


    function getEspanol(myData) {
        var c = 0;
        for (var e = 65; e < 72; e++) {
            oElm[e].value = oEsp.selectedIndex == 1 ? 6 : 0;
            c++;
        };
        data();
    };


    function getSets() {
        var c = 0;
        var set = oSets.selectedIndex;
        set = set == -1 ? 0 : set;
        this.iStr = iArr[0];
        this.sStr = sArr[0][set];
        for (var e = 7; e < 72; e++) {
            if (e > 42) {
                if (e > 54 && e < 57) {
                    oElm[e].value = sStr[iStr[c]];
                } else {
                    oElm[e].value = 0;
                };
            } else {
                oElm[e].value = sStr[iStr[c]];
                c++;
            };
        };
        if (oPun.selectedIndex > 0) {
            getPunct();
        };
        data();
    };


    function clearSets() {
        for (var e = 7; e < 72; e++) {
            oElm[e].value = 0;
            oElm[e].style.backgroundColor = "#ffffff";
        };
        oSets.options.selectedIndex = 0;
        oPun.options.selectedIndex = 0;
        oEsp.options.selectedIndex = 0;
        data();
    };


    function calc(d) {
        var siz = oForm.lsize.selectedIndex;
        siz = siz == -1 ? 0 : siz;
        this.cStr = cArr[0][siz];
        var myval = cStr[oForm.lines.value];
        oForm.result.value = myval;
        oForm.result1.value = cStr[5];
    };


    function doColor(siz) {
        var oldVal = oColor.selectedIndex;
        var colors = new Array;
        colors[0] = "#000000|Black";
        colors[1] = "#FF0000|Red";
        colors[2] = "#FFFFFF|White";
        colors[3] = "#003399|Blue";
        colors[4] = "#339900|Green";
        for (var j = oColor.options.length - 1; j > 0; j--) {
            oColor.options[j] = null;
        };
        var daLen = siz == 89 || siz == 10 || oFont.selectedIndex == 5 ? 2 : 5;
        for (var k = 0; k < daLen; k++) {
            var c = colors[k].split("|");
            oColor.options[k] = new Option(c[1], c[0]);
            if (k == oldVal) {
                doCol(c[1]);
                oColor.selectedIndex = oldVal;
            } else {
                doCol("Black");
                oColor.selectedIndex = 0;
            };
        };
    };


    function doCol(d) {
        document.getElementById("ltrColr").src = "gImages/changeable/" + d + ".png";
    };


    function resetForm() {
        oForm.reset();
        oFont.selectedIndex = 0;
        oUppht.selectedIndex = 0;
        oColor.value = "Black";
        oPgTotal.value = "0.00";
        oQty.value = "1";
        clearSets();
    };


    function pack() {
        var n = [];
        var c_max = 0;
        var i = 0;
        var list = "";
        var total = 0;
        for (var i = 7; i < 72; i++) {
            c = oElm[i].value;
            if (c > 0) {
                if (c > c_max) {
                    c_max = c;
                };
                if (n[c] == null) {
                    n[c] = c + " each of (";
                };
                if (oElm[i].name.length > 1) {
                    n[c] += " ," + oElm[i].name + ",";
                } else {
                    n[c] += oElm[i].name;
                };
                total += Math.floor(c);
            };
        };
        c = c_max + 1;
        while (c > 0) {
            if (n[c] != null) {
                list += n[c] + ")  <br>";
            };
            c--;
        };
        list = list.replace(/,\)/g, ")");
        list = list.replace(/\(\s\,/g, "(");
        list = list.replace(/\,\s\,/g, ",");
        if (total > 0) {
            list = " total letters =" + total + " : <br>" + list;
        };
        return list;
    };


    function addTo() {
        data();
        var qVal = oForm.qty.value;
        var rc = parseFloat(oTotal.value) == 0 &&
            oForm.qty1.value == 0 &&
            oForm.qty2.value == 0 &&
            oForm.qty3.value == 0 &&
            oForm.qty4.value == 0 && oForm.qty5.value == 0 ? "Nothing selected for adding!" : "";
        if (rc) {
            return alert(rc);
        };
        if (isNaN(qVal) ||
            qVal.indexOf(".") != -1 || qVal < 1 || qVal.charAt(0) == 0) {
            alert("The quantity entered is incorrect : " + qVal + " - whole numbers only     ");
            return oForm.qty.value = 1;
        };
        var newPhrase = pack();
        if (parseFloat(oTotal.value) > 0) {
            if (newPhrase == "") {
                newPhrase = "None";
            };
            var t = qVal * parseFloat(oPgTotal.value);
            var cookStr = 
					"Product Type   ~ Pronto Changeable" + 
					"|Material      ~ Acrylic" + 
					"|Letters       ~ " + newPhrase + 
					"|Font          ~ " + oFont[oFont.selectedIndex].text + 
					"|Letter Height ~ " + oUppht[oUppht.selectedIndex].text + 
					"|Panel Height  ~ " + oPanel.value + 
					"|Color         ~ " + oColor[oColor.selectedIndex].text + 
					"|Qty           ~ " + parseFloat(qVal) + 
					"|Price         ~ " + fixP(t);
					
            cookStr = cookStr.replace(/\s+\~\s/g, "~");
            cookStr = cookStr.replace(/\s+\|\s/g, "|");
            cookStr = cookStr.replace(/["]/g, "#Y");
            cookStr = cookStr.replace(/[']/g, "#Z");
            if (t != 0) {
                toCook("item_", cookStr);
            };
            cookStr = "";
        };
        var accStr = "Product Type~Changeable Accessories|";
        if (oForm.qty1.value > 0) {
            var idx = oForm.topRail.selectedIndex;
            var size = idx == 0 || idx == 3 ? 8 : idx == 1 || idx == 4 ? 10 : 12;
            var type = idx < 3 ? "acrylic" : "polycarbonate";
            var tLen = oForm.qty1.value * size;
            cookStr = accStr + "Top Rail~" + tLen + " feet of " + type + " top rail in " + size + " Foot Lengths";
            cookStr += "|Qty~" + oForm.qty1.value;
            cookStr += "|Price~" + oForm.tTot1.value;
            toCook("item_", cookStr);
            cookStr = "";
        };
        if (oForm.qty2.value > 0) {
            var idx = oForm.bRail.selectedIndex;
            var size = idx == 0 || idx == 3 ? 8 : idx == 1 || idx == 4 ? 10 : 12;
            var type = idx < 3 ? "acrylic" : "polycarbonate";
            var tLen = oForm.qty2.value * size;
            cookStr = accStr + "Bottom Rail~" + tLen + " feet of " + type + " bottom rail in " + size + " Foot Lengths";
            cookStr += "|Qty~" + oForm.qty2.value;
            cookStr += "|Price~" + oForm.tTot2.value;
            toCook("item_", cookStr);
            cookStr = "";
        };
        if (oForm.qty3.value > 0) {
            var idx = oForm.ctrRail.selectedIndex;
            var size = idx == 0 || idx == 3 || idx == 6 ? 8 : idx == 1 || idx == 4 || idx == 7 ? 10 : 12;
            var type = idx < 3 ? "acrylic" : idx < 6 ? "polycarbonate" : "Mini Acrylic";
            var tLen = oForm.qty3.value * size;
            cookStr = accStr + "Center Rail~" + tLen + " feet of " + type + " center rail in " + size + " Foot Lengths";
            cookStr += "|Qty~" + oForm.qty3.value;
            cookStr += "|Price~" + oForm.tTot3.value;
            toCook("item_", cookStr);
            cookStr = "";
        };
        if (oForm.qty4.value > 0) {
            cookStr = accStr + "Rivets~" + oForm.qty4.value + " Bag(s) " + oForm.rivet[oForm.rivet.selectedIndex].text;
            cookStr += "|Qty~" + oForm.qty4.value;
            cookStr += "|Price~" + oForm.tTot4.value;
            toCook("item_", cookStr);
            cookStr = "";
        };
        if (oForm.qty5.value > 0) {
            cookStr = accStr + "Change Arm~" + oForm.changearm[oForm.changearm.selectedIndex].text;
            cookStr += "|Qty~" + oForm.qty5.value;
            cookStr += "|Price~" + oForm.tTot5.value;
            toCook("item_", cookStr);
            cookStr = "";
        };
        location.href = "s_viewCart.htm";
    };


