function checkAvailability() { var iYear = 2009; var iMonth = 11; var iDay = 21; var todaydate = pad4(2009) + pad2(11) + pad2(21); var checkindate; var checkoutdate; var week50date; checkindate = document.frmMain.checkindate.value; var checkinyear = checkindate.substr(6,4); var checkinmonth = checkindate.substr(0,2); var checkinday = checkindate.substr(3,2); checkindate = checkinyear+ checkinmonth + checkinday; checkoutdate = document.frmMain.checkoutdate.value; var checkoutyear = checkoutdate.substr(6,4); var checkoutmonth = checkoutdate.substr(0,2); var checkoutday = checkoutdate.substr(3,2); checkoutdate = checkoutyear+ checkoutmonth + checkoutday; week50date = pad4(2010) + pad2(11) + pad2(6); if (checkindate < todaydate) { alert("Check In date cannot be a past date|"+checkindate+"|"+todaydate); return void(0); } if (checkoutdate <= todaydate) { alert("Check Out date cannot be today's date"); return void(0); } if (checkindate >= checkoutdate) { alert("Check In date must be before Check Out date"); return void(0); } if (checkoutdate > week50date) { alert("Availability for dates more than 50 weeks in the future is not available at this time."); return void(0); } //Check the company code is valid alphanumeric characters var sCompCode = ''; if (isAlphaNumeric('companycode')) { if(document.frmMain.companycode.value.length > 0){ sCompCode = document.frmMain.companycode.value; } else { sCompCode = ''; } } else { alert('The company code is invalid. Please try again.'); document.frmMain.companycode.value = ''; document.frmMain.companycode.focus(); return void(0); } //Check the promo code for valid alphanumeric characters var sPromo = ''; if (isAlphaNumeric('promocode')) { if(document.frmMain.promocode.value.length > 0){ sPromo = document.frmMain.promocode.value; } else { sPromo = ''; } } else { alert('The promotional code is invalid. Please try again.'); document.frmMain.promocode.value = ''; document.frmMain.promocode.focus(); return void(0); } if ((document.frmMain.state.selectedIndex <= 0) || (document.frmMain.MetroID.selectedIndex <= 0)) { //alert("You must select a State/province and metro area."); var locationurl; if (document.frmMain.state.selectedIndex <= 0) { locationurl = "findHotel/main.asp" + "?state=" + escape(document.frmMain.state.options[document.frmMain.state.selectedIndex].value)+ "&FromNewRes=1" + "&iata=" + escape("") + "&numadults=" + document.frmMain.numadults.options[document.frmMain.numadults.selectedIndex].value + "" + "&numkids=" + document.frmMain.numkids.options[document.frmMain.numkids.selectedIndex].value + "" + "&numrooms=" + document.frmMain.rooms.options[document.frmMain.rooms.selectedIndex].value + "" + "&inmonth=" + checkinmonth + "" + "&inday=" + checkinday + "" + "&inyear=" + checkinyear + "" + "&outmonth=" + checkoutmonth + ""+ "&outday=" + checkoutday + "" + "&outyear=" + checkoutyear + "" + "&rateid=" + escape(document.frmMain.rates.options[document.frmMain.rates.selectedIndex].value) + "&directbill=" + escape("") + "&promoCode=" + escape(sPromo); if (sCompCode.length > 0) { url = url + "&companycode=" + escape(sCompCode); } } else { locationurl = "findHotel/metroArea.asp"+ "?state=" + escape(document.frmMain.state.options[document.frmMain.state.selectedIndex].value)+ "&FromNewRes=1" + "&iata=" + escape("") + "&numadults=" + document.frmMain.numadults.options[document.frmMain.numadults.selectedIndex].value + "" + "&numkids=" + document.frmMain.numkids.options[document.frmMain.numkids.selectedIndex].value + "" + "&numrooms=" + document.frmMain.rooms.options[document.frmMain.rooms.selectedIndex].value + "" + "&inmonth=" + checkinmonth + "" + "&inday=" + checkinday + "" + "&inyear=" + checkinyear + "" + "&outmonth=" + checkoutmonth + ""+ "&outday=" + checkoutday + "" + "&outyear=" + checkoutyear + "" + "&rateid=" + escape(document.frmMain.rates.options[document.frmMain.rates.selectedIndex].value) + "&directbill=" + escape("") + "&promoCode=" + escape(sPromo); if (sCompCode.length > 0) { url = url + "&companycode=" + escape(sCompCode); } } parent.location.href = locationurl; return void(0); } //Check the numAdults and numKids < 5 var chkNumAdults = document.frmMain.numadults.options[document.frmMain.numadults.selectedIndex].value - 0; var chkNumKids = document.frmMain.numkids.options[document.frmMain.numkids.selectedIndex].value - 0; if ((chkNumAdults + chkNumKids) >= 5) { alert('Maximum occupancy per room is 4 people. Please reduce your numbers.'); return void(0); } var selectedrate = ""; if (document.frmMain.rates.selectedIndex >= 0) selectedrate = document.frmMain.rates.options[document.frmMain.rates.selectedIndex].value; var url = "http://www.ExtendedStayAmerica.com/session2.asp"+ "?page=" + escape("http://www.ExtendedStayAmerica.com/") + "&state=" + escape(document.frmMain.state.options[document.frmMain.state.selectedIndex].value) + "&metroid=" + escape(document.frmMain.MetroID.options[document.frmMain.MetroID.selectedIndex].value) + "&iata=" + escape("") + //"&corpinfo=" + escape("") + "&numadults=" + document.frmMain.numadults.options[document.frmMain.numadults.selectedIndex].value + "" + "&numkids=" + document.frmMain.numkids.options[document.frmMain.numkids.selectedIndex].value + "" + "&numrooms=" + document.frmMain.rooms.options[document.frmMain.rooms.selectedIndex].value + "" + "&inmonth=" + checkinmonth + "" + "&inday=" + checkinday + "" + "&inyear=" + checkinyear + "" + "&outmonth=" + checkoutmonth + ""+ "&outday=" + checkoutday + "" + "&outyear=" + checkoutyear + "" + "&rateid=" + escape(document.frmMain.rates.options[document.frmMain.rates.selectedIndex].value) + "&directbill=" + escape("") + "&promoCode=" + escape(sPromo); if (sCompCode.length > 0) { url = url + "&companycode=" + escape(sCompCode); } // if (document.frmMain.location.selectedIndex <= 0) { url = url + "&destpage=make"; // } else { // url = url + "&destpage=lodging"; // } //alert(url); parent.location.href = url + "&WTReferrer=http%3A%2F%2Fwww%2Eextendedstayamerica%2Ecom%2Fincludes%2Fcontent%2DreservationFormjsB%2Easp%3F"; return void(0); }