/***Arquivo Padroes.js -    criacao e controle dos processos padroes    ***/
/**************************************************************************/
/*** Funções: VerificarLogin()						***/
/**************************************************************************/

function VerificarLogin()
{
	if (document.frmLogin.txtNmUsuario.value == '') {
		alert ('O campo do Nome do usuário esta em branco!!!');
		document.frmLogin.txtNmUsuario.focus();
		return false;
	}
	if (document.frmLogin.txtSenha.value == '') {
		if (!confirm("O campo da senha esta em branco. Deseja continuar?")) {
			document.frmLogin.txtSenha.focus();
			return false;
		}
	}
}

// Pegar a Data, Dia da Semana mais o periodo (manhã/tarde/noite)
var diaw = new Date();
var mes = diaw.getMonth() + 1;
var dNome = diaw.getDay() + 1;
var dia = diaw.getDate();
var ano = diaw.getYear();
var horario= diaw.getHours();

if (dia < 10)
        dia = "0" + dia
if (mes < 10)
        mes = "0" + mes
if (ano < 2000)
        ano = "19" + ano

if ((horario>=0)&&(horario<12))
     var horario = "Bom Dia"
if ((horario>=12)&&(horario<18))
     var horario = "Boa Tarde"
if ((horario>=18)&&(horario<24))
     var horario = "Boa Noite"

if(dNome==1) semana = "Domingo";
if(dNome==2) semana = "Segunda-feira";
if(dNome==3) semana = "Terça-feira";
if(dNome==4) semana = "Quarta-feira";
if(dNome==5) semana = "Quinta-feira";
if(dNome==6) semana = "Sexta-feira";
if(dNome==7) semana = "Sábado";
if(mes==1) mesextenso = "janeiro";
if(mes==2) mesextenso = "fevereiro";
if(mes==3) mesextenso = "março";
if(mes==4) mesextenso = "abril";
if(mes==5) mesextenso = "maio";
if(mes==6) mesextenso = "junho";
if(mes==7) mesextenso = "julho";
if(mes==8) mesextenso = "agosto";
if(mes==9) mesextenso = "setembro";
if(mes==10) mesextenso = "outubro";
if(mes==11) mesextenso = "novembro";
if(mes==12) mesextenso = "dezembro";
var data = (" " + semana + ", " + dia + " de " + mesextenso + " de " + ano);

function MouseOvr(src){ 
	if (!src.contains(event.fromElement)){ 
		src.style.cursor = 'hand'; 
		src.className = 'Ativa'; 
	} 
} 
function MouseOut(src){ 
	if (!src.contains(event.toElement)){ 
		src.style.cursor = 'default'; 
		src.className = 'Inativa'; 
	} 
} 
function MouseClk(src){ 
	if(event.srcElement.tagName=='TD')
		src.children.tags('A')[0].click();
}

function ChamareSOA003(pPrograma,pRecId) {
	weSOA003 = open("esoa003.ASP?Programa=" + pPrograma + "&RecId=" + pRecId,
			"weSOA003",						
			"toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=600,height=450, top=10, left=100");
	if (weSOA003.opener == null)
		weSOA003.opener = self;
	weSOA003.focus();
}

function ChamareSOAReport(pUrl,pNomeJanela) {
	var sReports = pUrl.substring(0,7);
        //if (sReports.toUpperCase()=='REPORTS') pUrl = 'http://172.25.56.23/esoa/' + pUrl;
        //if (sReports.toUpperCase()=='REPORTS') pUrl = 'http://172.25.57.253/esoa/' + pUrl;
        if (sReports.toUpperCase()=='REPORTS') pUrl = 'http://reports.rrdnet.com.br/esoareports/' + pUrl;
        //pUrl = 'ManutServRel.htm';
        
	//if (pNomeJanela == null) pNomeJanela = 'weSOAReport'
	if (pNomeJanela == null) pNomeJanela = ''
	
	weSOAReport = open(pUrl,
			pNomeJanela,
			"toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=750,height=500, top=10, left=10");
	if (weSOAReport.opener == null)
		weSOAReport.opener = self;
	weSOAReport.focus();
}

function AbrirJanela(pUrl,pNomeJanela,pWidth,pHeight,pTop,pLeft) {
	pNomeJanela = pNomeJanela||'wAJ' //Valor o pNomeJanela ou wAJ se null
	pWidth = pWidth||750             //Valor o pWidth ou 750 se null
	pHeight = pHeight||500           //Valor o pHeight ou 500 se null
	pTop = pTop||10                  //Valor o pTop ou 10 se null
	pLeft = pLeft||10                //Valor o pLeft ou 10 se null
	wAJ = open(pUrl,
		   pNomeJanela,
		   'toolbar=no,location=no,directories=no,status=yes,scrollbars=yes,resizable=yes,copyhistory=no,width='+pWidth+',height='+pHeight+',top='+pTop+',left='+pLeft+',menubar=no')
	if (wAJ.opener == null)
		wAJ.opener = self;
	wAJ.focus();
}

function CrystalReportDate(pData) {
	var sData = pData.substring(6,10) + ',' + pData.substring(3,5) + ',' + pData.substring(0,2);
	return sData;
}

function AbrirHelp(pUrl,pNomeJanela,pWidth,pHeight,pTop,pLeft) {
	pNomeJanela = pNomeJanela
	pWidth = pWidth
	pHeight = pHeight
	pTop = pTop
	pLeft = pLeft
	wAJ = open(pUrl,
		   pNomeJanela,'toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,copyhistory=no,width='+pWidth+',height='+pHeight+',top='+pTop+',left='+pLeft+',menubar=no')
	if (wAJ.opener == null)
		wAJ.opener = self;
	wAJ.focus();
}


// Funções do menu

if (navigator.appName == "Netscape"){
	layerRef="document.layers";
	styleSwitch="";
	visible = 'show';
	hidden = 'hide';
} else {
	layerRef="document.all";
 	styleSwitch=".style";
	visible = 'visible';
	hidden = 'hidden';
}
function MenuOpcao(src,mnuAtual,mnuProximo){
	eval(layerRef+'["'+mnuAtual+'"]'+styleSwitch+'.visibility="'+hidden+'"');
	eval(layerRef+'["'+mnuProximo+'"]'+styleSwitch+'.visibility="'+visible+'"');
}
function MouseOvr(src,clrOver){ 
	if (!src.contains(event.fromElement)){ 
		src.style.cursor = 'hand'; 
		src.bgColor = clrOver; 
	} 
} 
function MouseOut(src,clrIn){ 
	if (!src.contains(event.toElement)){ 
		src.style.cursor = 'default'; 
		src.bgColor = clrIn; 
	} 
} 
function MouseClk(src){ 
	if(event.srcElement.tagName=='TD'){
		src.children.tags('A')[0].click();
	}
}
function ChainPrograma(src,pPrograma){ 
	parent.eSOAPath.MontarPath(src.innerText);
	parent.eSOACentro.location.replace(pPrograma);
	parent.EsconderMenu();
}


//Abrindo Calendário
function AbrirCalendario(pCampo,pFuncao,pAnosAnterioresA1996) {
	if (!pCampo)  pCampo  = '';
	if (!pFuncao) pFuncao = '';
	if (!pAnosAnterioresA1996) pAnosAnterioresA1996  = 'N';
	
	wCalendario = open(	"esoa005.ASP?NomeCampo=" + pCampo + "&Funcao=" + pFuncao + "&AnosAnterioresA1996=" + pAnosAnterioresA1996,
				"wCalendario",
				"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=200, height=192, top=140, left=300");
	if (wCalendario.opener == null)
		wCalendario.opener = self;
		wCalendario.focus();
}
	
	
function ValidaNumeroInteiro(sTexto){
	var ValidChars = "0123456789";
	var NumeroInt=true;
	var Char;
 
	for (i = 0; i < sTexto.length && NumeroInt == true; i++) { 
		Char = sTexto.charAt(i); 
		if (ValidChars.indexOf(Char) == -1) NumeroInt = false;
	}
	return NumeroInt;
}

function ColocarClasseMenu001(e) {
	if (!e) var e=window.event;
	var S=e.srcElement;
	while (S.tagName!="TD") {
		S=S.parentElement;
	}
	S.className="Menu001";
}

function ColocarClasseMenu002(e) {
	if (!e) var e=window.event;
	var S=e.srcElement;
	while (S.tagName!="TD") {
		S=S.parentElement;
	}
	S.className="Menu002";
}

//Capturando a tecla
function document_onkeypress() {
	el = event.srcElement;
	if (el.type== "text" || el.type == "textarea") {
		var iKeyCode=parseInt(window.event.keyCode);
		if ( (iKeyCode<32 || iKeyCode>126) && (iKeyCode!=8) && (iKeyCode!=13) ) { 
			alert ('[ '+String.fromCharCode(iKeyCode)+' ] Caracter Inválido!\n\nNão utilize acentuação, "ç" ou qualquer caracter gráfico.');
			event.srcElement.focus();
			return false;
		};
	}
}

document.onkeypress = document_onkeypress;
