Cookie.prototype.showcart = function(withfunc){
    curtains = this.prods.split("_");
    document.write('<TABLE class="cart">');
    fabreq = 0;
    widreq = 0;
    dropreq = 0;
    famreq = 0;
    liningreq = 0;
    interliningreq = 0;
    configreq = 0;
    stylereq = 0;
    retreq = 0;
    fitreq = 0;
    featreq = 0;
    var fabsperm = 0;
    var prodtype;
    for (i = 1; i <= this.numitems; i++) {
        prodtype = parseFloat(curtains[i].slice(0, 1));
        if (prodtype == 8) {
            fabsperm++;
            //alert('showcart:'+descquote(curtains[i]));
        }
        fabreq = fabreq + parseFloat(curtains[i].slice(15, 18));
        widreq = widreq + parseFloat(curtains[i].slice(1, 6));
        dropreq = dropreq + parseFloat(curtains[i].slice(0, 1));
        if (vertrep(parseFloat(curtains[i].slice(15, 18))) > 0) {
            famreq = famreq + parseFloat(curtains[i].slice(24, 25));
        }
        liningreq = liningreq + parseFloat(curtains[i].slice(11, 12));
        interliningreq = interliningreq + parseFloat(curtains[i].slice(12, 13));
        configreq = configreq + parseFloat(curtains[i].slice(13, 15));
        stylereq = stylereq + parseFloat(curtains[i].slice(25, 27));
        retreq = retreq + parseFloat(curtains[i].slice(29, 35));
        fitreq = parseFloat(curtains[i].slice(27, 29));
        featreq = featreq + parseFloat(curtains[i].slice(35, 37));
    }
    var cols = 2;
    h = '<COL><COL>';
    s = '<THEAD><TR><TH class=cart><TH class=cart>Item';
    if (stylereq > 0) {
        h = h + '<COL>';
        s = s + '<TH class=cart>Style';
        cols++;
    }
    if (configreq > 0) {
        h = h + '<COL>';
        s = s + '<TH class=cart>Configuration';
        cols++;
    }
    if (fabreq > 0) {
        h = h + '<COL>';
        s = s + '<TH class=cart>Fabric';
        cols++;
    }
    if (widreq > 0) {
        h = h + '<COL style="text-align:right;">';
        s = s + '<TH class=cart>Width<BR>(cm)';
        cols++;
    }
    if (dropreq > 0) {
        h = h + '<COL style="text-align:right;">';
        if (fabsperm > 0) {
            if (fabsperm == this.numitems) {
                s = s + '<TH class=cart>Length<BR>(cm)';
                
            }
            else {
                s = s + '<TH class=cart>Length<BR>or Drop (cm)';
            }
        }
        else {
            s = s + '<TH class=cart>Drop<BR>(cm)';
        }
        cols++;
    }
    if (liningreq > 0) {
        h = h + '<COL>';
        s = s + '<TH class=cart>Lining';
        cols++;
    }
    if (interliningreq > 0) {
        h = h + '<COL>';
        s = s + '<TH class=cart>Interlining';
        cols++;
    }
    if (fitreq > 0) {
        h = h + '<COL>';
        s = s + '<TH class=cart>Fitting';
        cols++;
    }
    if (retreq > 0) {
        h = h + '<COL>';
        s = s + '<TH class=cart>Return';
        cols++;
    }
    if (featreq > 0) {
        h = h + '<COL>';
        s = s + '<TH class=cart>Any Special Features';
        cols++;
    }
    h = h + '<COL style="text-align:right;"><COL>';
    s = s + '<TH class=cart>Price (&pound;)<TH class=cart>';
    document.write(h);
    itemno = 0;
    for (p = 1; p <= 8; p++) {
        for (i = 1; i <= this.numitems; i++) {
            ptype = parseFloat(curtains[i].slice(0, 1));
            if (ptype == p) {
                itemno = itemno + 1;
                s = s + '<TR class=bord><TD class=cart>' + itemno.toString();
                s = s + '<TD class=cart>' + descprodtype(curtains[i]);
                if (stylereq > 0) {
                    s = s + '<TD class=cart>' + descstyle(curtains[i]);
                }
                if (configreq > 0) {
                    s = s + '<TD class=cart>' + descconfig(curtains[i]);
                }
                if (fabreq > 0) {
                    s = s + '<TD class=cart>' + descfabric(curtains[i]);
                    if (famreq > 0) {
                        s = s + ' ' + descfamily(curtains[i]);
                    }
                }
                if (widreq > 0) {
                    s = s + '<TD class=cart>' + descwidth(curtains[i]);
                }
                if (dropreq > 0) {
                    s = s + '<TD class=cart>' + descdrop(curtains[i]);
                }
                if (liningreq > 0) {
                    s = s + '<TD class=cart>' + desclining(curtains[i]);
                }
                if (interliningreq > 0) {
                    s = s + '<TD class=cart>' + descinterlining(curtains[i]);
                }
                if (fitreq > 0) {
                    s = s + '<TD class=cart>' + descfitting(curtains[i]);
                }
                if (retreq > 0) {
                    s = s + '<TD class=cart>' + descreturn(curtains[i]);
                }
                if (featreq > 0) {
                    s = s + '<TD class=cart>' + descfeature(curtains[i]) + descfeaturefabric(curtains[i]);
                }
                s = s + '<TD class=cart>' + descquote(curtains[i]);
                if (withfunc === true) {
                    s = s + '<TD class=cart><A HREF=javascript:curtaindata.deleteitem(' + intstr(i) + ')>' + '<SPAN TITLE="Click here to delete this curtain from your order" class=smallprint>Delete</SPAN></A>';
                }
            }
        }
    }
    this.calccart();
    document.write(s);
    document.write('<TR style="bordertop:thin green solid;background-color:#EEF3F7;"><TD colspan=' + cols.toString() + '>Total:<TD>' + numstr(this.M_subtotal, true));
    document.write('<TR style="background-color:#EEF3F7;"><TD colspan=' + cols.toString() + '>Carriage:<TD>' + numstr(this.M_carriage, true));
    document.write('<TR style="font-weight:bold;background-color:#EEF3F7;"><TD colspan=' + cols.toString() + '>Grand Total:<TD>' + numstr(this.M_total, true));
    document.write('</TABLE>');
    document.write('<INPUT TYPE=hidden size=50 name="M_calcs"  VALUE="' + this.M_calcs + '">');
    //alert ('dbg: showcart concluded successfully');
};
Cookie.prototype.deleteitem = function(itemno){
    //convert the prods string into an array
    curtains = this.prods.split("_");
    //remove the item from the array
    curtains.splice(itemno, 1);
    //re-assemble the prods string
    this.prods = curtains.join('_');
    //adjust the numitems value
    this.numitems--;
    //convert the calcs string into an array
    calcs = this.M_calcs.split("_");
    //remove the item from the array
    calcs.splice(itemno, 1);
    //re-assemble the calcs string
    this.M_calcs = calcs.join('_');
    //store the cookie - no semi colon! (so numitems goes down but the cookie still has the item)
    this.store();
    //window.open(this.$document.URL,this.$name);
    var winname = new String();
    var rep = new String();
    winname = document.domain;
    rep = "www.";
    winname = winname.replace(rep, "");
    rep = ".co.uk";
    winname = winname.replace(rep, "");
    //alert("DBG:This winname="+winname);
    window.open(this.$document.URL, winname);
};
Cookie.prototype.updatespecs = function(form){
    form.M_specs.value = this.M_specs;
    form.M_deliverycountry.value = this.M_deliverycountry;
};
Cookie.prototype.setcountry = function(form){
    this.M_deliverycountry = form.M_deliverycountry.value;
    this.store();
};

Cookie.prototype.showord = function(){
    var s = '';
    
    curtains = this.prods.split("_");
    for (i = 1; i <= this.numitems; i++) {
        //could order later
        if (this.numitems > 1) {
            s = s + ' (' + i.toString() + ') ' + describe(curtains[i]);
        }
        else {
            s = s + describe(curtains[i]);
        }
    }
    return s;
};

Cookie.prototype.checkover = function(form){
    form.action = 'checkover.php';
    form.submit();
};
Cookie.prototype.buy = function(form){
    if (this.oktogo(form)) {
        form.action = 'transfer.php';
        form.M_orderid.value = this.prods;
        form.amount.value = this.M_total;
        form.desc.value = this.numitems.toString() + ' items: ' + this.showord();
        form.M_subtotal.value = this.M_subtotal;
        form.M_carriage.value = this.M_carriage;
        form.M_numitems.value = this.numitems;
        form.M_specs.value = this.M_specs;
        
        form.submit();
    }
};
Cookie.prototype.oktogo = function(form){
    this.load();
    if (this.numitems <= 0) {
        alert('Order not submitted: there are no items in your shopping cart');
    }
    else 
        if (this.M_subtotal <= 0 || this.M_total <= 0) {
            alert('Order not submitted: your shopping cart has no monetary value');
        }
        else 
            if (this.prods === "") {
                alert('Order not submitted: there are no products in your cart');
            }
            else 
                if (form.email.value === "") {
                    alert('Order not submitted: there is no email address');
                }
                else 
                    if (form.M_deliverypostcode.value === "") {
                        alert('Order not submitted: there is no delivery postcode');
                    }
                    else 
                        if (form.M_deliverycountry.value === "") {
                            alert('Order not submitted: there is no delivery country');
                        }
                        else 
                            if (form.M_address1.value === "") {
                                alert('Order not submitted: there is no address');
                            }
                            else 
                                if (form.M_state.value === "") {
                                    alert('Order not submitted: there is no state/county');
                                }
                                else 
                                    if (form.M_town.value === "") {
                                        alert('Order not submitted: there is no delivery town');
                                    }
                                    else 
                                        if (form.tel.value === "") {
                                            alert('Order not submitted: there is no contact telephone');
                                        }
                                        else 
                                            if (form.M_deliveryname.value === "") {
                                                alert('Order not submitted: there is no name');
                                            }
                                            else {
                                                return true;
                                            }
    return false;
};
Cookie.prototype.writetotal = function(){
    document.write(numstr(this.M_total, true));
};
