// Begin
var ns4 = (document.layers) ? true : false;
var ie4 = (document.all && !document.getElementById) ? true : false;
var ie5 = (document.all && document.getElementById) ? true : false;
var ns6 = (!document.all && document.getElementById) ? true : false;

//Tabulação
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;
}
//  End -->


//form extrato
function validaextrato(theForm)
{
  if (theForm.cp1CPF.value == "")
  {
    alert("O campo USUÁRIO não pode ser vazio!");
    theForm.cp1CPF.focus();
    return (false);
  }
  if (theForm.cp2SENHA.value == "")
  {
    alert("O campo SENHA não pode ser vazio!");
    theForm.cp2SENHA.focus();
    return (false);
  }
  return (true);
}

//form contato
function validacontato(theForm)
{
  if (theForm.cp1NOME.value == "")
  {
    alert("O campo NOME não pode ser vazio!");
    theForm.cp1NOME.focus();
    return (false);
  }
  if (theForm.cp2EMAIL.value == "")
  {
    alert("O campo EMAIL não pode ser vazio!");
    theForm.cp2EMAIL.focus();
    return (false);
  }
  if (theForm.cp3CIDADE.value == "")
  {
    alert("O campo CIDADE/UF não pode ser vazio!");
    theForm.cp3CIDADE.focus();
    return (false);
  }
  if (theForm.pminfor.value == "")
  {
    alert("O campo COMENTÁRIOS não pode ser vazio!");
    theForm.pminfor.focus();
    return (false);
  }
  return (true);
}

function go2url() {
//window.location = "javascript:self.history.go(-1)";
window.location = "inicio.asp";
}

function go2urlini() {
//window.location = "javascript:self.history.go(-1)";
window.location = "extrato_ini.asp";
}

function show(sw,obj) {
	// show/hide the divisions
	if (sw && (ie4 || ie5) ) document.all[obj].style.visibility = 'visible';
	if (!sw && (ie4 || ie5) ) document.all[obj].style.visibility = 'hidden';
	if (sw && ns4) document.layers[obj].visibility = 'visible';
	if (!sw && ns4) document.layers[obj].visibility = 'hidden';
}

function validabusca(theForm)
{
  if (theForm.csTipo.value == "")
  {
    alert("Selecione o TIPO!!");
    theForm.csTipo.focus();
    return (false);
  }
  if (theForm.csPara.value == "")
  {
    alert("Selecione uma opção PARA");
    theForm.csPara.focus();
    return (false);
  }
  return (true);
}

function placeFocus() {
if (document.forms.length > 0) {
var field = document.forms[0];
for (i = 0; i < field.length; i++) {
if ((field.elements[i].type == "text") || (field.elements[i].type == "textarea") || (field.elements[i].type.toString().charAt(0) == "s")) {
document.forms[0].elements[i].focus();
break;
         }
      }
   }
}


function show_window(name, url, left, top, width, height, toolbar, menubar, statusbar, scrollbar, resizable)
{
  toolbar_str = toolbar ? 'yes' : 'no';
  menubar_str = menubar ? 'yes' : 'no';
  statusbar_str = statusbar ? 'yes' : 'no';
  scrollbar_str = scrollbar ? 'yes' : 'no';
  resizable_str = resizable ? 'yes' : 'no';

  cookie_str = document.cookie;
  cookie_str.toString();

  pos_start  = cookie_str.indexOf(name);
  pos_end    = cookie_str.indexOf('=', pos_start);

  cookie_name = cookie_str.substring(pos_start, pos_end);

  pos_start  = cookie_str.indexOf(name);
  pos_start  = cookie_str.indexOf('=', pos_start);
  pos_end    = cookie_str.indexOf(';', pos_start);
  
  if (pos_end <= 0) pos_end = cookie_str.length;
  cookie_val = cookie_str.substring(pos_start + 1, pos_end);
  if (cookie_name == name && cookie_val  == "done")
    return;

  window.open(url, name, 'left='+left+',top='+top+',width='+width+',height='+height+',toolbar='+toolbar_str+',menubar='+menubar_str+',status='+statusbar_str+',scrollbars='+scrollbar_str+',resizable='+resizable_str);
}

function fotoZoom(img){
  foto1= new Image();
  foto1.src=(img);
  Controlla(img);
}
function Controlla(img){
  if((foto1.width!=0)&&(foto1.height!=0)){
    viewFoto(img);
  }
  else{
    funzione="Controlla('"+img+"')";
    intervallo=setTimeout(funzione,20);
  }
}
function viewFoto(img){
  largh=foto1.width+20;
  altez=foto1.height+20;
  stringa="width="+largh+",height="+altez;
  finestra=window.open(img,"",stringa);
}

function validaimovel(theForm)
{
  if (theForm.cp1NOME.value == "")
  {
    alert("O campo NOME não pode ser vazio!");
    theForm.cp1NOME.focus();
    return (false);
  }
  if (theForm.cp10ENDERECO.value == "")
  {
    alert("O campo ENDEREÇO não pode ser vazio!");
    theForm.cp10ENDERECO.focus();
    return (false);
  }
  if (theForm.cp3TELEFONE.value == "")
  {
    alert("O campo TELEFONE não pode ser vazio!");
    theForm.cp3TELEFONE.focus();
    return (false);
  }
  if (theForm.cp4CIDADE.value == "")
  {
    alert("O campo CIDADE não pode ser vazio!");
    theForm.cp4CIDADE.focus();
    return (false);
  }
  if (theForm.cp5ESTADO.value == "")
  {
    alert("O campo ESTADO não pode ser vazio!");
    theForm.cp5ESTADO.focus();
    return (false);
  }
  if (theForm.cp8DATACHEGADA.value == "")
  {
    alert("Informe a data prevista para sua CHEGADA!");
    theForm.cp8DATACHEGADA.focus();
    return (false);
  }
  if (theForm.cp9DTAASAIDA.value == "")
  {
    alert("Informe a data prevista para sua SAÌDA!");
    theForm.cp9DTAASAIDA.focus();
    return (false);
  }
  if (theForm.cp2EMAIL.value == "")
  {
    alert("O campo EMAIL não pode ser vazio!");
    theForm.cp2EMAIL.focus();
    return (false);
  }
  if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(theForm.cp2EMAIL.value)){
  return (true)
  }
  {
    alert("O E-mail não é válido!");
    theForm.cp2EMAIL.focus();
    return (false);
  }
  return (true);
}
// End