var num_RoomsRequired;var obj_Occupancy;var obj_ChildAges;var arr_RoomData=[];var arr_ChildAges=[];for(i=0;i<6;i++){arr_RoomData[i]={a:2,c:0,s:false}}function js_DOMCreateDiv(C,A,B){el_NewDiv=document.createElement("DIV");if(C.len>0){if(navigator.userAgent.indexOf("MSIE")==-1){el_NewDiv.setAttribute("class",C)}else{el_NewDiv.setAttribute("className",C)}}if(A!=""){el_NewText=document.createTextNode(A);el_NewDiv.appendChild(el_NewText)}if(B){el_NewDiv.appendChild(B)}return el_NewDiv}function js_DOMCreateP(C,A,B){el_NewDiv=document.createElement("P");if(C.len>0){if(navigator.userAgent.indexOf("MSIE")==-1){el_NewDiv.setAttribute("class",C)}else{el_NewDiv.setAttribute("className",C)}}if(A!=""){el_NewText=document.createTextNode(A);el_NewDiv.appendChild(el_NewText)}if(B){el_NewDiv.appendChild(B)}return el_NewDiv}function js_checkChildAgesFilled(A){while(A.tagName!=="FORM"){A=A.parentNode}rExp=/frm_Child[0-9]/gi;allSet=true;if(A.elements.length>0){for(i=0;i<A.elements.length;i++){if(A.elements[i].id.search(rExp)>-1&&A.elements[i].options[A.elements[i].selectedIndex].value==-1){allSet=false}}}return allSet}function js_DOMCreateSelect(B,C,A){el_NewSelect=document.createElement("SELECT");el_NewSelect.setAttribute("name",B);el_NewSelect.setAttribute("id",B);rExp=/frm_Child[0-9]/gi;if(B.search(rExp)>-1){js_addOption(el_NewSelect,"-1","-",false);if(document.getElementById("holSearchSubmit")){el_NewSelect.onchange=function(){js_checkChildAgesFilled(this)}}}rExp=/frm_AdultsRoom[0-9]/gi;for(j=C;j<=A;j++){if((B.search(rExp)>-1)&&(j==2)){js_addOption(el_NewSelect,j,j,true)}else{js_addOption(el_NewSelect,j,j,false)}}return el_NewSelect}function js_SelectRoomOccupants(A){for(rl=0;rl<A;rl++){num_RoomNum=rl+1;var B=parseInt(obj_Occupancy.occupancy[rl]["num_numchildren"])+parseInt(obj_Occupancy.occupancy[rl]["num_numinfants"]);js_selectValue("frm_AdultsRoom"+(num_RoomNum),obj_Occupancy.occupancy[rl]["num_numadults"],false);js_selectValue("frm_ChildrenRoom"+(num_RoomNum),B,false)}}function js_SelectChildAges(){var A=0;for(i=1;i<=num_RoomsRequired;i++){A=A+parseInt($("frm_ChildrenRoom"+i).value)}for(ch=1;ch<=A;ch++){js_selectValue("frm_Child"+(ch),arr_ChildAges[ch-1],false)}}function js_addOption(A,C,B,E){var D=document.createElement("OPTION");D.value=C;D.text=B;if(E){D.selected="selected"}if(navigator.userAgent.indexOf("MSIE")==-1){A.add(D,null)}else{A.add(D)}}function js_selectValue(D,E,A){var C=$(D);var B=C.childNodes.length;if(B!=0){for(i=0;i<B;i++){if(C.childNodes[i].value==E){C.childNodes[i].selected=true;if(A){C.onchange()}return true}}}}function js_removeFirstChild(A){A.removeChild(A.firstChild)}function js_removeAllChildren(A){if(A!==null&&A.firstChild){while(A.firstChild){A.removeChild(A.firstChild)}}}function checkHolidayForm(A){if($("num_destID")){if($("num_destID").value==0){alert("Please select a destination from the list. Thank you.");return false}}if($("num_deptID")){if($("num_deptID").value==0){alert("Please select a specific station/airport to travel from. Thank you.");return false}}if($("cal1input")){if(checkYCalDate(1)==false){alert("Please enter date in the format DD/MM/YYYY");return false}}if($("cal2input")){if(checkYCalDate(2)==false){alert("Please enter date in the format DD/MM/YYYY");return false}}if(!js_checkChildAgesFilled(A)){alert("Please enter the ages of all under 18s before continuing");return false}if($("package_type_ep")&&$("package_type_ep").checked){if($("str_ep_time_out")&&$("str_ep_time_out").value==""){alert("Please enter the desired outbound train time");return false}if($("str_ep_time_in")&&$("str_ep_time_in").value==""){alert("Please enter the desired return train time");return false}}return true}function initHolidaySearchForm(){var C=false;var E=false;if($("hs_adv_hide")){E=$("hs_adv_hide").style.display}if($("hs_adv_show")){C=$("hs_adv_show").style.display}if(C&&C==E){$("hs_adv_show").style.display="block"}for(i=1;i<10;i++){if($("JSonly_"+i)){$("JSonly_"+i).style.display="block"}else{break}}for(i=1;i<10;i++){if($("JSonlyrow_"+i)){$("JSonlyrow_"+i).style.display="table-row"}else{break}}try{$("cal1input").style.backgroundImage="url(/images/icon_calendar.gif)"}catch(D){}try{$("cal2input").style.backgroundImage="url(/images/icon_calendar.gif)"}catch(D){}try{num_RoomsRequired=$("frm_RoomsRequired").value}catch(D){}try{if($("hs_ChildAges")){$("hs_ChildAges").style.display="block"}js_OutputRoomOccupants(num_RoomsRequired);js_selectValue("frm_AdultsRoom1",2,false);if(obj_Occupancy){js_SelectRoomOccupants(num_RoomsRequired)}js_OutputChildAges();js_SelectChildAges()}catch(D){}try{hsf_SetNumRooms(num_RoomsRequired)}catch(D){}try{timeCheck.query()}catch(D){}}function js_OutputRoomOccupants(A){obj_Occupants=$("hs_Occupants");num_RoomsRequired=A;js_removeAllChildren(obj_Occupants);for(i=1;i<=A;i++){obj_AdultsSelect=js_DOMCreateSelect("frm_AdultsRoom"+i,1,9);obj_ChildrenSelect=js_DOMCreateSelect("frm_ChildrenRoom"+i,0,9);obj_RoomNumber=js_DOMCreateP("hs_OccupantsRoomNumber","Room "+i);obj_Adults=js_DOMCreateDiv("hs_OccupantsAdults","",obj_AdultsSelect);obj_Children=js_DOMCreateDiv("hs_OccupantsChildren","",obj_ChildrenSelect);if(navigator.userAgent.indexOf("MSIE")==-1){obj_Children.onchange=js_OutputChildAges}obj_frame=js_DOMCreateDiv("","");obj_frame.appendChild(obj_RoomNumber);obj_frame.appendChild(obj_Adults);obj_frame.appendChild(obj_Children);obj_Occupants.appendChild(obj_frame);if(navigator.userAgent.indexOf("MSIE")!=-1){eventAttached=document.getElementById("frm_ChildrenRoom"+i).attachEvent("onchange",js_OutputChildAges)}}js_OutputChildAges()}function js_OutputChildAges(){obj_ChildAges=$("hs_ChildAges");if(obj_ChildAges!==null){js_removeAllChildren(obj_ChildAges);var A=0;for(i=1;i<=num_RoomsRequired;i++){A=A+parseInt($("frm_ChildrenRoom"+i).value)}if(A!=0){obj_IntroText=js_DOMCreateDiv("hs_ChildIntroText","Please specify the ages of children on the date of return.");obj_IntroText.style.padding="5px";obj_ChildAges.appendChild(obj_IntroText);for(i=1;i<=A;i++){obj_ChildAgeSelect=js_DOMCreateSelect("frm_Child"+i,0,17);obj_frame=js_DOMCreateDiv("","");obj_ChildNumber=js_DOMCreateP("hs_ChildrenNumber","#"+i+" under 18");obj_ChildNumber.style.padding="0px";obj_ChildNumber.style.margin="0px";obj_ChildAge=js_DOMCreateDiv("hs_Children","",obj_ChildAgeSelect);obj_frame.appendChild(obj_ChildNumber);obj_frame.appendChild(obj_ChildAge);obj_ChildAges.appendChild(obj_frame)}obj_ChildAges.style.display="block"}else{obj_ChildAges.style.display="none"}}if($("hol_info_top")){$("hol_info_top").style.marginTop=$("search_box").getHeight()+"px"}}function hsf_ParseRooms(){var B=$("hsf_roomcanvas");var A=0;var F=[];var C;var H;var D;var E;var I;while(B.firstChild){B.removeChild(B.firstChild)}for(var G=0;G<arr_RoomData.length;G++){if(arr_RoomData[G].s){H=document.createTextNode("Room "+(G+1)+":");C=document.createElement("div");C.className="hsf_left";C.appendChild(H);F[F.length]=C;E=document.createElement("select");E.name="frm_AdultsRoom"+(G+1);E.id="f_ar_"+(G+1);E.onchange=function(J){hsf_SetRoomOcc(J,"a",$("f_ar_"+J).value)}.bind(this,(G+1));for(j=1;j<10;j++){D=document.createElement("option");D.value=j;if(j==arr_RoomData[G].a){D.selected=true}H=document.createTextNode(j);D.appendChild(H);E.appendChild(D)}C=document.createElement("div");C.className="hsf_centerhalf";C.appendChild(E);F[F.length]=C;E=document.createElement("select");E.name="frm_ChildrenRoom"+(G+1);E.id="f_cr_"+(G+1);E.onchange=function(J){hsf_SetRoomOcc(J,"c",$("f_cr_"+J).value)}.bind(this,(G+1));for(j=0;j<10;j++){D=document.createElement("option");D.value=j;if(j==arr_RoomData[G].c){D.selected=true}H=document.createTextNode(j);D.appendChild(H);E.appendChild(D)}C=document.createElement("div");C.className="hsf_centerhalf";C.appendChild(E);F[F.length]=C;C=document.createElement("div");C.className="hsf_clear";F[F.length]=C;if(arr_RoomData[G].c>0){for(j=0;j<arr_RoomData[G].c;j++){A++;switch(A%10){case 1:c_ext="st";break;case 2:c_ext="nd";break;case 3:c_ext="rd";break;default:c_ext="th";break}this_age=99;if(arr_ChildAges.length>j){this_age=arr_ChildAges[j]}else{arr_ChildAges[j]=this_age}H=document.createTextNode("Age of "+A+c_ext+" 'under 18' at time of travel");C=document.createElement("div");C.className="hsf_lefthalf";C.appendChild(H);F[F.length]=C;E=document.createElement("select");E.name="frm_Child"+A;E.id="f_c_"+A;E.onchange=function(J){hsf_SetChildage(J,$("f_c_"+J).value)}.bind(this,A);D=document.createElement("option");D.value="-";H=document.createTextNode(D.value);D.appendChild(H);E.appendChild(D);for(k=0;k<18;k++){D=document.createElement("option");D.value=k;H=document.createTextNode(D.value);if(arr_ChildAges[A-1]==k){D.selected=true}D.appendChild(H);E.appendChild(D)}C=document.createElement("div");C.className="hsf_centerhalf";C.appendChild(E);F[F.length]=C;C=document.createElement("div");C.className="hsf_clear";F[F.length]=C}}}else{break}}for(G=0;G<F.length;G++){B.appendChild(F[G])}if($("hol_info_top")){$("hol_info_top").style.marginTop=$("search_box").getHeight()+"px"}}function hsf_SetRoomOcc(C,A,B){switch(A){case"c":arr_RoomData[C-1].c=B;hsf_ParseRooms();break;case"a":arr_RoomData[C-1].a=B;break}}function hsf_SetChildage(B,A){arr_ChildAges[B-1]=A}function hsf_SetNumRooms(C){for(var B=0;B<C;B++){arr_RoomData[B].s=true}if(C<arr_RoomData.length){for(var A=C;A<arr_RoomData.length;A++){arr_RoomData[A].s=false}}hsf_ParseRooms()}function toggle_advSearch(){var C=false;var D=false;if($("hs_adv_hide")){D=$("hs_adv_hide").style.display}if($("hs_adv_show")){C=$("hs_adv_show").style.display}if(C&&D){$("hs_adv_show").style.display=D;$("hs_adv_hide").style.display=C;if($("hs_adv_1")){$("hs_adv_1").style.display=C}if($("hs_adv_2")){$("hs_adv_2").style.display=C}if($("hs_adv_3")){$("hs_adv_3").style.display=C}if($("hs_adv_4")){$("hs_adv_4").style.display=C}}}function choose_search(D){var C=$("cal1input");var B=false;switch(D.toLowerCase()){case"fh":case"cp":if($("str_ep_time_out_section")){$("str_ep_time_out_section").style.display="none"}if($("str_ep_time_in_section")){$("str_ep_time_in_section").style.display="none"}if($("num_deptID_ep")){ele_source=$("num_deptID_ep");ele_source.style.display="none";if(ele_source.value!==""&&$("num_deptID_cp")){ele_target=$("num_deptID_cp");var A=ele_source.options[ele_source.selectedIndex].text;if(A!==ele_target.options[ele_target.selectedIndex].text){for(var E=0;E<ele_target.options.length;E++){if(ele_target.options[E].text==A){ele_target.selectedIndex=E;break}}}}}if($("num_destID_ep")){ele_source=$("num_destID_ep");ele_source.style.display="none";if(ele_source.value!==""&&$("num_destID_cp")){ele_target=$("num_destID_cp");var A=ele_source.options[ele_source.selectedIndex].text;if(A!==ele_target.options[ele_target.selectedIndex].text){for(var E=0;E<ele_target.options.length;E++){if(ele_target.options[E].text==A){ele_target.selectedIndex=E;break}}}}}if($("num_deptID_cp")){$("num_deptID_cp").style.display=""}if($("num_destID_cp")){$("num_destID_cp").style.display="";routeCheck.query($("num_destID_cp").value,false)}try{if(calDateStorage.cp.mx){calDateStorage.ep.dat=DLHNS.calendar.cal1.cfg.config.pagedate.value;calDateStorage.ep.str=C.value;DLHNS.calendar.cal1=new DLHNS.widget.CalendarGroup("cal1","cal1Container",{pages:1,close:true,start_weekday:1,mindate:calDateStorage.cp.mn,pagedate:calDateStorage.cp.dat,MAXDATE:calDateStorage.cp.mx,hide_blank_weeks:true});B=true;C.value=calDateStorage.cp.str}}catch(F){}break;case"ep":timeCheck.query();if($("num_deptID_cp")){ele_source=$("num_deptID_cp");ele_source.style.display="none";if(ele_source.value!==""&&$("num_deptID_ep")){ele_target=$("num_deptID_ep");var A=ele_source.options[ele_source.selectedIndex].text;if(A!==ele_target.options[ele_target.selectedIndex].text){for(var E=0;E<ele_target.options.length;E++){if(ele_target.options[E].text==A){ele_target.selectedIndex=E;break}}}}}if($("num_destID_cp")){ele_source=$("num_destID_cp");ele_source.style.display="none";if(ele_source.value!==""&&$("num_destID_ep")){ele_target=$("num_destID_ep");var A=ele_source.options[ele_source.selectedIndex].text;if(A!==ele_target.options[ele_target.selectedIndex].text){for(var E=0;E<ele_target.options.length;E++){if(ele_target.options[E].text==A){ele_target.selectedIndex=E;break}}}}}if($("str_ep_time_out_section")){$("str_ep_time_out_section").style.display=""}if($("str_ep_time_in_section")){$("str_ep_time_in_section").style.display=""}if($("num_destID_ep")){$("num_destID_ep").style.display=""}if($("num_deptID_ep")){$("num_deptID_ep").style.display=""}try{if(calDateStorage.ep.mx){calDateStorage.cp.dat=DLHNS.calendar.cal1.cfg.config.pagedate.value;calDateStorage.cp.str=C.value;DLHNS.calendar.cal1=new DLHNS.widget.CalendarGroup("cal1","cal1Container",{pages:1,close:true,start_weekday:1,mindate:calDateStorage.ep.mn,pagedate:calDateStorage.ep.dat,MAXDATE:calDateStorage.ep.mx,hide_blank_weeks:true});B=true;C.value=calDateStorage.ep.str}}catch(F){}break}try{if(B){mydate=new Date(C.value.substr(6,4),(C.value.substr(3,2)-1),C.value.substr(0,2));DLHNS.calendar.cal1.select((mydate.getMonth()+1)+"/"+mydate.getDate()+"/"+mydate.getFullYear());DLHNS.calendar.cal1.setYear(mydate.getFullYear());DLHNS.calendar.cal1.setMonth(mydate.getMonth());DLHNS.calendar.cal1.selectEvent.subscribe(handleSelect1,DLHNS.calendar.cal1,true);DLHNS.calendar.cal1.hideEvent.subscribe(function(){hideCalendar(1)},DLHNS.calendar.cal1,true);DLHNS.calendar.cal1.changePageEvent.subscribe(function(){resizeShadow(1)},DLHNS.calendar.cal1,true);DLHNS.calendar.cal1.render()}}catch(F){}};
