function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function mostraLayer0(whichLayer)
{
  var elem, vis;
  if( document.getElementById )
    elem = document.getElementById(whichLayer);
  else if( document.all )
      elem = document.all[whichLayer];
  else if( document.layers )
    elem = document.layers[whichLayer];
  vis = elem.style;
  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
    vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
  vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}

function mostraLayer(whichLayer)
{
  var elem, vis;
  if( document.getElementById )
    elem = document.getElementById( whichLayer );
  else if( document.all )
      elem = document.all[whichLayer];
  else if( document.layers )
    elem = document.layers[whichLayer];
  vis = elem.style;
    vis.display = 'block';
}

function ocultaLayer(whichLayer)
{
  var elem, vis;
  if( document.getElementById )
    elem = document.getElementById( whichLayer );
  else if( document.all )
      elem = document.all[whichLayer];
  else if( document.layers )
    elem = document.layers[whichLayer];
  vis = elem.style;
    vis.display = 'none';
}

//******************************************
// Validacao do Formulario
//******************************************

function ValidaForm(n,m,z,t) {
oForm = document.form1; permite=false;
var a, b, c, d, e, f, g, h, i, j, k, l, soma;
var selbox = document.form1.IdHotel.value;
//a=(oForm.Idcidade.value == 0 || oForm.IdHotel.value == 0)?0:1;
a=(oForm.IdHotel.value < 3)?0:1;
if (oForm.IDah){
IDah = oForm.IDah.value;
a=(oForm.IdHotel.value != IDah)?0:1;
}

b=oForm.DataC.value.length;
c=oForm.DataP.value.length;

if (n){
d = (!a)?0:1;
//MM_findObj("selbord1").className = (!a)?"incorrecto_select":"correcto_select"; d = (!a)?0:1;
//MM_findObj("selbord2").className = (!a)?"incorrecto_select":"correcto_select";
}
if (m) {
//oForm.DataC.className = (!b || oForm.DataC.value == oForm.DataP.value)?"incorrecto":"correcto";
e = (!b || oForm.DataC.value == oForm.DataP.value)?0:1;
//oForm.DataP.className = (!c || oForm.DataC.value == oForm.DataP.value)?"incorrecto":"correcto";
f = (!c || oForm.DataC.value == oForm.DataP.value)?0:1;
}

soma = d+e+f;

if (soma == 3 && z) {
permite=true;
var temp1 = oForm.DataC.value;
var temp2 = oForm.DataP.value;
var ano1 = temp1.substring(6,10);
var mes1 = temp1.substring(3,5);
var dia1 = temp1.substring(0,2);
var comp1 = ano1+mes1+dia1;
var ano2 = temp2.substring(6,10);
var mes2 = temp2.substring(3,5);
var dia2 = temp2.substring(0,2);
var comp2 = ano2+mes2+dia2;
dInvertida = (comp1 > comp2);
if (dInvertida){
oForm.DataC.value = temp2;
oForm.DataP.value = temp1;
}
}
if (permite) {oForm.oSubmit.disabled=true; if (t) {oForm.oSubmit.value="A consultar, aguarde p.f. ..."}; oForm.submit();}
return false
}

function cancelhotel(){
	document.form1.IdHotel.value=document.form1.IdHotel.value;
}

