﻿// JScript File
        function CallPrint(strid){
            var prtContent = document.getElementById(strid);
            var WinPrint = window.open('','','left=0,top=0,width=800,height=600,menubar=1,mainbar=1,scrollbars=1,status=1');
            /*WinPrint.document.write('<link href="interface_web_impressao_pop.css" rel="stylesheet" type="text/css"><div align=center>IPDEP - Instituto de Pesquisa e Desenvolvimento Público e Privado</div><br>' + prtContent.innerHTML);*/
            WinPrint.document.write('<link href="interface_web_impressao_pop.css" rel="stylesheet" type="text/css">' + prtContent.innerHTML);
            WinPrint.document.close();
            WinPrint.focus();
            WinPrint.print();
            //WinPrint.close();
            //prtContent.innerHTML=strOldOne;
        } 
        function CallPrint2(strid){
            var prtContent = document.getElementById(strid);
            var WinPrint = window.open('','','left=0,top=0,width=800,height=600,menubar=1,mainbar=1,scrollbars=1,status=1');
            WinPrint.document.write('<link href="interface_web_impressao_pop.css" rel="stylesheet" type="text/css">' + prtContent.innerHTML);
            //WinPrint.document.close();
            //WinPrint.focus();
            //WinPrint.print();
            //WinPrint.close();
            //prtContent.innerHTML=strOldOne;
        }
        function CallPrintCartao(strid){
            var prtContent = document.getElementById(strid);
            var WinPrint = window.open('','','left=0,top=0,width=800,height=600,menubar=1,mainbar=1,scrollbars=1,status=1');
            WinPrint.document.write('<link href="interface_web_impressao_pop.css" rel="stylesheet" type="text/css"><div style="width: 100%; height: 0.4cm;"></div>' + prtContent.innerHTML);
            //WinPrint.document.close();
            //WinPrint.focus();
            //WinPrint.print();
            //WinPrint.close();
            //prtContent.innerHTML=strOldOne;
        } 
	    function abre(theURL,winName,features) {
		    window.open(theURL,winName,features);
		}
		function abrePop(theURL) {
		    window.open(theURL, '', 'width=800, height=700, resizable=1, menurbar=1, status=1, scrollbars=1');
		}
	    //mascara para o form
	    function formatar(src, mask) 
	    {
	    var i = src.value.length;
	    var saida = mask.substring(0,1);
	    var texto = mask.substring(i)
	    if (texto.substring(0,1) != saida) 
	    {
		    src.value += texto.substring(0,1);
	    }
	    }
	    /***
	    * AUTO TAB - ao prencher o campo, automaticamente manda o foco para o próximo!
	    ***/
	    var isNN = (navigator.appName.indexOf("Netscape")!=-1);
	    function autoTab(input,len, e) {
		    var keyCode = (isNN) ? e.which : e.keyCode;
		    var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
		    if(input.value.length >= len && !containsElement(filter,keyCode)) {
			    input.value = input.value.slice(0, len);
			    input.form[(getIndex(input)+1) % input.form.length].focus();
	    }
	    function containsElement(arr, ele) {
		    var found = false, index = 0;
		    while(!found && index < arr.length)
		    if(arr[index] == ele)
			    found = true;
		    else
			    index++;
			    return found;
	    }
	    function getIndex(input) {
		    var index = -1, i = 0, found = false;
		    while (i < input.form.length && index == -1)
		    if (input.form[i] == input)index = i;
		    else i++;
			    return index;
		    }
		    return true;
	    }
	    //Fim da Função AutoTab
	    var cor;
	    function selecionaGrid( elemento ) {
		    cor=elemento.style.backgroundColor;
		    elemento.style.backgroundColor = "#DDDDDD";
	    }
	    // Função para mudar a linha ao de-selecionar
	    function deSelecionaGrid( elemento) {
		    elemento.style.backgroundColor = cor; 
	    }
	    
	    /*
		function FormataValor(campo,tammax,teclapres) {
				var tecla = teclapres.keyCode;
				vr = document.aspnetForm[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 ){ 
					document.aspnetForm[campo].value = vr; }
				if ( (tam > 2) && (tam <= 5) ){
					document.aspnetForm[campo].value = vr.substr( 0, tam - 2 ) + ',' + vr.substr( tam - 2, tam ); }
				if ( (tam >= 6) && (tam <= 8) ){
					document.aspnetForm[campo].value = vr.substr( 0, tam - 5 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ); }
				if ( (tam >= 9) && (tam <= 11) ){
					document.aspnetForm[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) ){
					document.aspnetForm[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) ){
					document.aspnetForm[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 SetHelp(txt) {
 document.getElementById('lblStatus1').innerHTML = txt;
}


//Formata valor
//ex.: onKeyDown='FormataValor("valor", 13, event)
//Obs.: "valor" é o nome do campo, 13 o tamanho máximo permitido de carac. do campo e event é a tecla pressionada'
function FormataValor(obj,tammax,teclapres) {
 var tecla = teclapres.keyCode;
 vr = obj.value;
 vr = vr.replace( "/", "" );
 vr = vr.replace( "/", "" );
 vr = vr.replace( ",", "" );
 vr = vr.replace( ",", "" );
 vr = vr.replace( ".", "" );
 vr = vr.replace( ".", "" );
 vr = vr.replace( ".", "" );
 vr = vr.replace( ".", "" );
 //Replaces adicionais
 //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 ){ 
   obj.value = vr ; }
  if ( (tam > 2) && (tam <= 5) ){
   obj.value = vr.substr( 0, tam - 2 ) + ',' + vr.substr( tam - 2, tam ) ; }
  if ( (tam >= 6) && (tam <= 8) ){
   obj.value = vr.substr( 0, tam - 5 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ; }
  if ( (tam >= 9) && (tam <= 11) ){
   obj.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) ){
   obj.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) ){
   obj.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 JsDelete()
	    {
		    if (confirm ("Você deseja confirmar essa ação?"))
		    {
			    return true;
		    }
		    else
		    {
			    return false;
		    }
	    }
	    function JsDelete2(msg)
	    {
		    if (confirm (msg))
		    {
			    return true;
		    }
		    else
		    {
			    return false;
		    }
	    }
    
