$(document).ready(function(){
    $('.Slide').cycle({
        fx:'fade',
        speed:'500',
        timeout:'6000',
        pager: '.Nav',
        sync: true
    });

    $('.Meses li').click(function(){
        $('.BoxMes').hide();
        $('#'+$(this).attr('target')).show();
        $('#'+$(this).attr('target')).show();
    });
    $('.Meses li').hover(function(){
        $(this).css('background-color','#a0a3cb');
    }, function(){
        $(this).css('background-color','#d1d3e8');
    });
	
    $("a.group").fancybox({
        'transitionIn'	:	'elastic',
        'transitionOut'	:	'elastic',
        'speedIn'		:	400,
        'speedOut'		:	200,
        'overlayShow'	:	false,
        'hideOnContentClick': true
    });

    $('Form.Results .Resultado').hover(function(){
       $(this).css('background-image', 'url("img/icon3.png")');
    },function(){
       $(this).css('background-image', 'none');
    });

    $('Form.Results .Result').click(function(){
       $('.Results').find('input[name=resposta]').val($(this).attr('id'));
    });

    $('.Resultado').click(function(){
        var idpergunta = $(this).attr('id');
        $.ajax({
                type: "get",
                url: "enquete/answers/atualizapergunta/"+idpergunta,
                dataType: "",
                beforeSend: function(){

                },
                success: function(text){
                    $('#mostrai').html(text).show();
                    $('#poll').hide();
                    $('#mostrai').show();
                    $('.Results').find('.Result').each(function(){
                        $(this).find('.Progress').animate({
                            width: $(this).attr('resultado')+'%'
                        }, 1000, 'swing');
                    })
                },
                error: function(text){
                console.log(text);
                }
        });
    });
	/*
	$('.Results').find('.Result').each(function(){
        $(this).find('.Progress').animate({
            width: $(this).attr('resultado')+'%'
        }, 1000, 'swing');
    })
	*/
});


