(function($){
    $.fn.customSelect = function(options) {
        var opts = $.extend({}, $.fn.customSelect.defaults, options);
        $.fn.customSelect.opts = opts;
        return this.each(function() {
            var select = $(this);
            var value = getValue(this);

            value.bind('change', function(){
                var value = $(this);
                value.html(select.find('option:selected').html());
                value.css({
                    //'font-style': 'normal'
                })
            });

            value.trigger('change');
            select.bind('change-value', function() {
                getValue(this).trigger('change');
            });
            select.change(function() {
                getValue(this).trigger('change');
            });
            function getValue(select) {
                return $(select).parent(opts.container).find(opts.value);
            }
        });
    };

    $.fn.customSelect.defaults = {
        init: true,
        container: '.custom-select',
        value: '.custom-select-value',
        select: '.custom-select-select'
    };


    $(document).ready(function(){
        if ($.fn.customSelect.defaults.init) {
            $($.fn.customSelect.defaults.select).customSelect();
        }
    });
})(jQuery);
