"use strict";

var pf = {};

pf.vote = function () {
    $('#voteOverlay .close').click(function () {
        $(this).parent().hide();

        return false;
    });

    $('.btn-vote').click(function () {
        var elm = $(this);

        $.ajax({
            url: elm.attr('href'),
            dataType: 'json',
            cache: false,
            success: function (data) {
                if (data.status === 'success') {
					$('#voteOverlay').fadeIn();
					$('.btn-vote').fadeIn();
                } else if (data.status === 'error') {
                    alert(data.msg);
                }
            }
        });

        return false;
    });
};

pf.init = function () {
    pf.vote();
};

$(document).ready(function () {
    pf.init();
});
