$(document).ready(function () {
	// PNG transparency
	$("div#master").pngFix();
	
	// Acesso rapido
	var acessoRapidoClick = true;
	var acessoRapidoLabel = $("div#acesso-rapido div#busca input").val();
	$("select#model-site-acessorapido").change(function () {
		if (this.value != 0) {
			document.location = this.value;
		}
	});
	$("div#acesso-rapido div#busca input").click(function () {
		if (acessoRapidoClick) {
			this.value = "";
			acessoRapidoClick = false;
		}
	});
	$("div#acesso-rapido div#busca input").blur(function () {
		if (this.value == "") {
			this.value = acessoRapidoLabel;
			acessoRapidoClick = true;
		}
	});
	
	// Busca
	$("div#acesso-rapido div#busca img").click(function () {
		if (!acessoRapidoClick) {
			$("div#acesso-rapido form#busca-form").submit();
		} else {
			$("div#acesso-rapido div#busca input").addClass("obrigatorio");
		}
	});
	
	// Menu principal
	$(function () {
		$("ul.dropdown li").hover(function () {
			$(this).addClass("hover");
			$("ul:first", this).css("visibility", "visible");
	    }, function () {
	    	$(this).removeClass("hover");
	    	$("ul:first", this).css("visibility", "hidden");
	    });
		$("ul.dropdown li ul li:has(ul)").find("a:first").append(" &raquo; ");
	});
	
	// Marcas
	$("div#marcas div.marca").corner("round 10px bottom");
	
	// Toolbox
	$("div#toolbox").corner("round 12px top");
	
	// Parceiros
	$("div#parceiros").corner("round 12px top");
	
	/*
	$('#left').scrollFollow({
		"speed": 1000,
		"offset": 30
	});
	*/
	
	// Topmenu
	$("div#topmenu ul li").corner("round 12px top");
	$("div#topmenu ul li").hover(function () {
		$(this).addClass("hover");
    }, function () {
    	$(this).removeClass("hover");
    });
	
	// Content
	$("div.content-home").corner("round 12px top");
	
	// Blocos
	$("div.bloco div.veja-tambem div.titulo").corner("round 12px top");
	
	// Footer
	$("div#footer div#sponsors").corner("round 12px top");
	
	// Filtro por ano
	$("div.files select#filtro-por-ano").change(function () {
		window.location = window.location.href.split('?')[0] + '?ano=' + this.value;
	});
});

function goTo(url) {
	if (url) {
		window.open(url, "external");
	}
}

function download(url, file) {
	if (url) {
		window.location = baseUrl + langPath + "misc/download?url=" + url + "&file=" + file;
	}
}

function external(url) {
	window.open(url, "external");
}