function showErro(error, element) {
	//alert(error);
	//error é o elemento label e element é o input
	
	//Mostrar um erro por vez
	if( $('div[title=erro]').length==0 ){
		//Pegando ID do Elemento e as coordenadas
		var idElement = element.attr('id');
		var t = getCoords('#'+idElement);
					
		var lTop = 80;
		
		if(error.html().length>=30){ 
			lTop += 20;
		}
		
		if(error.html().length>=60){
			lTop += 20;
		}
		
		var para = error.attr('for');
		var	generated = error.attr('generated');
		var classe = error.attr('class');
		var erro = error.html();
		var tag = '<label for="'+ para +'" generated="'+ generated +'" class="'+ classe +'" id="label">'+ erro +'</label>';
		// top:'+(t.top-lTop)+'px;
		var teste = '<div title="erro" style="width:250px; position: absolute; left: '+(t.right-60)+'px; top: '+t.bottom+'px; z-index:999" id="err_'+para+'" class="erroLabel">'+
			'<div id="top-left"></div>'+
			'<div id="top-right"></div>'+
			'<div id="inside">'+
				'<div id="dErrorPng">&nbsp;</div>'
				+tag+
				'<div style="clear:both; height:10px;">&nbsp;</div>'+
			'</div><div id="bottom-left"></div>'+
			'<div id="bottom-right"></div>'+
		'</div>';
		
		$(teste).fadeIn("fast").insertAfter(element);
		
		
		// Pegando as coordenadas do div pai
		a = getCoords("#err_"+para);
		
		//topBox é o topo do input
		topBox = t.height + a.height;
		$("#err_"+para).animate({"top": "-="+topBox+"px"}, "slow");			
		
		//Scroll para o erro
		$('html, body').animate({scrollTop: t.top-150 }, 1700);
	}
}

$().ready(function() {	
	/*
	 * Limpa o campo para preenchimento
	*/
	$('input[type!=submit], textarea').focus(function(){
		var texto = $(this).val();
		var title = $(this).attr('title');
		
		/*
		 * Seleciona quando entra no Campo
		*/
		this.select();
		
		/*
		 * Se ao sair o cara nao mudou, volta o title
		
		$(this).blur(function(){
			if( $(this).val().length==0 ){ $(this).val(title); }
		});*/
	});
	
	
	/*
	 * Regra para forçar o usuário a mudar o valor do campo
	*/
	$.validator.addMethod("notEqualTo",function(value, element, params) {
			return this.optional(element) || value != params;
	
	}); 
	
	/*
	 * Regra para validar um telefone
	 * aceita ' - ()' = espaço, hífen e abre e fecha parenteses
	*/
	$.validator.addMethod("phone", function(ph, element) {
		if (ph == null) {
			return false;
		}
		
		var stripped = ph.replace(/[\s()+-]|ext\.?/gi, "");
		
		// 8 is the minimum number of numbers required
		return ((/\d{8,}/i).test(stripped) && (isInteger(stripped)) );
	});
	
	/*
	 * Funçao auxiliar da verificaçao do telefone
	*/
	function isInteger(s) {
		var i;
		for (i = 0; i < s.length; i++){
			// Check that current character is number.
			var c = s.charAt(i);
			if (((c < "0") || (c > "9"))) return false;
		}
		// All characters are numbers.
		return true;
	}
});
