// opens check-in selection window
function openPackSelCI(formName, hotelid, packid, adults, children, ln){
   width=550;
   height=210;
   selectedMonth =  window.document.forms[formName].monthsI.options[window.document.forms[formName].monthsI.selectedIndex].value;
   selectedYear =  window.document.forms[formName].yearI.options[window.document.forms[formName].yearI.selectedIndex].value;
   xPos = (screen.Width - width) / 2;
   yPos = (screen.Height - height) / 2;
   window.open('selpackci.php?formname=' + formName + '&id=' + hotelid + '&packid=' + packid + '&month=' + selectedMonth + '&year=' + selectedYear + '&adults=' + adults + '&children=' + children + '&ln=' + ln, 'selpackci','scrollbars=yes,status=no,width=' + width + ',height=' + height + ',top=' + yPos + ',left=' + xPos + ',menubar=no');
   return false;
}

function showHideChildrenAgeP(formName, paramMaxChildren){
   var nrChildren = window.document.forms[formName].children.options[window.document.forms[formName].children.selectedIndex].value;
   var nrMaxChildren = paramMaxChildren;
   for (var i=1; i <= nrChildren; i++){
      window.document.getElementById("childAgeTableP" + i).className = "classshown";
   }
   nrChildren ++;
   for (var j= nrChildren ; j <= nrMaxChildren; j++){
      window.document.getElementById("childAgeTableP" + j).className = "classhidden";
   }
}

function openPackDesc(hotelid,packid,ln){
   var wWin = 475;
   var hWin = 525;
   if (typeof(winNew) == "object" && winNew != null ){
      winNew.close();
   }
   xPos = (screen.Width - wWin) / 2;
   yPos = (screen.Height - hWin) / 2;
   winNew = window.open('packinfo.php?hotelid=' + hotelid + '&packid=' + packid + '&ln=' + ln,'packdesc','scrollbars=yes,status=no,width=' + wWin + ',height=' + hWin + ',top=' + yPos + ',left=' + xPos + ',menubar=no');
}

function enableCheckIn(formName) {
   window.document.forms[formName].monthsI.disabled=false;
   window.document.forms[formName].daysI.disabled=false;
   window.document.forms[formName].yearI.disabled=false;
}

function packSendRequest(forma, message){
   var regex = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;
   if(!regex.test(forma.email.value)){
      alert(message);
      //alert("<?=$a1?>");
      forma.email.focus();
      return false;
   }
}

function verificaP(nform,msg3,msg4) {
   var data1,data2,d,dat1,dat2;
   data1 = new Date();
   data2 = new Date();

   d = new Date();
   dc = new Date(d.getFullYear(),d.getMonth(), d.getDate());
   dataC = Date.parse(dc.toUTCString());
   dat1 = new Date(window.document.forms[nform].yearI.options[window.document.forms[nform].yearI.selectedIndex].value, parseInt(window.document.forms[nform].monthsI.options[window.document.forms[nform].monthsI.selectedIndex].value) -1 ,window.document.forms[nform].daysI.options[window.document.forms[nform].daysI.selectedIndex].value);
   dat2 = new Date(window.document.forms[nform].yearS.options[window.document.forms[nform].yearS.selectedIndex].value, parseInt(window.document.forms[nform].monthsS.options[window.document.forms[nform].monthsS.selectedIndex].value) -1 ,window.document.forms[nform].daysS.options[window.document.forms[nform].daysS.selectedIndex].value);
   data1 = Date.parse(dat1.toUTCString());
   data2 = Date.parse(dat2.toUTCString());

   if(dataC > data1){
      alert(msg3);
      return false;
   }
   if (data1 >= data2){
      alert (msg4);
      return false;
   }
   return true;
}
