(function ($) {
    $(document).ready(function () {
        var N = '',
            sexyCountryCode = '',
            sexyCity = '',
            sexyRegion = '';
        var O = 2;

        function check_pro_version(a) {
            $elem_1 = a.find('.powered_by');
            $elem_2 = a.find('.powered_by a');
            var b = parseInt($elem_1.css('font-size'));
            
            if (b == '16') return true;
            return false
        };
        $.ajax({
            url: sexyPath + 'components/com_sexypolling/geoip.php?ip=' + sexyIp,
            type: "get",
            dataType: "json",
            success: function (a) {
                if (a != null) {
                    N = a.countryName;
                    sexyCountryCode = a.countryCode;
                    sexyCity = a.cityName;
                    sexyRegion = a.regionName
                }
            },
            error: function () {}
        });
        setTimeout(function () {
            $(".polling_container_wrapper").each(function () {
                var w = $(this).width();
                $(this).css("width", w);
                var a = $(this).find('.answer_wrapper').height();
                $(this).find('.answer_wrapper').attr("h", a)
            })
        }, 100);
        var P = new Array();

        function create_seconds_timers() {
            var a = new Array();
            for (t in votedIds) {
                var b = votedIds[t][0];
                P[b] = parseInt(votedIds[t][2] * 3600)
            };
            setInterval(function () {
                for (t in P) {
                    if (P[t] > 0) P[t] -= 1
                }
            }, 1000)
        };
        create_seconds_timers();
        var Q = new Array();

        function create_start_poll_seconds_timers() {
            var a = startDisabledIds.length;
            for (var i = 0; i <= a; i++) {
                if (typeof startDisabledIds[i] !== 'undefined') {
                    var b = startDisabledIds[i][0];
                    Q[b] = parseInt(startDisabledIds[i][3] * 3600)
                }
            };
            setInterval(function () {
                for (tt in Q) {
                    if (Q[tt] > 0) Q[tt] -= 1
                }
            }, 1000)
        };
        create_start_poll_seconds_timers();

        function create_shadow() {
            var a = '<div id="sexy_shadow"></div>';
            $('body').css('position', 'relative').append(a);
            $("#sexy_shadow").css({
                'position': 'absolute',
                'top': '0',
                'right': '0',
                'bottom': '0',
                'left': '0',
                'z-index': '10000',
                'opacity': '0',
                'backgroundColor': '#000'
            }).fadeTo(200, '0.7')
        };

        function make_alert(a, b) {
            create_shadow();
            var c = '<div id="sexy_alert_wrapper"><div id="sexy_alert_body" class="' + b + '">' + a + '</div><input type="button" id="close_sexy_alert" value="' + sexyPolling_words[21] + '" /></div>';
            $('body').append(c);
            var d = $(window).scrollTop();
            var e = $(window).width();
            var f = $(window).height();
            var g = $("#sexy_alert_wrapper").height();
            var h = (e - 420) / 2;
            var i = (f - g) / 2;
            $("#sexy_alert_wrapper").css({
                'top': -1 * (g + 55 * 1) + d * 1,
                'left': h
            }).stop().animate({
                'top': i + d * 1
            }, 450, 'easeOutBack', function () {})
        };

        function remove_alert_box() {
            $("#sexy_shadow").stop().fadeTo(200, 0, function () {
                $(this).remove()
            });
            $("#sexy_alert_wrapper").stop().fadeTo(200, 0, function () {
                $(this).remove()
            })
        };

        function move_alert_box() {
            var a = $(window).scrollTop();
            var b = $(window).width();
            var c = $(window).height();
            var d = $("#sexy_alert_wrapper").height();
            var e = (b - 420) / 2;
            var f = (c - d) / 2;
            $("#sexy_alert_wrapper").stop().animate({
                'top': f + a * 1,
                'left': e
            }, 450, 'easeOutBack', function () {})
        };
        $('#close_sexy_alert').live('click', function () {
            remove_alert_box()
        });
        $(window).resize(function () {
            move_alert_box()
        });
        $(window).scroll(function () {
            move_alert_box()
        });
        setTimeout(function () {
            $(".polling_bottom_wrapper1").each(function () {
                var h = $(this).height();
                $(this).attr("h", h)
            });
            $(".polling_loading").each(function () {
                var h = $(this).height();
                $(this).attr("h", h)
            });
            $(".answer_input").each(function () {
                var w = $(this).width();
                $(this).attr("w", w)
            });
            $(".polling_ul").each(function () {
                var h = $(this).height();
                $(this).attr("h", h)
            });
            $(".polling_li").each(function () {
                var h = $(this).height();
                $(this).attr("h_start", h)
            });
            $(".answer_navigation").each(function () {
                var b = parseInt($(this).css("borderWidth"));
                $(this).attr("b", b)
            })
        }, 50);

        function create_timer(a, b) {
            var c = new Date();
            c.setSeconds(c.getSeconds() + a);
            var d = c.getDate();
            var e = c.getMonth() + 1;
            var f = c.getHours();
            var g = c.getMinutes();
            var h = c.getSeconds();
            var i = c.getFullYear();
            if (d < 10) d = '0' + d;
            if (e < 10) e = '0' + e;
            if (f < 10) f = '0' + f;
            if (g < 10) g = '0' + g;
            if (h < 10) h = '0' + h;
            var j = i + '/' + e + '/' + d + ' ' + f + ':' + g + ':' + h;
            var k = new Date().getTimezoneOffset();
            $("#sexy_timer").jCountdown({
                timeText: j,
                timeZone: 0,
                style: "slide",
                color: "black",
                width: 350,
                textGroupSpace: 15,
                textSpace: 0,
                reflection: true,
                reflectionOpacity: 20,
                reflectionBlur: 1,
                dayTextNumber: 2,
                displayDay: b,
                displayHour: true,
                displayMinute: true,
                displaySecond: true,
                displayLabel: true,
                onFinish: function () {
                    remove_alert_box()
                }
            })
        };
        $('.polling_submit').click(function () {
            $elem = $(this).parents('.polling_container');
            if (!check_pro_version($elem)) {
                make_alert('To hide a backlink please purchase a Sexy Polling PRO version', 'sexy_error');
                return false
            }
            if ($(this).hasClass('voted_button')) {
                make_alert(sexyPolling_words[9], 'sexy_error');
                return
            }
            var a = $(this).attr("id");
            var b = $(this).parent('span').parent('div').find('.poll_answer').attr('name');
            if (votingPermissions[b] != 'allow_voting') {
                make_alert(votingPermissions[b], 'sexy_error');
                return false
            };
            var c = new Array();
            var d = P[b];
            for (t in votedIds) {
                c.push(votedIds[t][0]);
                if (votedIds[t][0] == b) var e = votedIds[t][2]
            };
            if (d > 0 || e == 'never') {
                if ($.inArray(b, c) != -1) {
                    if (e == 'never') {
                        make_alert(sexyPolling_words[9], 'sexy_error');
                        return false
                    } else {
                        var f = parseInt(e / 24);
                        var g = f == 0 ? false : true;
                        var h = '<div id="sexy_timer"></div>';
                        make_alert(sexyPolling_words[9] + '<div id="estimated_time_message">' + sexyPolling_words[20] + '</div>' + h, 'sexy_error');
                        create_timer(d, g);
                        return false
                    }
                }
            };
            var j = Q[b];
            s_length = startDisabledIds.length;
            for (var i = 0; i <= s_length; i++) {
                if (typeof startDisabledIds[i] !== 'undefined') {
                    var k = "poll_" + startDisabledIds[i][2] + "_" + startDisabledIds[i][0];
                    if (k == a) {
                        var e = startDisabledIds[i][3];
                        if (j > 0 || e == 'never') {
                            if (e == 'never') {
                                make_alert(startDisabledIds[i][1], 'sexy_error');
                                return false
                            } else {
                                var f = parseInt(e / 24);
                                var g = f == 0 ? false : true;
                                var h = '<div id="sexy_timer"></div>';
                                make_alert(startDisabledIds[i][1] + '<div id="estimated_time_message">' + sexyPolling_words[22] + '</div>' + h, 'sexy_error');
                                create_timer(j, g);
                                return false
                            }
                        }
                    }
                }
            };
            e_length = endDisabledIds.length;
            for (var i = 0; i <= e_length; i++) {
                if (typeof endDisabledIds[i] !== 'undefined') {
                    var k = "poll_" + endDisabledIds[i][2] + "_" + endDisabledIds[i][0];
                    if (k == a) {
                        make_alert(endDisabledIds[i][1], 'sexy_normal');
                        return false
                    }
                }
            };
            var l = $(this).parent('span').parent('div').find('.poll_answer:checked').val();
            if (l == undefined) {
                make_alert(sexyPolling_words[8], 'sexy_normal');
                return false
            };
            var m = $(this);
            vote_polling(m)
        });
        $('.polling_result').click(function () {
            $elem = $(this).parents('.polling_container');
            if (!check_pro_version($elem)) {
                make_alert('To hide a backlink please purchase a Sexy Polling PRO version', 'sexy_error');
                return false
            }
            var a = $(this);
            show_polling(a)
        });
        $('.polling_select2,.polling_select1').change(function () {
            var a = $(this).parents('.polling_container');
            show_polling_by_date(a)
        });

        function show_polling(c) {
            var d = c.parent('span').parent('div').find('.poll_answer').attr('name');
            var e = c.parent('span').parent('div').parent('div').attr('roll');
            $container = c.parent('span').parent('div');
            $container.find('.doNotUncheck').parent('div').parent('div').parent('li').remove();
            c.parent('span').parent('div').find('.answer_input').animate({
                width: 0,
                opacity: 0
            }, 1000);
            c.parent('span').parent('div').find('.answer_name label').animate({
                marginLeft: 0
            }, 1000);
            var b = c.parent('span').parent('div').find('.answer_navigation').attr("b");
            c.parent('span').parent('div').find('.answer_navigation').css("borderWidth", "0").show().animate({
                height: animation_styles[e + "_" + d][9],
                borderWidth: b,
                opacity: 1
            }, 1000);
            var f = c.parent('span').parent('div').find('.polling_loading').height();
            c.parent('span').parent('div').find('.polling_loading').css({
                display: 'block',
                opacity: 0,
                height: 0
            });
            c.parent('span').parent('div').find('.polling_loading').animate({
                opacity: 0.85,
                height: f
            }, 1000);
            var h = $container.find('.answer_votes_data').height();
            setTimeout(function () {
                $.ajax({
                    url: sexyPath + 'components/com_sexypolling/vote.php',
                    type: "post",
                    data: 'polling_id=' + d + '&mode=view' + '&dateformat=' + dateFormat[d] + '&module_id=' + e,
                    dataType: "json",
                    success: function (a) {
                        $container = $("#mod_" + a[0].module_id + "_" + a[0].poll_id);
                        answers_array = new Array();
                        orders_array = new Array();
                        orders_array_start = new Array();
                        data_length = a.length;
                        max_percent = 'none';
                        $.each(a, function (i) {
                            answer_id = this.answer_id;
                            percent = this.percent;
                            percent_formated = parseFloat(this.percent_formated);
                            response_votes = this.votes;
                            order = this.order;
                            order_start = this.order_start;
                            total_votes = this.total_votes;
                            min_date = this.min_date;
                            max_date = this.max_date;
                            if (max_percent == 'none') max_percent = percent;
                            answers_array.push(parseInt(answer_id));
                            orders_array.push(order);
                            orders_array_start.push(order_start);
                            $container.find('#answer_navigation_' + answer_id).attr('title', sexyPolling_words[0] + ': ' + response_votes);
                            $nav_width = $container.find(".polling_li").width();
                            $current_width_rel = parseInt($nav_width * percent / 100);
                            $current_width_rel = $current_width_rel == 0 ? '1' : $current_width_rel;
                            $current_width = parseInt($nav_width * percent / max_percent);
                            $current_width = $current_width == 0 ? '1' : $current_width;
                            $container.find('#answer_navigation_' + answer_id).attr({
                                "rel_width": $current_width_rel,
                                "ab_width": $current_width
                            }).animate({
                                width: $current_width
                            }, 1000, sexyAnimationTypeBar[d]);
                            $container.find('#answer_navigation_' + answer_id).next(".ie-shadow").animate({
                                width: $current_width
                            }, 1000, sexyAnimationTypeBar[d]);
                            $container.find('#answer_votes_data_count_' + answer_id).html(response_votes);
                            $container.find('#answer_votes_data_count_val_' + answer_id).html(response_votes);
                            $container.find('#answer_votes_data_percent_' + answer_id).html(percent_formated);
                            $container.find('#answer_votes_data_percent_val_' + answer_id).html(percent_formated);
                            $container.find('.answer_votes_data').css({
                                'display': 'block',
                                'height': 0
                            }).animate({
                                height: h
                            }, 1000);
                            if (i == data_length - 1) {
                                animate_poll_items($container, answers_array, d, e, total_votes, min_date, max_date, orders_array, orders_array_start)
                            }
                        })
                    },
                    error: function () {}
                })
            }, 1000)
        };

        function animate_poll_items(i, j, k, l, m, n, o, p, q) {
            setTimeout(function () {
                var a = i.find('.polling_ul').offset();
                offset_0 = a.top;
                var c = new Array();
                for (var b = 0; b < j.length; b++) {
                    var d = i.find("#answer_" + j[b]).offset();
                    var e = d.top;
                    var f = e * 1 - offset_0;
                    c.push(f)
                };
                curr_top = 0;
                curr_height = 0;
                curr_z_index = 1000;
                i.find('.polling_ul').css('height', i.find('.polling_ul').height());
                for (var b = 0; b < j.length; b++) {
                    var g = i.find("#answer_" + j[b]).height() + O;
                    curr_height = curr_height * 1 + g;
                    i.find("#answer_" + j[b]).css({
                        position: 'absolute',
                        top: c[b],
                        'z-index': curr_z_index
                    });
                    i.find("#answer_" + j[b]).stop(true, false).animate({
                        top: curr_top
                    }, 1200, sexyAnimationTypeContainerMove[k]);
                    i.find("#answer_" + j[b] + " .animation_block").css({
                        'display': 'block',
                        'opacity': '0'
                    }).stop(true, false).animate({
                        opacity: 1,
                        boxShadow: animation_styles[l + "_" + k][2],
                        borderTopColor: animation_styles[l + "_" + k][1],
                        borderBottomColor: animation_styles[l + "_" + k][1],
                        borderLeftColor: animation_styles[l + "_" + k][1],
                        borderRightColor: animation_styles[l + "_" + k][1],
                        backgroundColor: animation_styles[l + "_" + k][0],
                        borderTopLeftRadius: animation_styles[l + "_" + k][3],
                        borderTopRightRadius: animation_styles[l + "_" + k][4],
                        borderBottomLeftRadius: animation_styles[l + "_" + k][5],
                        borderBottomRightRadius: animation_styles[l + "_" + k][6]
                    }, 1200, sexyAnimationTypeContainer[k], function () {
                        $(this).animate({
                            opacity: 0,
                            boxShadow: animation_styles[l + "_" + k][8] + '0 0 0 0 ' + animation_styles[l + "_" + k][7],
                            borderTopColor: animation_styles[l + "_" + k][7],
                            borderBottomColor: animation_styles[l + "_" + k][7],
                            borderLeftColor: animation_styles[l + "_" + k][7],
                            borderRightColor: animation_styles[l + "_" + k][7],
                            backgroundColor: animation_styles[l + "_" + k][7],
                            borderTopLeftRadius: 0,
                            borderTopRightRadius: 0,
                            borderBottomLeftRadius: 0,
                            borderBottomRightRadius: 0
                        }, 1200, sexyAnimationTypeContainer[k], function () {
                            $(this).hide()
                        })
                    });
                    i.find("#answer_" + j[b]).attr('order', p[b]);
                    i.find("#answer_" + j[b]).attr('order_start', q[b]);
                    curr_top = curr_top + g;
                    curr_z_index = curr_z_index - 1
                };
                i.find('.polling_ul').css('height', curr_height)
            }, 2700, function () {});
            i.find('.total_votes').html(m);
            i.find('.total_votes_val').html(m);
            i.find('.first_vote').html(n);
            i.find('.last_vote').html(o);
            i.find('.polling_bottom_wrapper1').stop(true, true).animate({
                height: 0
            }, 1000, function () {
                i.find('.polling_bottom_wrapper1').hide();
                i.find('.polling_loading').hide()
            });
            setTimeout(function () {
                i.find('.polling_info').css({
                    'display': 'block'
                });
                var h = i.find('.polling_info').height();
                i.find('.polling_info').css({
                    'display': 'none'
                });
                i.find('.polling_info').css({
                    'height': 0,
                    'display': 'block'
                }).animate({
                    height: h
                }, 1000);
                i.find('.timeline_icon').animate({
                    height: 32
                }, 1000);
                i.find('.add_answer_icon').animate({
                    height: 32
                }, 1000);
                i.find('.sexyback_icon').animate({
                    height: 32
                }, 1000);
                i.find('.scale_icon').animate({
                    height: 32
                }, 1000)
            }, 1700);
            if (autoOpenTimeline[k] == 1) {
                setTimeout(function () {
                    i.find('.timeline_icon').trigger("click")
                }, 2700)
            }
        }
        $digit_int = new Array();
        $digit_int_percent = new Array();
        $digit_int_total = '';

        function show_polling_by_date(m, n) {
            n = typeof n !== 'undefined' ? n : 'no';
            var o = m.find('.poll_answer').attr('name');
            var p = m.parent('div').attr('roll');
            var q = m.find('.polling_select1').val();
            var r = m.find('.polling_select2').val();
            $container = m;
            for (i_v in $digit_int) {
                clearInterval($digit_int[i_v])
            }
            for (i_v in $digit_int_percent) {
                clearInterval($digit_int_percent[i_v])
            }
            clearInterval($digit_int_total);
            setTimeout(function () {
                $nav_width = $container.find(".polling_li").width();
                $.ajax({
                    url: sexyPath + 'components/com_sexypolling/vote.php',
                    type: "post",
                    data: 'polling_id=' + o + '&mode=view_by_date&min_date=' + q + '&max_date=' + r + '&dateformat=' + dateFormat[o] + '&curr_date=' + n,
                    dataType: "json",
                    success: function (k) {
                        data_length = k.length;
                        answers_array = new Array();
                        orders_array = new Array();
                        orders_array_start = new Array();
                        $curr_count = new Array();
                        $new_count = new Array();
                        $step_sign = new Array();
                        $steps = new Array();
                        $interval_value = new Array();
                        $curr_count_ = new Array();
                        $curr_step = new Array();
                        $curr_percent = new Array();
                        $new_percent = new Array();
                        $step_sign_percent = new Array();
                        $steps_percent = new Array();
                        $interval_value_percent = new Array();
                        $curr_percent_ = new Array();
                        $curr_step_percent = new Array();
                        var l = 'none';
                        $.each(k, function (i) {
                            answer_id = this.answer_id;
                            percent = this.percent;
                            percent_formated = parseFloat(this.percent_formated);
                            response_votes = parseInt(this.votes);
                            order = this.order;
                            order_start = this.order_start;
                            if (l == 'none') l = percent;
                            total_votes = this.total_votes;
                            q = this.min_date;
                            r = this.max_date;
                            answers_array.push(answer_id);
                            orders_array.push(order);
                            orders_array_start.push(order_start);
                            $container.find('#answer_navigation_' + answer_id).attr('title', 'Votes: ' + response_votes);
                            $current_width_rel = parseInt($nav_width * percent / 100);
                            $current_width_rel = $current_width_rel == 0 ? '1' : $current_width_rel;
                            $current_width = parseInt($nav_width * percent / l);
                            $current_width = $current_width == 0 ? '1' : $current_width;
                            if ($container.find('.scale_icon').hasClass('opened')) new_w = $current_width_rel;
                            else new_w = $current_width;
                            $container.find('#answer_navigation_' + answer_id).attr({
                                "rel_width": $current_width_rel,
                                "ab_width": $current_width
                            }).stop(true, false).animate({
                                width: new_w
                            }, 1000, sexyAnimationTypeBar[o]);
                            if ($container.find('#answer_navigation_' + answer_id).next(".ie-shadow").width() != $current_width + 4 * 1) $container.find('#answer_navigation_' + answer_id).next(".ie-shadow").stop(true, false).animate({
                                width: new_w
                            }, 1000, sexyAnimationTypeBar[o]);
                            $curr_percent[answer_id] = parseFloat($container.find('#answer_votes_data_percent_' + answer_id).html());
                            $new_percent[answer_id] = percent_formated;
                            $steps_percent[answer_id] = Math.abs($curr_percent[answer_id] - $new_percent[answer_id]);
                            $steps_count_percent = 20;
                            $step_item_percent = $steps_percent[answer_id] / $steps_count_percent;
                            $step_sign_percent[answer_id] = ($new_percent[answer_id] > $curr_percent[answer_id]) ? 1 * $step_item_percent : (($new_percent[answer_id] < $curr_percent[answer_id]) ? -1 * $step_item_percent : 0);
                            $interval_value_percent[answer_id] = parseFloat(1000 / $steps_count_percent);
                            $curr_total = parseInt(m.find('.total_votes').html());
                            $new_total = total_votes;
                            $steps_total = Math.abs($curr_total - $new_total);
                            $steps_count_total = 20;
                            $step_item_total = $steps_total / $steps_count_total;
                            $step_sign_total = ($new_total > $curr_total) ? 1 * $step_item_total : (($new_total < $curr_total) ? -1 * $step_item_total : 0);
                            $interval_value_total = parseFloat(1000 / $steps_count_total);
                            $curr_count[answer_id] = parseInt($container.find('#answer_votes_data_count_' + answer_id).html());
                            $new_count[answer_id] = response_votes;
                            $steps[answer_id] = Math.abs($curr_count[answer_id] - $new_count[answer_id]);
                            $steps_count = 15;
                            $step_item = $steps[answer_id] / $steps_count;
                            $step_sign[answer_id] = ($new_count[answer_id] > $curr_count[answer_id]) ? 1 * $step_item : (($new_count[answer_id] < $curr_count[answer_id]) ? -1 * $step_item : 0);
                            $interval_value[answer_id] = parseFloat(1000 / $steps_count);
                            if (i == data_length - 1) {
                                m.find('.first_vote').html(q);
                                m.find('.last_vote').html(r);

                                function animate_total() {
                                    if ($step_sign_total != 0) {
                                        $digit_int_total = setInterval(function () {
                                            $curr_total_ = parseFloat(m.find('.total_votes_val').html());
                                            $curr_total_ = $curr_total_ + 1 * $step_sign_total;
                                            m.find('.total_votes').html($curr_total_.toFixed(1));
                                            m.find('.total_votes_val').html($curr_total_);
                                            if ($step_sign_total > 0) {
                                                if ($curr_total_ >= $new_total) {
                                                    clearInterval($digit_int_total);
                                                    m.find('.total_votes').html($new_total);
                                                    m.find('.total_votes_val').html($new_total)
                                                }
                                            } else {
                                                if ($curr_total_ <= $new_total) {
                                                    clearInterval($digit_int_total);
                                                    m.find('.total_votes').html($new_total);
                                                    m.find('.total_votes_val').html($new_total)
                                                }
                                            }
                                        }, $interval_value_total)
                                    } else {
                                        m.find('.total_votes').html($new_total);
                                        m.find('.total_votes_val').html($new_total)
                                    }
                                };
                                animate_total();
                                var g = function (a) {
                                    if ($step_sign_percent[a] !== 0) {
                                        $digit_int_percent[a] = setInterval(function () {
                                            $curr_percent_[a] = parseFloat($container.find('#answer_votes_data_percent_val_' + a).html());
                                            $curr_percent_[a] = $curr_percent_[a] + 1 * $step_sign_percent[a];
                                            $container.find('#answer_votes_data_percent_val_' + a).html($curr_percent_[a]);
                                            $container.find('#answer_votes_data_percent_' + a).html($curr_percent_[a].toFixed(2));
                                            if ($step_sign_percent[a] > 0) {
                                                if ($curr_percent_[a] >= $new_percent[a]) {
                                                    clearInterval($digit_int_percent[a]);
                                                    $container.find('#answer_votes_data_percent_' + a).html($new_percent[a]);
                                                    $container.find('#answer_votes_data_percent_val_' + a).html($new_percent[a])
                                                }
                                            } else {
                                                if ($curr_percent_[a] <= $new_percent[a]) {
                                                    clearInterval($digit_int_percent[a]);
                                                    $container.find('#answer_votes_data_percent_' + a).html($new_percent[a]);
                                                    $container.find('#answer_votes_data_percent_val_' + a).html($new_percent[a])
                                                }
                                            }
                                        }, $interval_value_percent[a])
                                    } else {
                                        $container.find('#answer_votes_data_percent_' + a).html($new_percent[a]);
                                        $container.find('#answer_votes_data_percent_val_' + a).html($new_percent[a])
                                    }
                                };
                                var h = function (a) {
                                    if ($step_sign[a] != 0) {
                                        $digit_int[a] = setInterval(function () {
                                            $curr_count_[a] = parseFloat($container.find('#answer_votes_data_count_val_' + a).html());
                                            $curr_count_[a] = $curr_count_[a] + 1 * $step_sign[a];
                                            $container.find('#answer_votes_data_count_' + a).html($curr_count_[a].toFixed(1));
                                            $container.find('#answer_votes_data_count_val_' + a).html($curr_count_[a]);
                                            if ($step_sign[a] > 0) {
                                                if ($curr_count_[a] >= $new_count[a]) {
                                                    clearInterval($digit_int[a]);
                                                    $container.find('#answer_votes_data_count_' + a).html($new_count[a]);
                                                    $container.find('#answer_votes_data_count_val_' + a).html($new_count[a])
                                                }
                                            } else {
                                                if ($curr_count_[a] <= $new_count[a]) {
                                                    clearInterval($digit_int[a]);
                                                    $container.find('#answer_votes_data_count_' + a).html($new_count[a]);
                                                    $container.find('#answer_votes_data_count_val_' + a).html($new_count[a])
                                                }
                                            }
                                        }, $interval_value[a])
                                    } else {
                                        $container.find('#answer_votes_data_count_' + a).html($new_count[a]);
                                        $container.find('#answer_votes_data_count_val_' + a).html($new_count[a])
                                    }
                                };
                                for (var b = 0; b < answers_array.length; b++) {
                                    h(answers_array[b]);
                                    g(answers_array[b])
                                }
                            };
                            if (i == data_length - 1) {
                                var j = m.find('.polling_ul').offset();
                                offset_0 = j.top;
                                setTimeout(function () {
                                    var a = new Array();
                                    for (var b = 0; b < answers_array.length; b++) {
                                        var c = $container.find("#answer_" + answers_array[b]).offset();
                                        var d = c.top;
                                        var e = d * 1 - offset_0;
                                        a.push(e)
                                    };
                                    curr_top = 0;
                                    curr_height = 0;
                                    curr_z_index = 1000;
                                    for (var b = 0; b < answers_array.length; b++) {
                                        var f = $container.find("#answer_" + answers_array[b]).height() + O;
                                        curr_height = curr_height * 1 + f;
                                        $container.find("#answer_" + answers_array[b]).css({
                                            position: 'absolute',
                                            top: a[b],
                                            'z-index': curr_z_index
                                        });
                                        $container.find("#answer_" + answers_array[b]).stop(true, false).animate({
                                            top: curr_top
                                        }, 1200, sexyAnimationTypeContainerMove[o]);
                                        $container.find("#answer_" + answers_array[b] + " .animation_block").css({
                                            'display': 'block'
                                        }).stop(false, false).animate({
                                            opacity: 1,
                                            boxShadow: animation_styles[p + "_" + o][2],
                                            borderTopColor: animation_styles[p + "_" + o][1],
                                            borderBottomColor: animation_styles[p + "_" + o][1],
                                            borderLeftColor: animation_styles[p + "_" + o][1],
                                            borderRightColor: animation_styles[p + "_" + o][1],
                                            backgroundColor: animation_styles[p + "_" + o][0],
                                            borderTopLeftRadius: animation_styles[p + "_" + o][3],
                                            borderTopRightRadius: animation_styles[p + "_" + o][4],
                                            borderBottomLeftRadius: animation_styles[p + "_" + o][5],
                                            borderBottomRightRadius: animation_styles[p + "_" + o][6]
                                        }, 1200, sexyAnimationTypeContainer[o], function () {
                                            $(this).animate({
                                                opacity: 0,
                                                boxShadow: animation_styles[p + "_" + o][8] + '0 0 0 0 ' + animation_styles[p + "_" + o][7],
                                                borderTopColor: animation_styles[p + "_" + o][7],
                                                borderBottomColor: animation_styles[p + "_" + o][7],
                                                borderLeftColor: animation_styles[p + "_" + o][7],
                                                borderRightColor: animation_styles[p + "_" + o][7],
                                                backgroundColor: animation_styles[p + "_" + o][7],
                                                borderTopLeftRadius: 0,
                                                borderTopRightRadius: 0,
                                                borderBottomLeftRadius: 0,
                                                borderBottomRightRadius: 0
                                            }, 1200, sexyAnimationTypeContainer[o], function () {
                                                $(this).hide()
                                            })
                                        });
                                        $container.find("#answer_" + answers_array[b]).attr('order', orders_array[b]);
                                        $container.find("#answer_" + answers_array[b]).attr('order_start', orders_array_start[b]);
                                        curr_top = curr_top + f;
                                        curr_z_index = curr_z_index - 1
                                    };
                                    $container.find('.polling_ul').css('height', curr_height)
                                }, 1)
                            }
                        })
                    },
                    error: function () {}
                })
            }, 1)
        };

        function vote_polling(k) {
            var l = k.parent('span').parent('div').find('.poll_answer').attr('name');
            var m = k.parent('span').parent('div').parent('div').attr('roll');
            $container = k.parent('span').parent('div');
            var n = voting_periods[m + '_' + l];
            $container.find('.answer_wrapper').css({
                'overflow': 'hidden'
            }).animate({
                height: 0
            }, 600);
            $container.find('.add_answer_icon').removeClass('opened').addClass('voted_button');
            $container.find('.polling_submit').addClass('voted_button');
            $ul_height = $container.children("ul").height();
            $container.children("ul").attr("h", $ul_height);
            var o = '';
            $container.find('.doNotUncheck').each(function (i) {
                var a = $(this).parents('li').find('label').html();
                a = a.replace(/\?\?/g, 'sexydoublequestionmark');
                o += '&answers[]=' + a
            });
            $container.find('.answer_input').animate({
                width: 0,
                opacity: 0
            }, 1000);
            $container.find('.answer_name label').animate({
                marginLeft: 0
            }, 1000);
            var b = $container.find('.answer_navigation').attr("b");
            $container.find('.answer_navigation').css("borderWidth", "0").show().animate({
                height: animation_styles[m + "_" + l][9],
                borderWidth: b,
                opacity: 1
            }, 1000);
            var p = k.parent('span').parent('div').find('.polling_loading').height();
            k.parent('span').parent('div').find('.polling_loading').attr("h", p).css({
                display: 'block',
                opacity: 0,
                height: 0
            });
            k.parent('span').parent('div').find('.polling_loading').animate({
                opacity: 0.85,
                height: p
            }, 1000);
            $nav_width = $container.find(".polling_li").width();
            var h = $container.find('.answer_votes_data').height();
            var q = '';
            k.parent('span').parent('div').find('.poll_answer:checked').not('.doNotUncheck').each(function () {
                q += '&answer_id[]=' + $(this).val()
            });
            setTimeout(function () {
                $.ajax({
                    url: sexyPath + 'components/com_sexypolling/vote.php',
                    type: "post",
                    data: 'polling_id=' + l + q + '&dateformat=' + dateFormat[l] + o + '&country_name=' + N + '&country_code=' + sexyCountryCode + '&city_name=' + sexyCity + '&region_name=' + sexyRegion + '&voting_period=' + n,
                    dataType: "json",
                    success: function (j) {
                        $container.find('.doNotUncheck').each(function (i) {
                            if (typeof j[0].addedanswers !== 'undefined') {
                                $(this).parents('li').attr("id", 'answer_' + j[0].addedanswers[i]);
                                $(this).parents('li').find('.answer_navigation').attr("id", 'answer_navigation_' + j[0].addedanswers[i]);
                                $(this).parents('li').find('.answer_votes_data').attr("id", 'answer_votes_data_' + j[0].addedanswers[i]);
                                $(this).parents('li').find('#answer_votes_data_count_0').attr("id", 'answer_votes_data_count_' + j[0].addedanswers[i]);
                                $(this).parents('li').find('#answer_votes_data_count_val_0').attr("id", 'answer_votes_data_count_val_' + j[0].addedanswers[i]);
                                $(this).parents('li').find('#answer_votes_data_percent_0').attr("id", 'answer_votes_data_percent_' + j[0].addedanswers[i]);
                                $(this).parents('li').find('#answer_votes_data_percent_val_0').attr("id", 'answer_votes_data_percent_val_' + j[0].addedanswers[i])
                            }
                        });
                        $container.find('.doNotUncheck').removeClass('doNotUncheck');
                        answers_array = new Array();
                        orders_array = new Array();
                        orders_array_start = new Array();
                        max_percent = 'none';
                        $.each(j, function (i) {
                            answer_id = this.answer_id;
                            percent = this.percent;
                            percent_formated = this.percent_formated;
                            response_votes = this.votes;
                            order = this.order;
                            order_start = this.order_start;
                            if (max_percent == 'none') max_percent = percent;
                            answers_array.push(answer_id);
                            orders_array.push(order);
                            orders_array_start.push(order_start);
                            $container.find('#answer_navigation_' + answer_id).attr('title', 'Votes: ' + response_votes);
                            $current_width_rel = parseInt($nav_width * percent / 100);
                            $current_width_rel = $current_width_rel == 0 ? '1' : $current_width_rel;
                            $current_width = parseInt($nav_width * percent / max_percent);
                            $current_width = $current_width == 0 ? '1' : $current_width;
                            $container.find('#answer_navigation_' + answer_id).attr({
                                "rel_width": $current_width_rel,
                                "ab_width": $current_width
                            }).animate({
                                width: $current_width
                            }, 1000, sexyAnimationTypeBar[l]);
                            $container.find('#answer_navigation_' + answer_id).next(".ie-shadow").animate({
                                width: $current_width
                            }, 1000, sexyAnimationTypeBar[l]);
                            $container.find('#answer_votes_data_count_' + answer_id).html(response_votes);
                            $container.find('#answer_votes_data_count_val_' + answer_id).html(response_votes);
                            $container.find('#answer_votes_data_percent_' + answer_id).html(percent_formated);
                            $container.find('#answer_votes_data_percent_val_' + answer_id).html(percent_formated);
                            $container.find('.answer_votes_data').css({
                                'display': 'block',
                                'height': 0
                            }).animate({
                                height: h
                            }, 1000);
                            if (i == 0) {
                                var g = $container.find('.polling_ul').offset();
                                offset_0 = g.top;
                                setTimeout(function () {
                                    var a = new Array();
                                    for (var b = 0; b < answers_array.length; b++) {
                                        var c = $container.find("#answer_" + answers_array[b]).offset();
                                        var d = c.top;
                                        var e = d * 1 - offset_0;
                                        a.push(e)
                                    };
                                    curr_top = 0;
                                    curr_height = 0;
                                    curr_z_index = 1000;
                                    $container.find('.polling_ul').css('height', $container.find('.polling_ul').height());
                                    for (var b = 0; b < answers_array.length; b++) {
                                        var f = $container.find("#answer_" + answers_array[b]).height() + O;
                                        curr_height = curr_height * 1 + f;
                                        $container.find("#answer_" + answers_array[b]).css({
                                            position: 'absolute',
                                            top: a[b],
                                            'z-index': curr_z_index
                                        });
                                        $container.find("#answer_" + answers_array[b]).stop(true, false).animate({
                                            top: curr_top
                                        }, 1200, sexyAnimationTypeContainerMove[l]);
                                        $container.find("#answer_" + answers_array[b] + " .animation_block").css({
                                            'display': 'block',
                                            'opacity': '0'
                                        }).stop(true, false).animate({
                                            opacity: 1,
                                            boxShadow: animation_styles[m + "_" + l][2],
                                            borderTopColor: animation_styles[m + "_" + l][1],
                                            borderBottomColor: animation_styles[m + "_" + l][1],
                                            borderLeftColor: animation_styles[m + "_" + l][1],
                                            borderRightColor: animation_styles[m + "_" + l][1],
                                            backgroundColor: animation_styles[m + "_" + l][0],
                                            borderTopLeftRadius: animation_styles[m + "_" + l][3],
                                            borderTopRightRadius: animation_styles[m + "_" + l][4],
                                            borderBottomLeftRadius: animation_styles[m + "_" + l][5],
                                            borderBottomRightRadius: animation_styles[m + "_" + l][6]
                                        }, 1200, sexyAnimationTypeContainer[l], function () {
                                            $(this).animate({
                                                opacity: 0,
                                                boxShadow: animation_styles[m + "_" + l][8] + '0 0 0 0 ' + animation_styles[m + "_" + l][7],
                                                borderTopColor: animation_styles[m + "_" + l][7],
                                                borderBottomColor: animation_styles[m + "_" + l][7],
                                                borderLeftColor: animation_styles[m + "_" + l][7],
                                                borderRightColor: animation_styles[m + "_" + l][7],
                                                backgroundColor: animation_styles[m + "_" + l][7],
                                                borderTopLeftRadius: 0,
                                                borderTopRightRadius: 0,
                                                borderBottomLeftRadius: 0,
                                                borderBottomRightRadius: 0
                                            }, 1200, sexyAnimationTypeContainer[l], function () {
                                                $(this).hide()
                                            })
                                        });
                                        $container.find("#answer_" + answers_array[b]).attr('order', orders_array[b]);
                                        $container.find("#answer_" + answers_array[b]).attr('order_start', orders_array_start[b]);
                                        curr_top = curr_top + f;
                                        curr_z_index = curr_z_index - 1
                                    };
                                    $container.find('.polling_ul').css('height', curr_height)
                                }, 2700);
                                total_votes = this.total_votes;
                                min_date = this.min_date;
                                max_date = this.max_date;
                                $container.find('.total_votes').html(total_votes);
                                $container.find('.total_votes_val').html(total_votes);
                                $container.find('.first_vote').html(min_date);
                                $container.find('.last_vote').html(max_date);
                                $container.find('.polling_bottom_wrapper1').animate({
                                    height: 0
                                }, 1000, function () {
                                    $container.find('.polling_bottom_wrapper1').hide();
                                    $container.find('.polling_loading').hide()
                                });
                                setTimeout(function () {
                                    $container.find('.polling_info').css({
                                        'display': 'block'
                                    });
                                    var h = $container.find('.polling_info').height();
                                    $container.find('.polling_info').css({
                                        'display': 'none'
                                    });
                                    $container.find('.polling_info').css({
                                        'height': 0,
                                        'display': 'block'
                                    }).animate({
                                        height: h
                                    }, 1000);
                                    $container.find('.timeline_icon').animate({
                                        height: 32
                                    }, 1000);
                                    $container.find('.add_answer_icon').animate({
                                        height: 32
                                    }, 1000);
                                    $container.find('.sexyback_icon').animate({
                                        height: 32
                                    }, 1000);
                                    $container.find('.scale_icon').animate({
                                        height: 32
                                    }, 1000)
                                }, 1700);
                                if (autoOpenTimeline[l] == 1) {
                                    setTimeout(function () {
                                        $container.find('.timeline_icon').trigger("click")
                                    }, 2700)
                                }
                            }
                        })
                    },
                    error: function () {}
                })
            }, 1000)
        };
        $('.timeline_icon').click(function () {
            var a = $(this).parent('div').children('.timeline_select_wrapper');
            var b = 90;
            var c = a.hasClass('opened') ? 'closed' : 'opened';
            if (c == 'opened') {
                $(this).addClass('opened');
                a.removeClass('closed');
                a.addClass('opened');
                $(this).attr('title', sexyPolling_words[5])
            } else {
                $(this).removeClass('opened');
                a.removeClass('opened');
                a.addClass('closed');
                $(this).attr('title', sexyPolling_words[4])
            }
            $(this).parent('div').children('.timeline_select_wrapper.opened').css({
                'overflow': 'hidden',
                'height': 0
            }).stop(true, true).animate({
                height: b
            }, 1000, function () {
                $(this).css({
                    'overflow': 'visible'
                })
            });
            $(this).parent('div').children('.timeline_select_wrapper.closed').css({
                'overflow': 'hidden'
            }).stop(true, true).animate({
                height: 0
            }, 1000, function () {
                $(this).css({
                    'overflow': 'hidden'
                })
            })
        });

        function make_relative(b) {
            var c = b.parent('div').parent('div').parent('div').attr('roll');
            var d = b.parent('div').parent('div').parent('div').find(".poll_answer").attr('name');
            b.parent('div').parent('div').find('.answer_navigation').each(function () {
                var a = $(this).attr("rel_width");
                $(this).stop(true, false).animate({
                    width: a
                }, 1000, sexyAnimationTypeBar[d])
            })
        };

        function make_absolute(b) {
            var c = b.parent('div').parent('div').parent('div').attr('roll');
            var d = b.parent('div').parent('div').parent('div').find(".poll_answer").attr('name');
            b.parent('div').parent('div').find('.answer_navigation').each(function () {
                var a = $(this).attr("ab_width");
                $(this).stop(true, false).animate({
                    width: a
                }, 1000, sexyAnimationTypeBar[d])
            })
        };

        function animate_back(a) {
            $container = a.parents('.polling_container');
            $container.find('.polling_result').removeClass('hide_sexy_button');
            $container.find('.poll_answer').attr("checked", false);
            $container.find('.twoglux_styled_element').removeClass("twoglux_checked");
            $container.find('.checkbox_part1').css("height", 0);
            $container.find('.checkbox_part2').css("height", 0);
            $container.find('.radio_part1').css("opacity", 0);
            $container.find('.polling_info').stop().stop(true, true).animate({
                height: 0
            }, 1000, function () {
                $(this).removeAttr("style")
            });
            $container.find('.timeline_select_wrapper').stop().stop(true, true).animate({
                height: 0
            }, 1000, function () {
                $(this).css({
                    'overflow': 'hidden'
                })
            });
            $('.timeline_icon').removeClass('opened');
            $('.timeline_select_wrapper').removeClass('opened');
            var b = $container.find('.polling_loading').attr("h");
            $container.find('.polling_loading').css({
                'display': 'none'
            });
            var h = $container.find('.polling_bottom_wrapper1').attr("h");
            $container.find('.polling_bottom_wrapper1').css({
                'display': 'block'
            }).stop().stop(true, true).animate({
                height: h
            }, 1000, function () {
                $(this).css('height', 'auto')
            });
            var c = $container.find('.answer_input').attr("w");
            var d = $container.find('.answer_result').height();
            var e = $container.find('.polling_ul').attr("h");
            $container.find('.timeline_icon').stop(true, true).animate({
                height: 0
            }, 1000);
            $container.find('.add_answer_icon').stop(true, true).animate({
                height: 0
            }, 1000);
            $container.find('.sexyback_icon').stop(true, true).animate({
                height: 0
            }, 1000);
            $container.find('.scale_icon').stop(true, true).animate({
                height: 0
            }, 1000);
            $container.find('.answer_votes_data').stop(true, true).animate({
                height: 0
            }, 1000, function () {
                $(this).removeAttr("style")
            });
            $container.find('.answer_input').stop(true, true).animate({
                width: c,
                opacity: 1
            }, 1000);
            $container.find('.answer_name label').stop(true, true).animate({
                marginLeft: c
            }, 1000);
            $container.find('.answer_navigation').stop(true, true).animate({
                height: 0,
                borderWidth: 0
            }, 1000, function () {
                $(this).hide()
            });
            var f = 0;
            $container.find('.polling_li').each(function (k) {
                var h = $(this).attr("h_start") * 1;
                $(this).stop(true, true).animate({
                    "top": f
                }, 1000, function () {
                    $(this).removeAttr("style")
                });
                f = f + h * 1
            });
            $container.find('.polling_ul').stop(true, true).animate({
                height: e
            }, 1000, function () {
                $(this).removeAttr("style")
            })
        };
        $('.scale_icon').click(function () {
            if ($(this).hasClass('opened')) {
                $(this).removeClass('opened');
                $(this).attr("title", sexyPolling_words[16]);
                make_absolute($(this))
            } else {
                $(this).addClass('opened');
                $(this).attr("title", sexyPolling_words[15]);
                make_relative($(this))
            }
        });
        $('.sexyback_icon').click(function () {
            animate_back($(this))
        });
        $('.add_answer_icon').click(function () {
            if ($(this).hasClass('voted_button')) {
                make_alert(sexyPolling_words[9], 'sexy_error');
                return
            }
            if ($(this).hasClass('disabled')) return;
            var a = $(this).parents('.polling_container').find('.answer_wrapper');
            var b = $(this).parents('.polling_container').find('.answer_wrapper').attr("h");
            $(this).parents('.polling_container').find('.answer_wrapper.closed').css({
                'overflow': 'hidden',
                'height': 0
            }).animate({
                height: b
            }, 600, function () {
                $(this).css({
                    'overflow': 'visible'
                })
            });
            $(this).parents('.polling_container').find('.answer_wrapper.opened').css({
                'overflow': 'hidden'
            }).animate({
                height: 0
            }, 600);
            var c = a.hasClass('opened') ? 'closed' : 'opened';
            if (c == 'opened') {
                $(this).addClass('opened');
                a.removeClass('closed');
                a.addClass('opened')
            } else {
                $(this).removeClass('opened');
                a.removeClass('opened');
                a.addClass('closed')
            }
        });
        $('.add_ans_name').focus(function () {
            var a = $(this).parents('.polling_container').find('.poll_answer').attr('name');
            var b = $(this).parents('.polling_container_wrapper').attr('roll');
            if ($(this).val() == sexyPolling_words[11]) {
                $(this).val('');
                $(this).css('color', animation_styles[b + "_" + a][11]);
                $(this).parent('div').children('.add_ans_submit').show();
                var c = $(this).parent('div').children('.add_ans_submit').width();
                c += 14;
                $(this).parent('.add_answer').css('paddingRight', c)
            }
        });
        $('.add_ans_name').blur(function () {
            var a = $(this).parents('.polling_container').find('.poll_answer').attr('name');
            var b = $(this).parents('.polling_container_wrapper').attr('roll');
            if ($.trim($(this).val()) == '') {
                $(this).val(sexyPolling_words[11]);
                $(this).css('color', animation_styles[b + "_" + a][10]);
                $(this).parent('div').children('.add_ans_submit').hide();
                $(this).parent('.add_answer').css('paddingRight', 0)
            } else {
                $(this).val($.trim($(this).val()))
            }
        });
        $(".add_ans_name").keydown(function (e) {
            if (e.keyCode == 13) {
                var a = $(this).parent('div').children('.add_ans_submit').css("display");
                if (a == 'block' || a == 'inline-block') {
                    $(this).parent('div').children('.add_ans_submit').trigger('click');
                    $(this).blur()
                }
            }
        });
        $('.add_ans_submit').click(function () {
            var r = parseInt($(this).parents('.polling_container_wrapper').find('.answer_input').length);
            if (r >= 30) {
                make_alert('This poll can not have more than 30 answers', 'sexy_error');
                return false
            }
            if (!check_allowed_answers_count($(this).parents('.polling_container_wrapper'))) return false;
            $this = $(this);
            $ans_name = $.trim($this.parent('div').children('.add_ans_name').val());
            $ans_name = $ans_name.replace(/\\/g, "");
            if ($ans_name == '') return false;
            $poll_id = $this.parent('div').children('.poll_id').val();
            var s = $(this).parents('.polling_container_wrapper').attr('roll');
            var u = voting_periods[s + '_' + $poll_id];
            var v = new Array();
            var w = P[$poll_id];
            for (t in votedIds) {
                v.push(votedIds[t][0]);
                if (votedIds[t][0] == $poll_id) var x = votedIds[t][2]
            };
            if (w > 0 || x == 'never') {
                if ($.inArray($poll_id, v) != -1) {
                    if (x == 'never') {
                        make_alert(sexyPolling_words[9], 'sexy_error');
                        return false
                    } else {
                        var y = parseInt(x / 24);
                        var z = y == 0 ? false : true;
                        var A = '<div id="sexy_timer"></div>';
                        make_alert(sexyPolling_words[9] + '<div id="estimated_time_message">' + sexyPolling_words[20] + '</div>' + A, 'sexy_error');
                        create_timer(w, z);
                        return false
                    }
                }
            };
            var B = $this.parents('.polling_container').find('.polling_submit').attr("id");
            var C = Q[$poll_id];
            s_length = startDisabledIds.length;
            for (var i = 0; i <= s_length; i++) {
                if (typeof startDisabledIds[i] !== 'undefined') {
                    var D = "poll_" + startDisabledIds[i][2] + "_" + startDisabledIds[i][0];
                    if (D == B) {
                        var x = startDisabledIds[i][3];
                        if (C > 0 || x == 'never') {
                            if (x == 'never') {
                                make_alert(startDisabledIds[i][1], 'sexy_error');
                                return false
                            } else {
                                var y = parseInt(x / 24);
                                var z = y == 0 ? false : true;
                                var A = '<div id="sexy_timer"></div>';
                                make_alert(startDisabledIds[i][1] + '<div id="estimated_time_message">' + sexyPolling_words[22] + '</div>' + A, 'sexy_error');
                                create_timer(C, z);
                                return false
                            }
                        }
                    }
                }
            };
            e_length = endDisabledIds.length;
            for (var i = 0; i <= e_length; i++) {
                if (typeof endDisabledIds[i] !== 'undefined') {
                    var D = "poll_" + endDisabledIds[i][2] + "_" + endDisabledIds[i][0];
                    if (D == B) {
                        make_alert(endDisabledIds[i][1], 'sexy_normal');
                        return false
                    }
                }
            };
            var E = false;
            var F = $this.parents('.polling_container').find('.polling_li').css('position');
            if (F == 'absolute') {
                E = true
            };
            var G = multipleAnswersInfoArray[$poll_id] == 1 ? 'checkbox' : 'radio';
            var H = (G == 'checkbox' && !E) ? 0 : 1;
            var I = $ans_name.replace(/\?\?/g, 'sexydoublequestionmark');
            $this.parent('div').children('.loading_small').fadeIn(400);
            $this.fadeOut(400);
            $.ajax({
                url: sexyPath + 'components/com_sexypolling/addanswer.php',
                type: "post",
                data: 'polling_id=' + $poll_id + '&answer=' + I + '&autopublish=' + sexyAutoPublish[$poll_id] + '&writeinto=' + H + '&country_name=' + N + '&country_code=' + sexyCountryCode + '&city_name=' + sexyCity + '&region_name=' + sexyRegion + '&voting_period=' + u,
                dataType: "json",
                success: function (a) {
                    if (G == 'radio' || (G == 'checkbox' && E)) {
                        $this.parents('.polling_container').find('.add_answer_icon').addClass('voted_button');
                        $this.parents('.polling_container').find('.polling_submit').addClass('voted_button')
                    }
                    $this.parent('div').children('.loading_small').fadeOut(400);
                    if (sexyAutoPublish[$poll_id] == 1) {
                        $this.parents('.polling_container').find('.add_answer_icon').addClass('disabled');
                        setTimeout(function () {
                            if ((G == 'checkbox' && !E)) {
                                $this.parent('div').children('.add_ans_name').css("color", animation_styles[s + "_" + $poll_id][10]).removeAttr('readonly').val(sexyPolling_words[11]);
                                $this.parents('.polling_container').find('.add_answer_icon').removeClass('disabled');
                                $this.parent('.add_answer').css('paddingRight', 0)
                            } else {
                                $this.parents('.polling_container').find('.add_answer_icon').removeClass('opened');
                                $this.parents('.answer_wrapper').removeClass('opened').addClass('closed').css({
                                    'overflow': 'hidden'
                                }).animate({
                                    height: 0
                                }, 600, function () {
                                    $this.parent('div').children('.add_ans_name').css("color", animation_styles[s + "_" + $poll_id][10]).removeAttr('readonly').val(sexyPolling_words[11]);
                                    $this.parents('.polling_container').find('.add_answer_icon').removeClass('disabled');
                                    $this.parent('.add_answer').css('paddingRight', 0)
                                })
                            }
                        }, 1);
                        add_answer($this.parents('.polling_container'), a[0].answer, a[0].id)
                    } else {
                        $this.parent('div').children('.add_ans_name').css("color", animation_styles[s + "_" + $poll_id][10]).attr("readonly", "readonly").val(sexyPolling_words[13]);
                        make_alert(sexyPolling_words[13], 'sexy_normal');
                        $this.parent('.add_answer').css('paddingRight', 0);
                        $this.parents('.polling_container').find('.add_answer_icon').addClass('disabled');
                        setTimeout(function () {
                            $this.parents('.polling_container').find('.add_answer_icon').removeClass('opened');
                            $this.parents('.answer_wrapper').removeClass('opened').addClass('closed').css({
                                'overflow': 'hidden'
                            }).animate({
                                height: 0
                            }, 600, function () {
                                $this.parent('div').children('.add_ans_name').css("color", animation_styles[s + "_" + $poll_id][10]).removeAttr('readonly').val(sexyPolling_words[11]);
                                $this.parents('.polling_container').find('.add_answer_icon').removeClass('disabled')
                            })
                        }, 3000)
                    }
                }
            });

            function add_answer(a, b, c) {
                var d = false;
                var e = a.find('.polling_li').css('position');
                if (e == 'absolute') {
                    d = true
                };
                var f = a.find('.poll_answer').attr('name');
                var g = a.parent('div').attr('roll');
                var h = a.find('.answer_votes_data').height();
                var i = multipleAnswersInfoArray[f] == 1 ? 'checkbox' : 'radio';
                var j = 'blue';
                if (i == 'radio') var k = '<div class="radio_part1 ' + j + '_radio_part1 unselectable" style="opacity: 1;" >&nbsp;</div>';
                else var k = '<div class="checkbox_part1 ' + j + '_checkbox_part1 unselectable" style="height: 9px;" >&nbsp;</div><div class="checkbox_part2 ' + j + '_checkbox_part2 unselectable" style="height: 12px;">&nbsp;</div>'; if (d) {
                    var l = a.find('.total_votes_val').html();
                    var m = ++l;
                    a.find('.total_votes_val').html(m);
                    a.find('.total_votes').html(m);
                    var n = parseFloat(100 / l).toFixed(1);
                    $new_li = '<li id="answer_' + c + '" class="polling_li"><div class="animation_block"></div><div class="answer_name"><label style="margin-left:0" uniq_index="' + c + '"  class="twoglux_label">' + b + '</label></div><div class="answer_input" style="width: 0px; opacity: 0; "><div class="twoglux_styled_input_wrapper" ><input name="' + f + '" id="' + c + '" type="' + i + '" checked="checked" class="poll_answer ' + c + ' twoglux_styled" style="display:none" value="' + c + '" /><a id="twoglux_styled_elem_' + c + '_' + p + '" class="twoglux_styled_element twoglux_styled_' + j + ' twoglux_styled_' + i + ' unselectable name_' + f + ' twoglux_checked">' + k + '</a></div></div><div class="sexy_clear"></div><div class="answer_result"><div class="answer_navigation polling_bar_' + newAnswerBarIndex + '" id="answer_navigation_' + c + '" style=" opacity: 1; width: 1px;display:block;"><div class="grad"></div></div><div class="answer_votes_data" id="answer_votes_data_' + c + '" style="height: ' + h + 'px;display:block; ">' + sexyPolling_words[0] + ': <span id="answer_votes_data_count_' + c + '">1</span><span id="answer_votes_data_count_val_' + c + '" style="display:none">1</span> (<span id="answer_votes_data_percent_' + c + '">' + n + '</span><span style="display:none" id="answer_votes_data_percent_val_' + c + '">' + n + '</span>%)</div><div class="sexy_clear"></div></div></li>';
                    a.find("li").last().after($new_li);
                    $("#answer_navigation_" + c).css('height', animation_styles[g + "_" + f][9]);
                    $new_height = $("#answer_" + c).height() + O;
                    $ul_height = a.children("ul").height();
                    $("#answer_" + c).css({
                        "position": "absolute",
                        "top": $ul_height
                    });
                    a.children("ul").stop(true, false).animate({
                        height: "+=" + $new_height
                    }, 600, function () {
                        show_polling_by_date(a, 'yes')
                    })
                } else {
                    var o = i == 'checkbox' ? 'doNotUncheck' : '';
                    var p = a.find(".doNotUncheck").length;
                    $new_li = '<li id="answer_' + c + '" class="polling_li"><div class="animation_block"></div><div class="answer_name"><label uniq_index="elem_' + c + '_' + p + '"  class="twoglux_label">' + b + '</label></div><div class="answer_input"><div class="twoglux_styled_input_wrapper" ><input name="' + f + '" id="elem_' + c + '_' + p + '" type="' + i + '" checked="checked"  class="poll_answer ' + c + ' twoglux_styled" style="display:none" value="' + c + '" /><a id="twoglux_styled_elem_' + c + '_' + p + '" class="' + o + ' twoglux_styled_element twoglux_styled_' + j + ' twoglux_styled_' + i + ' unselectable name_' + f + ' twoglux_checked">' + k + '</a></div></div><div class="sexy_clear"></div><div class="answer_result"><div class="answer_navigation polling_bar_' + newAnswerBarIndex + '" id="answer_navigation_' + c + '"><div class="grad"></div></div><div class="answer_votes_data" id="answer_votes_data_' + c + '">' + sexyPolling_words[0] + ': <span id="answer_votes_data_count_' + c + '"></span><span id="answer_votes_data_count_val_' + c + '" style="display:none">0</span> (<span id="answer_votes_data_percent_' + c + '">0</span><span style="display:none" id="answer_votes_data_percent_val_' + c + '">0</span>%)</div><div class="sexy_clear"></div></div></li>';
                    a.find("li").last().after($new_li);
                    $ul_height = a.children("ul").height();
                    a.children("ul").attr("h", $ul_height)
                }; if (d) $("#answer_" + c + " .animation_block").css({
                    'display': 'block',
                    'opacity': '0'
                }).stop(true, false).animate({
                    opacity: 1,
                    boxShadow: animation_styles[g + "_" + f][2],
                    borderTopColor: animation_styles[g + "_" + f][1],
                    borderBottomColor: animation_styles[g + "_" + f][1],
                    borderLeftColor: animation_styles[g + "_" + f][1],
                    borderRightColor: animation_styles[g + "_" + f][1],
                    backgroundColor: animation_styles[g + "_" + f][0],
                    borderTopLeftRadius: animation_styles[g + "_" + f][3],
                    borderTopRightRadius: animation_styles[g + "_" + f][4],
                    borderBottomLeftRadius: animation_styles[g + "_" + f][5],
                    borderBottomRightRadius: animation_styles[g + "_" + f][6]
                }, 1200, sexyAnimationTypeContainer[f], function () {
                    $(this).animate({
                        opacity: 0,
                        boxShadow: animation_styles[g + "_" + f][8] + '0 0 0 0 ' + animation_styles[g + "_" + f][7],
                        borderTopColor: animation_styles[g + "_" + f][7],
                        borderBottomColor: animation_styles[g + "_" + f][7],
                        borderLeftColor: animation_styles[g + "_" + f][7],
                        borderRightColor: animation_styles[g + "_" + f][7],
                        backgroundColor: animation_styles[g + "_" + f][7],
                        borderTopLeftRadius: 0,
                        borderTopRightRadius: 0,
                        borderBottomLeftRadius: 0,
                        borderBottomRightRadius: 0
                    }, 1200, sexyAnimationTypeContainer[f], function () {
                        $(this).hide()
                    })
                });
                if (!d && i == 'radio') {
                    var q = a.find(".polling_submit");
                    show_polling(q)
                }
            }
        });
        s_length = sexyPollingIds.length;
        for (var i = 0; i <= s_length; i++) {
            if (typeof sexyPollingIds[i] !== 'undefined') {
                var R = sexyPollingIds[i][0];
                var S = sexyPollingIds[i][1];
                $("#" + R + ",#" + S).selectToUISlider({
                    labels: 0,
                    sliderOptions: {
                        stop: function (e, a) {
                            show_polling_by_date($(this).parents('.polling_container'))
                        }
                    }
                })
            }
        };
        v_length = votedIds.length;
        for (var i = 0; i <= v_length; i++) {
            if (typeof votedIds[i] !== 'undefined' && autoAnimate[votedIds[i][0]] == '1') {
                var T = (i * 1 + 1) * 10;
                var t = $("#res_" + votedIds[i][1] + "_" + votedIds[i][0]);
                animate_poll(t, T)
            }
        };

        function animate_poll(t, a) {
            setTimeout(function () {
                show_polling(t)
            }, a)
        }
        $('.twoglux_styled').each(function () {
            var a = $(this);
            var b = a.attr("type");
            var c = a.attr("data-color");
            var d = a.attr("name");
            var e = a.attr("id");
            a.wrap('<div class="twoglux_styled_input_wrapper" />');
            if (b == 'radio') var f = '<div class="radio_part1 ' + c + '_radio_part1 unselectable" >&nbsp;</div>';
            else var f = '<div class="checkbox_part1 ' + c + '_checkbox_part1 unselectable" >&nbsp;</div><div class="checkbox_part2 ' + c + '_checkbox_part2 unselectable">&nbsp;</div>';
            var g = '<a id="twoglux_styled_' + e + '" class="twoglux_styled_element twoglux_styled_' + c + ' twoglux_styled_' + b + ' unselectable name_' + d + '">' + f + '</a>';
            a.after(g);
            a.hide()
        });
        $('.twoglux_styled_element').live('mouseenter', function () {
            make_mouseenter($(this))
        });
        $('.twoglux_styled_element').live('mouseleave', function () {
            make_mouseleave($(this))
        });

        function make_mouseenter(a) {
            if (a.hasClass('twoglux_styled_radio')) a.addClass('twoglux_styled_radio_hovered');
            else a.addClass('twoglux_styled_checkbox_hovered')
        };

        function make_mouseleave(a) {
            if (a.hasClass('twoglux_styled_radio')) a.removeClass('twoglux_styled_radio_hovered');
            else a.removeClass('twoglux_styled_checkbox_hovered')
        };
        var U = 150;
        var V = 'up';
        var W = 'up';
        var X = false;

        function animate_checkbox1_down(a) {
            a.animate({
                height: 9
            }, U)
        };

        function animate_checkbox1_up(a) {
            a.parent('a').removeClass('twoglux_checked');
            a.parent('a').prev('input').attr("checked", false);
            a.animate({
                height: 0
            }, U)
        };

        function animate_checkbox2_up(a) {
            a.animate({
                height: 12
            }, U);
            a.parent('a').addClass('twoglux_checked');
            a.parent('a').prev('input').attr("checked", true)
        };

        function animate_checkbox2_down(a) {
            a.animate({
                height: 0
            }, U)
        };
        $('.twoglux_styled_checkbox').live('mousedown', function () {
            if ($(this).hasClass('twoglux_checked')) animate_checkbox2_down($(this).find('.checkbox_part2'));
            else animate_checkbox1_down($(this).find('.checkbox_part1'));
            V = 'down';
            X = true
        });
        $('.twoglux_styled_checkbox').live('mouseup', function () {
            if (!($(this).hasClass('twoglux_checked'))) {
                if (!check_allowed_answers_count($(this).parents('.polling_container'))) {
                    V = 'up';
                    X = false;
                    animate_checkbox1_up($(this).find('.checkbox_part1'));
                    return false
                }
            }
            if (V == 'down') {
                if ($(this).hasClass('twoglux_checked')) animate_checkbox1_up($(this).find('.checkbox_part1'));
                else animate_checkbox2_up($(this).find('.checkbox_part2'))
            }
            V = 'up';
            X = false
        });

        function check_allowed_answers_count(a) {
            var b = a.find('.poll_answer').attr('name');
            var c = allowedNumberAnswers[b];
            if (c == 0) return true;
            var d = a.find('input[type="checkbox"]:checked').length;
            if (parseInt(d) == c) {
                make_alert(sexyPolling_words[23] + ' <span class="max_allowed_checkox_limit">' + c + '</span>', 'sexy_normal');
                return false
            }
            return true
        }
        $('.radio_part1').css('opacity', '0');
        $('.twoglux_styled_radio').live('mousedown', function () {
            if (!($(this).hasClass('twoglux_checked'))) {
                $(this).find('.radio_part1').fadeTo(U, 0.5)
            }
            W = 'down';
            X = true
        });
        $('.twoglux_styled_radio').live('mouseup', function () {
            if (W == 'down') {
                if (!($(this).hasClass('twoglux_checked'))) {
                    $(this).addClass('twoglux_checked');
                    var a = $(this).prev('input').attr("name");
                    $('input[name="' + a + '"]').attr("checked", false);
                    $(this).prev('input').attr("checked", true);
                    $('.name_' + a).removeClass('twoglux_checked');
                    $(this).addClass('twoglux_checked');
                    $('.name_' + a).not($(this)).find('.radio_part1').fadeTo(U, 0);
                    $(this).find('.radio_part1').fadeTo(U, 1)
                }
            }
            W = 'up';
            X = false
        });
        $('.twoglux_styled_input_wrapper').bind("dragstart", function () {
            return false
        });
        $("body").live('mouseup', function () {
            if (X) {
                var a = $('.twoglux_styled_element').not('.twoglux_checked').find('.checkbox_part1');
                animate_checkbox1_up(a);
                var a = $('.twoglux_styled_element.twoglux_checked').find('.checkbox_part2');
                animate_checkbox2_up(a);
                var a = $('.twoglux_styled_element').not('.twoglux_checked').find('.radio_part1');
                a.fadeTo(U, 0)
            }
        });
        $('.twoglux_label').live('mouseenter', function () {
            var a = $(this).attr("uniq_index");
            make_mouseenter($("#twoglux_styled_" + a))
        });
        $('.twoglux_label').live('mouseleave', function () {
            var a = $(this).attr("uniq_index");
            make_mouseleave($("#twoglux_styled_" + a))
        });
        $('.twoglux_label').live('mousedown', function () {
            var a = $(this).attr("uniq_index");
            $("#twoglux_styled_" + a).trigger("mousedown")
        });
        $('.twoglux_label').live('mouseup', function () {
            var a = $(this).attr("uniq_index");
            $("#twoglux_styled_" + a).trigger("mouseup")
        });
        $('.doNotUncheck').live('mouseup', function () {
            if (!$(this).hasClass('twoglux_checked')) {
                $(this).parent('div').parent('div').parent('li').remove()
            }
        })
    })
})(sexyJ);