	function Trim(str){return str.replace(/^\s+|\s+$/g,"");}
	
	function eskemaFocos(obj){
		trimed = Trim(obj.value);
		if (trimed == Trim(obj.defaultValue)){
			obj.value = "";
		}
	}
	
	function eskemaBlur(obj){
		trimed = Trim(obj.value);
		if (trimed == ''){
			obj.value = obj.defaultValue;
		}
	}
	
	function checkMail(mail){
		var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
		if(typeof(mail) == "string"){
			if(er.test(mail)){
				return true;
			}
		}else if(typeof(mail) == "object"){
			if(er.test(mail.value)){
				return true;
			}
		}else{
			return false;
		}
	}
	
	function hidePop() {
		$('#popup').hide();	
	}
	
	$(document).ready(function(){
							   
 		$(".foco").focus(function(){
			eskemaFocos(this);			  
		});
		$(".foco").blur(function(){
			eskemaBlur(this);			  
		});
		
		$('#imprimirPag').click(function() {
			 window.print();							
		});
		
		$('.btnVoltar').click(function() {
			history.back();							
		});
				
	});

	
	function validaNewsletter() {	
		if ( !checkMail( $("#news").val() ) ){
			alert('Favor preencher o campo E-mail corretamente!');
			$("#news").focus();
			return false;
		}else{
			return true;
		}
	}
	
	function validaNewsletterP() {	
		if ( !checkMail( $("#newspg").val() ) ){
			alert('Favor preencher o campo E-mail corretamente!');
			$("#newspg").focus();
			return false;
		}else{
			return true;
		}
	}
	
	function validaCircular() {
		if ( $("#nome").val() == '' ){
			alert('Favor preencher o campo Nome corretamente!');
			$("#nome").focus();
			return false;
		} else if ( !checkMail( $("#email").val() ) ){
			alert('Favor preencher o campo E-mail corretamente!');
			$("#email").focus();
			return false;
		} else if ( $("#empresa").val() == '' ){
			alert('Favor preencher o campo Empresa!');
			$("#empresa").focus();
			return false;
		}else{
			return true;
		}
		return false;
	}
	
	function validaCadastroRacial() {
		if ( $("#nome").val() == '' ){
			alert('Favor preencher o campo Nome!');
			$("#nome").focus();
			return false;
		} else if ( $("#entidade").val() == '' ){
			alert('Favor preencher o campo Entidade / Fábrica!');
			$("#entidade").focus();
			return false;
		} else if ( !checkMail( $("#email").val() ) ){
			alert('Favor preencher o campo E-mail corretamente!');
			$("#email").focus();
			return false;
		} else if ( $("#telefone").val() == '' ){
			alert('Favor preencher o campo Telefone ou Celular!');
			$("#telefone").focus();
			return false;
		}else{
			return true;
		}
		return false;
	}
	
	function f_busca(s){
		s = s.replace(/ /gi,'-');
		s = s.replace(/[+]/gi,'-');
		s = s.replace(/[//]/gi,'-');
		s = s.replace(/[\\]/gi,'-');
		s = s.replace(/[--]/gi,'-');
		return s;
	}

	//_# SISTEMA DE VISIVEL #_
	function listarConvenios(ide){
		$.post("/ajax.php?funcao=convenios", { ID: ide }, function(data){
			$('#conveniosResultado').html(data);
		});
	}
	//_#
	
	
	//_# Sistema de Busca
	function Amigavel(str){
		str = Trim(str);
		str = str.toLowerCase();
		while (str.indexOf("--") > -1 || str.indexOf(" ") > -1){
			str = str.replace(/ /gi,"-");
			str = str.replace(/--/gi,"-");
		}
		return str;
	}
	
	$(document).ready(function() {
		$('.frmBusca').submit(function(){
			str = $(this).find(".buscaTxt").val();
			str = Amigavel(str);
			if (str!= '' && str!= 'busca'){
				location.href = '/busca/' + str;
			}
			return false;
		});
		
		/*$("#btnBuscaVideo").click(function(){
			str = $("#buscav").val();
			str = Amigavel(str);
			if (str!= '' && str!= 'buscar-por-vídeos'){
				location.href = '/buscavideos/' + str;
			}
		});
		
		$('#buscav').keypress(function(event) {
			if (event.keyCode == '13') {
				$("#btnBuscaVideo").click();
			}
		});*/

		/*$("#buscar").click(function(){
			str = $("#busca").val();
			str = Amigavel(str);
			if (str!= '' && str!= 'buscar-...'){
				location.href = '/busca/' + str;
			}
		});*/
		
		/*$('#busca').keypress(function(event) {
			if (event.keyCode == '13') {
				$("#buscar").click();
			}
		});*/
		
		$("#FaceBook_Share").click(function(){
			titulo = $("h1").html();
			if (titulo == "") {
				titulo = $("h2").html();				
			}
			url = location.href;
			window.open("http://www.facebook.com/sharer.php?u="+url+"&t="+titulo);
		});
		
		$("#Twitter_Share").click(function(){
			titulo = $("h1").html();
			if (titulo == "") {
				titulo = $("h2").html();				
			}
			url = location.href;
			window.open("/twittar");
		});
		
		$("#Orkut_Share").click(function(){
			titulo = $("h1").html();
			if (titulo == "") {
				titulo = $("h2").html();				
			}
			url = location.href;
			window.open("http://promote.orkut.com/preview?nt=orkut.com&tt="+titulo+"&du="+url+"");
		});

	});
	
		//_# TEXTFIELD SOMENTE NUMERIC . PARA USO: $("#yourTextBoxName").ForceNumericOnly();  #_	
	jQuery.fn.ForceNumericOnly =
	function()
	{
		return this.each(function()
		{
			$(this).keydown(function(e)
			{
				var key = e.charCode || e.keyCode || 0;
				// allow backspace, tab, delete, arrows, numbers and keypad numbers ONLY
				return (
					key == 8 || 
					key == 9 ||
					key == 46 ||
					(key >= 37 && key <= 40) ||
					(key >= 48 && key <= 57) ||
					(key >= 96 && key <= 105));
			})
		})
	};
	//_#
	
	//_#
	
	function abrirSB(img, title, description) 
	{
		$.prettyPhoto.open(img,title,description);
	}; 

