function updateQuantity()
{
        var tqty = 0;
        // loop through all the elements
        for (x=0; x < document.summary.elements.length; x++)
         {
            // get the name of the field as well as the value
            var name = document.summary.elements[x].name;
            var value = document.summary.elements[x].value;
            // check if the name contains the string "qty"
            var bqty = name.indexOf("qty");
            // if it contains 'qty' and isn't called tqty
            if (bqty != -1 && name != "tqty") {
                    // make sure the numbers are not negative values and float them to real numbers ( no leading zeros )0
                    document.summary.elements[x].value = resetNumbers(value);
                    value = resetNumbers(value);
                    // add the quantity for total quantity calculations
                    tqty = parseFloat(tqty) + parseFloat(value);
            }
         }
         // and last but no least set the quantity
         document.summary.tqty.value = tqty;
}

 function jsrsArrayFromString(string) {
        var d = '~';
        return string.split(d);
}

function returnItemNumber(string) {
        return string.replace(/[^0-9]/g, "");
}

function resetNumbers(string) {
        if (isNaN(parseFloat(string))) {
                return 0;
        }
        if (parseFloat(string) < 0) {
                return 0;
        }
        return parseFloat(string);
}

// change the browse mode
function changeBrowseMode() {
        var catid = document.browsemode.catid.value;
        var sort = document.browsemode.sort.value;
        var displayType = document.browsemode.browsetype.value;
        
        if (displayType != 'summary') {
                url = 'shop/cat/' + catid + '.' + sort;
        } else {
                if(sort == '') sort = 'item';
                url = 'shop/cat/'  + catid + '.' + sort + '.' + displayType;
        }
        document.browsemode.action=url;
        document.browsemode.submit();
}

function changeBrowseModeNew() {
        url = 'shop/cat/detail.new';
        document.browsemode.action=url;
        document.browsemode.submit();
}
