	function mostrarAba(aba){

		abaSelecionada = '#aba-'+aba.substr(1);
		$('#homeProduto').hide();

		var produto = location.pathname.replace((idioma_link + "/produtos/"),"").replace(".htm","");

		$("#boxInfoProduto, #boxInfoSubmenu, #fecharBox").fadeIn('fast');
		$("#boxInfoProduto").load('/produtos/'+produto+'-'+aba.substr(1)+'.php',function(){
			if(aba.substr(1) == "downloads") {
				mouseOverDownloads();
			}
		});
	
		/* highlight */
		$('#boxInfoSubmenu a').removeClass('selecionado');
		$('#boxInfoSubmenu').find('li.' + aba.substr(1) + ' a').addClass('selecionado');
	}

	function abrirVideo() {
		// abrir lightbox
		var prod = location.pathname.replace((idioma_link + "/produtos/"),"").replace(".htm","");
		//console.log(linkSwf);

		if (idioma_link == '/en') {
			var linkSwf = '/swf/' + prod + '-en.swf';
		} else {
			var linkSwf = '/swf/' + prod + '.swf';
		}
		//console.log(linkSwf);

		linkSwf = "/produtos/" + prod + "-video.php";
		//alert(linkSwf);

		$.fancybox({
			'width' : 966,
			'height' : 550,
			'autoScale' : false,
			'overlayColor' : "#000",
			'overlayOpacity' : 0.6,
			'padding'		: 5,
			'scrolling'		: 'no',
			'href'			: linkSwf
		});
	}

	/* DOWNLOADS WALLPAPERS */
	function mouseOverDownloads() {
	
		$('.listaWallpapers li').hover(function(){
			liAtual = $(this);
			delay = setTimeout(function(){
				liAtual.find('div').slideDown(300);
			}, 100);
		}, function(){
			clearTimeout(delay);
			$(this).find('div').slideUp(200);
		});
	
	}


	function tooltip(target, msg) {
		/* Função para exibir um tooltip
		   ao passar o mouse por algum objeto */

		if(!$('#tooltip').length) { $('body').append('<span id="tooltip" />'); }
	
		$(target).live('mousemove', function(e){
			topPos = parseInt(e.pageY) + 25;
			left = e.pageX;
			$('#tooltip').css({'top' : topPos , 'left' : left});
			$('#tooltip').html(msg).show();
		});
		$(target).live('mouseout', function(){ $('#tooltip').hide(); });
	
	}


$(document).ready(function(){

	//tooltip('#novaLinha a', 'Você será direcionado para o Hot Site da Nova Linha Intermarine');
	mouseOverDownloads();

	tooltip('.obs1 strong', 'Altura máxima com deslocamento vazio, não considera antenas de rádio, radar, televisão por satélite e demais equipamentos instalados na targa');
	tooltip('.obs2 strong', 'Deslocamento com tanques vazios, sem passageiros, salvatagem ou provisões');
	tooltip('.obs3 strong', 'Deslocamento com tanques cheios e capacidade máxima de passageiros');
	tooltip('.obs4 strong', 'Preparação do paiol de popa para cabine de marinheiro opcional');

	tooltip('.obs1en strong', 'Height with unladen displacement, not including radio antennas, radar, satellite TV and other equipment installed on flybridge arch');
	tooltip('.obs2en strong', 'Displacement with empty tanks, no passengers, life vests or provisions');
	tooltip('.obs3en strong', 'Displacement with full tanks and maximum passengers capacity');
	tooltip('.obs4en strong', 'Transformation of storage compartment into crew cabin is optional');


	$('#menu a').hover(function(){
		$(this).fadeTo(300, 0);
	}, function(){
		$(this).fadeTo(300, 1);
	});

	$('#menuProdutos li a').hover(function(){
		$(this).fadeTo(200, 0);
	}, function(){
		$(this).fadeTo(150, 1);
	});

	$('#destaquesHome img').css('opacity', 0.8);
	
	$('#destaquesHome img').hover(function(){
		$(this).fadeTo(150, 1);
	}, function(){
		$(this).fadeTo(150, 0.8);
	});

	/* ABAS PRODUTOS */
	$('#menuProduto a:not(.abrirVideo)').click(function(){

		aba = $(this).attr('href');

		if(aba == "#fotos"){
			linkGaleria = location.pathname.replace(".htm","").replace((idioma_link),"")+'.json';
			galeriaOpen(linkGaleria);
		} else if (aba == "#videos") {
			abrirVideo();
			return false;
		} else {
			mostrarAba(aba);
			$('#boxInfoProduto, #boxInfoSubmenu, #fecharBox').fadeIn();
		}
		
	});
	
	$('#boxInfoSubmenu a:not(.abrirVideo)').click(function(){
		aba = $(this).attr('href');
		if(aba == "#fotos"){
			linkGaleria = location.pathname.replace(".htm","").replace((idioma_link),"")+'.json';
			galeriaOpen(linkGaleria);
		} else if (aba == "#videos") {
			abrirVideo();
		} else if(location.hash != "#fotos") {
			if($("#galeriaFoto").length > 0){
				$("#fecharBox").animate({'top':'30'});
				$("#boxInfoSubmenu").animate({'top':'90'});
				$("#galeria").fadeOut(1000);
				$(".thumbs ul li").remove();
				$("#galeriaFoto").remove();
				$("#rodape").slideDown();
				$("#conteudo").height('');
			}
			
			mostrarAba(aba);
		}
	});

	/* EXIBIR A ABA ABERTA AO ABRIR A PÁGINA */
	if($('body').hasClass('produtos') && location.hash != ''){
		aba = location.hash;
		if(location.hash == "#fotos"){
			galeriaOpen(location.pathname.replace(".htm","").replace("/produtos/","")+'.json');
		} else if (aba == "#videos") {
			abrirVideo();
		} else {
			mostrarAba(aba);
		}
	}
	
	/* EXIBIR CONTEÚDO AO CLICAR NO SUBMENU DA MESMA PÁGINA */
	$('.linksProduto a').live('click', function(){
		linkProduto = $(this).attr('href');
		hashPos = linkProduto.indexOf('#');
		hash = linkProduto.substring(hashPos);

		linkProduto = linkProduto.replace(hash, "");
		linkPagina = location.pathname;
		
		//console.log(linkProduto);
		//console.log(linkPagina);
		
		if(linkProduto == linkPagina) {

			if(hash == "#fotos"){
				linkGaleria = location.pathname.replace(".htm","").replace((idioma_link),"")+'.json';
				galeriaOpen(linkGaleria);
			} else if (hash == "#videos") {
				abrirVideo();
			} else {
				
				mostrarAba(hash);
				$('#boxInfoProduto, #boxInfoSubmenu, #fecharBox').fadeIn();
				if(location.hash == "#fotos"){
					fecharBox();
				}
			}
		}

		//console.info(linkProduto);
		//console.info(linkPagina);
		//return false;
	});

	function fecharBox(){
		if($("#galeriaFoto").length == 0){
			$('#boxInfoProduto, #boxInfoSubmenu, #fecharBox').fadeOut('fast',function(){ $("#boxInfoProduto").html(''); });
			$('#homeProduto').fadeIn('fast');
			location.hash = "";
			pagTemp = false;

		} else {
			
			if($("#boxInfoProduto").css('display') == 'none'){
				$("#boxInfoSubmenu").fadeOut(1000);
				$("#fecharBox").fadeOut(1000)
			}
			$("#fecharBox").animate({'top':'30'});
			$("#boxInfoSubmenu").animate({'top':'90'});
			$("#galeria").fadeOut(1000);
			//$("#boxInfoSubmenu").fadeOut(1000);
			//$("#fecharBox").fadeOut(1000).animate({'top':'30'});
			$(".thumbs ul li").remove();
			$("#galeriaFoto").remove();
			$("#rodape").slideDown();

			$("#conteudo").height('');
			
			if(pagTemp){
				$("#boxInfoProduto").html(pagTemp);
			} else {
				$('#boxInfoProduto, #boxInfoSubmenu, #fecharBox').fadeOut('fast',function(){ $("#boxInfoProduto").html(''); });
				$('#homeProduto').fadeIn('fast');
				location.hash = "";
				pagTemp = false;
			}
			$(window).unbind();
		}
		
		return false;
	}

	$('#fecharBox a').click(function(){
		fecharBox();
		return false;
	});

	/* NOTICIAS EM DESTAQUE [inicio] */
	if ($('#noticiasEmDestaque').attr('id')){
		$(window).load(function(){
	
			var proximo = 2;
			var totalDestaques = 3;
			var tempoDestaque = 3000; /* Intervalo entre um destaque e outro */
	
			$('#noticiasEmDestaque div:first, #noticiasEmDestaque li:first').addClass('selecionado');
	
			function exibirDestaque(num) {
				$('#noticiasEmDestaque div.anterior').removeClass('anterior');
	
				var anterior = $('#noticiasEmDestaque div.selecionado');
				var selecionado = $('#noticiasEmDestaque #destaque' + num);

				anterior.removeClass('selecionado').addClass('anterior');
				selecionado.addClass('selecionado');

				$('#noticiasEmDestaque li.selecionado').removeClass('selecionado');
				$('#noticiasEmDestaque li:nth-child(' + num + ')').addClass('selecionado');

				/* Exibição da imagem */
				$(selecionado).find('img').fadeOut(0);
				$(selecionado).find('img').fadeIn(400);
				
				proximo = num+1
				if (proximo > totalDestaques){
					proximo = 1;
				}
	
			}
	
			/* Mouseover */
			$('#noticiasEmDestaque li').mouseenter(function(){
				clearInterval(iniciarSlideshow); /* Parar slideshow */

				num = $(this).attr('value');
				if($(this).hasClass('selecionado')) {
					return;
				}
				exibirDestaque(num);
			});
	
			$('#noticiasEmDestaque').mouseleave(function(){
				//iniciarSlideshow = window.setInterval(slideShow, tempoDestaque);
			});
	
			/* Slideshow */
			function slideShow() {
				exibirDestaque(proximo);
			}
	
			iniciarSlideshow = window.setInterval(slideShow, tempoDestaque);
			
		});
	}
	/* NOTICIAS EM DESTAQUE [fim] */


	/* HISTORICO */
	$('#arquivo span').click(function(){
		if ($(this).parent().hasClass('listaAberta')){
			$('#arquivo li').removeClass('listaAberta');		
		} else {
			$('#arquivo li').removeClass('listaAberta');
			$(this).parent().toggleClass('listaAberta');
		}
		return false;
	});
	

});

