window.defaultUrl = "";

$(function(){
	
	if((s = $(document).find("SCRIPT")).length > 0)
	{
		window.defaultUrl = s.attr("src").split("js/")[0];
	}
	
	$("#content form fieldset select").find("option:odd").addClass("odd");	
	
	$("ul li:first-child").addClass("first");
	$("ul li:last-child").addClass("last");
	
	$("#contato div.direito ul:last-child").addClass("last");
	
	$("#content table tr:odd").addClass("odd");
	
	
	/*$("#activity").ajaxStart(function(){
		window.showAguarde();
	}).ajaxComplete(function(){
		window.hideAguarde();
	});*/
	
	if($("div.message").length > 0)
	{
		$("div.message").css({"opacity": 0.9}).hide().slideDown("normal");
		window.hideMessage = function(){ $("div.message").stop().slideUp("normal"); };
		setTimeout("window.hideMessage();", 5000);
	}
	
	if($('body').attr('id') == 'capa')
	{
		$('#banner-capa').flash({
			src: 'app/webroot/swf/banner.swf',
			width: '100%',
			height: '100%',
			wmode: 'transparent'
		});
	}
	
	if($('body').attr('class') == 'acomodacao')
	{
		$('#banner').flash({
			src: 'app/webroot/swf/banner_acomodacao.swf',
			width: '100%',
			height: '100%',
			wmode: 'transparent'
		});
	}
	
	if ($('.paging').length > 0 && $('.paging a').length < 1){
		$('.paging').hide();
	}
	
	for(var i=0, a = document.links; i<a.length; i++)
		if(a[i].rel && a[i].rel == "blank") a[i].target = "_blank";
	
});

$.url = function(webroot)
{
	if(!webroot)
	{
		if(window.defaultUrl.indexOf(($ext="app")) > -1)
		{
			$url = window.defaultUrl.split($ext);
			return $url[0] + "index.php?/";
		}
		
		return window.defaultUrl;
	}
	else
	{
		return window.defaultUrl;
	}
}

