function CaixaBaixa(fsValor, foForm, foNome) { 
	if (window.event.keyCode >= 65 && window.event.keyCode <= 90){
		x = new String(document.forms[foForm].elements[foNome].value);
		document.forms[foForm].elements[foNome].value = x.toLowerCase();
	}
} 

function xGetElementById(e) {
  if(typeof(e)!='string') return e;
  if(document.getElementById) e=document.getElementById(e);
  else if(document.all) e=document.all[e];
  else e=null;
  return e;
}

function xDef() {
  for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])=='undefined') return false;}
  return true;
}

function xShow(objeto) {
  if(!(objeto=xGetElementById(objeto))) return;
  if(objeto.style && xDef(objeto.style.visibility)){ 
  var x;
  var y;
	if (navigator.appName == 'Netscape'){
		objeto.style.top='px';
		objeto.style.left='380px';
	}
	else{
		x = event.clientX+document.body.scrollLeft; 
		y = event.clientY+document.body.scrollTop;
 		objeto.style.top= y + -120 +"px";
 		objeto.style.left= x + 5 +"px";
	}
  objeto.style.visibility='visible';
  }
}

function xHide(e) {
  if(!(e=xGetElementById(e))) return;
  	e.style.top='10px';
	e.style.left='10px';
  if(e.style && xDef(e.style.visibility)) e.style.visibility='hidden';
}


function validaEmail(Email){
	var filter = /^(([a-zA-Z0-9_-])+(([\.\])+([a-zA-Z0-9_-]{0,1})))+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; 
	var arrayEmail = Email.split(";"); //Separa os email 
	for (var i=0;i < arrayEmail.length; i++){ //varre a lista de emails 
		if ( !filter.test(arrayEmail[i]) ){ 
			return false; //se tiver erro sai com false 
		}
		else{ 
			return true; // se nao achou erro retorrna verdadeiro 
		}
	}
}
function enviarEmail(){
	if(document.form.txtNome.value==''){
		alert('Informe um nome!');
		document.form.txtNome.focus();
	}
	else if(document.form.txtEmail.value==''){
		alert('Informe um e-mail!');
		document.form.txtEmail.focus();
	}
	else if(validaEmail(document.form.txtEmail.value)==false){
		alert('E-mail inválido');
		document.form.txtEmail.value = '';
	}
	else if(document.form.txtAssunto.value==''){
		alert('Informe um assunto!');
		document.form.txtAssunto.focus();
	}
	else if(document.form.txtMsg.value==''){
		alert('Digite uma mensagem!');
		document.form.txtMsg.focus();
	}
	else{
		document.form.action='?ac=contato';
		document.form.submit();
	}
}
function busca(valor,teclapres){
   var tecla = 0;
   if(document.all){
        tecla = teclapres.keyCode;
    }
    else{
      tecla = teclapres.which;
      if(tecla==1){tecla=0}
    }
    if (tecla == 13 || tecla == 0){
       if(document.formBusca.txtCriterio.value==''){
			alert('Informe um critério de busca!');
			document.formBusca.txtCriterio.focus();
		}
		else{
			document.formBusca.action='?ac=busca';
			document.formBusca.submit();
		}
   } 
}
function popup_tarifas(id,hotel,obs){
	window.open('?ac=UHs&id='+id+'&hotel='+hotel+'&obs='+obs,'popup','status=no,menubar=no,scrollbars=yes,toolbar=no,location=no,width=450,height=370,top=50,left=100');
}
function atualizarimagem(valor,div){
	var frame=document.getElementById("iFrameImagem");
	frame.src='?ac=carregar_imagem&id='+valor+'&div='+div;
} 