window.defaultUrl = "";

$(function(){	
	
	if(!empty(s = $(document).find("SCRIPT")))
	{
		window.defaultUrl = s.get(0).src.toString().split("js/")[0];
	}
	
	$("#conteudo form fieldset select option:odd").addClass("odd");	

	$("ul li:last-child").addClass("last");
	
	showAguarde.create();
	
	$("#activity").ajaxStart(function(){
		window.showAguarde();
	}).ajaxComplete(function(){
		window.hideAguarde();
	});
	
	/* IE6 */
	if($.browser.msie && $.browser.version < 7)
	{
		$("#menu").FixSFMenu();
	}
	
	/* SWF */
	$("#topo-flash").flash({
		src: window.defaultUrl + "flash/top.swf",
		height: "100%",
		width: "100%",
		wmode: "opaque",
		scale: "noscale"
	});
	
	$("#topo h1, #topo form").hide();
	
	$('a[rel~=blank],a[rel~=external]').each(function(){
		$(this).attr('target','_blank');
	});
});

function showAguarde()
{
	$("#activity").remClass("disabled");
	
	//fixed activity...
	window.onscroll = showAguarde.fixed;
	window.onscroll();
	
	showAguarde.inProcess = true;	
}
showAguarde.create = function()
{
	var d = $('Carregando Dados...');
	$(document.body).append(d);
}
showAguarde.fixed = function()
{
	var a = $("#activity");
	if(!empty(a))
	{
		var y1 = document.documentElement.scrollTop || 0;
		var y2 = document.body.scrollTop || 0;
		var y3 = window.scrollY || 0;
		
		var y = Math.max(y1, Math.max(y2, y3));
			
		a.css({"top": (y + 200) + "px"});
	}
	else
	{
		window.onscroll = function(){};
		delete window.onscroll;
	}
		
}
showAguarde.inProcess = false;
