var banner = 1;

$(document).ready(function() {
            
    $("#various3").fancybox({
            'width'			: 450,
            'height'			: 300,                    
            'autoScale'			: false,
            'transitionIn'		: 'none',
            'transitionOut'		: 'none',
            'type'			: 'iframe'
    });  

    $("#noticia1").fancybox({
            'width'			: '50%',
            'height'			: '80%',                    
            'autoScale'			: false,
            'transitionIn'		: 'none',
            'transitionOut'		: 'none',
            'type'			: 'iframe'
    });
    
    $("#noticia2").fancybox({
            'width'			: '50%',
            'height'			: '80%',                    
            'autoScale'			: false,
            'transitionIn'		: 'none',
            'transitionOut'		: 'none',
            'type'			: 'iframe'
    }); 
    
    $("#noticia3").fancybox({
            'width'			: '50%',
            'height'			: '80%',                    
            'autoScale'			: false,
            'transitionIn'		: 'none',
            'transitionOut'		: 'none',
            'type'			: 'iframe'
    }); 
    
    $("#noticia4").fancybox({
            'width'			: '50%',
            'height'			: '80%',                    
            'autoScale'			: false,
            'transitionIn'		: 'none',
            'transitionOut'		: 'none',
            'type'			: 'iframe'
    }); 
    
    
    
    
    /*$.fancybox(		
            {
                'width'			: 420, 
                'height'			: 325,                    
                'autoScale'			: false,
                'transitionIn'		: 'none',
                'transitionOut'		: 'none',
                'href'                  : 'banner.php',
                'type'			: 'iframe'
            }
    );*/
    
    
    //Ajustes da apresentacao das imagens
    $(document).ready(function() {
            $('#slide').s3Slider({
                timeOut: 4000 
            });
    });

});


function telalogin(opc)
{
if(opc==1)
{
    document.getElementById('spanlogin1').style.display = 'none';
    document.getElementById('spanlogin2').style.display = '';
}
else
{
    document.getElementById('spanlogin1').style.display = '';
    document.getElementById('spanlogin2').style.display = 'none';
}
}

function login()
{       
document.getElementById("frlogin").submit();
document.getElementById('spanlogin1').style.display = 'none';
document.getElementById('spanlogin2').style.display = 'none';
document.getElementById('spfrlogin').style.display = '';
} 

function lembrar_senha()
{
alert('Em desenvolvimento...');
}

function enviasugestao()
{
    
}

function limpasugestao()
{
document.getElementById('nome').value= 'Seu nome';
document.getElementById('email').value= 'Seu e-mail';
document.getElementById('comments').value= 'Sua sugestão....';

}

function enviasugestao()
{
    //alert(jQuery('form').serialize());
    jQuery.ajax({
        type: 'POST',
        url: 'enviasugestoes.php',
        data: jQuery('form').serialize(),      
        success: function(msg)
        {
            //jQuery('#galeriaimg').html(msg);                
            //tpfiltro_ = 1;
            alert(msg);
        }
    });
}


$(function(){
    var loader=$('#loader');
    var pollcontainer=$('#pollcontainer');
    loader.fadeIn();
    //Load the poll form
    $.get('poll.php', '', function(data, status){
            pollcontainer.html(data);
            animateResults(pollcontainer);
            pollcontainer.find('#viewresult').click(function(){
                    //if user wants to see result
                    loader.fadeIn();
                    $.get('poll.php', 'result=1', function(data,status){
                            pollcontainer.fadeOut(1000, function(){
                                    $(this).html(data);
                                    animateResults(this);
                            });
                            loader.fadeOut();
                    });
                    //prevent default behavior
                    return false;
            }).end()
            
            pollcontainer.find('#voltarpoll1').click(function(){
                
               loader.fadeIn();
                    $.get('poll.php', 'result=0', function(data,status){
                            pollcontainer.fadeOut(1000, function(){
                                    $(this).html(data);
                                    animateResults(this);
                            });
                            loader.fadeOut();
                    });
               
                //prevent default behavior
                return false;
            }).end()
            
            pollcontainer.find('#salvavotos').click(function(){
                    //if user wants to see result
                    jQuery.ajax({
                        type: 'POST',
                        url: 'salvavotoenquete.php',
                        data: jQuery('form').serialize(),      
                        success: function(msg)
                        {                                                                                                      
                            loader.fadeIn();
                            $.get('poll.php', 'result=1', function(data,status){
                                    pollcontainer.fadeOut(1000, function(){
                                            $(this).html(data);
                                            animateResults(this);
                                    });
                                    loader.fadeOut();
                            });                                                                                    
                            return false;
                        }
                    });    
                                                        
                    //prevent default behavior
                    
            }).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('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=$(this).css('width');
                                                            $(this).css('width', '0').animate({ width: bar_width }, 1000);
                                                    });
                                            });
    }
    
});


function teste2()
{

 var loader=$('#loader');
    var pollcontainer=$('#pollcontainer');
    loader.fadeIn();
    //Load the poll form
    $.get('poll.php', '', function(data, status){
            pollcontainer.html(data);
            animateResults(pollcontainer);
            pollcontainer.find('#viewresult').click(function(){
                    //if user wants to see result
                    loader.fadeIn();
                    $.get('poll.php', 'result=1', function(data,status){
                            pollcontainer.fadeOut(1000, function(){
                                    $(this).html(data);
                                    animateResults(this);
                            });
                            loader.fadeOut();
                    });
                    //prevent default behavior
                    return false;
            }).end()
            
            pollcontainer.find('#voltarpoll1').click(function(){
                
               loader.fadeIn();
                    $.get('poll.php', 'result=0', function(data,status){
                            pollcontainer.fadeOut(1000, function(){
                                    $(this).html(data);
                                    animateResults(this);
                            });
                            loader.fadeOut();
                    });
               
                //prevent default behavior
                return false;
            }).end()
            
            pollcontainer.find('#salvavotos').click(function(){
                    //if user wants to see result
                    jQuery.ajax({
                        type: 'POST',
                        url: 'salvavotoenquete.php',
                        data: jQuery('form').serialize(),      
                        success: function(msg)
                        {                                                                                                      
                            loader.fadeIn();
                            $.get('poll.php', 'result=1', function(data,status){
                                    pollcontainer.fadeOut(1000, function(){
                                            $(this).html(data);
                                            animateResults(this);
                                    });
                                    loader.fadeOut();
                            });                                                                                    
                            return false;
                        }
                    });    
                                                        
                    //prevent default behavior
                    
            }).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('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=$(this).css('width');
                                                            $(this).css('width', '0').animate({ width: bar_width }, 1000);
                                                    });
                                            });
    }
}






