$(document).ready(function(){

	block();
	
	$("#mostrarcomentarios").click(function(){
		$(".commentInvisivel").fadeIn('slow');
		$(self).hide();
	});

/***************************************************
	BARRA DE OFERTAS
***************************************************/
	if($(window).width() > 1350){
		$(".widget_categoryposts").each(function(){
			if($(this).children('h2').html() == 'Mais Roteiros'){
				$(this).hide().addClass('sidebarAnuncios');
				$(this).show();
			}
		});
	} else {
		$(".widget_categoryposts").each(function(){
			if($(this).children('h2').html() == 'Mais Roteiros')
				$(this).hide();
		});
	}

/***************************************************
	FADEIN/OUT DO FORM DE COMENTARIOS
***************************************************/
	$("#displayCommForm").click(function(){
		$(this).fadeOut('slow',function(){
			$(".leaveComment").fadeIn('fast');	
		});		
	});
	
	$("#resetForm").click(function(){
		$(".leaveComment").fadeOut('fast',function(){
			$("#displayCommForm").fadeIn('slow');	
		});		
	});
	
/***************************************************
	CONTEUDO DO INPUT DA BUSCA
***************************************************/
	$("#searchform #s").focus(function(){if($(this).val() == 'Busca') $(this).val('');});
	$("#searchform #s").blur(function(){if($(this).val() == '') $(this).val('Busca');});
	
/***************************************************
	TEMPO REAL WIDGET
***************************************************/
	$('#tempo-real-widget > ul li > a').click(function(){
		if($(this).next('div').css('display') == 'block')
			$(this).next('div').slideUp('fast');
		else
			$(this).next('div').slideDown('fast');
	});
	$('#tempo-real-widget').prev('h2').addClass('tempo-real-widget-topo');

/***************************************************
	BLOCO ONIBUS WIDGET
***************************************************/

	$('.painelOnibus > .seta-esquerda').click(function(){
		if($('.onibusLista').css('margin-left') == '')
			var margin = 0;
		else
			var margin = parseInt($('.onibusLista').css('margin-left'));
			
		if(margin < 0){
			$('.onibusLista').animate({'margin-left': '+=58px'},400);	
		}
	});
	$('.painelOnibus > .seta-direita').click(function(){
		
		if($('.onibusLista').css('margin-left') == '')
			var margin = 0;
		else
			var margin = parseInt($('.onibusLista').css('margin-left'));	
			
		if(margin > (($("#bloco-onibus-widget ul li").length - 7) * 58 * -1)){
			$('.onibusLista').animate({'margin-left': '-=58px'},400);
		}
	});
	
/***************************************************
	EQUIPE WIDGET
***************************************************/
	$('#equipe-widget .nome_cargo').html( $('#equipe-widget .bloco_fotos img:first').attr('alt') );
	var img_eq = 0;

	$('#equipe-widget .seta_esquerda').click(function(){
		if(img_eq > 0){
			$('.bloco_fotos').animate({'margin-left': '+=256px'},'slow');
			img_eq--;
			$('#equipe-widget .nome_cargo').html( $('#equipe-widget .bloco_fotos img:eq(' + img_eq + ')').attr('alt') );
		}		
	});
	$('#equipe-widget .seta_direita').click(function(){
		if(img_eq < 43){
			$('#equipe-widget .bloco_fotos').animate({'margin-left': '-=256px'},'slow');
			img_eq++;
			$('#equipe-widget .nome_cargo').html( $('#equipe-widget .bloco_fotos img:eq(' + img_eq + ')').attr('alt') );
		}
	});
	
/***************************************************
	CONTEUDO DO INPUT DO NEWSLETTER
***************************************************/	
	
	$("#fieldmail").focus(function(){if($(this).val() == 'Seu e-mail') $(this).val('');});
	$("#fieldmail").blur(function(){if($(this).val() == '') $(this).val('Seu e-mail');});	

	$("#fieldnome").focus(function(){if($(this).val() == 'Seu nome') $(this).val('');});
	$("#fieldnome").blur(function(){if($(this).val() == '') $(this).val('Seu nome');});

/***************************************************
	HOVER MENU
***************************************************/

	$("#header .menu ul li a").hover(function(){
		$(this).addClass("hover");
	},function(){
		$(this).removeClass("hover");
		hoverMe();
	});
	
/***************************************************
	VALIDAÇÃO QUERO SABER MAIS!
***************************************************/

	$("#commentform").submit(function(){
		
		var campo_nome = $("#nome").val();
		var campo_email = $("#email").val();
		var campo_infosobre = $("#infosobre").val();
		var campo_mensagem = $("#mensagem").val();
		var erro = 0;
		
		
		if(campo_nome ==""){
			erro=1; 
			$("#msg-enviada").html('Erro ao enviar mensagem...');		
		}
		if(campo_email.indexOf('@')==-1 && campo_email.indexOf('.com')==-1){
			erro=1; 
			$("#msg-enviada").html('Erro ao enviar mensagem...');
		}
		
		if(campo_infosobre =="" ){
			erro=1;
			$("#msg-enviada").html('Erro ao enviar mensagem...');
		}
		if(campo_mensagem =="" ){
			erro=1;
			$("#msg-enviada").html('Erro ao enviar mensagem...');
		}
		
		if(erro > 0){
			return false;
		} else{
			return true;
		}
		
		
	});

/***************************************************
	DOCUMENTACOES
***************************************************/

	if(window.location.href.indexOf('/documentacoes') > -1)
	{
		$(".Content").addClass("documentacoes");
	}

});


function hoverMe(pagina){
	if(!pagina){
		url = '' + window.location;
		
		if(url.indexOf('/tempo-real') > -1)
			$('.temporeal').addClass("hover");
		else if(url.indexOf('/disney') > -1)
			$('.disney').addClass("hover");
		else if(url.indexOf('/internacionais') > -1)
			$('.internacionais').addClass("hover");
		else if(url.indexOf('/nacionais') > -1)
			$('.nacionais').addClass("hover");
		else if(url.indexOf('/intercambio') > -1)
			$('.intercambio').addClass("hover");
		else if(url.indexOf('/contato') > -1)
			$('.contato').addClass("hover");
	}
	else{
		$('.' + pagina).addClass("hover");
	}
}

/***************************************************
	HOVER MENU
***************************************************/
function searchHover(){
	var url = new String(window.location);
	
	brokeme = url.split('?s=');
		
	$('.colunaEsquerda').highlight(brokeme[1]);
	
	$(".highlight").css({ backgroundColor: "#FFFF88" });
}

/***************************************************
	IE6 BLOCK
***************************************************/
function block(){
	var IE6 = (navigator.userAgent.indexOf("MSIE 6")>=0) ? true : false;
	var IE7 = (navigator.userAgent.indexOf("MSIE 7")>=0) ? true : false;
	
	if(IE6 || IE7){
		$('body').prepend('<div class="ie6_blocked"><h1>Cuidado! Você está usando um navegador antigo e inseguro! </h1><p>&nbsp;Por favor atualize com uma das opções a seguir:</p><p><a href="http://www.mozilla.com/firefox?from=sfx&uid=258329&t=326"><img src="http://www.tiaeliane.com.br/wp-content/themes/blogtiaeliane/images/firefox.png" border="0" width="24" /></a><a href="http://www.microsoft.com/brasil/windows/internet-explorer/"><img src="http://www.tiaeliane.com.br/wp-content/themes/blogtiaeliane/images/ei.png" border="0" width="24" /></a><a href="http://www.google.com/chrome"><img src="http://www.tiaeliane.com.br/wp-content/themes/blogtiaeliane/images/chrome.png" border="0" width="24" /></a><a href="http://www.apple.com/safari/"><img src="http://www.tiaeliane.com.br/wp-content/themes/blogtiaeliane/images/safari.png" border="0" width="24" /><a href="http://download.opera.com/"><img src="http://www.tiaeliane.com.br/wp-content/themes/blogtiaeliane/images/opera.png" border="0" width="24" /></a></p></div>');	
	}
}
