/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  Banco de Funções (Java Script) do SIAP
  Programador : Leandro Sampaio Naves
  Data Criação: 23/04/2003
  Descrição   : Centralizador de funções .JS 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//  Comando que Redimenciona o Tamanho da Tela
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

window.moveTo(0,1)
//window.resizeTo(800,572)
document.title = "CTIS - Help ISE"

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//  Função que cria a menu ao clicar com o botão direito do Mouse
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

var isie=0;
if(window.navigator.appName=="Microsoft Internet Explorer"&&window.navigator.appVersion.substring(window.navigator.appVersion.indexOf("MSIE")+5,window.navigator.appVersion.indexOf("MSIE")+8)>=5.5) {
isie=1;
}
else {
isie=0;
}
if(isie) {
var html="";
html+='<TABLE STYLE="border:1pt solid #808080" BGCOLOR="#CCCCCC" WIDTH="140" HEIGHT="220" CELLPADDING="0" CELLSPACING="1">';
html+='<ST'+'YLE TYPE="text/css">\n';
html+='a:link {text-decoration:none;font-family:Arial;font-size:8pt;}\n';
html+='a:visited {text-decoration:none;font-family:Arial;font-size:8pt;}\n';
html+='td {font-size:8pt;}\n';
html+='</ST'+'YLE>\n';
html+='<SC'+'RIPT LANGUAGE="JavaScript">\n';
html+='\n<'+'!--\n';
html+='window.onerror=null;\n';
html+='/'+' -'+'->\n';
html+='</'+'SCRIPT>\n';
html+='<TR><TD STYLE="border:1pt solid #CCCCCC" ID="i0" ONMOUSEOVER="document.all.i0.style.background=\'#CFD6E8\';document.all.i0.style.border=\'1pt solid #737B92\';" ONMOUSEOUT="document.all.i0.style.background=\'#CCCCCC\';document.all.i0.style.border=\'1pt solid #CCCCCC\';" ONCLICK="window.history.go(-1);">&nbsp;<IMG SRC="' + PathGif + 'menuback.gif" WIDTH="12" HEIGHT="12" BORDER="0" HSPACE="0" VSPACE="0" ALIGN="absmiddle">&nbsp;Voltar</TD></TR>';
html+='<TR><TD STYLE="border:1pt solid #CCCCCC" ID="i1" ONMOUSEOVER="document.all.i1.style.background=\'#CFD6E8\';document.all.i1.style.border=\'1pt solid #737B92\';" ONMOUSEOUT="document.all.i1.style.background=\'#CCCCCC\';document.all.i1.style.border=\'1pt solid #CCCCCC\';" ONCLICK="window.history.go(1);">&nbsp;<IMG SRC="' + PathGif + 'menuforward.gif" WIDTH="12" HEIGHT="12" BORDER="0" HSPACE="0" VSPACE="0" ALIGN="absmiddle">&nbsp;Avançar</TD></TR>';
html+='<TR><TD STYLE="border:1pt solid #CCCCCC"><IMG SRC="' + PathGif + 'pixel.gif" WIDTH="130" HEIGHT="1"></TD></TR>';
html+='<TR><TD STYLE="border:1pt solid #CCCCCC" ID="i6" ONMOUSEOVER="document.all.i6.style.background=\'#CFD6E8\';document.all.i6.style.border=\'1pt solid #737B92\';" ONMOUSEOUT="document.all.i6.style.background=\'#CCCCCC\';document.all.i6.style.border=\'1pt solid #CCCCCC\';" ONCLICK="window.parent.print();">&nbsp;<IMG SRC="' + PathGif + 'menuprint.gif" WIDTH="12" HEIGHT="12" BORDER="0" HSPACE="0" VSPACE="0" ALIGN="absmiddle">&nbsp;Imprimir</TD></TR>';
html+='<TR><TD STYLE="border:1pt solid #CCCCCC" ID="i7" ONMOUSEOVER="document.all.i7.style.background=\'#CFD6E8\';document.all.i7.style.border=\'1pt solid #737B92\';" ONMOUSEOUT="document.all.i7.style.background=\'#CCCCCC\';document.all.i7.style.border=\'1pt solid #CCCCCC\';" ONCLICK="window.parent.location.href=window.parent.location.href;">&nbsp;<IMG SRC="' + PathGif + 'menurefresh.gif" WIDTH="12" HEIGHT="12" BORDER="0" HSPACE="0" VSPACE="0" ALIGN="absmiddle">&nbsp;Atualizar</TD></TR>';
html+='<TR><TD STYLE="border:1pt solid #CCCCCC"><IMG SRC="' + PathGif + 'pixel.gif" WIDTH="130" HEIGHT="1"></TD></TR>';
html+='<TR><TD STYLE="border:1pt solid #CCCCCC" ID="i8" ONMOUSEOVER="document.all.i8.style.background=\'#CFD6E8\';document.all.i8.style.border=\'1pt solid #737B92\';" ONMOUSEOUT="document.all.i8.style.background=\'#CCCCCC\';document.all.i8.style.border=\'1pt solid #CCCCCC\';" ONCLICK="if(window.parent.document.body.style.zoom!=0) window.parent.document.body.style.zoom*=1.6; else window.parent.document.body.style.zoom=1.6;">&nbsp;<IMG SRC="' + PathGif + 'menuzoom.gif" WIDTH="12" HEIGHT="12" BORDER="0" HSPACE="0" VSPACE="0" ALIGN="absmiddle">&nbsp;Zoom In</TD></TR>';
html+='<TR><TD STYLE="border:1pt solid #CCCCCC" ID="i9" ONMOUSEOVER="document.all.i9.style.background=\'#CFD6E8\';document.all.i9.style.border=\'1pt solid #737B92\';" ONMOUSEOUT="document.all.i9.style.background=\'#CCCCCC\';document.all.i9.style.border=\'1pt solid #CCCCCC\';" ONCLICK="if(window.parent.document.body.style.zoom!=0) window.parent.document.body.style.zoom*=0.625; else window.parent.document.body.style.zoom=0.625;">&nbsp;<IMG SRC="' + PathGif + 'menuzoom.gif" WIDTH="12" HEIGHT="12" BORDER="0" HSPACE="0" VSPACE="0" ALIGN="absmiddle">&nbsp;Zoom Out</TD></TR>';
html+='</TABLE>';

var oPopup = window.createPopup();
}
function dopopup(x,y) {
if(isie) {
var oPopupBody = oPopup.document.body;
oPopupBody.innerHTML = html;
oPopup.show(x, y, 140, 220, document.body);
}
}

function click(e) {
if(isie) {
if(document.all) {
if(event.button==2||event.button==3) {
dopopup(event.x-1,event.y-1);
}
}
}
}

if(isie) {
//document.oncontextmenu = function() { dopopup(event.x,event.y);return false; }
//document.onmousedown = click;
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// Abre nova Janela
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function AbreNovaJanela(url, nome_pg, width, height)
{
	NewWin=window.open(url,nome_pg,'toolbar=0,menubar=0,status=0,resizable=1,top=177,left=10,width=' + width + ',height=' + height);
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// Retorna a Data por Extenso
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function data()
	{
	  var D = new Date();
	  var temp  = new Array('Segunda','Terça','Quarta','Quinta','Sexta','Sábado','Domingo');
	  var temp1 = new Array('Janeiro','Fevereiro','Março','Abril','Maio','Junho','Julho','Agosto','Setembro','Outubro','Novembro','Dezembro');
	  mes = temp1[D.getMonth()];
	  alert(D.getDay());
	  semana = temp[D.getDay()-1];
	  var data = semana + " , " + D.getDate() + " de " + mes + " de " + D.getFullYear();	  
	  document.write(data);
	}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// Insere Mascara na digitação de dados
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function Mascara(formato, keypress, objeto, size)
{
	campo = eval(objeto);

	if (formato=='textarea'){
		if (campo.value.length < size){
			event.returnValue=true;
		}
		else event.returnValue=false;
	}

	if (formato=='numero')
	{
		caracteres = '01234567890';
		separacoes = 1;
		separacao1 = '.';
		conjuntos = 2;
		conjunto1 = 4;
		conjunto2 = 1;
		if ((caracteres.search(String.fromCharCode(keypress))!=-1) && campo.value.length < (conjunto1 + conjunto2 + 2))
		{
			if (campo.value.length == conjunto1) campo.value = campo.value + separacao1;
		}
			else event.returnValue=false;
	}

	if (formato=='data')
	{
		caracteres = '01234567890';
		separacoes = 2;
		separacao1 = '/';
		separacao2 = '/';
		conjuntos = 3;
		conjunto1 = 2;
		conjunto2 = 2;
		conjunto3 = 4;
		if ((caracteres.search(String.fromCharCode(keypress))!=-1) && campo.value.length < (conjunto1 + conjunto2 + conjunto3 + 2))
		{
			if (campo.value.length == conjunto1) campo.value = campo.value + separacao1;
			if (campo.value.length == conjunto1 + conjunto2 + 1) campo.value = campo.value + separacao2;
		}
		else event.returnValue=false;
	 }

	if (formato=='hora')
		{
		caracteres = '01234567890';
		separacoes = 1;
		separacao1 = ':';
		conjuntos = 2;
		conjunto1 = 2;
		conjunto2 = 2;
		if ((caracteres.search(String.fromCharCode(keypress))!=-1) && campo.value.length < (conjunto1 + conjunto2 + 1))
		{
		if (campo.value.length == conjunto1) campo.value = campo.value + separacao1;
		}
		else event.returnValue=false;
	 }

	if (formato=='cpf')
	 {
		caracteres = '01234567890';
		separacoes = 3;
		separacao1 = '.';
		separacao2 = '.';
		separacao3 = '-';
		conjuntos = 4;
		conjunto1 = 3;
		conjunto2 = 3;
		conjunto3 = 3;
		conjunto4 = 2;
		if ((caracteres.search(String.fromCharCode(keypress))!=-1) && campo.value.length < (conjunto1 + conjunto2 + conjunto3 + conjunto4 + 3))
		{
		if (campo.value.length == conjunto1) campo.value = campo.value + separacao1;
		if (campo.value.length == conjunto1 + conjunto2 + 1) campo.value = campo.value + separacao2;
		if (campo.value.length == conjunto1 + conjunto2 + conjunto3 + 2) campo.value = campo.value + separacao3;
		}
		else event.returnValue=false;
	 }

	if (formato=='cep')
	{
		caracteres = '01234567890';
		separacoes = 2;
		separacao1 = '.';
		separacao2 = '-';
		conjuntos = 3;
		conjunto1 = 2;
		conjunto2 = 3;
		conjunto3 = 3;
		if ((caracteres.search(String.fromCharCode(keypress))!=-1) && campo.value.length < (conjunto1 + conjunto2 + conjunto3 + 2))
		{
		if (campo.value.length == conjunto1) campo.value = campo.value + separacao1;
		if (campo.value.length == conjunto1 + conjunto2 + 1) campo.value = campo.value + separacao2;
		}
		else event.returnValue=false;
	}

	if (formato=='telefone')
		{
		caracteres = '01234567890-';
		separacoes = 0;
		conjuntos = 1;
		conjunto1 = 10;
		if ((caracteres.search(String.fromCharCode(keypress))!=-1) && campo.value.length < (conjunto1+ 1))
		{
		}
		else event.returnValue=false;
		}

		if (formato=='telcompleto')
		{
		caracteres = '01234567890()-';
		separacoes = 0;
		conjuntos = 1;
		conjunto1 = 15;
		if ((caracteres.search(String.fromCharCode(keypress))!=-1) && campo.value.length < (conjunto1+ 1))
		{
		}
		else event.returnValue=false;
	}

}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//   Mensagem na barra de status SIAP
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function FormataValor(campo,tammax,tecla) {
//        var tecla = teclapres.keyCode;
        vr = campo.value;
        vr = vr.replace( "/", "" );
        vr = vr.replace( "/", "" );
        vr = vr.replace( ",", "" );
        vr = vr.replace( ".", "" );
        vr = vr.replace( ".", "" );
        vr = vr.replace( ".", "" );
        vr = vr.replace( ".", "" );
        tam = vr.length;

        if (tam < tammax && tecla != 8){ tam = vr.length + 1 ; }

        if (tecla == 8 ){        tam = tam - 1 ; }

        if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ){
                if ( tam <= 2 ){
                         campo.value = vr ; }
                 if ( (tam > 2) && (tam <= 5) ){
                         campo.value = vr.substr( 0, tam - 2 ) + ',' + vr.substr( tam - 2, tam ) ; }
                 if ( (tam >= 6) && (tam <= 8) ){
                         campo.value = vr.substr( 0, tam - 5 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ; }
                 if ( (tam >= 9) && (tam <= 11) ){
                         campo.value = vr.substr( 0, tam - 8 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ; }
                 if ( (tam >= 12) && (tam <= 14) ){
                         campo.value = vr.substr( 0, tam - 11 ) + '.' + vr.substr( tam - 11, 3 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ; }
                 if ( (tam >= 15) && (tam <= 17) ){
                         campo.value = vr.substr( 0, tam - 14 ) + '.' + vr.substr( tam - 14, 3 ) + '.' + vr.substr( tam - 11, 3 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ;}
        }

}
//&&&&&&&&&&&&&&&&&&&&&&&

function validaData(campo) {
/*  var err=0
  a = campo.value;
  if (a.length != 10) err=1
  d = a.substring(0, 2)// day
  c = a.substring(2, 3)// '/'
  b = a.substring(3, 5)// month
  e = a.substring(5, 6)// '/'
  f = a.substring(6, 10)// year
  if (b<1 || b>12) err = 1
  if (c != '/') err = 1
  if (d<1 || d>31) err = 1
  if (e != '/') err = 1
  if (f<0 || f>2100) err = 1

  if (b==4 || b==6 || b==9 || b==11){
    if (d==31) err=1
  }
  if (b==2){
    var g=parseInt(f/4)
    if (isNaN(g)) {
      err=1
    }
    if (d>29) err=1
    if (d==29 && ((f/4)!=parseInt(f/4))) err=1
  }
  if (err==1) {
        campo.focus();
        alert('Entre com uma data valida no formato DD/MM/YYYY');
        return false;
  }
  else{
        return true;
  }*/
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

