var facelenta = {

    show_facelenta_add_popup: function() {
        jQuery('#facelenta-popup').show();
        showOverlay();
    }
    ,hide_facelenta_add_popup: function() {
        hideOverlay();
        jQuery('#facelenta-popup').hide();
    }
    ,buyFacelenta: function(confirm_code) {
        $.get('/ajax/facelenta_add.php?confirmed=true&confirm_code='+confirm_code, '', function(data) {
            if (data.status == 'OK') {
                location.reload();
            }
            else {
                $('#facelenta-buy').hide();
                $('#facelenta-balance').show();
                errors = '';
                $.each(data.errors, function(index, value) {
                    errors += index + '<br>';
                });

                $('#facelenta-error').html(errors);
            }
        }, 'json');
    }
}

var lover_status = {

    show_popup: function() {
        jQuery('#lover-status-popup').show();
        showOverlay();
    }
    ,hide_popup: function() {
        hideOverlay();
        jQuery('#lover-status-popup').hide();
        location.reload();
    }
    ,buy: function(confirm_code) {
        $('#lover-status-buy').hide();
        $('#lover-status-loading').show();
        $.get('/ajax/purchase/lover-status.php?confirmed=true&confirm_code='+confirm_code, '', function(data) {
            if (data.status == 'OK') {
                $('#lover-status-content').html('Оплата произведена успешно');
            }
            else {
                $('#lover-status-loading').hide();
                $('#lover-status-balance').show();
                errors = '';
                $.each(data.errors, function(index, value) {
                    errors += index + '<br>';
                });

                $('#lover-status-error').html(errors);
            }
        }, 'json');
    }

    ,show_gift_popup : function(){
        var giftpopup = jQuery('#lover-status-gift-popup');
        giftpopup.remove();
        giftpopup.prependTo('body');
        giftpopup.show();
        showOverlay();
    }
    ,hide_gift_popup: function() {
        hideOverlay();
        jQuery('#lover-status-gift-popup').hide();
        location.reload();
    }
    ,gift: function(user_id,confirm_code){
        $('#lover-gift-buy').hide();
        $('#lover-gift-loading').show();
        $.post('/ajax/gift/lover_status.php?confirmed=true&user_id='+user_id+'&confirm_code='+confirm_code, {'comment':$('#status-gift-comment').val()}, function(data) {
            if (data.status == 'OK') {
                $('#lover-gift-content').html('Оплата произведена успешно');
                //location.reload();
            }
            else {
                $('#lover-gift-loading').hide();
                $('#lover-gift-balance').show();
                errors = '';
                $.each(data.errors, function(index, value) {
                    errors += index + '<br>';
                });

                $('#lover-gift-error').html(errors);
            }
        }, 'json');
    }
}


