$(document).ready(function(){

	var booShowTransition = true;

	// Checks if current user browser is IE6 or lower IE version.
	if (jQuery.browser.msie) {
		if (jQuery.browser.version <= 6) {
			booShowTransition = false;
		}
	}
	
	if (booShowTransition) {
		
		$('div.rounded_tl').css('background-image', 'url(img/layout/rounded-corner_tl.png)')
		$('div.rounded_tr').css('background-image', 'url(img/layout/rounded-corner_tr.png)')
		$('div.rounded_bl').css('background-image', 'url(img/layout/rounded-corner_bl.png)')
		$('div.rounded_br').css('background-image', 'url(img/layout/rounded-corner_br.png)')
	
		$('.menuitem').mouseover(function() {
			$(this).css('background-image','url(img/layout/bg_block_hover.png)');
			$(this).css('background-repeat','repeat-x');
		});
		
		$('.menuitem').mouseout(function() {
			$(this).css('background-image','url(img/layout/spacer.gif)');
			$(this).css('background-repeat','repeat-x');
		});
	}

	// Fixes the bottom size of the last block/paragraph in each container box.
	$('div.boxcontainer div:last-child').css("margin-bottom","0");
	
	// Adds toggle button to softbox class
	$("div.togglebox div.boxtitle").append("<div class=\"togglebutton\"><img src=\"img/layout/toggle_collapse.gif\" width=\"15\" height=\"15\" alt=\"ocultar\" /></div>");
	
	// Gets the height of each box to be collapsed. This code was commented. Not necessary
	/*
	$("div.togglebox div.boxcontent").each(function(){
		$(this).css("height", $(this).height() + "px");
		$(this).css("display", "block");
	});
	*/
	
	// Toggles the two arrow buttons.
	$("div.togglebutton").children("img").toggle(
		function() {
			$(this).attr({
			src: "img/layout/toggle_expand.gif",
			alt: "expandir"
			})
		},
		function() {
			$(this).attr({
			src: "img/layout/toggle_collapse.gif",
			alt: "expandir"
			});
		}
	);
	
	// Expands and collapses the affected boxes.
	$("div.togglebutton").mouseup(function(){
		//find the body whose header was clicked
		var body = $(this).parent().parent().children("div.boxcontent");

		//slide the panel
		if(body.is(":hidden"))
			body.slideDown("fast");
		else
			body.slideUp("fast");
	});

	// O código a seguir adiciona caixas automaticamente aos conteúdos que exigem muitos wrappers, simplificando o código fonte do site.
	/*
	$('div.softbox').each(function() {
		var i = $(this).html();
		$(this).html('<div class="top"><div class="bottom"><div class="content">' + i + '</div></div></div>');
	})
	*/


	
});