function getForm() { return document.SearchResultsForm; } function trim(value){ return value.replace(/^\s+|\s+$/,''); } function populatePuDate(dropList) { //if month selected is a month gone, select next year as the year. if(dropList != null && dropList == 'puMonth') { var date = new Date(); if(getForm().puMonth.value < date.getMonth()+1) { getForm().puYear.value = Number(date.getFullYear())+1; } } getForm().doDay.selectedIndex=getForm().puDay.selectedIndex; getForm().doMonth.selectedIndex=getForm().puMonth.selectedIndex; getForm().doYear.selectedIndex=getForm().puYear.selectedIndex; } function populateDoDate(dropList) { //if month selected is a month gone, select next year as the year. if(dropList != null && dropList == 'doMonth') { var date = new Date(); if(getForm().doMonth.value < date.getMonth()+1) { getForm().doYear.value = Number(date.getFullYear())+1; } } } function setPuMultipleValues(y,m,d) { getForm().puDay.value=d; getForm().puMonth.value=m; getForm().puYear.value=LZ(y); } function setDoMultipleValues(y,m,d) { getForm().doDay.value=d; getForm().doMonth.value=m; getForm().doYear.value=LZ(y); } function validateSearchResultsForm(searchForm){ /* searchForm.action=searchForm.action+"?puDay="+searchForm.puDay.value+"&location="+searchForm.location.value+"&dropLocation="+searchForm.dropLocation.value+"&driversAge="+searchForm.driversAge.value+"&puMonth="+searchForm.puMonth.value+"&puYear="+searchForm.puYear.value+"&doDay="+searchForm.doDay.value+"&doMonth="+searchForm.doMonth.value+"&doYear="+searchForm.doYear.value+"&puHour="+searchForm.puHour.value+"&puMinute="+searchForm.puMinute.value+"&doHour="+searchForm.doHour.value+"&doMinute="+searchForm.doMinute.value; */ var errors = ""; errors = validateDriversAge(searchForm.driversAge, "La edad del conductor", errors); errors = validateMandatoryDroplist(searchForm.country, "País de Recogida", errors); errors = validateMandatoryDroplist(searchForm.city, "Ciudad de Recogida", errors); errors = validateMandatoryDroplist(searchForm.location, "Lugar de recogida", errors); errors = validateMandatoryDroplist(searchForm.dropCountry, "País de Devolución", errors); errors = validateMandatoryDroplist(searchForm.dropCity, "Ciudad de Devolución", errors); errors = validateMandatoryDroplist(searchForm.dropLocation, "Lugar de devolución ", errors); errors = validateDate(searchForm.puYear.value, searchForm.puMonth.value-1, searchForm.puDay.value, "Fecha de recogida", errors); errors = validateDate(searchForm.doYear.value, searchForm.doMonth.value-1, searchForm.doDay.value, "Fecha de Devolución", errors); errors = validateDates( searchForm.puYear.value, searchForm.puMonth.value-1, searchForm.puDay.value, searchForm.puHour.value, searchForm.puMinute.value, "Fecha de recogida", searchForm.doYear.value, searchForm.doMonth.value-1, searchForm.doDay.value, searchForm.doHour.value, searchForm.doMinute.value, "Fecha de Devolución", errors); errors = validateCutOffDate(searchForm.puYear.value, searchForm.puMonth.value-1, searchForm.puDay.value, "Fecha de recogida", errors); if(errors==""){ return true; } else { alert(errors); return false; } } function validateMandatoryDroplist(droplist, name, errors){ if(droplist.value=="" || droplist.value==0){ errors = errors + name + " debe ser especificado\n"; } return errors; } function validateDates(yearFrom, monthFrom, dayFrom, hourFrom, minuteFrom, nameFrom, yearTo, monthTo, dayTo, hourTo, minuteTo, nameTo, errors){ var date = new Date(); var dateFrom = new Date(yearFrom, monthFrom, dayFrom, hourFrom, minuteFrom, 0); var dateTo = new Date(yearTo, monthTo, dayTo, hourTo, minuteTo, 0); if(dateFrom.valueOf() < date.valueOf()){ errors = errors + nameFrom + " es antes de fecha de hoy\n"; } if(dateFrom.valueOf() > dateTo.valueOf()){ errors = errors + nameFrom + " debe ser antes de la " + nameTo + "\n"; } return errors; } function validateDate(year, month, day, name, errors){ if(!isValidDate(year, month, day)){ errors = errors + name + " no es una fecha válida\n"; } return errors; } function validateCutOffDate(year, month, day, name, errors){ var cutOffDate = new Date(2005, 11, 28); var newDate = new Date(year, month, day); if(cutOffDate.valueOf()>newDate.valueOf()){ errors = errors + "Pickup date must be after 27th December 2005\n"; } return errors; } function isValidDate(year, month, day){ var tempDate = new Date(year, month, day); var tempYear = tempDate.getYear()<2000?tempDate.getYear()+1900:tempDate.getYear(); return (tempYear==year && tempDate.getMonth()==month && tempDate.getDate()==day); } function isNumeric(sText){ var validChars = "0123456789"; var returnValue = true; var currentChar; for (var i = 0; i < sText.length && returnValue == true; i++) { currentChar = sText.charAt(i); if (validChars.indexOf(currentChar) == -1) { returnValue = false; } } return returnValue; } function validateDriversAge(driversAge, name, errors){ var minDriversAge = 21; var maxDriversAge = 75; if(driversAge.value==""){ errors = errors + name + " debe ser especificado\n"; } /* else if(!isNumeric(driversAge.value)) { errors = errors + name + " debe ser un número\n"; } else if(driversAge.value < minDriversAge) { errors = errors + name + " debe ser por lo menos " + minDriversAge + "\n"; } else if(driversAge.value > maxDriversAge) { errors = errors + name + " no debe ser más de " + maxDriversAge + "\n"; }*/ return errors; } function headingClick(checkbox, options, index){ var element = document.getElementById(options); if(checkbox.checked==true){ element.style.display='none'; var i=0; while(true){ var subelem = document.getElementById("optionCB" + index + ":" + i++); if(subelem==null || i>100) break; subelem.checked = false; } } else { element.style.display=''; } } function disableSearchResultsForm(isDisabled){ if(isDisabled){ getForm().country.disabled=isDisabled; getForm().city.disabled=isDisabled; getForm().location.disabled=isDisabled; getForm().dropCountry.disabled=isDisabled; getForm().dropCity.disabled=isDisabled; getForm().dropLocation.disabled=isDisabled; } getForm().puDay.disabled=isDisabled; getForm().puMonth.disabled=isDisabled; getForm().puYear.disabled=isDisabled; getForm().puHour.disabled=isDisabled; getForm().puMinute.disabled=isDisabled; getForm().doDay.disabled=isDisabled; getForm().doMonth.disabled=isDisabled; getForm().doYear.disabled=isDisabled; getForm().doHour.disabled=isDisabled; getForm().doMinute.disabled=isDisabled; } function ptSetup() { var e; e = document.getElementsByName('promoCountry$7280'); for(var i=0; i= 5.5) { /* encode whole url */ dynaURL = encodeURI(dynaURL); } /* Show url to debug */ if(debug!=""){ alert(dynaURL); } return dynaURL; } function populateDroplists(dropList, serverUrl) { var dynaURL = makeDynaDroplistUrl(dropList, serverUrl); document.getElementById("dynaFrame").src = dynaURL; } function populateSecureDroplists(dropList, serverUrl) { var dynaURL = makeDynaDroplistUrl(dropList, serverUrl); var response=makeRequest(dynaURL); eval(response); } function makeRequest(url) { var req=false; var returnValue = ""; if(window.XMLHttpRequest) { try { req = new XMLHttpRequest(); } catch(e) { req = false; } } else if(window.ActiveXObject) { try { req = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { try { req = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { req = false; } } } if(req){ req.open("GET", url, false); req.send(null); if (req.readyState==4) { returnValue = req.responseText; } } return returnValue; } function addOption(droplist, name, value){ droplist.options[droplist.options.length] = new Option(name, value); }