	function validaEmail(_email) {
		var invalid;
		invalid = /\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
	
		if (invalid.test(_email) == false)
		  return false;
		else
		  return true;
	}
	
	function validaData(_data) {
		var invalid;
		invalid = /^(([0-2]\d|[3][0-1])\/([0]\d|[1][0-2])\/[1-2][0-9]\d{2})$/;

		if (invalid.test(_data) == false)
		  return false;
		else
		  return true;
	}
	
	function validaTelefone(_telefone) {
		var invalid;
		invalid = /^([0-9]{2})?(\([0-9]{2})\)([0-9]{3}|[0-9]{4})-[0-9]{4}$/;
	
		if (invalid.test(_telefone) == false)
		  return false;
		else
		  return true;
	}
	
	function validaPreInscricao(){
					
		var formPreInscricao = document.frmPreInscricao;
		
		if (!formPreInscricao)
		    formPreInscricao = document.forms['frmPreInscricao'];
		
		var erros= "";
		
		//CIDADE
		if(document.getElementById('slcCidades').selectedIndex == '0' ) erros += " - Selecione uma cidade. <br />";

		//NOME
		if(document.getElementById('txtNome').value == '') erros += " - Informe o nome. <br />";
		
		//DATA DE NASCIMENTO
		if((document.getElementById('txtDia').value == '') || (document.getElementById('txtMes').value == '') || (document.getElementById('txtAno').value == '')) 
			erros += " - Informe a data de Nascimento. <br />";
		else if(!validaData(document.getElementById('txtDia').value + '/' + document.getElementById('txtMes').value + '/' + document.getElementById('txtAno').value)) 		        	erros += " - Data de Nascimento  invlida. <br />";		
		
		//EMAIL		
		if(document.getElementById('txtEmail').value == '') erros += " - Informe o email. <br />";
		else if(!validaEmail(document.getElementById('txtEmail').value)) erros += " - Informe o email corretamente. <br />";
		
		//TELEFONE
		if(document.getElementById('txtDDD').value == '') erros += " - Informe o DDD. <br />";
		if(document.getElementById('txtTelefone').value == '') erros += " - Informe o telefone. <br />";
		if(validaTelefone('(' + document.getElementById('txtDDD').value + ')' + document.getElementById('txtTelefone').value)) erros += " - Telefone invlido. <br />";

		if(erros != ''){
			document.getElementById('validator').innerHTML = erros;
			document.getElementById('validator').style.display = 'block';
			return false;
		}
		else{
			document.getElementById('validator').style.display = 'inline';
			formPreInscricao.action = '/Blog/index.php?mtd=InclusaoParticipante&Cidade=' + document.getElementById('slcCidades').selectedIndex;
			formPreInscricao.submit();
			return true;
		}
	}

	function SomenteNumero(e){
		var tecla=(window.event)?event.keyCode:e.which;
		if((tecla > 47 && tecla < 58)) 
			return true;
		else if(tecla != 8) 
			return false;
		else return true;
	}
	
	
	function ExibePreInscricao(AncoraPagina) {
		
		document.getElementById('Div_PreInscricao').style.display = 'inline';
		document.getElementById('DivFormPreInscricao').style.display = 'inline';
		document.getElementById('DivErroPreInscricao').style.display = 'none';
		document.getElementById('DivSucessoPreInscricao').style.display = 'none';
		
		var strPageName = "Caminhao Itinerante: Pre Inscricao";
		
		if(AncoraPagina != null){
			
			if(window.location.href.indexOf('#') != -1)
				window.location.href.split('#')[0] + "#" + AncoraPagina.split(';')[0];
			else
				window.location.href + "#" + AncoraPagina.split(';')[0];
		
			if(AncoraPagina.split(';')[1] == "Agenda")
			{
				if(AncoraPagina.split(';')[2] == '')
					strPageName = 'Caminhao Itinerante: Agenda Pre Inscricao: ' + AncoraPagina.split(';')[2];
				else
					strPageName = 'Caminhao Itinerante: Agenda Pre Inscricao';
			}
			else if(AncoraPagina.split(';')[1] == "Participe")
				strPageName = 'Caminhao Itinerante: Participe';
		}

		s.pagename = strPageName;
		s.t();
	}
	
	function FechaPreInscricao(Url) {
		document.getElementById('Div_PreInscricao').style.display = 'none';
		document.getElementById('DivFormPreInscricao').style.display = 'none';
		document.getElementById('DivErroPreInscricao').style.display = 'none';
		document.getElementById('DivSucessoPreInscricao').style.display = 'none';
	}
	
	function ExibeMsgSucesso(AncoraPagina) {
		document.getElementById('validator').innerHTML == 'Cadastro efetuado com sucesso!';
		document.getElementById('Div_PreInscricao').style.display = 'inline';
		document.getElementById('DivFormPreInscricao').style.display = 'block';
		document.getElementById('DivErroPreInscricao').style.display = 'none';
		document.getElementById('tableFormPreInscricao').style.display = 'none';
		document.getElementById('btEnviarPre').style.display = 'none';
		document.getElementById('DivSucessoPreInscricao').style.display = 'inline';
		
		var strPageName = "Caminhao Itinerante: Pre Inscricao Ok";
		
		if(AncoraPagina != null){
			
			if(window.location.href.indexOf('#') != -1)
				window.location.href.split('#')[0] + "#" + AncoraPagina.split(';')[0];
			else
				window.location.href + "#" + AncoraPagina.split(';')[0];
		
			if(AncoraPagina.split(';')[1] == "Agenda")
			{
				if(AncoraPagina.split(';')[2] == '')
					strPageName = 'Caminhao Itinerante: Agenda Pre Inscricao Ok: ' + AncoraPagina.split(';')[2];
				else
					strPageName = 'Caminhao Itinerante: Agenda Pre Inscricao Ok';
			}
			else if(AncoraPagina.split(';')[1] == "Participe")
				strPageName = 'Caminhao Itinerante: Participe Ok';
		}

		s.pagename = strPageName;
		s.t();
	}
	
	function addFav(){
    var urlFav      = window.location;
    var titleFav    = document.title;
    if (window.sidebar) window.sidebar.addPanel(titleFav, urlFav,"");
    else if(window.opera && window.print){
        var mbm = document.createElement('a');
        mbm.setAttribute('rel','sidebar');
        mbm.setAttribute('href',urlFav);
        mbm.setAttribute('title',titleFav);
        mbm.click();
    }
    else if(document.all){window.external.AddFavorite(urlFav, titleFav);}
	}
	