var req = false, bookingResultDiv=0, bookingValues; function bookingInit() { bookingResultDiv = document.getElementById("bookingResult"); var cookie = new Object; if(typeof(document.cookie)!='undefined') { var ca = document.cookie.split(';'); for(var c in ca) { var p=ca[c].split('='); while(p[0].charAt(0) == ' ') p[0] = p[0].substring(1); cookie[p[0]] = unescape(p[1]); } } var hadCookie = true; if(cookie.resDay == null) { hadCookie = false; var d = new Date(); /* d.setDate(d.getDate()+7); */ cookie.resDay = d.getDate(); cookie.resDate = d.getFullYear()+'-'+((d.getMonth()+1)<10?'0':'')+(d.getMonth()+1); cookie.nights = cookie.people = 1; cookie.currency = 'USD'; } document.bookingForm.resDay.value = cookie.resDay; document.bookingForm.resDate.value = cookie.resDate; document.bookingForm.nights.value = cookie.nights; document.bookingForm.people.value = cookie.people; /* document.bookingForm.currency.value = cookie.currency; */ if(hadCookie) bookingUpdate(); else bookingResultDiv.innerHTML = '
(Choose your booking dates to see availability information here.)
'; } function bookingUpdate() { if(document.bookingForm.people.value == '9+') { document.bookingForm.people.value = 1; window.location = 'http://www.hb-247.com/aff/hostelz/groups'; return false; } bookingValues = '&resDate='+document.bookingForm.resDate.value+'&resDay='+document.bookingForm.resDay.value+ '&nights='+document.bookingForm.nights.value+'&people='+document.bookingForm.people.value+'¤cy=USD'; var cPost = ';domain=.hostelz.com;path=/'; document.cookie = 'resDay='+escape(document.bookingForm.resDay.value)+cPost; document.cookie = 'resDate='+escape(document.bookingForm.resDate.value)+cPost; document.cookie = 'nights='+escape(document.bookingForm.nights.value)+cPost; document.cookie = 'people='+escape(document.bookingForm.people.value)+cPost; bookingResultDiv.innerHTML = '
Searching Booking Systems...
'; try { req = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { req = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e2) { try { req = new XMLHttpRequest(); } catch (e3) { return false; } } } req.onreadystatechange = xmlRespond; req.open('GET', '/bookingData.php?hostelID='+hostelID+bookingValues, true); req.send(null); return true; } function availText(name,prefix,data) { var text = '
'; if(data.freeBooking==1) freeText = ' FREE BOOKING - No Booking Fee!'; else freeText = ''; // ' Lowest Prices Guaranteed.'; if(data.availRating>0) { text += ''; if(data.availRating<1) text += 'Limited Availability for '+name+'. See Availability Details >>'; else text += 'Yes, '+name+' Available!'+freeText+' Reserve It Now >>'; text += ''; } else { text += ''+name+' not available for these dates. Try a Search for '+name+' in all of '+city+'.'; } text += '
'; return text; } function xmlRespond() { if(req.readyState == 4 && req.status == 200) { eval('avail='+req.responseText); if(avail.priv.availRating>0 && avail.dorm.availRating==0) bookingResultDiv.innerHTML = availText('Private Rooms','Priv',avail.priv)+availText('Dorm Beds','Dorm',avail.dorm); else bookingResultDiv.innerHTML = availText('Dorm Beds','Dorm',avail.dorm)+availText('Private Rooms','Priv',avail.priv); } }