function add_to_favorites(pproduct) {
    $.ajax({
        type: 'POST',
        url: '/x_wshp_funcs/add_to_favorites',
        data: {
            product: pproduct
        },
        success: function(){
            $('#addtofav').hide();
            $('#delfromfav').show();
            $('#dialog_content').html('A termék sikeresen bekerült a kedvencekbe.');
            $('#dialog:ui-dialog' ).dialog( 'destroy' );
            $('#dialog-message' ).dialog({
                modal: true,
                width: 460,
                buttons: {
                    Ok: function() {
                        $( this ).dialog( 'close' );
                    }
                }
            });
        },
        error: function() {
            alert('Sikertelen adatbázis művelet!');
        }
    });                    
}

function delete_from_favorites(pproduct) {
    $.ajax({
        type: 'POST',
        url: '/x_wshp_funcs/delete_from_favorites',
        data: {
            product: pproduct
        },
        success: function(){
            $('#delfromfav').hide();
            $('#addtofav').show();
            $('#dialog_content').html('A termék a kedvencekből sikeresen eltávolítva!');
            $('#dialog:ui-dialog' ).dialog( 'destroy' );
            $('#dialog-message' ).dialog({
                modal: true,
                width: 460,
                buttons: {
                    Ok: function() {
                        $( this ).dialog( 'close' );
                    }
                }
            });
        },
        error: function() {
            alert('Sikertelen adatbázis művelet!');
        }
    });                    
}

function add_to_cart(pproduct, pnum) {
    $.ajax({
        type: 'POST',
        url: '/x_wshp_funcs/add_to_cart',
        data: {
            product: pproduct,
            num: pnum
        },
        success: function(msg){
            $('#mini_cart').html(msg);
            $('#dialog_content').html('A termék sikeresen bekerült a kosárba.');
            $('#dialog:ui-dialog').dialog('destroy');
            $('#dialog-message').dialog({
                modal: true,
                width: 460,
                buttons: {
                    Ok: function() {
                        $( this ).dialog( 'close' );
                    }
                }
            });
        },
        error: function() {
            alert('Sikertelen adatbázis művelet!');
        }
    });                    
}

