// JavaScript Document



function ValidaCamposNumeros()

{

	if ((window.event.keyCode>=48 && window.event.keyCode<=57) || (window.event.keyCode==13 || window.event.keyCode==8))

	{

		return true;	

	}else{

		event.returnValue=false;   

        event.keyCode=0;

		return false;		

	}	

	

}





//funcionando para apenas um formulario especifico(parametro)

function verifica_form(formulario)

{

	//alert(formulario);

	var form, cont;

	cont = 0;

	i=0;

	var curso1,curso2;

	

	//for(c=0;c<document.forms.length;c++){

			form = formulario;			

			while ((i<form.elements.length)&&(cont==0)){

				

				if((form.elements[i].alt!='')&&(form.elements[i].value=='')){

			  		cont++;

				}else i++;

			}

		//}

		

	if(cont>0){

		alert('Preencha o campo '+ form.elements[i].alt +'.');

		

		if(form.elements.disabled==true){

			form.elements[i].focus();

		}

		return false;

	}

	else{

		curso1 = $("#curso_id1").val();	
		curso2 = $("#curso_id2").val();	

		if(curso1==0 ) //|| curso2==0
		{
			alert('Selecione as opções de curso. ');
			return false;
		}
		else
		{
			return true;
		}

	}

}



function verifica_gen(campo){

		var partes;

		

		partes = campo.value.split(".");

		

		if((partes[1]!='GEN')&&(partes[2]!='GEN')&&(partes[1]!='gen')&&(partes[2]!='gen')){

			alert('Arquivo inválido. Escolha um com formato .GEN');			

			return false;

		}else{

			return true;

		}

		

}



function verifica_txt(campo){

		var partes;

		

		partes = campo.value.split(".");

		

		if((partes[1]!='TXT')&&(partes[2]!='TXT')&&(partes[1]!='txt')&&(partes[2]!='txt')){

			alert('Arquivo inválido. Escolha um com formato .TXT');			

			return false;

		}else{

			return true;

		}

		

}



//função que formata cpf, data, telefone, cep, hora .. ..  na pagina coloca OnKeyPress="formatar('##/##/####', this)"  obs.: ##/##/#### -> o que determina o tipo de formatação

function formatar(mascara, documento){

  var i = documento.value.length;

  var saida = mascara.substring(0,1);

  var texto = mascara.substring(i)

  

  if (texto.substring(0,1) != saida){

	documento.value += texto.substring(0,1);

  }

  

}



//EXEMPLO DE USO: CEP: <input type="text" name="cep" value="" onkeypress="return mascara(event,this,'#####-###');" size="9" maxlength="9">



function mascara(e,src,mask,quant) {

	if(src.value.length<quant){	

		if(window.event) { 

			_TXT = e.keyCode; 

		} else 

			if(e.which) { 

			_TXT = e.which; 

			} 

		if(_TXT > 47 && _TXT < 58) { 

			var i = src.value.length; 

			var saida = mask.substring(0,1); 

			var texto = mask.substring(i); 

			if(texto.substring(0,1) != saida) { 

				src.value += texto.substring(0,1); 

			} 

			return true; 

		} else { 

				if (_TXT != 8) { 

					return false; 

				} else { 

					return true; 

				} 

			}

	}else

		return false;

} 



function confirmacao(aURL,msg) {

    if(confirm(msg)) {		

      location.href = aURL;

    }

  }

  

