// JavaScript Document

// Funções Agendamento

	// Prevent users from typing any text 
	// into the Textbox
	function ProtectBox(e) 
	{
		return false;
	}
	 
	function novaAgenda(e, f, dia, mes, ano)
	{
	    GB_show("", "../pessoa_lsPop.aspx?horario=" + e + "&profissional=" + f + "&dia=" + dia + "&mes=" + mes + "&ano=" + ano, 500, 500, null)
	}
	function editaConsulta(e)
	{
	    GB_show("", "../consulta_ed.aspx?codigo=" + e, 500, 500, null)
	}
	function confirmaConsulta(e)
	{
	    GB_show("", "../consultaconf.aspx?codigo=" + e, 500, 500, null)
	}
	function cancelaConsulta(e)
	{
	    GB_show("", "../consultacanc.aspx?codigo=" + e, 500, 500, null)
	}
	function consultaPrint(e)
	{
	    contentwindow=window.open("consulta_print.aspx?codigo=" + e,'ContentWindow','toolbar=no,top=165,left=160,location=no,directories=no,status=no,menubar=no,resizable=no,scrollbars=no,width=500,height=500');
	}

// Fim Funções Agendamento

// Funções Gerais - Pop

	function novaPessoa(e,f)
	{
	    GB_show("", "../pessoa_addPop.aspx?codPessoa=" + e + "&codContrato=" + f, 500, 500, null)
	}

// Fim Funções Gerais - POP

//Função que lê o browser. Se não for IE gera alert

function verificaBrowser() {
    var browser=navigator.appName;
    var b_version=navigator.appVersion;
    var version=parseFloat(b_version);
    
    if (browser=='Microsoft Internet Explorer'&&version>=4)
      {
           

      }
    else
      {
         //var el = document.getElementById('div_erroBrowser_geral');
         //el.style.display = (el.style.display=="") ? "none" : "";
      }
}

// Função para máscara de números e data
// Exemplo de utilizacao: OnKeyPress="formatar('##/##/####', this)"

function formatar(mascara, documento){
  var i = documento.value.length;
  var saida = mascara.substring(0,1);
  var texto = mascara.substring(i)
  
  if (texto.substring(0,1) != saida){
	documento.value += texto.substring(0,1);
  }
  
}




 
// Função de Somente Números em um campo
// Exemplo de utilização: onkeypress='return SomenteNumero(event)'

function SomenteNumero(e){
    var tecla=(window.event)?event.keyCode:e.which;
    if((tecla > 47 && tecla < 58)) return true;
    else{
    if (tecla != 8) return false;
    else return true;
    }
}



// Função Valida CNPJ - CPF
////

function valida_cnpj(CPF,FORM,CAMPO) {
	var invalid, s;
	invalid = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;

	var s;

    var ValorCpf = CPF;
    var Campo = CAMPO;
    var FormEntrada = FORM;
    
    //alert(Campo);
    //alert(FormEntrada);

	if (ValorCpf > 0) {
		
	s = limpa_string(ValorCpf);
	
	// checa se é cpf	
	if (s.length == 11) {
		if (valida_CPF(ValorCpf) == false ) {
			alert("O CPF não é válido !");
			Campo.focus();
			return false;	}
     }
     
     // checa se é cnpj
	else if (s.length == 14) {
		if (valida_CGC(ValorCpf) == false ) {
			alert("O CNPJ não é válido !");
			Campo.focus();
			return false;	}
			}
		else {
			alert("O CPF/CNPJ não é válido !");
			Campo.focus();
			return false;
		}
	
// fim da funcao validar()
}
}
function limpa_string(S){
	// Deixa so' os digitos no numero
	var Digitos = "0123456789";
	var temp = "";
	var digito = "";

	for (var i=0; i<S.length; i++)	{
		digito = S.charAt(i);
		if (Digitos.indexOf(digito)>=0)	{
			temp=temp+digito	}
	} //for

	return temp
}
// fim da funcao


function valida_CPF(s)	{
	var i;
	s = limpa_string(s);
	var c = s.substr(0,9);
	var dv = s.substr(9,2);
	var d1 = 0;
	for (i = 0; i < 9; i++)
	{
		d1 += c.charAt(i)*(10-i);
	}
        if (d1 == 0) return false;
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(0) != d1)
	{
		return false;
	}

	d1 *= 2;
	for (i = 0; i < 9; i++)
	{
		d1 += c.charAt(i)*(11-i);
	}
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(1) != d1)
	{
		return false;
	}
        return true;
}

function valida_CGC(s)
{
	var i;
	s = limpa_string(s);
	var c = s.substr(0,12);
	var dv = s.substr(12,2);
	var d1 = 0;
	for (i = 0; i < 12; i++)
	{
		d1 += c.charAt(11-i)*(2+(i % 8));
	}
        if (d1 == 0) return false;
        d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(0) != d1)
	{
		return false;
	}

	d1 *= 2;
	for (i = 0; i < 12; i++)
	{
		d1 += c.charAt(11-i)*(2+((i+1) % 8));
	}
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(1) != d1)
	{
		return false;
	}
	return true;
}

// 





// Função para abrir Lightbox

function onoff1(id1) {
var el = document.getElementById(id1);

el.style.display = (el.style.display=="") ? "none" : "";

}

function onoff2(id1, id2) {
var el = document.getElementById(id1);
var ela = document.getElementById(id2);

el.style.display = (el.style.display=="") ? "none" : "";
ela.style.display = (ela.style.display=="") ? "none" : "";

}

function onoff3(id1, id2, id3) {
var el = document.getElementById(id1);
var ela = document.getElementById(id2);
var elb = document.getElementById(id3);
el.style.display = (el.style.display=="") ? "none" : "";
ela.style.display = (ela.style.display=="") ? "none" : "";
elb.style.display = (elb.style.display=="") ? "none" : "";
}
// Fim função Lightbox 


//Alterações Maicon

 function confirmBox(codigo) {
    alert(codigo);
       // if (confirm("Deseja mesmo excluir este registro?")) {

        //    location.href= "pessoa_ls.aspx?codPessoa=" + codigo;
        //    alert('Qualquer coisa');
     //   }

        }
  function ReciboSimplifPrint()
	{
	    contentwindow=window.open("fechamentoCaixa_print.aspx?op=n",'ContentWindow','toolbar=no,top=165,left=160,location=no,directories=no,status=no,menubar=no,resizable=no,scrollbars=no,width=500,height=500');
	} 
	
	function ReciboPrint()
	{
	    window.open("fechamentoCaixa_print.aspx",'ContentWindow','toolbar=no,top=165,left=160,location=no,directories=no,status=no,menubar=no,resizable=no,scrollbars=no,width=500,height=500');
	} 
	function ReciboGeralPrint(e)
	{
	    contentwindow=window.open("reciboprint.aspx?codigo=" + e,'ContentWindow','toolbar=no,top=165,left=160,location=no,directories=no,status=no,menubar=no,resizable=no,scrollbars=no,width=500,height=500');
	}   
	function ReciboDireitoPrint(e)
	{
	    contentwindow=window.open("reciboDireito_print.aspx?codigo=" + e,'ContentWindow','toolbar=no,top=165,left=160,location=no,directories=no,status=no,menubar=no,resizable=no,scrollbars=no,width=500,height=650');
	}   
	
	function AgendaPrint(e,f)
	{
	    contentwindow=window.open("Agenda_PrintPop.aspx?codigo=" + e +"data="+ f,'ContentWindow','toolbar=no,top=165,left=160,location=no,directories=no,status=no,menubar=no,resizable=no,scrollbars=yes,width=500,height=650');
	}   
 


//Fim das alterações
