// JavaScript Document
function enviaForm() {
    if (frmAluno.unidade[0].selected) {
	  frmAluno.unidade.focus();
	  alert("Selecione a unidade.");
	  return false;
	}
	if (frmAluno.login.value == "") {
	  frmAluno.login.focus();
	  alert("Informe o seu login.");
	  return false;
	}
	if (frmAluno.senha.value == "") {
	  frmAluno.senha.focus();
	  alert("Informe a senha.");
	  return false;
	}
	return true;
  }

function txtBoxFormat(objeto, sMask, evtKeyPress) {
    var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;

	
if(document.all) { 
    nTecla = evtKeyPress.keyCode;
} else if(document.layers) { 
    nTecla = evtKeyPress.which;
} else {
    nTecla = evtKeyPress.which;
    if (nTecla == 8) {
        return true;
    }
}

    sValue = objeto.value;

    sValue = sValue.toString().replace( "-", "" );
    sValue = sValue.toString().replace( "-", "" );
    sValue = sValue.toString().replace( ".", "" );
    sValue = sValue.toString().replace( ".", "" );
    sValue = sValue.toString().replace( "/", "" );
    sValue = sValue.toString().replace( "/", "" );
    sValue = sValue.toString().replace( ":", "" );
    sValue = sValue.toString().replace( ":", "" );
    sValue = sValue.toString().replace( "(", "" );
    sValue = sValue.toString().replace( "(", "" );
    sValue = sValue.toString().replace( ")", "" );
    sValue = sValue.toString().replace( ")", "" );
    sValue = sValue.toString().replace( " ", "" );
    sValue = sValue.toString().replace( " ", "" );
    fldLen = sValue.length;
    mskLen = sMask.length;

    i = 0;
    nCount = 0;
    sCod = "";
    mskLen = fldLen;

    while (i <= mskLen) {
      bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/") || (sMask.charAt(i) == ":"))
      bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " "))

      if (bolMask) {
        sCod += sMask.charAt(i);
        mskLen++; }
      else {
        sCod += sValue.charAt(nCount);
        nCount++;
      }

      i++;
    }
/*
    objeto.value = sCod;

	if (nTecla != 8) {
	
	if (browserName!="Microsoft Internet Explorer" && nTecla==9){
	   // nTecla = evtKeyPress.keyCode;
	//	if(nTecla == 9){
			preenche(objeto,6);
		}
	
      if (sMask.charAt(i-1) == "9") { 
        return ((nTecla > 47) && (nTecla < 58)); }
      else { 
        return true;
      }
    }
    else {
      return true;
    }
  }
*/
    objeto.value = sCod;

    if (nTecla != 8) {
      if (sMask.charAt(i-1) == "9") { 
        return ((nTecla > 47) && (nTecla < 58)); }
      else { 
        return true;
      }
    }
    else {
      return true;
    }
  }




function preenche(campo, tamanho){
	var strText = campo.value;
	//alert(campo+ ' e '+tamanho)
	if (strText == "" ) 
	{
				campo.value = "00000-0";
	}
	else
	{ 
		var intTamStr = strText.length;

		if (intTamStr <= tamanho)
		{
			var intTam = parseInt(tamanho) - intTamStr;
			
			for (i=0; i<intTam; i++)
			{		
				strText = "0" + strText;			
			}

			campo.value = strText;
			comeco	=	campo.value.substr(0,5);
			fim		=	campo.value.substr(5,1);
			if(campo.value.substr(5,1)=="-")
			{			
				campo.value = 0+campo.value.substr(0,4)+"-"+campo.value.substr(4,1);
			}	
			else
				campo.value = comeco+"-"+fim;
			
		}
	}
}
