function ajaxAddToCart(productElement, cenovaSkupina,productForm) {
    var quantity = $("#" + productElement + "quantity").attr("value");
    var productValueForm = document.getElementById("products[" + productForm + "][zbozi_id]"); 
    var productValueId = productValueForm.options[productValueForm.selectedIndex].value;
    var button = $("#" + productElement + "submit");
    button.attr("disabled", true);
    var box = $("#" + productElement + "pridavam");
    box.text("..Pridavam..");
    
    box.slideDown("fast");

    $.post(baseUrl + '/order/ajax' ,{"product": '{ "product" : "' + productValueId + '", "cenovaskupina" : "' + cenovaSkupina + '", "quantity" : "' + quantity + '"}'}, function(responseJson) {
        //var a = eval(response);
        response = eval( "(" + responseJson + ")");

        if (undefined != response.message) {
            if (response.message.length > 0) {
                alert(response.message);
            }
        }

        if (undefined != response.cart) {
            $('#kosik').html(response.cart);
        }

        $("#" + productElement + "submit").attr("disabled", false);
        $("#" + productElement + "pridavam").text("Hotovo");
        $("#" + productElement + "pridavam").slideUp("slow");

    });
    return true;
}

function ajaxAddAllToCart() {
    var button = $("#addAll");
    button.attr("disabled", true);
    var box = $("#pridavamAll");
    box.text("..Pridavam..");

    box.slideDown("fast");

    var productIds = [];
    var quantities = [];
    var priceTypes = [];
    var forms = $("div.item form");

    // nacist data z policek formularu
    $.each(forms, function(index, value) {
       if ($("input.quantity", value).get(0).value > 0) {
            productIds.push($("input.productsId", value)[0].value);
            quantities.push($("input.quantity", value)[0].value);
            priceTypes.push($("input.priceType", value)[0].value);
       }
    });

    // vytvorit z dat casti jsonovske struktury
    var partStrings = [];

    $.each(productIds, function(index, value) {
        partStrings.push('{ "product" : "' + value +
            '", "cenovaskupina" : "' + priceTypes[index] +
            '", "quantity" : "' + quantities[index] + '" }' );
    });

    // casti spojit do jednoho json stringu
    var jsonString = "";
    $.each(partStrings, function(index, value) {
        jsonString = jsonString + ', "product' + index + '" : ' + '\'' + value + '\'';
    });

    // na json string zavolat eval, aby z neho byl javascriptovy objekt
    jsonString = "{ " + jsonString.substring(2) + " }";
    var dataObject = eval( "(" + jsonString + ")" );


    // AJAX (heureka)
    $.post(baseUrl + '/order/ajax', dataObject, function(responseJson) {
        response = eval( "(" + responseJson + ")");

        if (undefined != response.message) {
            if (response.message.length > 0) {
                alert(response.message);
            }
        }

        if (undefined != response.cart) {
            $('#kosik').html(response.cart);
        }

        $("#addAll").attr("disabled", false);
        $("#pridavamAll").text("Hotovo");
        $("#pridavamAll").slideUp("slow");
    });
}