var bolBrowserOK = false; version=0; if(navigator.appVersion.indexOf("MSIE")!=-1){ temp = navigator.appVersion.split("MSIE"); version = parseFloat(temp[1]); if (version>=5.5){ bolBrowserOK = true; } }else{ if(navigator.userAgent.indexOf("Firefox")!=-1){ var versionindex = navigator.userAgent.indexOf("Firefox") + 8; if(parseInt(navigator.userAgent.charAt(versionindex))>=1){ bolBrowserOK = true; } } } var theMonths = new Array("January", "Febuary", "March", "April", "May", "June", "July", "August", "Spetember", "October", "November", "December"); var SystemDate = new Date("2008/07/12"); var intSpecialDaysForDisneyLandParis = -469 function DayExtension(xDay){ val = ""; switch (parseInt(xDay)){ case 1: case 21: case 31: val = "st"; break; case 2: case 22: val = "nd"; break; case 3: case 23: val = "rd"; break; default: val = "th"; break; } return val; } function CalDays(){ if(document.expressForm.ORIGINE.value.substr(3,2) == "ST" || document.expressForm.DESTINATION.value.substr(3,2) == "ST"){ if(document.expressForm.ORIGINE.value.substr(0,2) == "FR" && document.expressForm.DESTINATION.value.substr(0,2) == "FR"){ intDaysToBook = 90; }else{ if((document.expressForm.ORIGINE.value.substr(0,2) == "UK" && document.expressForm.DESTINATION.value.substr(0,2) == "FR") || (document.expressForm.ORIGINE.value.substr(0,2) == "FR" && document.expressForm.DESTINATION.value.substr(0,2) == "UK")){ intDaysToBook = 90; } } } if(document.expressForm.ORIGINE.value.substr(3,2) == "ES" && document.expressForm.DESTINATION.value.substr(3,2) == "ES"){ if((document.expressForm.ORIGINE.value.substr(0,2) == "UK" && document.expressForm.DESTINATION.value.substr(0,2) != "UK") || (document.expressForm.ORIGINE.value.substr(0,2) != "UK" && document.expressForm.DESTINATION.value.substr(0,2) == "UK")){ intDaysToBook = 120; }else{ intDaysToBook = 90; } } if((document.expressForm.ORIGINE.value.substr(0,2) == "UK" && document.expressForm.DESTINATION.value == "FR,ES,MARNE LA VALLEE") || (document.expressForm.ORIGINE.value == "FR,ES,MARNE LA VALLEE" && document.expressForm.DESTINATION.value.substr(0,2) == "UK")){ intDaysToBook = intSpecialDaysForDisneyLandParis; } } function makeDate(objToUpdate){ datCDate = ""; var tmpValue = objToUpdate.value.split("/"); if(tmpValue.length == 3){ if((isNaN(tmpValue[0]) == false) && (isNaN(tmpValue[1]) == false) && (isNaN(tmpValue[2]) == false) && (tmpValue[0] != "") && (tmpValue[1] != "") && (tmpValue[2] != "")){ if(tmpValue[2].length > 4){ var tmpYear = SystemDate.getFullYear(); }else{ if(tmpValue[2].length == 4){ var tmpYear = tmpValue[2]; }else{ if(tmpValue[2].length == 3) { tmpValue[2] = tmpValue[2].substr(1,2); } if(tmpValue[2].length == 1) { tmpValue[2] = "0" + tmpValue[2]; } var tmpYear = (SystemDate.getFullYear() + "").substr(0,2) + tmpValue[2]; } } if(tmpValue[1] > 12) {tmpValue[1] = 12;} if(tmpValue[0] > 31) {tmpValue[0] = 31;} datCDate = new Date(tmpYear + "/" + tmpValue[1] + "/" + tmpValue[0]); } } return(datCDate); } var intDaysToBook = 60; function TestForm(){ if(bolBrowserOK == true){ if((document.expressForm.DESTINATION.value == " , ,SNOWTRAIN") || (document.expressForm.ORIGINE.value == " , ,SNOWTRAIN")){ window.location.href = "http://www.raileurope.co.uk/snowtrains/snowtrain_bookingform.asp"; return false; } var strErr = ''; CalDays(); var departdate = new Date(makeDate(document.expressForm.LeavingOn)); var returndate = new Date(makeDate(document.expressForm.ReturningOn)); var endDate = new Date(SystemDate.getFullYear() + "/" + (SystemDate.getMonth() + 1) + "/" + (SystemDate.getDate() + intDaysToBook)); if(returndate.toString().length > 0){ if(returndate > endDate){ strErr = "Your return date is to far in the furture. You can only make bookings up to " + endDate.getDate() + DayExtension(endDate.getDate().toString()) + " " + theMonths[endDate.getMonth()] + " " + endDate.getYear() + " for this route."; } if(returndate < SystemDate){ strErr = "Your return date must be after " + SystemDate.getDate() + DayExtension(SystemDate.getDate().toString()) + " " + theMonths[SystemDate.getMonth()] + " " + SystemDate.getYear(); } if(returndate < departdate){ strErr = "Your return date must be after your depature date."; } } if(departdate > endDate){ strErr = "Your depature date is to far in the furture. You can only make bookings up to " + endDate.getDate() + DayExtension(endDate.getDate().toString()) + " " + theMonths[endDate.getMonth()] + " " + endDate.getYear() + " for this route."; } if(departdate < SystemDate){ strErr = "Your depature date must be after " + SystemDate.getDate() + DayExtension(SystemDate.getDate().toString()) + " " + theMonths[SystemDate.getMonth()] + " " + SystemDate.getYear();; } if(document.expressForm.DESTINATION.value == " , ,"){ strErr = "Please select a destination station."; } if(document.expressForm.ORIGINE.value == " , ,"){ strErr = "Please select a depature station."; } if(document.expressForm.LeavingOn.value == ""){ strErr = "Please enter a depature date."; } if((departdate == "") || (isNaN(departdate) == true)){ strErr = "Please enter a correctly formated date. (dd/mm/yyyy)"; } if(strErr != ""){ alert(strErr); }else{ document.expressForm.submit(); } }else{ document.expressForm.submit(); } }