/*************************************************************
 * Autor: Mitsuo Takaki.                                     *
 * Data: 09/04/2010                                          *
 * Descrição:                                                *
 *************************************************************/
$(document).ready(function(){
	window.url = $("#base_url").val();
    var menu_index = $("#menu_index").val();

    //$("#menu").accordion({ header: 'h3', animated: 'bounceslide' });
    
    $("#firstpane p.menu_head").click(function() {
    		    //$(this).toggleClass("menu_head_selected").next("div.menu_body").toggle("bounce").siblings("div.menu_body").toggle("bounce");
    	var display = $(this).next("div.menu_body").css("display");
    	
    	if (display == "none") {
	    	$(this).toggleClass("menu_head_selected").next("div.menu_body").slideDown().siblings("div.menu_body").slideUp();
	    	$(this).siblings("p.menu_head_selected").toggleClass("menu_head_selected");
    	} else {
    		
    	}
    });
    
    $("#janela").dialog({
        autoOpen: false
    });

    $("#janelaDepoimentos").dialog({
        autoOpen: false
    });

    $(".conteudo").click(function() {
        var id = $(this).children(".texto").attr("id");
        var index = id.indexOf("_");
        var tipo = id.substr(0, index);
        id = id.substr(index+1, id.length-index-1);

        if (tipo == "noticia") {
            $("#noticiaTexto").html($("#noticiaConteudo_" + id).val());
            $("#noticiaData").html($("#noticiaData_" + id).val());
            $("#janela").dialog("option", "title", $(this).children(".texto").attr('title'));
            $("#janela").dialog("open");
        }
    });
    
	// Replaces the email span to avoid automatic email gathering
	$(".email").each(function() { 
		var content = $(this).html();
        var index = content.indexOf("/at/");
        var username = content.substr(0, index);
        var hostname = content.substr(index+4, content.length-index-1);
        
        $(this).html(username + "@" + hostname);
	});
});

