function saudacao () {
    now = new Date();
    var valor1 = "Bom dia";
    var valor2 = "Boa tarde";
    var valor3 = "Boa noite";
    var valor4 = ", seja bem-vindo";

    if ((window.navigator.appName) == "Netscape")
        {if ((now.getHours() >= 0) && (now.getHours() <= 12))
            document.write (valor1+inString+valor4)
        else if ((now.getHours() >= 12) && (now.getHours() <= 18))
	    document.write (valor2+inString+valor4)
        else if ((now.getHours() >= 18) && (now.getHours() <= 23))
	    document.write (valor3+valor4)}
    else
        {if ((now.getHours() >= 0) && (now.getHours() <= 12))
            document.write (valor1+valor4)
        else if ((now.getHours() >= 12) && (now.getHours() <= 18))
	    document.write (valor2+valor4)
        else if ((now.getHours() >= 18) && (now.getHours() <= 23))
	    document.write (valor3+valor4)}
}

function allowInString (InString, RefString)  {
	if(InString.length==0) return (false);
	for (Count=0; Count < InString.length; Count++)  {
		TempChar= InString.substring (Count, Count+1);
		if (RefString.indexOf (TempChar, 0)==-1)  
			return (false);
	}
	return (true);
}

function allowNotInString (InString, RefString)  {
	if(InString.length==0) return (false);
	for (Count=0; Count < InString.length; Count++)  {
		TempChar= InString.substring (Count, Count+1);
		if (RefString.indexOf (TempChar, 0)!=-1)  
			return (false);
	}
	return (true);
}

function key_press_login_senha () {
   var whichKey = window.event.keyCode;
   var realKey = String.fromCharCode(whichKey);

   realKey = realKey.toUpperCase();

   if (allowInString(realKey, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ') == false) event.returnValue = false
   else window.event.keyCode = realKey.charCodeAt();
}

function key_press_numero (strAdicional) {
   strAdicional = strAdicional + '';

   var whichKey = window.event.keyCode;
   var realKey = String.fromCharCode(whichKey);

   realKey = realKey.toUpperCase();

   if (allowInString(realKey, '0123456789'+strAdicional) == false) event.returnValue = false
   else window.event.keyCode = realKey.charCodeAt();
}

function key_press_maiuscula () {
   var whichKey = window.event.keyCode;
   var realKey = String.fromCharCode(whichKey);

   realKey = realKey.toUpperCase();
   window.event.keyCode = realKey.charCodeAt();
}

function key_press_estado () {
   var whichKey = window.event.keyCode;
   var realKey = String.fromCharCode(whichKey);

   realKey = realKey.toUpperCase();

   if (allowInString(realKey, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ') == false) event.returnValue = false
   else window.event.keyCode = realKey.charCodeAt();
}

function VerificarCampos (NomeForm, Campos) {
    var contador = 0;

    while (contador <= Campos.length-1) {
        valor = NomeForm.elements(Campos[contador]).value;

        if (valor == '') {
            alert('Algum campo deixou de ser preenchido ou seu valor é inválido.');
            return (false);
        }

        contador++
    }

    return (true);
}

function stripChar (InString, StripThis)  {
	OutString="";
	for (Count=0; Count < InString.length; Count++)  {
		TempChar=InString.substring (Count, Count+1);
		if (TempChar!=StripThis)
			OutString=OutString+TempChar;
	}
	return (OutString);
}

function placeFocus() {
    if (document.forms.length > 0) {
        var field = document.forms[0];

        for (i = 0; i < field.length; i++) {
            if ((field.elements[i].type == "text") || (field.elements[i].type == "textarea")) {
                document.forms[0].elements[i].focus();
                document.forms[0].elements[i].select();
                break;
            }
        }
    }
}

function mOver(src, clrOver) {
    if (!src.contains(event.fromElement)) {
        src.style.cursor = 'hand';
        src.bgColor = clrOver;
    }
}

function mOut(src, clrIn) {
    if (!src.contains(event.toElement)) {
        src.style.cursor = 'default';
        src.bgColor = clrIn;
    }
}

function mClick(src) {
    if(event.srcElement.tagName == 'TD') {
        src.children.tags('A')[0].click();
    }
}

function ShowHide(id)
{
	el = document.getElementById(id);
	var display = el.style.display ? '' : 'none';
	el.style.display = display;
}

function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0;(a=document.getElementsByTagName("link")[i]);i++)
    {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}


function ValidarData(pStr) {
    var reDate5 = /^((0[1-9]|[12]\d)\/(0[1-9]|1[0-2])|30\/(0[13-9]|1[0-2])|31\/(0[13578]|1[02]))\/\d{4}$/;
    var reDate = reDate5;

    if (reDate.test(pStr)) {
        return (true);
    }
    else if (pStr != null && pStr != "") {
        alert('Algum campo deixou de ser preenchido ou seu valor é inválido.');
        return (false);
    }
}
