﻿// JScript File
// Abre janela pop-up centralizada
function Centrar(arquivo, janela, largura, altura, scrollbar) {
	posx = (screen.width / 2) - (largura / 2);
	posy = (screen.height / 2) - (altura / 2);
	features = "width=" + largura + " ,height=" + altura + " ,top=" + posy + " ,left=" + posx + "," + scrollbar;
	window.open(arquivo, "", features);
}

function dateTab(origem,tipoCampo,destino){
	switch (tipoCampo){
		case 1 : //Campo de Dia/Mês
				{
					if(origem.value.length == 2)
						destino.focus();
					break;
				}
		case 2 : //Campo Ano
				{
					if(origem.value.length == 4)
						destino.focus();
					break;
				}
		case 3 : //Data Completa: "dd/MM/yyyy"
				{
					if(origem.value.length == 10)
						destino.focus();
					break;
				}
	}
}

// Formata campos de data, CPF e CNPJ
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);
    }
}

//Seleciona os elementos do gridview
function selecionarLinhas(ckall, dtg) { 
   var actVar = ckall.checked ;
   for(var i = 0; i < document.forms[0].length; i++) {
      if (document.forms[0].elements[i].type == "checkbox") {
         if ((document.forms[0].elements[i].name.indexOf("chkItem") != -1) && (document.forms[0].elements[i].name.indexOf(dtg) != -1)) {
            document.forms[0].elements[i].checked = actVar;
         }
      }
   }
}

// Seta os valores selecionados via popup para Tipo de Serviço
function dadosTipoServico(CodTipoServico, NomTipoServico){
	document.form1.txtCodTipoServico.value = CodTipoServico;
	document.form1.txtTipoServico.value = NomTipoServico;
}

function setaVisibilidade(valor){
    if (valor == "casa"){
        document.getElementById("dvCadastro").style.visibility = "visible";
    }
    else
    {
        document.getElementById("dvCadastro").style.visibility = "hidden";
    }
}

