function zoomMapa () {
	var PopUp_W = 800;
    var PopUp_H = 600;
    var PopUp_L = (screen.width - PopUp_W) / 2;
    var PopUp_T = ((screen.height - PopUp_H) / 2) - 50;
    PopUp_T = (PopUp_T > 0 ? PopUp_T : 0);
    var PopUp_Win = window.open('zoomMapa.html', '', 'width=' + PopUp_W + ', height=' + PopUp_H + ', left=' + PopUp_L + ', top=' + PopUp_T + ', resizable=no, scrollbars=no, toolbar=no, location=no, directories=no, status=no, menubar=no, copyhistory=no');
    if (parseInt(navigator.appVersion) >= 4) {
        PopUp_Win.window.focus();
    }
}

function atendimento () {
    var PopUp_W = 640;
    var PopUp_H = 455;
    var PopUp_L = (screen.width - PopUp_W) / 2;
    var PopUp_T = ((screen.height - PopUp_H) / 2) - 50;
    PopUp_T = (PopUp_T > 0 ? PopUp_T : 0);
    var PopUp_Win = window.open('./atendimento/chat/', '', 'width=' + PopUp_W + ', height=' + PopUp_H + ', left=' + PopUp_L + ', top=' + PopUp_T + ', resizable=no, scrollbars=no, toolbar=no, location=no, directories=no, status=no, menubar=no, copyhistory=no');
    if (parseInt(navigator.appVersion) >= 4) {
        PopUp_Win.window.focus();
    }
}

// Formatar Telefone
function formatarTelefone (Campo,e) { 
  var key = '';
  var len = 0;
  var strCheck = '0123456789';
  var aux = '';
  var whichCode = (window.Event) ? e.which : e.keyCode;
  if (whichCode == 13 || whichCode == 8 || whichCode == 0) { return true; /*Enter backspace ou FN qualquer um que no seja alfa numerico*/ }
  key = String.fromCharCode(whichCode);
  if (strCheck.indexOf(key) == -1) { return false; /*no  vlido*/ }
  aux =  formatarTelefoneRemove(Campo.value);
  len = aux.length;
  if (len >= 10) { return false; /*impede de digitar um telefone maior que 10*/ }
  aux += key;
  Campo.value = formatarTelefoneMont(aux);
  return false;
}

function formatarTelefoneMont (Telefone) {
  var aux = len = '';
  len = Telefone.length;
  if (len <= 9) { tmp = 5; }
  else { tmp = 6; }
  aux = '';
  for(i = 0; i < len; i++) {
    if (i == 0) { aux = '('; }
    aux += Telefone.charAt(i);
    if (i+1 == 2) { aux += ')'; }
    if (i+1 == tmp) { aux += '-'; }
  }
  return aux;
}

function formatarTelefoneRemove (Telefone) {
  var strCheck = '0123456789';
  var len = i = aux = '';
  len = Telefone.length;
  for (i = 0; i < len; i++) {
    if (strCheck.indexOf(Telefone.charAt(i))!=-1) {
      aux += Telefone.charAt(i);
    }
  }
  return aux;
}
// -----

// Formatao para qualquer mscara 
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);
  }
}
// -----

// Formatar Data
function formatarData(campo,teclapress) {
  if (somenteNumero(teclapress) == false) return false;
  var tecla = teclapress.keyCode;  
  vr = campo.value;
  vr = vr.replace(".","");
  vr = vr.replace("/","");
  vr = vr.replace("/","");
  tam = vr.length + 1;
  if (tecla != 9 && tecla != 8) {
    if (tam > 2 && tam < 5) {
      campo.value = vr.substr( 0, tam - 2  ) + '/' + vr.substr( tam - 2, tam );
    }
    if (tam >= 5 && tam <= 10) {
      campo.value = vr.substr( 0, 2 ) + '/' + vr.substr( 2, 2 ) + '/' + vr.substr( 4, 4 );
    }
  }
}
// -----

// Funo que Formata Valor
// Modificado por Anderson Böger Roveda - Testando no IE e FF
// Uso: onkeydown="formatarValor(this,20,event);"
function formatarValor(valor,tammax,event) {
  var tecla = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
  vr = valor.value;
  vr = vr.replace("/","");
  vr = vr.replace("/","");
  vr = vr.replace(",","");
  vr = vr.replace(".","");
  vr = vr.replace(".","");
  vr = vr.replace(".","");
  vr = vr.replace(".","");
  if (vr.length > 0) { vr = parseInt(vr,10); }
  vr = '' + vr
  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 ) {
      if (tam == 1) { valor.value = "0,0" + vr ; }
      else if (tam == 2) { valor.value = "0," + vr ; }
      else { valor.value = "" ; }
    }
    if ((tam > 2) && (tam <= 5)) { valor.value = vr.substr( 0, tam - 2 ) + ',' + vr.substr( tam - 2, tam ); }
    if ((tam >= 6) && (tam <= 8)) { valor.value = vr.substr( 0, tam - 5 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ); }
    if ((tam >= 9) && (tam <= 11)) { valor.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)) { valor.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)) { valor.value = vr.substr( 0, tam - 15 ) + '.' + vr.substr( tam - 15, 3 ) + '.' + vr.substr( tam - 12, 3 ) + '.' + vr.substr( tam - 9, 3 ) + ',' + vr.substr( tam - 8, 0 ) ; }
  }
}
// -----

// Formatar CEP
function formatarCEP (objeto) {
  if (objeto.value.indexOf("-") == -1 && objeto.value.length > 5) objeto.value = "";
  if (objeto.value.length == 5) objeto.value += "-";
}
// -----

// Somente Numero
function somenteNumero (e) {
  var key = '';
  var strCheck = '0123456789';
  var whichCode = (window.Event) ? e.which : e.keyCode;
  if (whichCode == 13 || whichCode == 8 || whichCode == 0) return true;
  key = String.fromCharCode(whichCode);
  if (strCheck.indexOf(key) == -1) return false;
  
}
/* ----- */

/* Open Window */
function OpenWindow (URL,Name,W,H,Scroll) {
  var WinLeft = (screen.width - W) / 2;
  var WinTop = (screen.height - H) / 2;
  WinProps = 'width='+W+',height='+H+',top='+WinTop+',left='+WinLeft+',scrollbars='+Scroll+',toolbar=0,location=0,directories=0,status=0,menuBar=0,resizable=0';
  Win = window.open(URL,Name,WinProps); 
  if (parseInt(navigator.appVersion) >= 4) {
    Win.window.focus();
  }
}
/* ----- */
