Advertisement
Guest User

Chameleon Search Box

a guest
Jun 10th, 2011
1,021
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 21.81 KB | None | 0 0
  1. <div id="searchForm">
  2.  
  3.     <form id="hotSearch" name="hotSearch" action="http://cname.travelnow.com/index.jsp" method="post" onSubmit="return validate(this);">
  4.  
  5.     <input type="hidden" name="pageName" value="hotSearch">
  6.     <input type="hidden" name="validateDates" value="true">
  7.     <input type="hidden" name="validateCity" value="true">
  8.     <input type="hidden" name="mode" value="2">
  9.     <input type="hidden" name="submitted" value="true">
  10.     <input type="hidden" name="netOnly" value="true">
  11.     <input type="hidden" name="fc" value="list">
  12.     <input type="hidden" name="locale" value="">
  13.  
  14.     <input type="hidden" name="specials" value="false">
  15.     <input type="hidden" name="city" value="">
  16.     <input type="hidden" name="stateProvince" value="">
  17.     <input type="hidden" name="country" value="">
  18.     <input type="hidden" name="showPopUp" value="true">
  19.     <input type="hidden" name="passThrough" value="true">
  20. <input type="hidden" name="cid" value="9999">
  21.  
  22.  
  23.     <div >
  24.  
  25.     <div >
  26.     <p >1. Select a Destination</p>
  27.  
  28.     <div>
  29.  
  30.  
  31.  
  32.     <fieldset class="city">
  33.     <label for="city">City<br /><input name="cityText" class="city" value="City name"></label>
  34.  
  35.  
  36.                                
  37.  
  38.  
  39.  
  40.  
  41. </div>
  42. </div><!-- end insideBorder -->
  43.  
  44. <div >
  45. <p >2. Select your Dates</p>
  46.  
  47. <div>
  48.  
  49. <fieldset>
  50. <label>Check in<br />
  51.  
  52. <select onchange="amadChange(document.hotSearch.arrivalMonth, document.hotSearch.arrivalDay, document.hotSearch.departureMonth, document.hotSearch.departureDay)" name="arrivalMonth">
  53.  
  54.  
  55. <option value=0>January</option>
  56. <option value=1>February</option>
  57. <option value=2>March</option>
  58. <option value=3>April</option>
  59. <option value=4>May</option>
  60. <option value=5>June</option>
  61. <option value=6>July</option>
  62. <option value=7>August</option>
  63. <option value=8>September</option>
  64. <option value=9>October</option>
  65. <option value=10>November</option>
  66. <option value=11>December</option>
  67.  
  68.  
  69. </select>
  70.  
  71. <select onChange="amadChange(document.hotSearch.arrivalMonth, document.hotSearch.arrivalDay, document.hotSearch.departureMonth, document.hotSearch.departureDay)" name="arrivalDay">
  72. <option value="1">1</option>
  73. <option value="2">2</option>
  74. <option value="3">3</option>
  75. <option value="4">4</option>
  76. <option value="5">5</option>
  77. <option value="6">6</option>
  78. <option value="7">7</option>
  79. <option value="8">8</option>
  80. <option value="9">9</option>
  81. <option value="10">10</option>
  82. <option value="11">11</option>
  83. <option value="12">12</option>
  84. <option value="13">13</option>
  85. <option value="14">14</option>
  86. <option value="15">15</option>
  87. <option value="16">16</option>
  88. <option value="17">17</option>
  89. <option value="18">18</option>
  90. <option value="19">19</option>
  91. <option value="20">20</option>
  92. <option value="21">21</option>
  93. <option value="22">22</option>
  94. <option value="23">23</option>
  95. <option value="24">24</option>
  96. <option value="25">25</option>
  97. <option value="26">26</option>
  98. <option value="27">27</option>
  99. <option value="28">28</option>
  100. <option value="29">29</option>
  101. <option value="30">30</option>
  102. <option value="31">31</option>
  103. </select>
  104.  
  105. <a href="javascript:openCalendar('hotSearch', 'arrival');"><img src="http://travel.ian.com/BU40/_media/icons/calendar.gif" align="bottom"></a>
  106. </label>
  107. </fieldset>
  108.  
  109. <fieldset>
  110. <label>Check out<br />
  111.  
  112. <select onchange="dmddChange(document.hotSearch.departureMonth,document.hotSearch.departureDay)" name="departureMonth">
  113.  
  114.  
  115. <option value=0>January</option>
  116. <option value=1>February</option>
  117. <option value=2>March</option>
  118. <option value=3>April</option>
  119. <option value=4>May</option>
  120. <option value=5>June</option>
  121. <option value=6>July</option>
  122. <option value=7>August</option>
  123. <option value=8>September</option>
  124. <option value=9>October</option>
  125. <option value=10>November</option>
  126. <option value=11>December</option>
  127.  
  128.  
  129. </select>
  130.  
  131. <select onchange="dmddChange(document.hotSearch.departureMonth,document.hotSearch.departureDay)" name="departureDay">
  132. <option value="1">1</option>
  133. <option value="2">2</option>
  134. <option value="3">3</option>
  135. <option value="4">4</option>
  136. <option value="5">5</option>
  137. <option value="6">6</option>
  138. <option value="7">7</option>
  139. <option value="8">8</option>
  140. <option value="9">9</option>
  141. <option value="10">10</option>
  142. <option value="11">11</option>
  143. <option value="12">12</option>
  144. <option value="13">13</option>
  145. <option value="14">14</option>
  146. <option value="15">15</option>
  147. <option value="16">16</option>
  148. <option value="17">17</option>
  149. <option value="18">18</option>
  150. <option value="19">19</option>
  151. <option value="20">20</option>
  152. <option value="21">21</option>
  153. <option value="22">22</option>
  154. <option value="23">23</option>
  155. <option value="24">24</option>
  156. <option value="25">25</option>
  157. <option value="26">26</option>
  158. <option value="27">27</option>
  159. <option value="28">28</option>
  160. <option value="29">29</option>
  161. <option value="30">30</option>
  162. <option value="31">31</option>
  163. </select>
  164.  
  165. </select>
  166. <a href="javascript:openCalendar('hotSearch', 'departure');"><img src="http://travel.ian.com/BU40/_media/icons/calendar.gif" align="bottom"></a>
  167. </label><br>
  168.                    
  169.                    
  170.                    
  171. </fieldset>
  172. <p>
  173. <fieldset>
  174. <table align="left" border="0" cellspacing="0" cellpadding="0" >
  175. <tr>
  176. <td><div id="hot-search-params"></div></td>
  177. </tr>
  178. <tr>
  179. <td valign="bottom"><input type="submit" value="Search" class="button"></td>
  180. </tr>
  181. </table>
  182. </fieldset>
  183. </div>
  184. </div><!-- end insideBorder -->
  185.  
  186.        
  187. </div><!-- end outsideBorder -->
  188. </form>
  189. </div>
  190. <!-- END SEARCH  -->
  191. <script langage="javascript">
  192. <!--
  193. //start new script code
  194. // Checks if browser is Netscape 2.0x since the options array properties don't work with Netscape 2.0x
  195. function isBrowserSupp() {
  196. // Get the version of the browser
  197. version =  parseFloat( navigator.appVersion );
  198.  
  199. if ( ( version >= 2.0 ) && ( version < 2.1 ) && ( navigator.appName.indexOf( "Netscape" ) != -1 ) ) {
  200.   return false;
  201. } else {
  202.   return true;
  203. }
  204. return true;
  205. }
  206. function isLeapYear( yrStr ) {
  207. var leapYear = false;
  208. var year = parseInt( yrStr, 10 );
  209. // every fourth year is a leap year
  210. if ( year % 4 == 0 ) {
  211.   leapYear = true;
  212.   // unless it's a multiple of 100
  213.   if( year % 100 == 0 ) {
  214.       leapYear = false;
  215.       // unless it's a multiple of 400
  216.       if( year % 400 == 0 ) {
  217.           leapYear=true;
  218.       }
  219.   }
  220. }
  221. return leapYear;
  222. }
  223. function getDaysInMonth( mthIdx, YrStr ) {
  224. // all the rest have 31
  225. var maxDays = 31
  226. // expect Feb. (of course)
  227. if( mthIdx == 1 ) {
  228.   if( isLeapYear( YrStr ) ) {
  229.       maxDays=29;
  230.   } else {
  231.       maxDays=28;
  232.   }
  233. }
  234. // thirty days hath...
  235. if( mthIdx == 3 || mthIdx == 5 || mthIdx == 8 || mthIdx == 10 ) {
  236.   maxDays=30;
  237. }
  238. return maxDays;
  239. }
  240. //the function which does some magic to the date fields
  241. // return non-zero if it is the last day of the month
  242. function adjustDate( mthIdx, Dt ) {
  243. var value = 0;
  244.  
  245. var today = new Date()
  246. var theYear = parseInt( today.getFullYear(), 10 )
  247.  
  248. if( mthIdx < today.getMonth() ) {
  249.   theYear = ( parseInt( today.getFullYear(), 10 ) + 1 )
  250. }
  251. if( theYear < 100 ) {
  252.   theYear = "19" + theYear
  253. } else {
  254.   if( ( theYear - 100 ) < 10 ) {
  255.       theYear = "0" + ( theYear - 100 )
  256.   } else {
  257.       theYear = ( theYear - 100 ) + ""
  258.   }
  259.   theYear = "20" + theYear
  260. }
  261. var numDays = getDaysInMonth( mthIdx, theYear );
  262.  
  263. if( mthIdx == 1 ) {
  264.   if( Dt.options.selectedIndex + 1 < numDays ) {
  265.       return 0;
  266.   } else {
  267.       Dt.options.selectedIndex=numDays - 1;
  268.       //check for leap year
  269.       if( numDays == 29 ) {
  270.           return 99;
  271.       } else {
  272.           return 1;
  273.       }
  274.   }
  275. }
  276.  
  277. if( Dt.options.selectedIndex + 1 < numDays ) {
  278.   value = 0;
  279. } else {
  280.   if ( Dt.options.selectedIndex + 1 > numDays ) {
  281.       Dt.options.selectedIndex--;
  282.       value = 3;
  283.   } else {
  284.       //index is 31 or 30
  285.       value = 2;
  286.   }
  287. }
  288. return value;
  289. }
  290.  
  291. //changes departure month when arrival month is changed
  292. function amadChange( inM, inD, outM, outD ) {
  293. if ( !isBrowserSupp() ) {
  294.   return;
  295. }
  296.  
  297. var res = adjustDate( inM.options.selectedIndex, inD );
  298. if( res != 0 ) {
  299.   outD.options.selectedIndex = 0;
  300.   if ( outM.options.selectedIndex == 11 ) {
  301.       outM.options.selectedIndex = 0
  302.   } else {
  303.       outM.options.selectedIndex=inM.options.selectedIndex + 1;
  304.       outD.options.selectedIndex = 1;
  305.   }
  306. } else {
  307.   outM.options.selectedIndex = inM.options.selectedIndex;
  308.   if (outD.options.selectedIndex <= inD.options.selectedIndex) {
  309.       outD.options.selectedIndex = inD.options.selectedIndex + 2;
  310.   }
  311. }
  312. return;
  313. }
  314.  
  315.  
  316.  
  317.  
  318. function dmddChange( outM, outD ) {
  319. if ( !isBrowserSupp() ) {
  320.   return;
  321. }
  322.  
  323. adjustDate( outM.options.selectedIndex, outD );
  324. return;
  325. }
  326.  
  327.  
  328.  
  329.  
  330. function loadDates(arrivalMonthSelect,  arrivalDaySelect, departureMonthSelect, departureDaySelect)
  331. {
  332. var calendar = new Date();
  333. var calendar2 = new Date();
  334. var cal
  335. var cal2
  336. var date;
  337. var month;
  338. var year;
  339. var date2;
  340. var month2;
  341. var year2;
  342.  
  343. //Here is the variable to change for to advance the arrival Date
  344. var advanceArrival = 14;
  345. //Here is the variable to change for to advance the departure Date
  346. var advanceDeparture = 16;
  347.  
  348.  
  349. //Set the arrival Days
  350. calendar.setDate(calendar.getDate()+ advanceArrival);
  351. date = calendar.getDate();
  352. month = calendar.getMonth();
  353.  
  354. //Set the Departure Days
  355. calendar2.setDate(calendar2.getDate()+advanceDeparture);
  356. date2 = calendar2.getDate();
  357. month2 = calendar2.getMonth();
  358.  
  359. arrivalMonthSelect.value=month;
  360. arrivalDaySelect.value=date;
  361. departureMonthSelect.value=month2;
  362. departureDaySelect.value=date2;
  363. }
  364. //-->
  365. </script>
  366.  
  367. <script langauage="javascript">
  368. <!--
  369. function update(themonth,theday){
  370. document.forms[fName].elements[formType+'Day'].options[theday - 1].selected = true;
  371. document.forms[fName].elements[formType+'Month'].options[themonth].selected = true;
  372.  
  373. testWindow.close();
  374. }
  375. function loadCalendar(viewMonth) {
  376. testWindow.document.close();
  377. testWindow.document.open();
  378.  
  379. var day_of_week = new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat");
  380. var month_of_year = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
  381.  
  382. var dateObj = new Date();
  383. var year = dateObj.getFullYear();        // Returns year
  384. var month = dateObj.getMonth();  // Returns month (0-11)
  385. var today = dateObj.getDate();   // Returns day (1-31)
  386. var weekday = dateObj.getDay();  // Returns day (1-31)
  387.  
  388. var DAYS_OF_WEEK = 7;   // "constant" for number of days in a week
  389. var DAYS_OF_MONTH = 31; // "constant" for number of days in a month
  390. var cal;                // Used for printing
  391.  
  392. if (viewMonth < month) {
  393.   year = year + 1;
  394. }
  395.  
  396. if(year < 1900){
  397.   year += 1900; //done to solve the problem of netscape and mozilla returning year in form 10X for years > 2000
  398. }
  399.  
  400. month = viewMonth;
  401. dateObj.setDate(1);      // Start the calendar day at '1'
  402. dateObj.setMonth(month); // Start the calendar month at now
  403. dateObj.setFullYear((year));
  404.  
  405. // VARIABLES FOR FORMATTING
  406. var TR_start = '<TR>';
  407. var TR_end = '</TR>';
  408. var highlight_start = '<TD WIDTH="30"><TABLE CELLSPACING=0 BORDER=0 BORDERCOLOR=CCCCCC><TR><TD WIDTH=20><B><CENTER>';
  409. var highlight_end   = '</CENTER></TD></TR></TABLE></B>';
  410. var TD_start = '<TD WIDTH="30"><CENTER>';
  411. var TD_end = '</CENTER></TD>';
  412. var prevM = month - 1;
  413. var nextM = month + 1;
  414.  
  415. if (nextM == 12) {
  416.   nextM = 0;
  417. }
  418.  
  419. if (prevM == -1) {
  420.   prevM = 11;
  421. }
  422.  
  423. // BEGIN CODE FOR CALENDAR
  424. cal =  '<html><head><title>Calendar</title></head><body>';
  425. cal += '<style>a{cursor: hand}body,table,td{cursor: default;font-family:sans-serif;font-size:12px;color:black;}p.masterHEADER {background: gray; color:white; font-weight: bold; font-size: 13px;margin:0;padding:5px;text-align: center;}</style>';
  426.  
  427. cal += '<div style="border:black 1px solid;">';
  428. cal += '<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="2" width="100%">' + TR_start;
  429. cal += '<TD COLSPAN="' + DAYS_OF_WEEK + '"><p class=masterHEADER>';
  430. cal += month_of_year[month] + '   ' + year + '</p>' + TD_end + TR_end;
  431. cal += TR_start;
  432.  
  433. ///////////////////////////////////
  434. // DO NOT EDIT BELOW THIS POINT  //
  435. ///////////////////////////////////
  436.  
  437. // LOOPS FOR EACH DAY OF WEEK
  438. for(index=0; index < DAYS_OF_WEEK; index++) {
  439.   // PRINTS DAY
  440.   cal += TD_start + day_of_week[index] + TD_end;
  441. }
  442.  
  443. cal += TD_end + TR_end;
  444. cal += TR_start;
  445.  
  446. // FILL IN BLANK GAPS UNTIL TODAY'S DAY
  447. for(index=0; index < dateObj.getDay(); index++) {
  448.   cal += TD_start + '  ' + TD_end;
  449. }
  450.  
  451. // LOOPS FOR EACH DAY IN CALENDAR
  452. for(index=0; index < DAYS_OF_MONTH; index++) {
  453.   if( dateObj.getDate() > index ) {
  454.       // RETURNS THE NEXT DAY TO PRINT
  455.       week_day =dateObj.getDay();
  456.  
  457.       // START NEW ROW FOR FIRST DAY OF WEEK
  458.       if(week_day == 0) {
  459.           cal += TR_start;
  460.       }
  461.  
  462.       if(week_day != DAYS_OF_WEEK) {
  463.           // SET VARIABLE INSIDE LOOP FOR INCREMENTING PURPOSES
  464.           var day  = dateObj.getDate();
  465.  
  466.           // PRINTS DAY
  467.           cal += TD_start + "<span onclick='window.opener.update(" + month + "," + day + "," + year +")'>" + day + "</span>" + TD_end;
  468.       }
  469.  
  470.       // END ROW FOR LAST DAY OF WEEK
  471.       if(week_day == DAYS_OF_WEEK) {
  472.           cal += TR_end;
  473.       }
  474.   }
  475.  
  476.   // INCREMENTS UNTIL END OF THE MONTH
  477.   dateObj.setDate(dateObj.getDate()+1);
  478.  
  479. }// end for loop
  480.  
  481. cal += '</td></TR></TABLE></div><br>';
  482. cal += '<div align="center"><a href="javascript:" onClick="window.opener.loadCalendar(' + prevM + ');">&lt;&lt;</a>&nbsp;&nbsp;&nbsp;&nbsp;';
  483. cal += '<a href="javascript:" onClick="window.opener.loadCalendar(' + nextM + ');">&gt;&gt;</a></div>';
  484. cal += '<a href="javascript:window.close();" style="float:right">close</a>';
  485. cal += '</body></html>';
  486.  
  487. //  PRINT CALENDAR
  488. testWindow.document.write(cal);
  489. }
  490.  
  491. var testWindow;
  492. var fieldName;
  493. var fName;
  494.  
  495. function openCalendar(formName,type) {
  496. formType=type;
  497. fName=formName;
  498. testWindow = window.open('','dates','width=300,height=225,resizable=1,status=1,menubar=0,location=0');
  499. loadCalendar(document.forms[fName].elements[formType+'Month'].selectedIndex);
  500. }
  501. //-->
  502. </script>
  503. <script language="javascript">
  504. <!--
  505. function setCityInformation(_city, _state, _country) {
  506. clearTextBox(document.forms["hotSearch"].cityText);
  507. document.forms["hotSearch"].city.value = _city;
  508. document.forms["hotSearch"].stateProvince.value = _state;
  509. document.forms["hotSearch"].country.value = _country;
  510. }
  511.  
  512. function clearTextBox(_textbox) {
  513. _textbox.value = "";
  514. }
  515.  
  516. function validate(form) {
  517. if (form.numberOfRooms.selectedIndex == 8) {
  518.   window.location = "http://travel.ian.com/index.jsp?pageName=groups&cid="&document.forms["hotsearch"].cid.value&"locale=en_US";
  519.   return false;
  520. }
  521.  
  522. if (document.forms["hotSearch"].cityText.value != "") {
  523.   document.forms["hotSearch"].stateProvince.value = "";
  524.   document.forms["hotSearch"].country.value = "";
  525.   document.forms["hotSearch"].city.value = document.forms["hotSearch"].cityText.value;
  526. }
  527.  
  528. return submitGuestInfoForm(form);
  529. }
  530. //-->
  531. </script>
  532. <!-- my custom search box -->
  533. <script language="javascript">
  534. <!--
  535. // NOTE: customize variables in this javascript block as appropriate.
  536. var defaultAdults="2";
  537. var cellStyle="";
  538. var childHelp="<p id=SUBHEADLINE>Please provide the ages of children in each room. Children's ages should be their age at the time of travel.</p>";
  539. var adultHelp="";
  540. var textRooms="<span id=SUBHEADLINE>Rooms</span>";
  541. var textAdults="<span id=SUBHEADLINE>Adults <br> (age 19+)<span id=SUBHEADLINE>";
  542. var textChildren="<span id=SUBHEADLINE>Children</span>";
  543. var textChildError="<span id=SUBHEADLINE>Please specify the ages of all children.</span>";
  544. var pad='<img src="http://travel.ian.com/images/p.gif" width="5" height="1">';
  545. // NOTE: Question marks ("?") get replaced with a numeric value
  546. var textRoomX="<span id=SUBHEADLINE>Room ?:</span>";
  547. var textChildX="<span id=SUBHEADLINE>Child ?:</span>";
  548.  
  549. //-->
  550. </script>
  551. <!-- NOTE: DO NOT MODIFY THIS JAVASCRIPT BLOCK -->
  552. <script language="javascript">
  553. <!--
  554. var adultsPerRoom=new Array(defaultAdults);
  555. var childrenPerRoom=new Array();
  556. var childAgesPerRoom=new Array();
  557. var numRooms=1;
  558. var maxChildren=0;
  559.  
  560. refresh();
  561.  
  562. function setChildAge(room, child, age) {
  563. if (childAgesPerRoom[room] == null) {
  564.   childAgesPerRoom[room] = new Array();
  565. }
  566. childAgesPerRoom[room][child] = age;
  567. }
  568.  
  569. function setNumAdults(room, numAdults) {
  570. adultsPerRoom[room] = numAdults;
  571. }
  572.  
  573. function setNumChildren(room, numChildren) {
  574. childrenPerRoom[room] = numChildren;
  575. refresh();
  576. }
  577.  
  578. function setNumRooms(x) {
  579. numRooms = x;
  580. for (i = 0; i < x; i++) {
  581.   if (adultsPerRoom[i] == null) {
  582.       adultsPerRoom[i] = 2;
  583.   }
  584.   if (childrenPerRoom[i] == null) {
  585.       childrenPerRoom[i] = 0;
  586.   }
  587. }
  588. refresh();
  589. }
  590.  
  591. function renderRoomSelect() {
  592. var x = '';
  593. x += '<select name="numberOfRooms" onchange="setNumRooms(this.options[this.selectedIndex].value);">';
  594. for (var i = 1; i < 9; i++) {
  595.   x += '<option value="'+i+'"'+(numRooms == i ? ' selected' : '')+'>' + i;
  596. }
  597. x += '<option value="9"'+(numRooms == 9 ? ' selected' : '')+'>9+';
  598. x += '</select>';
  599. return x;
  600. }
  601.  
  602. function refresh() {
  603. maxChildren = 0;
  604. for (var i = 0; i < numRooms; i++) {
  605.   if (childrenPerRoom[i] > maxChildren) {
  606.       maxChildren = childrenPerRoom[i];
  607.   }
  608. }
  609.  
  610. var x = '';
  611. if (adultHelp.length > 0) {
  612.   x = adultHelp + "<p>\n";
  613. }
  614.  
  615. if (numRooms > 8) {
  616.   x += textRooms;
  617.   x += renderRoomSelect();
  618.  
  619. } else {
  620.   x += '<table border="0" cellspacing="2" cellpadding="0" class="SUBHEADELINE">\n';
  621.   x += '<tr><td>'+textRooms+pad+'</td>';
  622.   if (numRooms >= 1) {
  623.       x += '<td>&nbsp;</td>';
  624.   }
  625.   x += '<td><nobr>'+textAdults+pad+'</nobr></td><td'+cellStyle+'><nobr>'+textChildren+pad+'</nobr></td></tr>\n';
  626.   for (var i = 0; i < numRooms; i++) {
  627.       x += '<tr><td'+cellStyle+'>';
  628.       if (i == 0) {
  629.           x += renderRoomSelect();
  630.       } else {
  631.           x += '&nbsp;';
  632.       }
  633.       x += '</td>';
  634.       if (numRooms >= 1) {
  635.           x += '<td><nobr>'+getValue(textRoomX, i+1)+pad + '</nobr></td>';
  636.       }
  637.       x += '<td>';
  638.       x += buildSelect('room-' + i + '-adult-total', 'setNumAdults(' + i + ', this.options[this.selectedIndex].value)', 1, 4, adultsPerRoom[i]);
  639.       x += '</td><td>';
  640.       x += buildSelect('room-' + i + '-child-total', 'setNumChildren(' + i + ', this.options[this.selectedIndex].value)', 0, 5, childrenPerRoom[i]);
  641.       x += '</td></tr>\n';
  642.   }
  643.   x += '</table>\n';
  644.  
  645.   var didHeader = false;
  646.   for (var i = 0; i < numRooms; i++) {
  647.       if (childrenPerRoom[i] > 0) {
  648.           if (!didHeader) {
  649.               x += '<table border="0" cellpadding="0" cellspacing="2">\n';
  650.               x += '<tr><td colspan="'+(maxChildren+1)+'">';
  651.               x += '<img src="/images/p.gif" width="1" height="5"><br>';
  652.               x += childHelp;
  653.               x += '<img src="/images/p.gif" width="1" height="5"><br>';
  654.               x += '</td></tr>\n<tr><td>&nbsp;</td>';
  655.               for (var j = 0; j < maxChildren; j++) {
  656.                   x += '<td'+cellStyle+'><nobr>'+getValue(textChildX, j+1)+pad+'</nobr></td>\n';
  657.               }
  658.               didHeader = true;
  659.           }
  660.           x += '</tr>\n<tr><td><nobr>'+getValue(textRoomX, i+1)+pad+'</nobr></td>';
  661.           for (var j = 0; j < childrenPerRoom[i]; j++) {
  662.               x += '<td'+cellStyle+'>';
  663.               var def = -1;
  664.               if (childAgesPerRoom[i] != null) {
  665.                   if (childAgesPerRoom[i][j] != null) {
  666.                       def = childAgesPerRoom[i][j];
  667.                   }
  668.               }
  669.               x += '<select name="room-'+i+'-child-'+j+'-age" onchange="setChildAge('+i+', '+j+', this.options[this.selectedIndex].value);">';
  670.               x += '<option value="-1"'+(def == -1 ? ' selected' : '')+'>-?-';
  671.               x += '<option value="0"'+(def == 0 ? ' selected' : '')+'>&lt;1';
  672.               for (var k = 1; k <= 18; k++) {
  673.                   x += '<option value="'+k+'"'+(def == k ? ' selected' : '')+'>'+k;
  674.               }
  675.               x += '</td>';
  676.           }
  677.           if (childrenPerRoom[i] < maxChildren) {
  678.               for (var j = childrenPerRoom[i]; j < maxChildren; j++) {
  679.                   x += '<td'+cellStyle+'>&nbsp;</td>';
  680.               }
  681.           }
  682.           x += '</tr>\n';
  683.       }
  684.   }
  685.   if (didHeader) {
  686.       x += '</table>\n';
  687.   }
  688. }
  689.  
  690. document.getElementById("hot-search-params").innerHTML = x;
  691. }
  692.  
  693. function buildSelect(name, onchange, min, max, selected) {
  694. var x = '<select name="' + name + '"';
  695. if (onchange != null) {
  696.   x += ' onchange="' + onchange + '"';
  697. }
  698. x +='>\n';
  699. for (var i = min; i <= max; i++) {
  700.   x += '<option value="' + i + '"';
  701.   if (i == selected) {
  702.       x += ' selected';
  703.   }
  704.  
  705.   x += '>' + i + '\n';
  706. }
  707. x += '</select>';
  708. return x;
  709. }
  710.  
  711. function validateGuests(form) {
  712. if (numRooms < 9) {
  713.   var missingAge = false;
  714.   for (var i = 0; i < numRooms; i++) {
  715.       var numChildren = childrenPerRoom[i];
  716.       if (numChildren != null && numChildren > 0) {
  717.           for (var j = 0; j < numChildren; j++) {
  718.               if (childAgesPerRoom[i] == null || childAgesPerRoom[i][j] == null || childAgesPerRoom[i][j] == -1) {
  719.                   missingAge = true;
  720.               }
  721.           }
  722.       }
  723.   }
  724.  
  725.   if (missingAge) {
  726.       alert(textChildError);
  727.       return false;
  728.   } else {
  729.       return true;
  730.   }
  731. } else {
  732.   return true;
  733. }
  734. }
  735.  
  736. function submitGuestInfoForm(form) {
  737. if (!validateGuests(form)) {
  738.   return false;
  739. }
  740.  
  741. return true;
  742. }
  743.  
  744. function getValue(str, val) {
  745. return str.replace(/\?/g, val);
  746. }
  747. //-->
  748. </script>
  749.  
  750. <script defer="defer" type="text/javascript">
  751. loadDates(document.forms['hotSearch'].arrivalMonth,document.forms['hotSearch'].arrivalDay, document.forms['hotSearch'].departureMonth, document.forms['hotSearch'].departureDay)
  752. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement