$(document).ready(function(){
	
	// efeito input
		
	$('.inputsgeral,.texteareageral').focus(function(){
		
		$(this).addClass('efeitoinput');
		
		$(this).blur(function(){
							   
			$(this).removeClass('efeitoinput');
			
		});
		
	});
	
	$('#termo_busca2').focus(function(){
		
		$("#termo_busca").val('');
		
	});
	
	// Tipo negociação
	
	$('#tipo_negociacao').change(function(){
		
		if( $('#tipo_negociacao').val() == 3){
			
				$(".periodo_loc").css("display", 'block');
		}else{
				
				$(".periodo_loc").css("display", 'none');
			
		}
		
	});
	
	

});


function validaCadastro(){
	
	var d = document.form3;
	
	 if(d.imagem.value.length == " "){
	  
	  alert('Campo imagem é obrigatório');
	  d.imagem.focus();
	  return false;
  }

	
	
}


function validaCheckbox(v)
{ 
    todos = document.getElementsByTagName('input'); 
	
    for(x = 0; x < todos.length; x++) 
    { 
        if (todos[x].checked) 
        { 
            return true; 
        } 
    } 
	
    alert("Selecione alguma página!"); 
	
    return false; 
}



function tipoNegociacao(tipo) {
		
		if(tipo == '3'){
	
			document.getElementById('error').getElementsByClassName('teste').style.display = 'block';

		}			
	
}



//contador
jQuery.fn.contador = function(opcoes) {
	opcoes = jQuery.extend({
		max: $(this).attr('maxlength'),				//Número máximo de caracteres no campo.
		mensagem: 'Restam $cont caracteres.',		//Texto que será exibido para os caracteres restantes. Obrigatório o $cont.
		elemento: 'div',							//Tipo do elemento que mostrará a quantidade de caracteres restantes.
		elementoId: $(this).attr('id'),				//ID do elemento que mostrará a quantidade de caracteres restantes.
		elementoClasse: 'contador',					//Nome da classe CSS do elemento que mostrará a quantidade de caracteres restantes.
		elementoInsert: 'depois'					//Posição do elemento que mostrará a quantidade de caracteres restantes em relação ao campo texto. Aceita 'antes' ou 'depois'.
	}, opcoes);
	$(this).each(function() {
		var val = $(this).val().length;
		var cur = (val > 0) ? val : 0;
		var resta = opcoes.max - cur;
		var mensagem = opcoes.mensagem.replace('$cont', resta.toString());
		
		opcoes.elementoId += "_" + opcoes.elemento;
		var elemento = "<"+opcoes.elemento+" id='"+opcoes.elementoId+"' class='"+opcoes.elementoClasse+"'>"+mensagem+"</"+opcoes.elemento+">";
		if (opcoes.elementoInsert == 'depois') {
			$(this).after(elemento);
		} else if (opcoes.elementoInsert == 'antes') {
			$(this).before(elemento);
		}
		$(this).keyup(function(e) {
			atualiza($(this));
		});
		$(this).blur(function() {
			atualiza($(this));
		});
		var atualiza = function(campo) {
			var val = campo.val().length;
			var cur = (val > 0) ? val : 0;
			var resta = opcoes.max-cur;
			if (resta <= 0) {
				campo.val(campo.val().substr(0, opcoes.max));
				resta = 0;
			}
			var mensagem = opcoes.mensagem.replace('$cont', resta.toString());
			$("#"+opcoes.elementoId).text(mensagem);
			return campo;
		};
	});
	return this;
};


$(document).ready(function(){
	
	
	
	$("#aumet").click(function(){
		
		$("body , #texto_detalhada ,  #listagens a").removeClass('diminuiFonte');		
		$("body , #texto_detalhada ,  #listagens a").addClass('aumentaFonte');								
									
	});
	
	$("#dimi").click(function(){
		
		$("body , #texto_detalhada ,  #listagens a").removeClass('aumentaFonte');		
		$("body , #texto_detalhada ,  #listagens a").addClass('diminuiFonte');								
									
	});
	
	$('.tabSelect1').addClass("marca_link_player");
	
	$(".tabSelect1").click(function(){
		
		$('#img1').fadeIn("slow");
		$('#img1').css("display" , "block");
		$('.tabSelect2').removeClass("marca_link_player");
		$('.tabSelect3').removeClass("marca_link_player");	
		$('.tabSelect1').addClass("marca_link_player");
		$('#img2').css("display" , "none");
		$('#img3').css("display" , "none");
		return false;
	
	});
	
	$(".tabSelect2").click(function(){
		
		$('#img2').fadeIn("slow");
		$('#img2').css("display" , "block");
		$('.tabSelect1').removeClass("marca_link_player");
		$('.tabSelect3').removeClass("marca_link_player");	
		$('.tabSelect2').addClass("marca_link_player");
		$('#img1').css("display" , "none");
		$('#img3').css("display" , "none");
		return false;
	
	});
	
	
	$(".tabSelect3").click(function(){
		
		$('#img3').fadeIn("slow");
		$('#img3').css("display" , "block");
		$('.tabSelect1').removeClass("marca_link_player");
		$('.tabSelect2').removeClass("marca_link_player");	
		$('.tabSelect3').addClass("marca_link_player");
		
		$('#img1').css("display" , "none");
		$('#img2').css("display" , "none");
		return false;
	
	});

}); 

$(document).ready(function(){
							
	$('.enviar_mkt').click(function(){
			
			if(!confirm('Tem certeza dessa ação ?')){ return false; }
			  
					   
	 });
 
 
});

