function saudacao () {
    now = new Date();
    var valor1 = "Bom dia";
    var valor2 = "Boa tarde";
    var valor3 = "Boa noite";
    var valor4 = "";

    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();
    }
}
