﻿/* Standardfuntkion bei Erfolg */
function CallSuccess(res, destCtrl) {
    var dest = document.getElementById(destCtrl);
    dest.innerHTML = res;
}

function reload() {
    window.location.href = window.location.href;
}

/* Standardfuntkion bei Fehler */
function CallFailed(res) {
    alert(res.get_message());
}

function ChangeItemListStyle(newStyle) {
    logicbase.Shop.LBShopWebService.ChangeItemListStyle(newStyle, reload, CallFailed);
}

function addItem2Cart(itemID, versionID, msg, msg100) {
    if (document.getElementById('tbQuantity_' + itemID) != null) {
        var quantity = document.getElementById('tbQuantity_' + itemID).value;

        if (quantity == '') { quantity = 0; }

        if (!isNaN(quantity)) {

            if (quantity > 100) {
                document.getElementById('tbQuantity_' + itemID).value = 100;
                quantity = 100;
                alert(msg100);
            }
            logicbase.Shop.LBShopWebService.addItem2Cart(itemID, versionID, quantity, CallSuccess, CallFailed, 'divOrderValue');
        }
        else{
            alert(msg);
        }
    }
}

