// JavaScript Document
function AbreModal(url)
{
window.showModalDialog(url,window,"dialogWidth:500px;dialogHeight:600px");
}
function TextBoxCaixaAlta_OnKeyUp(fsValor, foForm, foNome) { 
	if (window.event.keyCode >= 65 && window.event.keyCode <= 90){
		x = new String(document.forms[foForm].elements[foNome].value);
		document.forms[foForm].elements[foNome].value = x.toUpperCase();
	}
   }

   function TextBoxCaixaAlta_OnBlur(fsValor, foForm, foNome){ 	
	var tam=0;
	x = new String(document.forms[foForm].elements[foNome].value);
	while (tam != x.length){
		tam = x.length;
		x = x.replace('\'', '');
	}
	document.forms[foForm].elements[foNome].value = x.toUpperCase();
   }
/*function click() {
	if (event.button==2) {
	alert('CUIDADO - Não faça mas isso.');
	}
}
document.onmousedown=click
*/
function txtBoxFormat(objForm, strField, sMask, evtKeyPress) {
      var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;

      if(document.all) { // Internet Explorer
        nTecla = evtKeyPress.keyCode; }
      else if(document.layers) { // Nestcape
        nTecla = evtKeyPress.which;
      }

      sValue = objForm[strField].value;

      // Limpa todos os caracteres de formatação que
      // já estiverem no campo.
      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) == "/"))
        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++;
      }

      objForm[strField].value = sCod;

      if (nTecla != 8) { // backspace
        if (sMask.charAt(i-1) == "9") { // apenas números...
          return ((nTecla > 47) && (nTecla < 58)); } // números de 0 a 9
        else { // qualquer caracter...
          return true;
        } }
      else {
        return true;
      }
    }

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function preencheNovo(campo, tamanho){
//captura do texto
var strText = campo.value;
//tamanho da string
var intTamStr = strText.length;
/*verifica se o tamanho da string eh menor ou igual ao tamanho que eh pedido na funcão*/
if (intTamStr <= tamanho){//executa a adaptação do texto
//quantos zeros serão incluídos no texto
var intTam = parseInt(tamanho) - intTamStr;
//preenchimento do campo
for (i=0; i<intTam; i++){
strText = "0" + strText;
}
//atribuição da variável ao campo
campo.value = strText;
}
}

//onBlur="preenche(this, ?)"; COMO USAR ? é o numero de zeros que vc deseja

function data(){
mdata      = new Date()
mhora      = mdata.getHours()
mdia       = mdata.getDate()
mdiasemana = mdata.getDay()
mmes       = mdata.getMonth()
mano       = mdata.getYear()

//if (mhora < 12)
//    document.write('Bom Dia - Amap&aacute; ');
//else if(mhora >=12 && mhora < 18)
//    document.write('Boa Tarde - Amap&aacute; ');
//else if(mhora >= 18 && mhora < 24)
//    document.write('Boa Noite - Amap&aacute; ');
//document.write('');

/*if(mdiasemana == 0)
   document.write('Domingo, ');
else if(mdiasemana == 1)
   document.write('Segunda Feira, ');
else if(mdiasemana == 2)
   document.write('Ter&ccedil;a Feira, ');
else if(mdiasemana == 3)
   document.write('Quarta Feira, ');
else if(mdiasemana == 4)
   document.write('Quinta Feira, ');
else if(mdiasemana == 5)
   document.write('Sexta Feira, ');
else if(mdiasemana == 6)
   document.write('S&aacute;bado, ');
*/
document.write(mdia+'/');
if(mmes == 0)
   document.write('1/');
else if(mmes == 1)
   document.write('2/');
else if(mmes == 2)
   document.write('3/');
else if(mmes == 3)
   document.write('4/');
else if(mmes == 4)
   document.write('5/');
else if(mmes == 5)
   document.write('6/');
else if(mmes == 6)
   document.write('7/');
else if(mmes == 7)
   document.write('8/');
else if(mmes == 8)
   document.write('9/');
else if(mmes == 9)
   document.write('10/');
else if(mmes == 10)
   document.write('11/');
else if(mmes == 11)
   document.write('12/');

document.write(mano+'');
document.write('');
}
function gettheDate() {

               Todays = new Date();

               TheDate = "" + Todays.getDate() +"/"+ (Todays.getMonth() + 1) + "/" +  

               Todays.getYear() 

               formTexto.DATA.value = TheDate;

}

var timerID = null;

var timerRunning = false;



//  Final da Função -->



function stopclock (){

        if(timerRunning);

                clearTimeout(timerID);

        timerRunning = false;

    }



//  - - - - - - - - Inicializa o Clock-->



function startclock () {

        stopclock();

        gettheDate()

        showtime();

    }

//  - - - - - - - -  Mostra a Hora-->



function showtime () {

        var now = new Date();

        var hours = now.getHours();

        var minutes = now.getMinutes();

        var seconds = now.getSeconds()

        var timeValue = "" + ((hours >24) ? hours -24 :hours)

        timeValue += ((minutes < 10) ? ":0" : ":") + minutes

        //timeValue += ((seconds < 10) ? ":0" : ":") + seconds

        // timeValue += (hours >= 12) ? " P.M." : " A.M."

         example.HORA.value = timeValue;

        // you could replace the above with this

        // and have a clock on the status bar:

        // window.status = timeValue;

        timerID = setTimeout("showtime()",1000);

        timerRunning = true;

    }

// - - - - - - - -   Final do código JavaScript --->


