// JavaScript Document

      function setCurrentDate(){

         checkin = new Date();

         checkout = new Date();

         checkin.setDate(checkin.getDate()+1);

         checkout.setDate(checkout.getDate()+2);

         selectElement(window.document.checka.daysI,checkin.getDate());

         selectElement(window.document.checka.monthsI,checkin.getMonth()+1);

         selectElement(window.document.checka.yearI,checkin.getYear());

         selectElement(window.document.checka.daysS,checkout.getDate());

         selectElement(window.document.checka.monthsS,checkout.getMonth()+1);

         selectElement(window.document.checka.yearS,checkout.getYear());

      }



      function setDateS(data,nform){

         var a = data.split("/");

         document.forms[nform].monthsS.options[a[1]-1].selected=true;

         document.forms[nform].daysS.options[a[0]-1].selected=true;

         for(var i=0;i< document.forms[nform].yearS.options.length;i++){

            if(document.forms[nform].yearS.options[i].value==a[2]){

               document.forms[nform].yearS.options[i].selected=true;

            }

         }

      }



      function setDateI(data,nform){

         var a = data.split("/");

         document.forms[nform].monthsI.options[a[1]-1].selected=true;

         document.forms[nform].daysI.options[a[0]-1].selected=true;

         for(var i=0;i< document.forms[nform].yearI.options.length;i++){

            if(document.forms[nform].yearI.options[i].value==a[2]){

               document.forms[nform].yearI.options[i].selected=true;

            }

         }

      }



      function openC(frm,nform) {

         window.open('obm30/calendar.php?frm=' + frm + '&nform=' + nform + '&ln=en','in','scrollbars=yes,status=no,width=265,height=270,top=100,left=250,menubar=no');

         return false;

      }





      function selectElement(param,testValue){

         for (var i = 0; i < param.length; i++) {

            if (param.options[i].value == testValue) {

               param.options[i].selected = true;

            }

         }

      }



      function verifica() {

         var data1,data2,d,dat1,dat2;

         data1 = new Date();

         data2 = new Date();

         if (window.document.checka.yearI.options[window.document.checka.yearI.selectedIndex].value == "0" ||

            window.document.checka.monthsI.options[window.document.checka.monthsI.selectedIndex].value == "0" ||

            window.document.checka.daysI.options[window.document.checka.daysI.selectedIndex] == "0" ||

            window.document.checka.yearS.options[window.document.checka.yearS.selectedIndex] == "0" ||

            window.document.checka.monthsS.options[window.document.checka.monthsS.selectedIndex] == "0" ||

            window.document.checka.daysS.options[window.document.checka.daysS.selectedIndex] == "0")

         {

            alert ("Invalid date! Please check.");

            return false;

         }

         d = new Date();

         dc = new Date(d.getFullYear(),d.getMonth(), d.getDate());

         dataC = Date.parse(dc.toUTCString());



         dat1 = new Date(window.document.checka.yearI.options[window.document.checka.yearI.selectedIndex].value, parseInt(window.document.checka.monthsI.options[window.document.checka.monthsI.selectedIndex].value) -1 ,window.document.checka.daysI.options[window.document.checka.daysI.selectedIndex].value);

         dat2 = new Date(window.document.checka.yearS.options[window.document.checka.yearS.selectedIndex].value, parseInt(window.document.checka.monthsS.options[window.document.checka.monthsS.selectedIndex].value) -1 ,window.document.checka.daysS.options[window.document.checka.daysS.selectedIndex].value);

         data1 = Date.parse(dat1.toUTCString());

         data2 = Date.parse(dat2.toUTCString());



         if(dataC > data1){

            alert("'Check-in' date cannot be earlier than current date!");

            return false;

         }

         if (data1 >= data2){

            alert ("'Check-in' date cannot be later than 'Check-out' date");

            return false;

         }

         return true;

      }



      function openW(){

         if (verifica()){

            var width = screen.Width - 50;

            var height = screen.Height - 200;

            var str = "height=" + height + ",innerHeight=" + height;

            str += ",width=" + width + ",innerWidth=" + width;

            if (window.screen) {

               var ah = screen.availHeight - 100;

               var aw = screen.availWidth - 10;

               var xc = (aw - width) / 2;

               var yc = (ah - height) / 2;

               str += ",left=" + xc + ",screenX=" + xc;

               str += ",top=" + yc + ",screenY=" + yc;

            }

            window.open('','obm30','scrollbars=yes,status=yes,menubar=no,toolbar=yes,resizable=yes');

            window.document.checka.submit();

         }else{

            return false;

         }

      }



      // Checks if browser is Netscape 2.0x since the options array properties don't work with Netscape 2.0x

      function isBrowserSupp() {

         // Get the version of the browser

         version =  parseFloat( navigator.appVersion );

         if ( ( version >= 2.0 ) && ( version < 2.1 ) && ( navigator.appName.indexOf( "Netscape" ) != -1 ) ) {

            return false;

         }else {

            return true;

         }

         return true;

      }



      function isLeapYear( yrStr ) {

         var leapYear = false;

         var year = parseInt( yrStr, 10 );

         if ( year % 4 == 0 ) {

            leapYear = true;

            if( year % 100 == 0 ) {

               leapYear = false;

               if( year % 400 == 0 ) {

                  leapYear=true;

               }

            }

         }

         return leapYear;

      }



      function getDaysInMonth( mthIdx, YrStr ) {

         var maxDays = 31

         if( mthIdx == 1 ) {

            if( isLeapYear( YrStr ) ) {

               maxDays=29;

            } else {

               maxDays=28;

            }

         }



         if( mthIdx == 3 || mthIdx == 5 || mthIdx == 8 || mthIdx == 10 ) {

            maxDays=30;

         }

         return maxDays;

      }



      function adjustDate( monthObj, dayObj, yearObj ) {

         var value = 0;

         var mthIdx = monthObj.options.selectedIndex;

         var Dt = dayObj;

         var theYear = yearObj.options[yearObj.options.selectedIndex].value;

         var numDays = getDaysInMonth( mthIdx, theYear );

         if( mthIdx == 1 ) {

            if( Dt.options.selectedIndex + 2 < numDays ) {

               return 0;

            } else {

               if( Dt.options.selectedIndex + 1 > numDays) {

                  Dt.options.selectedIndex=numDays - 1;

               }

               if( (Dt.options.selectedIndex + 1) == numDays ) {

                  return 1;

               } else {

                  return 4;

               }

            }

         }

         if( Dt.options.selectedIndex + 2 < numDays ) {

            value = 0;

         } else {

            if ( Dt.options.selectedIndex + 1 > numDays ) {

               Dt.options.selectedIndex--;

               value = 3;

            } else if ( Dt.options.selectedIndex + 1 == numDays ) {

               value = 2;

            } else {

               value = 4;

            }

         }

         return value;

      }



      function amadChange( inM, inD, inY ) {

         if ( !isBrowserSupp() ) {

            return;

         }

         var res = adjustDate( inM.options.selectedIndex, inD, inY.options[inY.options.selectedIndex].value );

         return;

      }



      function dmddChange( outM, outD, outY ) {

         if ( !isBrowserSupp() ) {

            return;

         }

         adjustDate( outM.options.selectedIndex, outD, outY.options[outY.options.selectedIndex].value );

         return;

      }



      function showHideChildrenAge(formName){

         var nrChildren = window.document.forms[formName].childs.options[window.document.forms[formName].childs.selectedIndex].value;

         var nrMaxChildren = 7;

         for (var i=1; i <= nrChildren; i++){

            window.document.getElementById("childAgeTable" + i).className = "classshown";

         }

         nrChildren ++;

         for (var j= nrChildren ; j <= nrMaxChildren; j++){

            window.document.getElementById("childAgeTable" + j).className = "classhidden";

         }

      }

      

       function openMR(){

       var width = screen.Width - 50;

       var height = screen.Height - 200;

       var str = "height=" + height + ",innerHeight=" + height;

       str += ",width=" + width + ",innerWidth=" + width;

       if (window.screen) {

         var ah = screen.availHeight - 100;

           var aw = screen.availWidth - 10;

      var xc = (aw - width) / 2;

           var yc = (ah - height) / 2;

           str += ",left=" + xc + ",screenX=" + xc;

           str += ",top=" + yc + ",screenY=" + yc;

       }

    window.open('obm30/checkavail.php?ln=en','obm30','scrollbars=yes,status=yes,menubar=no,toolbar=yes,resizable=yes');

  }

  function openCR(){

       var width = screen.Width - 50;

    var height = screen.Height - 200;

    var str = "height=" + height + ",innerHeight=" + height;

    str += ",width=" + width + ",innerWidth=" + width;

    if (window.screen) {

      var ah = screen.availHeight - 100;

      var aw = screen.availWidth - 10;

      var xc = (aw - width) / 2;

      var yc = (ah - height) / 2;

      str += ",left=" + xc + ",screenX=" + xc;

      str += ",top=" + yc + ",screenY=" + yc;

   }

   window.open('obm30/cancel_res.php?ln=en','obm30','scrollbars=yes,status=yes,menubar=no,toolbar=yes,resizable=yes');

  }
