/* Minification failed. Returning unminified contents.
(1,18): run-time error CSS1031: Expected selector, found '='
(1,18): run-time error CSS1025: Expected comma or open brace, found '='
 */
var _PROP_DETAIL = {

    //Images: '',

    //init: function (images) {
    //    this.Images = images;
    //},

    getPhoneNumber: function (obj, phoneNumber, propid) {
        $(obj).html(phoneNumber);

        $.ajax({
            url: '/ajax/home/ClickToGetPhoneNumber',
            cache: false,
            async: true,
            type: 'POST',
            dataType: 'html',
            data: {
                propid: propid
            },
            success: function (html) { }
        });

    },
    
    getMoreClosingPriceProperties: function () {
        var currentIndex = $('#hfPageIndex').val();
        var nextIndex = parseInt(currentIndex) + 1;

        $('#div_show_more').show();

        $.ajax({
            url: '/ajax/home/GetMoreClosingPriceProperties',
            cache: false,
            async: true,
            type: 'POST',
            dataType: 'html',
            data: {
                type: $('#hfCategory').val(),
                id: $('#ipPropID').val(),
                index: nextIndex
            },
            success: function (html) {
                $('#div_show_more').hide();

                $('#main-grid-closingP').append("<div class='more-closing-price-properties' style='display: none;'>" + html + "</div>");
                $('.more-closing-price-properties').show(400);

                $('#hfPageIndex').val(nextIndex);
                $('.paging').remove();
                var currentClosingPricePropertiesCount = $('#main-grid-closingP .grey-prop-box').length;

                var total = parseInt($('#main-grid-closingP .closePriceTotal:first').val());
                if (currentClosingPricePropertiesCount >= total) {
                    $('.show-more-button2').remove();
                }

                if (total == 0) {
                    $('#divClosingP').hide();
                }
            }
        });

    },

    validateSendMessageForm: function () {
        $('#txtCustomerName').css({ 'border-color': '#cccccc' });
        $('#txtCustomerPhone').css({ 'border-color': '#cccccc' });
        $('#txtCustomerComment').css({ 'border-color': '#cccccc' });

        var message = "";

        if ($.trim($('#txtCustomerName').val()) === '') {
            $('#txtCustomerName').css({ 'border-color': 'red' });
            message += "false";
        }

        if ($.trim($('#txtCustomerPhone').val()) === '') {
            $('#txtCustomerPhone').css({ 'border-color': 'red' });
            message += "false";
        }

        if ($.trim($('#txtCustomerComment').val()) === '') {
            $('#txtCustomerComment').css({ 'border-color': 'red' });
            message += "false";
        }

        if ($.trim($('#txtCustomerEmail').val()) !== '' && _COMMON.IsValidEmail($.trim($('#txtCustomerEmail').val())) === false) {
            $('#txtCustomerEmail').css({ 'border-color': 'red' });
            message += "false";
        }

        return $.trim(message).length === 0;
    },

    sendMessage: function (userid, propid) {

        var self = this;
        if (self.validateSendMessageForm() === false)
            return;

        if ($('#inpCaptGG').val()) {
            $('#sendMessageResponse').html("<img src='/images/ajax-loader.gif' width='16' /> Đang gửi tin nhắn ...");

            $.ajax({
                url: '/ajax/home/SendMessage',
                cache: false,
                async: true,
                type: 'POST',
                dataType: 'html',
                data: {
                    userid: userid,
                    propid: propid,
                    name: $('#txtCustomerName').val(),
                    phone: $('#txtCustomerPhone').val(),
                    email: $('#txtCustomerEmail').val(),
                    comment: $('#txtCustomerComment').val(),
                    adURL: $('#hfAdURL').val(),
                    captchagg: $('#inpCaptGG').val()
                },
                success: function (html) {
                    BootstrapDialog.show({
                        title: 'Thông Báo',
                        message: 'Bạn đã gửi tin nhắn thành công. Người đăng tin sẽ liên hệ với bạn trong thời gian ngắn nhất.'
                    });

                    $('#txtCustomerName').val('');
                    $('#txtCustomerPhone').val('');
                    $('#txtCustomerEmail').val('');
                    $('#txtCustomerComment').val('');
                    $('#sendMessageResponse').html('');
                }
            });
        }
        else {
            BootstrapDialog.show({
                title: 'Thông Báo',
                message: 'Tôi không phải là người máy?'
            });
        }
    },
    openSendMessageForm: function (userid, propid) {
        var self = this;
        
        var html = '<script src="https://www.google.com/recaptcha/api.js" async defer></script>' +
         '<div class="seller-info-bottom">' +
            '<div class="form-group">' +
            '    Gửi Tin Nhắn' +
            '</div>' +
            '<div class="form-group">' +
            '    <input class="form-control" id="txtCustomerName" placeholder="Họ Tên" />' +
            '</div>' +
            '<div class="form-group">' +
            '    <input class="form-control" id="txtCustomerPhone" placeholder="Số Điện Thoại" />' +
            '</div>' +
            '<div class="form-group">' +
            '    <input class="form-control" id="txtCustomerEmail" placeholder="Email" />' +
            '</div>' +
            '<div class="form-group">' +
            '    <textarea class="form-control" id="txtCustomerComment" style="height: 100px;" placeholder="Tin Nhắn">Tôi quan tâm tới bất động sản này. Hãy liên lạc lại với tôi, cảm ơn.</textarea>' +
            '</div>' +
            '<div class="g-recaptcha" data-sitekey="6LcvPZ8UAAAAANkxacdXkbiVzRMvBB1SYxa63sO9" data-callback="correctCaptcha"></div>' +
            '<input id="inpCaptGG" type="hidden" value="" />' +
            '<div id="sendMessageResponse" class="sending-email">' +
            '</div>' +
        '</div>';

        BootstrapDialog.show({
            title: 'Gửi Tin Nhắn',
            message: $("<div id='divSendMBMessageContainer'>" + html + "</div>"),
            buttons: [
                {
                    label: 'Gửi Tin Nhắn',
                    cssClass: 'btn btn-primary',
                    action: function (dialog) {
                        self.sendMBMessage(userid, propid);
                    }
                },
                {
                    label: 'Thoát',
                    action: function (dialog) {
                        dialog.close();
                    }
                }]
        });
    },

    validateMBSendMessageForm: function () {
        $('#txtMBCustomerName').css({ 'border-color': '#cccccc' });
        $('#txtMBCustomerPhone').css({ 'border-color': '#cccccc' });
        $('#txtMBCustomerComment').css({ 'border-color': '#cccccc' });

        var message = "";

        if ($.trim($('#txtMBCustomerName').val()) === '') {
            $('#txtMBCustomerName').css({ 'border-color': 'red' });
            message += "false";
        }

        if ($.trim($('#txtMBCustomerPhone').val()) === '') {
            $('#txtMBCustomerPhone').css({ 'border-color': 'red' });
            message += "false";
        }

        if ($.trim($('#txtMBCustomerComment').val()) === '') {
            $('#txtMBCustomerComment').css({ 'border-color': 'red' });
            message += "false";
        }

        if ($.trim($('#txtMBCustomerEmail').val()) !== '' && _COMMON.IsValidEmail($.trim($('#txtMBCustomerEmail').val())) === false) {
            $('#txtMBCustomerEmail').css({ 'border-color': 'red' });
            message += "false";
        }

        return $.trim(message).length === 0;
    },

    sendMBMessage: function (userid, propid) {
        var self = this;
        if (self.validateSendMessageForm() === false)
            return;

        if ($('#inpCaptGG').val()) {
            $('#sendMessageResponse').html("<img src='/images/ajax-loader.gif' width='16' /> Đang gửi tin nhắn ...");

            $.ajax({
                url: '/ajax/home/SendMessage',
                cache: false,
                async: true,
                type: 'POST',
                dataType: 'html',
                data: {
                    userid: userid,
                    propid: propid,
                    name: $('#txtCustomerName').val(),
                    phone: $('#txtCustomerPhone').val(),
                    email: $('#txtCustomerEmail').val(),
                    comment: $('#txtCustomerComment').val(),
                    adURL: $('#hfAdURL').val(),
                    captchagg: $('#inpCaptGG').val()
                },
                success: function (html) {
                    BootstrapDialog.show({
                        title: 'Thông Báo',
                        message: 'Bạn đã gửi tin nhắn thành công. Người đăng tin sẽ liên hệ với bạn trong thời gian ngắn nhất.'
                    });

                    $('#txtCustomerName').val('');
                    $('#txtCustomerPhone').val('');
                    $('#txtCustomerEmail').val('');
                    $('#txtCustomerComment').val('');
                    $('#sendMessageResponse').html('');
                }
            });
        }
        else {
            BootstrapDialog.show({
                title: 'Thông Báo',
                message: 'Tôi không phải là người máy?'
            });
        }
    },

    showContactInfo: function () {
        if ($('#divMessageInfo').is(':visible') === false) {
            $('#divMessageInfo').show(400);
            $('.mb-message-toggle a').html("<span class='contact-down-arrow'>Thu Gọn <i class='fa fa-chevron-up' aria-hidden='true'></i></span>");
        }
        else {
            $('#divMessageInfo').hide(400);
            $('.mb-message-toggle a').html("<span class='contact-down-arrow'>Gửi Tin Nhắn <i class='fa fa-chevron-down' aria-hidden='true'></i></span>");
        }
    },

    ShowPhoneClick: function () {
        $("span.show_phone").each(function (index) {
            $(this).addClass("show_active");
        });

        $("span.click_me").each(function (index) {
            $(this).addClass("click_me_active");
        });
        $('.hide-phone').hide();

        $.ajax({
            url: '/ajax/home/ClickToGetPhoneNumber',
            cache: false,
            async: true,
            type: 'POST',
            dataType: 'html',
            data: {
                propid: $('#ipPropID').val(),
            },
            success: function (html) { }
        });
    },

    IncreasePhoneClick: function () {
        $.ajax({
            url: '/ajax/home/ClickToGetPhoneNumber',
            cache: false,
            async: true,
            type: 'POST',
            dataType: 'html',
            data: {
                propid: $('#ipPropID').val(),
            },
            success: function (html) { }
        });
    }
};

