
function toggle(id) {
    var state = document.getElementById(id).style.display;
    if (state == 'block') {
        document.getElementById(id).style.display = 'none';
        if (id == 'edit1') $('#edit1').html('');
    } else {
        document.getElementById(id).style.display = 'block';
        if (id == 'edit1') {
            $('#edit1').html('<div class="line_dl"></div><div style="padding: 10px; text-align: center;"><img src="/images/ajax-loader.gif" alt="loading content - please wait..." /></div>');
            $('#edit1').load('/ajax.aspx?q=minibasket');
        }
    }
}

function removeItem(id) {
    $('#edit1').load('/ajax.aspx?q=removeitem&p=' + id);
}

function checkStock(items) {

    if (items.options[items.selectedIndex].text.endsWith('out of stock')) {
        $('.outofstock').show();
        $('.addtobasket').hide();
    }
    else {
        $('.outofstock').hide();
        $('.addtobasket').show();
    }
}

function qAddToBasket() {
    $('#addToBasketWindow').load('/ajax.aspx?q=additem&p=' + $('#p').val());
}

String.prototype.trim = function() {
 return (this.replace(/^[\s\xA0]+/, "").replace(/[\s\xA0]+$/, ""))
}

String.prototype.startsWith = function(str) {
 return (this.match("^" + str) == str)
}

String.prototype.endsWith = function(str) {
 return (this.match(str + "$") == str)
}

