

function quickCheckAndSearch(the_input){ // put together the search string and submit
if((document.form1.bybedrooms.options[document.form1.bybedrooms.selectedIndex].value=='0') && (document.form1.bysleeps.options[document.form1.bysleeps.selectedIndex].value=='0') && (document.form1.rental.options[document.form1.rental.selectedIndex].value=='0')) {
alert('Please select at least one option to search for');
return false;
}
var url ="../searchscript/aptsearch.cgi?database=vadb2&template=2008Res"; // basic URL - options added below
//bedrooms
if(document.form1.bybedrooms.options[document.form1.bybedrooms.selectedIndex].value!='0') {
var num_bedrooms = document.form1.bybedrooms.options[document.form1.bybedrooms.selectedIndex].value;
if (num_bedrooms == 'S') url +="&bedrooms=S" ;
if (num_bedrooms == '1') url +="&bedrooms=1" ;
if (num_bedrooms == '2') url +="&bedrooms=2" ;
if (num_bedrooms == '3') url +="&bedrooms=3" ;
if (num_bedrooms == '4') url +="&bedrooms=4" ;
}
// persons
if(document.form1.bysleeps.options[document.form1.bysleeps.selectedIndex].value!='0') {
var num_pers = eval(document.form1.bysleeps.options[document.form1.bysleeps.selectedIndex].value);
if (num_pers == num_bedrooms) { // If the no of people is the same as the no of rooms
var num_pers_max = num_pers * 2; // For example, if three people want a bedroom each, sets max number to twice the number of people
} else {
var num_pers_max = num_pers + 2; // Else sets a max number for two more persons
}
url +="&sleepsno>=" + num_pers; // Sets limits for no of rooms
url +="&sleepsno<=" + num_pers_max; 
} 
if(document.form1.rental.options[document.form1.rental.selectedIndex].value!='0') {
// rental 
var max_rent = eval(document.form1.rental.options[document.form1.rental.selectedIndex].value);
url +="&rentalsort<=" + max_rent;
}
url +="&collection!=PSG";
url +="&order_by=rentalsort&order=123";
url +="&records=10";
url +="&listed=1";
url +="&method=any";
// submit the form
document.location.href = url; 
} // quickCheckAndSearch
