$(document).ready(function() {
    
    var loc = location.pathname.substring(1, 4);
    jQuery("#hmenu_block a").each(function() {
        if(loc.indexOf(jQuery(this).attr('href').substring(1, 4)) > -1) {
            jQuery(this).addClass('active');
        }
    });
	
    $( "#announcements_date, #archive_date" ).datepicker({
        dateFormat: 'yy-mm-dd',
        monthNames: ['Январь','Февраль','Март','Апрель','Май','Июнь','Июль','Август','Сентябрь','Октябрь','Ноябрь','Декабрь'],
        firstDay: 1,
        dayNamesMin: ['Вс', 'Пн', 'Вт', 'Ср', 'Чт', 'Пт', 'Сб']
    });
	
    $(".show_full").toggle(
        function () {
            $(".about_full", this).slideDown('slow');
        },
        function () {
            $(".about_full", this).slideUp('slow');
        }
        );

    $('.imgPrev').fancybox(function() {
        
        });

    function showPollResults() {
        $.post('/page/pollresult', {
            pollid : $('#poll_frm input:hidden').attr('value')
        },
        function(data){
            $("#poll_variants").html(data);
        });
        $('#poll_submit').hide();
        $('#poll_show').hide();
    }

    if($.Storage.get("voted3") != null){
        showPollResults();
    }
	
    $('#poll_submit').click(function(){
        if($.Storage.get("voted3") == null){
            $.post('/page/poll', {
                voteid : $('#poll_frm input:radio:checked').attr('voteid')
            },
            function(){
                $.Storage.set("voted3", "1");
                showPollResults();
            });
        }
        else{
            alert('Вы уже голосовали!')
        }
    })

    $('#poll_show').click(function(){
        $.post('/page/pollresult', {
            pollid : $('#poll_frm input:hidden').attr('value')
        },
        function(data){
            $("#poll_variants").html(data);
        });
    })
	
    $(".show_video").click(function() {
        $.fancybox({
            'overlayColor'	: '#000',
            'overlayOpacity': 0.9,
            'padding'		: 0,
            'autoScale'		: false,
            'transitionIn'	: 'none',
            'transitionOut'	: 'none',
            'title'			: this.title,
            'width'		: 680,
            'height'		: 495,
            'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
            'type'			: 'swf',
            'swf'			: {

                'wmode'		: 'transparent',
                'allowfullscreen'	: 'true'
            }
        });
        return false;
    });
});
