function showWindow()
  {
    //window.open('my_calendar.asp?param=selectHotelForm&type=arrival','lvs', 230, 190);  
    window.open('my_calendar.asp?param=selectHotelForm&type=arrival','signup','resizable=1,scrollbars=1,width=230,height=190');
  }
     function DoSubmit()
     {
     
     
     var d = new String(document.form1.arrivalDay.value);
      if (d.length ==1) d = "0" + d;
        var y = new String(document.form1.checkoutdate2.value).substring(0,4);
        var m = new String(document.form1.checkoutdate2.value).substring(4,6);
      if (m.length ==1) m = "0" + m;
         document.getElementById("txtstartdate1").value = m+"/"+d+"/"+y;
         m++;
         document.getElementById("txtstartdate").value = m+"/"+d+"/"+y;
       
       var dd = new String(document.form1.departureday.value);
            if (dd.length ==1) dd = "0" + dd;
      var yy= new String(document.form1.checkoutdate3.value).substring(0,4);
      var mm = new String(document.form1.checkoutdate3.value).substring(4,6);
        //mm = mm + 1;
              if (mm.length ==1) mm = "0" + mm;
      //alert(mm+"/"+dd+"/"+yy);
      
          
           document.getElementById("txtenddate1").value = mm+"/"+dd+"/"+yy;
       mm++;
        document.getElementById("txtenddate").value = mm+"/"+dd+"/"+yy;
      // alert(document.getElementById("txtenddate").value);
     
     var mytool_array = new Array();
     var mytool_array1 = new Array();
     
       var dayElement = document.getElementById("txtstartdate1").value;    
     mytool_array=dayElement.split("/");     
     var yer = mytool_array[2] +""+ mytool_array[0];
    
     
     var dayElement1 = document.getElementById("txtenddate1").value;     
     mytool_array1=dayElement1.split("/");
     var yer1 = mytool_array1[2] +""+ mytool_array1[0];
     
       var monthYearElement = document.getElementById("arrivalMonthYear");
       var y = new String(mytool_array[2]);
       var m = new String(mytool_array[0]);
       var d = new String(mytool_array[1]+1);
       var checkinDate = new Date(y,m,d);
       var minimumDate = new Date(2007,7,09);
     
     
     //alert(mytool_array1[0]);
     //alert(mytool_array[0]);
       var ddayElement = document.getElementById("departureDay");
       var dmonthYearElement = document.getElementById("departureMonthYear");
       var dy = new String(mytool_array1[2]);
       var dm = new String(mytool_array1[0]);
       var dd = new String(mytool_array1[1]+1);
       var checkoutDate = new Date(dy,dm,dd);
    if (mytool_array[1]=="")
    {
      alert("Please enter Arrival Date.");
    } 
    else if (mytool_array1[1]=="")
    {
      alert("Please enter Departure Date.");
    } 
       else if (checkinDate < minimumDate)
       {
          alert("Checkin date cannot be in the past.");
       }
     else if (document.form1.checkoutdate3.selectedIndex < document.form1.checkoutdate2.selectedIndex)
       {        
          alert("Checkout date must be after checkin date.");
       }
       else if ((checkoutDate <= checkinDate) &&  (document.form1.checkoutdate3.selectedIndex < document.form1.checkoutdate2.selectedIndex))
       {        
          alert("Checkout date must be after checkin date.");
       }
     else if ((document.form1.checkoutdate3.selectedIndex == document.form1.checkoutdate2.selectedIndex) && (document.form1.arrivalDay.selectedIndex >= document.form1.departureday.selectedIndex))
       {
          alert("Checkout date must be after checkin date.");
       }
       else
       {
         var href = "http://book.bestwestern.com/bestwestern/priceAvail.do" +
                    "?propertyCode=84071" +         
                   // "&numRooms=1" +
                    "&arrivalDay=" + mytool_array[1] +
                    "&arrivalMonthYear=" + yer +
                    "&departureDay=" + mytool_array1[1] +
                    "&departureMonthYear=" + yer1 +
          "&disablenav=true&language=en_US&showPropertyLink=true&suppressSSLPopup=true&notAffiliate=false&sob=P59&cm_mmc=Property-_-Ireland-_-AcademyPlaza-_-84071";
          
        // parent.window.location = href;
    // window.open(href,'book.bestwestern.com','width=400,height=200')
     window.open(href,'','titlebar=yes,width=800,height=700,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=yes,resizable=no')
         //alert(href);
    // popup(href);
       }
     }
   

     function DoArrivalDatePopUpCalendar()
     {
       var dayElement = document.getElementById("arrivalDay");
       var monthYearElement = document.getElementById("arrivalMonthYear");
       var y = new String(monthYearElement.options[monthYearElement.selectedIndex].value).substring(0,4);
       var m = new String(monthYearElement.options[monthYearElement.selectedIndex].value).substring(4,6);
       var d = new String(dayElement.selectedIndex+1);
       if (d.length == 1) d = "0" + d;

       var cal = new CalendarPopup(); 
       cal.addDisabledDates(null,"06/20/2007");
       cal.addDisabledDates("2007-12-20",null);
       cal.setReturnFunction("DoArrivalDatePopUpCalendarReturn");
       cal.select(document.getElementById("hidArrivalDate"),"arrivalDateAnchor","MM/dd/yyyy");
     }
 
     function DoArrivalDatePopUpCalendarReturn(y,m,d)
     {
       
     m = new String(m);
       if (m.length ==1) m = "0" + m;
       d = new String(d);
       if (d.length ==1) d = "0" + d;
       document.getElementById("hidArrivalDate").value = m+"/"+d+"/"+y;

       var dayElement = document.getElementById("arrivalDay");
       var monthYearElement = document.getElementById("arrivalMonthYear");
       
       // set selected day
       dayElement.selectedIndex = d-1;

       // set selected month
       var month = new String(m-1);
       if (month.length ==1) month = "0" + month;
       
       for(var i=0;i<monthYearElement.options.length;i++)
         if (monthYearElement.options[i].value == y+month)
            monthYearElement.selectedIndex = i;

       // is checkout day < new checkin day? if so, checkout is 1+checkin
       var departDayElement = document.getElementById("departureDay");
       var departMonthYearElement = document.getElementById("departureMonthYear");
       var dmy = new String(departMonthYearElement.options[departMonthYearElement.selectedIndex].value);
       var checkoutDate = new Date(dmy.substring(0,4),dmy.substring(4,6), departDayElement.options[departDayElement.selectedIndex].value);
       var checkinDate = new Date(y,m-1,d);
       //alert(checkinDate+" "+checkoutDate+" "+(checkinDate > checkoutDate));
       if (checkinDate >= checkoutDate)
       {
         // first figure out the new checkout date
         checkoutDate.setMonth(checkinDate.getMonth());
         checkoutDate.setDate(checkinDate.getDate()+1);

         // second set the monthyear select
         var checkoutmonth = new String(checkoutDate.getMonth());
         if (checkoutmonth.length ==1) checkoutmonth = "0" + checkoutmonth;
         for(var i=0;i<departMonthYearElement.options.length;i++)
           if (monthYearElement.options[i].value == checkoutDate.getFullYear()+checkoutmonth)
              departMonthYearElement.selectedIndex = i;

         // third set the date select
         departDayElement.selectedIndex = checkoutDate.getDate()-1;

         // fourth set the hidden element
         var dm = new String(checkoutDate.getMonth()+1);
         if (dm.length ==1) dm = "0" + dm;
         dd = new String(checkoutDate.getDate());
         if (dd.length ==1) dd = "0" + dd;
           document.getElementById("hidDepartureDate").value = dm+"/"+dd+"/"+checkoutDate.getFullYear();
       }

       // make sure the days in month is set (in case the month has changed)
       ResetDaysInMonth(monthYearElement,dayElement);
       ResetDaysInMonth(departMonthYearElement,departDayElement);
     }

     function DoDepartureDatePopUpCalendar()
     {
       var dayElement = document.getElementById("departureDay");
       var monthYearElement = document.getElementById("departureMonthYear");
       var y = new String(monthYearElement.options[monthYearElement.selectedIndex].value).substring(0,4);
       var m = new String(monthYearElement.options[monthYearElement.selectedIndex].value).substring(4,6);
       var d = new String(dayElement.selectedIndex+1);
       if (d.length == 1) d = "0" + d;

       var cal = new CalendarPopup(); 
       cal.addDisabledDates(null,document.getElementById("hidArrivalDate").value);
       cal.addDisabledDates("2007-12-20",null);
       cal.setReturnFunction("DoDepartureDatePopUpCalendarReturn");
       cal.select(document.getElementById("hidDepartureDate"),"departureDateAnchor","MM/dd/yyyy");
     }

     function DoDepartureDatePopUpCalendarReturn(y,m,d)
     {
       m = new String(m);
       if (m.length ==1) m = "0" + m;
       d = new String(d);
       if (d.length ==1) d = "0" + d;
       document.getElementById("hidDepartureDate").value = m+"/"+d+"/"+y;

       var dayElement = document.getElementById("departureDay");
       var monthYearElement = document.getElementById("departureMonthYear");
       
       // set selected day
       dayElement.selectedIndex = d-1;

       // set selected month
       var month = new String(m-1);
       if (month.length ==1) month = "0" + month;
       
       for(var i=0;i<monthYearElement.options.length;i++)
         if (monthYearElement.options[i].value == y+month)
            monthYearElement.selectedIndex = i;
     }

     function ResetDaysInMonth(ymSel, dSel)
     {
        //alert(dSel.value);
    //alert(ymSel.value);
    var monthnum = new String(ymSel.value).substring(4,6);
        var year = new String(ymSel.value).substring(0,4);
        var daysInMonth = LastDayOfMonth(monthnum,year);
        if (dSel.options.length > daysInMonth)
        {
          var daysToRemove = dSel.options.length - daysInMonth;
          var len = dSel.options.length;
          for (var i=len;i>=daysInMonth;i--)
            dSel.options[i] = null;
        }      
        else if (dSel.options.length < daysInMonth)
        {
          var daysToAdd =  daysInMonth - dSel.options.length;
          var len = dSel.options.length;
          //alert(len);
          for (var i=len;i<len+daysToAdd;i++)
            dSel.options[dSel.options.length] = new Option(i+1);
        }
     }


     function LastDayOfMonth(month_num,year)
     {
       // create a varible to specify what the
       // last day for the current month is
       var theday = 0;
       if (
       month_num == 0 || 
       month_num == 2 || 
       month_num == 4 || 
       month_num == 6 || 
       month_num == 7 || 
       month_num == 9 || 
       month_num == 11)
       { 
         return 31;
       }
       if (
       month_num == 3 || 
       month_num == 5 || 
       month_num == 8 || 
       month_num == 10)
       { 
         return 30;
       }

       if (month_num == 1)
       { 
         // This will check for a leap year
         // If the year is evenly divisible by four
         // or in the case of a new century evenly divisible
         // by 400 then the end of the February month should be the 29th

         right_year_divided=year/4;
         right_year_divided_string= new String(right_year_divided);
         var is_decimal = right_year_divided_string.indexOf('.');
         if (is_decimal != -1)
         { return 28; }
         else
         { return 29; }     
       }
  }
  function nextday()
  {
    var d = 0;
  d = document.form1.arrivalDay.value;
  //alert(d);
  d++;
  var mmm;
  var yy= new String(document.form1.checkoutdate2.value).substring(0,4);
   
      var mm = new String(document.form1.checkoutdate2.value).substring(4,6);
        mm++;
        //alert(mm);
        var dayinmonth = LastDayOfMonth(mm,yy);
        if(d > dayinmonth)
        {
          document.form1.departureday.selectedIndex = 0;
          document.form1.checkoutdate3.selectedIndex = document.form1.checkoutdate3.selectedIndex + 1;
        }
        else
        {
          document.form1.departureday.selectedIndex = d-1;        
          document.form1.checkoutdate3.selectedIndex = document.form1.checkoutdate2.selectedIndex ;       
        }
        if (mm.length ==1) mm = "0" + mm;
       var dd = d;
           document.getElementById("txtenddate").value = mm+"/"+dd+"/"+yy;
  }
  
  function chk()
  { 
        
      var d = new String(document.form1.arrivalDay.value);
            if (d.length ==1) d = "0" + d;
      var y = new String(document.form1.checkoutdate2.value).substring(0,4);
      var m = new String(document.form1.checkoutdate2.value).substring(4,6);
      m++;
        if (m.length ==1) m = "0" + m;
           document.getElementById("txtstartdate").value = m+"/"+d+"/"+y;
       
       var dd = new String(document.form1.departureday.value);
            if (dd.length ==1) dd = "0" + dd;
      var yy= new String(document.form1.checkoutdate3.value).substring(0,4);
      var mm = new String(document.form1.checkoutdate3.value).substring(4,6);
      mm++;
              if (mm.length ==1) mm = "0" + mm;
      //alert(mm+"/"+dd+"/"+yy);
           document.getElementById("txtenddate").value = mm+"/"+dd+"/"+yy;
  }
  function nxtmn()
  {
    
  var d = new String(document.form1.arrivalDay.value);
  var m = new String(document.form1.checkoutdate2.value).substring(4,6);
  if (m==01 && d==29)
  {
    document.form1.arrivalDay.selectedIndex = document.form1.arrivalDay.value - 1;    
    document.form1.departureday.selectedIndex = 0;
    //document.form1.checkoutdate3.selectedIndex = document.form1.checkoutdate2.selectedIndex;
  }
  else
  {
    document.form1.arrivalDay.selectedIndex = document.form1.arrivalDay.value - 1;
    document.form1.departureday.selectedIndex = document.form1.departureday.value - 1;
    document.form1.checkoutdate3.selectedIndex = document.form1.checkoutdate2.selectedIndex;
  }
  //alert(document.form1.txtstartdate.value);
  }
