$(document).ready(function() {  
   
    //Rede Social
    $('div.thumb img').hoverpulse();

    //Slider
    $('#slideshow').cycle({
        timeout: 9000,       // milliseconds between slide transitions (0 to disable auto advance)
        fx: 'fade',     // choose your transition type, ex: fade, scrollUp, shuffle, etc...
        pager: '#pager',   // selector for element to use as pager container
        pause: 0,	         // true to enable "pause on hover"
        pauseOnPagerHover: 0 // true to pause when hovering over pager link
    });
    $('#slideshowEsportes').cycle({
        timeout: 9000,       // milliseconds between slide transitions (0 to disable auto advance)
        fx: 'fade',     // choose your transition type, ex: fade, scrollUp, shuffle, etc...
        pager: '#pagerEsportes',   // selector for element to use as pager container
        pause: 0,	         // true to enable "pause on hover"
        pauseOnPagerHover: 0 // true to pause when hovering over pager link
    });


    //Enquete
    var loader=$('#loader');
    var pollcontainer=$('#pollcontainer');
    loader.fadeIn();
    //Load the poll form
    $.get('estrutura/enquete/poll.php', '', function(data, status){
        pollcontainer.html(data);
        animateResults(pollcontainer);
        pollcontainer.find('#viewresult').click(function(){
            //if user wants to see result
            loader.fadeIn();
            $.get('estrutura/enquete/poll.php', 'result=1', function(data,status){
                pollcontainer.fadeOut(1000, function(){
                    $(this).html(data);
                    animateResults(this);
                });
                loader.fadeOut();
            });
            //prevent default behavior
            return false;
        }).end()
        .find('#pollform').submit(function(){
            var selected_val=$(this).find('input[name=poll]:checked').val();
            if(selected_val!=''){
                //post data only if a value is selected
                loader.fadeIn();
                $.post('estrutura/enquete/poll.php', $(this).serialize(), function(data, status){
                    $('#formcontainer').fadeOut(100, function(){
                        $(this).html(data);
                        animateResults(this);
                        loader.fadeOut();
                    });
                });
            }
            //prevent form default behavior
            return false;
        });
        loader.fadeOut();
    });

    function animateResults(data){
        $(data).find('.bar').hide().end().fadeIn('slow', function(){
            $(this).find('.bar').each(function(){
                var bar_width=$jQuery(this).css('width');
                $(this).css('width', '0').animate({ width: bar_width }, 1000);
            });
        });
    }

    //Esporte
    $(".menu_serie_flip").click(function(){
        $(".menu_serie").toggle();
        $(".menu_serie_name").toggle();
    });    

    $("#buscanoticia").Watermark("Buscar notícia","#999");

});


/*
 * jQuery HoverPulse Plugin by M. Alsup
 * Examples and docs at: http://malsup.com/jquery/hoverpulse/
 * Dual licensed under the MIT and GPL
 * Requires: jQuery v1.2.6 or later
 * @version: 1.01  26-FEB-2009
 */

(function($) {
$.fn.hoverpulse = function(options){
    // in 1.3+ we can fix mistakes with the ready state
    if (this.length == 0) {
        if (!$.isReady && this.selector) {
            var s = this.selector, c = this.context;
            $(function() {
                $(s,c).hoverpulse(options);
            });
        }
        return this;
    }

	var opts = $.extend({}, $.fn.hoverpulse.defaults, options);

	// parent must be relatively positioned
	this.parent().css({ position: 'relative' });
	// pulsing element must be absolutely positioned
	this.css({ position: 'absolute', top: 0, left: 0 });

	this.each(function() {
		var $this = $(this);
		var w = $this.width(), h = $this.height();
		$this.data('hoverpulse.size', { w: parseInt(w), h: parseInt(h) });
	});

	// bind hover event for behavior
	return this.hover(
		// hover over
		function() {
			var $this = $(this);
			$this.parent().css('z-index', opts.zIndexActive);

			var size = $this.data('hoverpulse.size');
			var w = size.w, h = size.h;
			$this.stop().animate({
				top:  ('-'+opts.size+'px'),
				left: ('-'+opts.size+'px'),
				height: (h+2*opts.size)+'px',
				width:	(w+2*opts.size)+'px'
			}, opts.speed);
		},
		// hover out
		function() {
			var $this = $(this);
			var size = $this.data('hoverpulse.size');
			var w = size.w, h = size.h;

			$this.stop().animate({
				top:  0,
				left: 0,
				height: (h+'px'),
				width:	(w+'px')
			}, opts.speed, function() {
				$this.parent().css('z-index', opts.zIndexNormal);
			});
		}
	);
};

$.fn.hoverpulse.defaults = {
	size:  12,
	speed: 100,
	zIndexActive: 100,
	zIndexNormal: 1
};



})(jQuery);
