active_current = function() {
	$('#menu a').each(function (i) {
		var tit = $('#titulo').text();
  	if ($(this).text() == tit) {
  	 $(this).parent().addClass('active');
  	 if($(this).parent().parent().is('#arquivo')){
  	 	$('#arquivo').show();
  	 	$('#recentes').hide();
  	 	$('#menu h3:last').removeClass('closed').addClass('open');
  	 	$('#menu h3:first').removeClass('open').addClass('closed');
  	 }else if($(this).parent().parent().is('#recentes')){
		$('#arquivo').hide();
  	 	$('#recentes').show();
  	 	$('#menu h3:eq(0)').removeClass('closed').addClass('open');
  	 	$('#menu h3:last').removeClass('open').addClass('closed');
	 }
  	} else {
   		$(this).parent().removeClass('active');
  	}
  });
}

sobre = function() {
	$('#sobre').hide();
	  $("#link_sobre a").click(function () {
      $("#sobre").slideToggle("slow", "easeOutQuad");
    });
		$("#link_contato a").click(function () {
      var targetOffset = $("#rodape").offset().top;
      $('html,body').animate({scrollTop: targetOffset}, 2000, "easeOutQuad");
    });
}

menu = function() {
 $("#menu h3").wrapInner("<a href='javascript:null(0)'></a>");

	$('#arquivo').hide();
	$('#recentes').hide();
	$("#menu h3:last a").click(function () {
	if($(this).parent().hasClass('open')){
	    $(this).parent().removeClass('open')
			$(this).parent().addClass('closed')
		}else{
			$(this).parent().removeClass('closed')
			$(this).parent().addClass('open')
		}
    $("#arquivo").slideToggle("slow");
  });
	
	$("#menu h3:first a").click(function () {
		if($(this).parent().hasClass('open')){
	    $(this).parent().removeClass('open')
			$(this).parent().addClass('closed')
		}else{
			$(this).parent().removeClass('closed')
			$(this).parent().addClass('open')
		}
    $("#recentes").slideToggle("slow");
  });
	
	$("#menu li a").hover(
      function () {
        $(this).animate( { color:"#FFFFFF", paddingLeft:"20px" } , 100, "easeOutQuad" );
      }, 
      function () {
        $(this).animate( { color:"#858585", paddingLeft:"15px" } , 100, "easeInQuad" );
      }
    );


}

$(document).ready(function(){
	sobre();
	menu();
	active_current();
});
