
if (navigator.appName.indexOf('Microsoft') != -1){
 	clientNavigator = "IE";
 }else{
 	clientNavigator = "Other";
 }

function Compara_Datas(data_inicial,data_final,obrigatorio){
//alert(data_inicial.value.length);

 	//Verifica se a data inicial é maior que a data final
	if ((data_inicial.value.length > 0)&&(data_final.value.length > 0)) {
	  if ((data_inicial.value.length == 10)&&(data_final.value.length == 10)) {				
		//alert(data_inicial.value.length);
		dia_inicial      = data_inicial.value.substr(0,2);
		dia_final        = data_final.value.substr(0,2);
		mes_inicial      = data_inicial.value.substr(3,2);
		mes_final        = data_final.value.substr(3,2);
		ano_inicial      = data_inicial.value.substr(6,4);
		ano_final        = data_final.value.substr(6,4);
		if(ano_inicial > ano_final){
			alert("A data inicial deve ser menor que a data final."); 
			//document.frm.data_inicial.focus();
			return false;
		}//end if
		else{
			if(ano_inicial == ano_final){
				if(mes_inicial > mes_final){
					alert("A data inicial deve ser menor que a data final.");
							//document.frm.data_final.focus();
							return false
				}//end if
				else{
					if(mes_inicial == mes_final){
						if(dia_inicial > dia_final){
							alert("A data inicial deve ser menor que a data final.");
							//document.frm.data_final.focus();
							return false
						}//end if
						else {//recarrega_iframe(cmb,data_inicial,data_final,caminho);
						//return true;
						}
					}//end if
					else {//recarrega_iframe(cmb,data_inicial,data_final,caminho);
					//return true;
					}
				}//end else
			}//end if
			else {//recarrega_iframe(cmb,data_inicial,data_final,caminho);
			//return true;
			}			
		}//end else
	//nova funcao para verificar dia mes e ano das datas
	if(obrigatorio == 1){		
		    	//busca o dia mes e ano da data inicial
				dia_inicial = data_inicial.value.substr(0,2);
				//alert(dia_inicial);
		 		mes_inicial = data_inicial.value.substr(3,2);
		 		ano_inicial = data_inicial.value.substr(6,4);
				//busca o dia mes e ano da data final								
				dia_final = data_final.value.substr(0,2);
		 		mes_final = data_final.value.substr(3,2);
		 		ano_final = data_final.value.substr(6,4);
						//Verifica o dia inicial
 						if ((isNaN(dia_inicial) || dia_inicial > 31 || dia_inicial < 1)){
				 			alert("Formato do dia da data inicial não é válido.");
				 			data_inicial.focus();
				 			return false
							}
						//verifica dia final	
						if ((isNaN(dia_final) || dia_final > 31 || dia_final < 1)){
							alert("Formato do dia da data final não é válido.");
				 			data_final.focus();
				 			return false
							}
						//verifica mes inicial
							if (mes_inicial == 4 || mes_inicial == 6 || mes_inicial == 9 || mes_inicial == 11){
 								if (dia_inicial == "31"){
					 				alert("O mês da data inicial informado não possui 31 dias.");
					 				data_inicial.focus();
					 				return false
					 			}
					 		}
						//verifica mes final
							if (mes_final == 4 || mes_final == 6 || mes_final == 9 || mes_final == 11){
 								if (dia_final == "31"){
					 				alert("O mês da data final informado não possui 31 dias.");
					 				data_final.focus();
					 				return false
					 			}
					 		}
							//verifica ano bissexto data inicial							
							if (mes_inicial == "02"){
								bissexto = ano_inicial % 4;
									if (bissexto == 0){
										if (dia_inicial > 29){
											alert("O mês da data inicial informado possui somente 29 dias.");
											data_inicial.focus();
											return false
										}
									}else{
										if (dia_inicial > 28){
											alert("O mês da data inicial informado possui somente 28 dias.");
											data_inicial.focus();
											return false
										}
									}
							}
							//verifica ano bissexto data final
							if (mes_final == "02"){
								bissexto = ano_final % 4;
									if (bissexto == 0){
										if (dia_final > 29){
											alert("O mês da data final informado possui somente 29 dias.");
											data_final.focus();
											return false
										}
									}else{
										if (dia_final > 28){
											alert("O mês da data final informado possui somente 28 dias.");
											data_final.focus();
											return false
										}
									}
							}
							//Verifica o mês da data inicial
							if (isNaN(mes_inicial) || mes_inicial > 12 || mes_inicial < 1){
								alert("Formato do mês da data inicial não é válido.");
								data_inicial.focus();
								return false
							}
							//Verifica o ano da data inicial
							if (isNaN(ano_inicial)){
								alert("Formato do ano da data inicial não é válido.");
								data_inicial.focus();
								return false
							}
							
							//Verifica o mês da  data final
							if (isNaN(mes_final) || mes_final > 12 || mes_final < 1){
								alert("Formato do mês da data final não é válido.");
								data_final.focus();
								return false
							}
							//Verifica o ano da data final
							if (isNaN(ano_final)){
								alert("Formato do ano da data inicial não é válido.");
								data_final.focus();
								return false
							}
			}				
   		//fim nova funcao
   		}//If data maior que 10 digitos
		else{
		alert('Por Favor Digite uma data no formato xx/xx/xxxx!');
		//document.frm.data_inicial.focus();
		return false
		}
	}//If valor maior que Zero
    else{
		alert('Por Favor Digite uma data!');
		//document.frm.data_inicial.focus();
		return false
	}//end else*
}//end function


 
 function Bloqueia_Caracteres(evnt){
 //Função permite digitação de números
 	if (clientNavigator == "IE"){
 		if (evnt.keyCode < 48 || evnt.keyCode > 57){
 			return false
 		}
 	}else{
 		if ((evnt.charCode < 48 || evnt.charCode > 57) && evnt.keyCode == 0){
 			return false
 		}
 	}
 }

 function Ajusta_Data(input, evnt){
 //Ajusta máscara de Data e só permite digitação de números
 //alert('teste');
 	if (input.value.length == 2 || input.value.length == 5){
 		if(clientNavigator == "IE"){
 			input.value += "/";
 		}else{
 			if(evnt.keyCode == 0){
 				input.value += "/";
 			}
 		}
 	}
 //Chama a função Bloqueia_Caracteres para só permitir a digitação de números
 	return Bloqueia_Caracteres(evnt);
 }	
 function Ajusta_CPF(input, evnt){
 //Ajusta máscara de Data e só permite digitação de números
 //alert('teste');
 	if (input.value.length == 3 || input.value.length == 7){
			if(clientNavigator == "IE"){
		 			input.value += ".";
			}
			else{		
						if(evnt.keyCode == 0){
							input.value += ".";
						}
			}			
 	}	
	if (input.value.length == 11){
		 if(clientNavigator == "IE"){
		 					input.value += "-";
					}
					else{		
								if(evnt.keyCode == 0){
									input.value += "-";
								}
					}
 			}	
 //Chama a função Bloqueia_Caracteres para só permitir a digitação de números
 	return Bloqueia_Caracteres(evnt);
 }



 function Ajusta_Telefone(input, evnt){
 //Ajusta máscara de Data e só permite digitação de números
 //alert('teste');
 	if (input.value.length == 0 ){
			if(clientNavigator == "IE"){
		 			input.value += "(";
			}
			else{		
						if(evnt.keyCode == 0){
							input.value += "(";
						}
			}			
 	}	
	
 	if (input.value.length == 4 ){
			if(clientNavigator == "IE"){
		 			input.value += ")";
			}
			else{		
						if(evnt.keyCode == 0){
							input.value += ")";
						}
			}			
 	}	
	
	
	if (input.value.length == 9){
		 if(clientNavigator == "IE"){
		 					input.value += "-";
					}
					else{		
								if(evnt.keyCode == 0){
									input.value += "-";
								}
					}
 			}	
 //Chama a função Bloqueia_Caracteres para só permitir a digitação de números
 	return Bloqueia_Caracteres(evnt);
 }



function Ajusta_CEP(input, evnt){
 //Ajusta máscara de Data e só permite digitação de números
 //alert('teste');
 	if (input.value.length == 5 ){
			if(clientNavigator == "IE"){
		 			input.value += "-";
			}
			else{		
						if(evnt.keyCode == 0){
							input.value += "-";
						}
			}			
 	}		
	
	
 //Chama a função Bloqueia_Caracteres para só permitir a digitação de números
 	return Bloqueia_Caracteres(evnt);
 }


function verifica_obrigatoriedade(){
	/*DATA DE NASCIMENTO*/
	if (document.forms[0].txtdatanascResp.value == document.forms[0].txtdatanasc.value  ) {
		alert('Verifique as datas de nascimento ');
		document.forms[0].txtdatanasc.focus();
		document.forms[0].txtdatanasc.select();
		return false;
    }	
	/* FIM DATA DE NASCIMENTO*/
	
	if(document.forms[0].txtRespon.value == '') {
		alert('Campo Nome é obrigatório!');
		document.forms[0].txtRespon.focus();
		document.forms[0].txtRespon.select();
		return false;
	}
	if(document.forms[0].txtdatanascResp.value == '') {
		alert('Campo Data Nascimento é obrigatório!');
		document.forms[0].txtdatanascResp.focus();
		document.forms[0].txtdatanascResp.select();
		return false;
	}
	if (document.forms[0].txtEmail.value == ''){
		alert('Campo Email é obrigatório!');
		document.forms[0].txtEmail.focus();
		document.forms[0].txtEmail.select();
		return false;
	}
	if (document.forms[0].regiaors.value == 0){
		alert('Campo Região é obrigatório!');
		document.forms[0].regiaors.focus();
		return false;
	}
    if (document.getElementById("sexoRespM").checked == false
        && document.getElementById("sexoRespF").checked == false) {
        alert('Informe o sexo do responsável!');
        return false;
    }
	if (document.forms[0].txtCEP.value == ''){
		alert('Campo CEP é obrigatório!');
		document.forms[0].txtCEP.focus();
		document.forms[0].txtCEP.select();
		return false;
	}
	if (document.forms[0].txtNome.value == ''){
		alert('Campo Nome é obrigatório!');
		document.forms[0].txtNome.focus();
		document.forms[0].txtNome.select();
		return false;
	}
    if (document.getElementById("sexoCandM").checked == false
        && document.getElementById("sexoCandF").checked == false) {
        alert('Informe o sexo do candidato!');
        return false;
    }
	if (document.forms[0].txtTRes.value == '' &&document.forms[0].txtTCom.value == ''&&document.forms[0].txtTCel.value == ''){
		alert('É necessário o cadastramento de um contato telefônico!');
		document.forms[0].txtTRes.focus();
		document.forms[0].txtTRes.select();
		return false;
	}
	
	if(document.forms[0].txtdatanasc.value == '') {
		alert('Campo Data Nascimento é obrigatório!');
		document.forms[0].txtdatanasc.focus();
		document.forms[0].txtdatanasc.select();
		return false;
	}	
	
	if (document.forms[0].txtEmailResponsavel.value == '') {
		alert('Campo Email é obrigatório!');
		document.forms[0].txtEmailResponsavel.focus();
		document.forms[0].txtEmailResponsavel.select();
		return false;
	}
	if (document.forms[0].txtEnd.value == '') {
		alert('Campo Endereço é obrigatório!');
		document.forms[0].txtEnd.focus();
		document.forms[0].txtEnd.select();
		return false;            
	}
	if (document.forms[0].txtNum.value == '') {
		alert('Campo Número é obrigatório!');
		document.forms[0].txtNum.focus();
		document.forms[0].txtNum.select();
		return false;
	}
	if (document.forms[0].txtBairro.value == '') {
		alert('Campo Bairro é obrigatório!');
		document.forms[0].txtBairro.focus();
		document.forms[0].txtBairro.select();
		return false;
	}
	if (document.forms[0].txtMunicipio.value == '') {
		alert('Campo Cidade é obrigatório!');
		document.forms[0].txtMunicipio.focus();
		document.forms[0].txtMunicipio.select();
		return false;
	}
	if (document.forms[0].txtUF.value == '') {
		alert('Campo Estado é obrigatório!');
		document.forms[0].txtUF.focus();
		document.forms[0].txtUF.select();
		return false;
	}
    if (document.forms[0].textescproc.value == 0 ) {
		alert('Informe a escola de procedência!');
		document.forms[0].textescproc.focus();
		document.forms[0].textescproc.select();
		return false;
    }
	if (!confirm("Deseja realmente gravar?"))
		return false;

}

function contadorTeclaDigitada(txt, prox){
    prox.value = txt.value.length
}


function validaEmail(email){

TEmail = email;
//with(email){
//alert(value);
	if (email.value != ""){
		prim = email.value.indexOf("@");
		if(prim < 2) {
			alert("O e-mail informado parece não estar correto!");			
			return false;
		}
		if(email.value.indexOf("@",prim + 1) != -1) {
			alert("O e-mail informado parece não estar correto.");
			return false;
		}
		if(email.value.indexOf(".") < 1) {
			alert("O e-mail informado parece não estar correto.");
			return false;
		}
		if(email.value.indexOf(" ") != -1) {
			alert("O e-mail informado parece não estar correto.");
			return false;
		}
		if(email.value.indexOf("zipmeil.com") > 0) {
			alert("O e-mail informado parece não estar correto.");
			return false;
		}
		if(email.value.indexOf("hotmeil.com") > 0) {
			alert("O e-mail informado parece não estar correto.");
			return false;
		}
		if(email.value.indexOf(".@") > 0) {
			alert("O e-mail informado parece não estar correto.");
			return false;
		}
		if(email.value.indexOf("@.") > 0) {
			alert("O e-mail informado parece não estar correto.");
			return false;
		}
		if(email.value.indexOf(".com.br.") > 0) {
			alert("O e-mail informado parece não estar correto.");
			return false;
		}
		if(email.value.indexOf("/") > 0) {
			alert("O e-mail informado parece não estar correto.");
			return false;
		}
		if(email.value.indexOf("[") > 0) {
			alert("O e-mail informado parece não estar correto.");
			return false;
		}
		if(email.value.indexOf("]") > 0) {
			alert("O e-mail informado parece não estar correto.");
			return false;
		}
		if(email.value.indexOf("(") > 0) {
			alert("O e-mail informado parece não estar correto.");
			return false;
		}
		if(email.value.indexOf(")") > 0) {
			alert("O e-mail informado parece não estar correto.");
			return false;
		}
		if(email.value.indexOf("..") > 0) {
			alert("O e-mail informado parece não estar correto.");
			return false;
		}
		
	}
//}//end with
}


//Funções removidas da página de inscrição no Colégio e agrupadas aqui em 02/06/2009
function mostra(id){
	var obj = document.getElementById(id);
	obj.style.display = 'block';
	if(id=="div2"){
		var obj2 = document.getElementById("publicacoes");
		obj2.style.position = '';
	}
}
function oculta(id){
	var obj = document.getElementById(id);
	obj.style.display = 'none';
	if(id=="div2"){
		var obj2 = document.getElementById("publicacoes");
		obj2.style.position = 'relative';
	}
}
//maxLength do textarea
	function maxLength(textAreaField, limit) {
 		var ta = document.getElementById(textAreaField);

 		if (ta.value.length >= limit) {
 			ta.value = ta.value.substring(0, limit-1);
 		}
 	}

function campo_detalhe(checkbox,elemento_check) {
    if (document.getElementById(checkbox).checked==true) {
        document.getElementById(elemento_check).style.display = "block";
        document.getElementById(elemento_check).focus();
    }
    else {
        document.getElementById(elemento_check).style.display = "none";
        document.getElementById(elemento_check).value = '';

    }

}