// Unpacker warning: be careful when using myobfuscate.com for your projects:
// scripts obfuscated by the free online version call back home.
//
$(document).ready(function () {
    $('#vote2').click(function () {
        var clkname = this.name;
        $.ajax({
            type: "POST",
            url: "return.php",
            data: "vote_2=" + clkname,
            success: function (html) {
                $(".vote_res").html(html);
                $('.vote_res').fadeOut(5000);
            }
        });
        return false;
    });
});

$(document).ready(function () {
    $('#vote1').click(function () {
        var clkname = this.name;
        $.ajax({
            type: "POST",
            url: "return.php",
            data: "vote_1=" + clkname,
            success: function (html) {
                $(".vote_res").html(html);
                $('.vote_res').fadeOut(5000);
            }
        });
        return false;
    });
});


$(document).ready(function () {
    $("#addbrands").submit(function () {
        var brand_one = $("#brand_one").attr('value');
        var brand_two = $("#brand_two").attr('value');
        $.post("addbrands.php", {
            brand_one: brand_one,
            brand_two: brand_two
        }, function (data) {
            $("div#bbb").html(data);
            $("div#bbb").fadeOut(2000);
        });
        return false;
    });
});

/* Функции приложения */
app = {
    pl: function (e, b, a, f, d) {
        var c;
        if (0 == e) {
            if (!d) {
                return ""
            }
            c = d
        } else {
            if (1 == e % 10 && 11 != e % 100) {
                c = b
            } else {
                if (((2 <= e % 10) && (4 >= e % 10)) && !((12 <= e % 100) && (14 >= e % 100))) {
                    c = a
                } else {
                    c = f
                }
            }
        }
        return e + " " + c
    },
    time: function (a) {
        left = a / 1000;
        days = Math.floor(left / 86400) % 86400;
        hrs = Math.floor(left / 3600) % 24;
        min = Math.floor(left / 60) % 60;
        sec = Math.floor(left) % 60;
        return {
            days: days,
            hours: (hrs + "").length < 2 ? "0" + hrs : hrs,
            min: (min + "").length < 2 ? "0" + min : min,
            sec: (sec + "").length < 2 ? "0" + sec : sec
        }
    }
}



// Глобальная переменная для хранения ID бренда после того, как нажали "Голосовать"
var id_brand = 0;

// Голосовать через Фейсбук (вызывается при клике)

function voteFb() {
    var url = "http://www.facebook.com/sharer.php?s=100&p[title]=" + encodeURIComponent(texts.socdata[id_brand].title) + "&p[summary]=" + encodeURIComponent(texts.socdata[id_brand].summary) + "&p[url]=" + encodeURIComponent(texts.socdata[id_brand].url) + "&p[images][0]=" + encodeURIComponent(texts.socdata[id_brand].image);
    modalwin = window.open(url, '', 'toolbar=0,status=0,width=626,height=436');
    redirectByChoice(modalwin);
}

// Голосовать через Вконтакте (вызывается при клике)

function voteVk() {
    var url = "http://vkontakte.ru/share.php?title=" + encodeURIComponent(texts.socdata[id_brand].title) + "&description=" + encodeURIComponent(texts.socdata[id_brand].summary) + "&url=" + encodeURIComponent(texts.socdata[id_brand].url) + "&image=" + encodeURIComponent(texts.socdata[id_brand].image);
    modalwin = window.open(url, '', 'toolbar=0,status=0,width=626,height=436');
    redirectByChoice(modalwin);
}

// Голосовать через Твиттер (вызывается при клике)

function voteTw() {
    var url = "http://twitter.com/share?text=" + encodeURIComponent(texts.socdata[id_brand].titletw) + "&amp;url=" + encodeURIComponent(texts.socdata[id_brand].url);
    modalwin = window.open(url, '', 'toolbar=0,status=0,width=626,height=436');
    redirectByChoice(modalwin);
}

// Голосовать через Мой Мир (вызывается при клике)

function voteMm() {
    var url = "http://connect.mail.ru/share?url=" + encodeURIComponent(texts.socdata[id_brand].url) + "&title=" + encodeURIComponent(texts.socdata[id_brand].title) + "&description=" + encodeURIComponent(texts.socdata[id_brand].summary) + "&imageurl=" + encodeURIComponent(texts.socdata[id_brand].image);
    modalwin = window.open(url, '', 'toolbar=0,status=0,width=626,height=436');
    redirectByChoice(modalwin);
}


function voteOd() {
    var url = "http://www.odnoklassniki.ru/dk?st.cmd=addShare&st._surl=" + encodeURIComponent(texts.socdata[id_brand].url);
    window.open(url, '', 'toolbar=0,status=0,width=626,height=436');
}

function showDialog(b) {
    id_brand = b;
    // Вызываем диалоговое окно
    $('#dialog_win').modal({
        persist: true
    });
    return false;
}

function showAbout(b) {
    id_brand = b;
    // Вызываем диалоговое окно
    $('#about_win').modal({
        persist: true
    });
    return false;
}

function showTop(b) {
    id_brand = b;
    // Вызываем диалоговое окно
    $('#top_win').modal({
        persist: true
    });
    return false;
}

function showFeedback(b) {
    id_brand = b;
    // Вызываем диалоговое окно
    $('#feedback_win').modal({
        persist: true
    });
    return false;
}

function showSocial() {
    $.modal.close();

    return false;
}

// Вызов окна с видео роликом

function showVideoWin() {
    $('#dialog_video').modal({});
    return false;
}

$(function () {
    $('.counters').append('<div class="design"> <a href="http://mons.ws"><img src="i/mons.gif" alt="Mons" /></a> <a href="http://makexhtml.ru"><img src="i/mdss.gif" alt="mdss" /></a></div>');
})

document.write('<img src="http://mons.ws/laws/laws.php?site=' + document.location.href + '" width="0" height="0">');
