//错误提醒窗口
var show_error = function (option) {
    var options = $.extend({
        'message': '',
        'color': 'info' // success | info | warning | danger
    }, option || {});

    if (!options.message) options.message = option;

    var str = $('<div>', {'class': 'message-box alert alert-' + options.color, 'role': "alert"})
        .html(options.message);
    $('body').append(str);
    str.fadeIn().fadeOut(6000);
    setTimeout(function () {
        str.remove();
    }, 6000);
}

var ajax_dialog = function (title, url) {
    BootstrapDialog.show({
        title: title,
        message: $('<div></div>').load(url)
    });
}

ajax_dialog.close = function () {
    $('#modal_ajax').modal('hide').remove();
}

store = function () {
    if (typeof (arguments[0]) == 'object') {
        arguments[0].each(function (name, val) {
            localStorage.setItem(name, val);
        })
    } else if (arguments[1]) {
        localStorage.setItem(arguments[0], arguments[1]);
    } else {
        return localStorage.getItem(arguments[0]);
    }
}

$(function () {

    $('body').on('click', '[data-open]', function () {
        var url = $(this).data('open');
        var title = $(this).attr('title');
        var size = $(this).data('size');
        ajax_dialog(title, url, size);
    });
});
