$(document).ready(function(){

    var UOLPROD = window.UOLPROD || {}
        UOLPROD.faqManager = function (){
            $('#main a.ask').each(function(){
            $(this).click(function(e){
            e.preventDefault();e.stopPropagation();
            /*$(this).ancestors('li').siblings('.open').removeClass('open');*/
            $(this).parents().toggleClass('open');
            })
            })
            $('.fechar a').click(function(e){
            e.preventDefault();e.stopPropagation();
            $(this).parents().toggleClass('open');
         })
    }

    UOLPROD.openAllAnswers = function (){
        $('#main a.openAll').each(function(){
            $(this).click(function(e){
            e.preventDefault();e.stopPropagation();
            htm = $(this).html();
            if (htm.match("Abrir")) {
                $(this).html(htm.replace("Abrir","Fechar"))
                $('#main a.ask').parents().addClass('open');
            } else {
                $(this).html(htm.replace("Fechar","Abrir"))
                $('#main a.ask').parents().removeClass('open');
            }
            })
        })
    }

    UOLPROD.openLocal = function (){
        $('#main a.local').each(function(){
        $(this).click(function(e){
        //e.preventDefault();
        e.stopPropagation();
        var x = this.href.slice(this.href.search(/#/));
        if ($(x).attr("class") == undefined) {
        $(x).toggleClass('open');
        }
        })
        })
    }
		
		
		
		
	$(function(e){
			//$("#main ol li>div").append('<p class="fechar"><a href="#">Fechar</a></p>');
			$("#main ol li>div").append('<p class="topo"><a href="#">Voltar para o topo</a></p>');
			UOLPROD.faqManager();
			UOLPROD.openAllAnswers();
			UOLPROD.openLocal();
			if(location.hash) {$(location.hash+" a.ask").click();
			
			};
	});

    /* Popup - Conheça o toda oferta */

    $(".conheca").click(function(){
        window.open("http://todaoferta.uol.com.br/extras/conheca/index.htm","","width=570, height=429, resizable=yes, statusbar=yes");
    });
});

