

      function getLoc(t) {
        aForm = document.getElementById('search');
        for(i=aForm.location.options.length; i > 0; i--) {
          aForm.location.options[i] = null;
        }
          add_option(aForm.location,'London All - England (330)','10,4,6,23,3,7,23,5,9,43,42,44,45');
          add_option(aForm.location,'London South - England (4)','188');
          add_option(aForm.location,'London South East - England (17) ','6');
          add_option(aForm.location,'London South West - England (69)','23');
          add_option(aForm.location,'London West Central - England (84)','7');
          add_option(aForm.location,'London West - England (77)','3');
          add_option(aForm.location,'London East Central - England (14)','10');
          add_option(aForm.location,'London East - England (11)','5');
          add_option(aForm.location,'London North - England (31)','4');
          add_option(aForm.location,'London North West - England (17) ','9');
          add_option(aForm.location,'London Luton - England (2)','43');
          add_option(aForm.location,'London Gatwick - England (6)','42');
          add_option(aForm.location,'London Stansted - England (1)','44');
          add_option(aForm.location,'London Heathrow - England (5)','45');

			}
			function selAcc(){
				document.getElementById('accommodation').style.display='block';
				document.getElementById('divactivities').style.display='none';
				document.getElementById('choice').innerHTML='<li><a href="#" onclick="selAcc()" title="Select Accommodation"><img src="images/booking-dynamic_active.png" alt="Book Accommodation" title="Book Accommodation" width="15" height="15"/> <span>Accommodation</span></a></li><li><a href="#" onclick="selAct()" title="Select Activities"><img src="images/booking-dynamic_inactive.png" alt="Book Activities" title="Book Activities" width="15" height="15"/> <span>Activities</span></a></li>'
			}
			function selAct(){
				document.getElementById('accommodation').style.display='none';
				document.getElementById('divactivities').style.display='block';
				document.getElementById('choice').innerHTML='<li><a href="#" onclick="selAcc()" title="Select Accommodation"><img src="images/booking-dynamic_inactive.png" alt="Book Accommodation" title="Book Accommodation" width="15" height="15"/> <span>Accommodation</span></a></li><li><a href="#" onclick="selAct()" title="Select Activities"><img src="images/booking-dynamic_active.png" alt="Book Activities" title="Book Activities" width="15" height="15"/> <span>Activities</span></a></li>'
			}



function fillstay() {
 	aForm = document.getElementById("search"); 
 	if(aForm){
  		if(aForm.stay){
  			var it = aForm.stay.selectedIndex;
  			aForm.ddate.value = "";
//   			for(i=aForm.stay.options.length; i >= 0; i--) {
//   				aForm.stay.options[i] = null;
//   			}
  		}
  		for(i=1; i< 31; i++) {
  			add_option(aForm.stay,i,i);
  		}
  		if(aForm.acctype){
  			if (aForm.acctype.value == "Studios") {
  				//CHANGE 7 IF YOU WANT TO CHANGE THE NUMBER MINIMUM OF NIGTHS TO BOOK A FLAT
  				getLoc("fs");
  				//CHANGE 7 IF YOU WANT TO CHANGE THE NUMBER MINIMUM OF NIGTHS TO BOOK A FLAT
  				if(it > 1) {
  					aForm.stay.selectedIndex = it;
				}else{
					aForm.stay.selectedIndex = 1;
				}
  			} else {
				if (aForm.acctype.value == "All") getLoc("all");
  				if (aForm.acctype.value == "Hotel / Bed and Breakfast / Guest House") getLoc("hb");
  				if (aForm.acctype.value == "Luxury Hotels") getLoc("lh");
  				if (aForm.acctype.value == "Youth Hostel") getLoc("h");
  				if (aForm.acctype.value == "Apartments") getLoc("a");
  				if (aForm.acctype.value == "Campsites / Caravans / Resorts") getLoc("c");
  				if (aForm.acctype.value == "YHA / Youth hostels Association") getLoc("yh");
  				aForm.stay.selectedIndex = it;
  			}
  		}
 	}
 }
function validate() {
 	aForm = document.getElementById("search");
 	if (aForm.acctype && aForm.acctype.value == "Select") {
 		alert("You did not select an accommodation type!");
 	} else if (aForm.location && aForm.location.value == "Location") {
	 	alert("You did not select a location");
 	} else if (aForm.ddate.value == "") {
 		alert("Your departure date has unselected values, please check it carefully");
	} else if (!validateDate()){
 		alert("Please select at least 3 days ahead for your arrival date!")
 	} else if (!checkDateExist()) {
 		alert("Arrival date does not exist !");
 	} else if (aForm.stay.value == "nights") {
 		alert("You did not select your length of stay!");
 	} else if (aForm.people.value == "Select") {
 		alert("You did not select the number of people");
	} else {
 		var xMax = screen.width, yMax = screen.height;
 		var xOffset = (xMax - 270)/2, yOffset = (yMax - 70)/2;
 		//window.open('popups/finding.htm','finding','width=270,height=70,screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+'');
 		aForm.submit();
 		//finding.focus();
 	}
}
function setDefaultYear(){
 	aForm = document.getElementById("search");
 	bForm = document.getElementById("activities");
 	if(aForm){
 		var now = new Date();
 		now.setDate(now.getDate()+3);
 		aForm.aday.selectedIndex = now.getDate();
 		aForm.amonth.selectedIndex = now.getMonth()+1;
 		aForm.ayear.selectedIndex = 1;
	}
 	if (bForm){
 		var now = new Date();
 		//now.setDate(now.getDate()+2);
 		bForm.act_day.selectedIndex = now.getDate();
 		bForm.act_month.selectedIndex = now.getMonth()+1;
 		bForm.act_year.selectedIndex = 1;
 	}
}

function validateDate(){
 	aForm = document.getElementById("search");
 	if((aForm.aday.value != "Select") && (aForm.amonth.value != "Select") && (aForm.ayear.value != "Select")) {
 		var day = aForm.aday.value;
 		var month = aForm.amonth.value;
 		var year = aForm.ayear.value;
 		var arrivalDate = new Date(year,month,day);
 		arrivalDate.setDate(arrivalDate.getDate()-2);
 		if (compare(arrivalDate,new Date()) < 0) return false;
 		else return true;
 	}else
 	return false;
}
