function $get(id)
{
	if (document.getElementById)
	    var returnVar = document.getElementById(id);
	else if (document.all)
	    var returnVar = document.all[id];
	else if (document.layers)
	    var returnVar = document.layers[id];
	return returnVar;
}
function MapWindow(URL){
	popupWin = window.open(URL, 'HotelMap','scrollbars=0,width=525,height=525,top=40,left=40');
}
function fnMapSearch(){
	var strLocation='';
	var nZoomLevel=4;
	if($get('HotelAction').value=='TownSearch'){
		if($get('postcodeOrTown2').value!=''){
			strLocation+=$get('postcodeOrTown2').value;
			nZoomLevel=13;
		}
	}
	if(strLocation==''){
		if($get('Country').value!=''){
			strLocation+=$get('Country').value + ',';
			nZoomLevel=6;
		}
		if($get('Region').value!=''){
			strLocation+=$get('Region').value + ',';
			nZoomLevel=7;
		}
		if($get('Town').value!=''){
			strLocation+=$get('Town').value;
			nZoomLevel=13;
		}
	}
	$get('frmHotels').mapZoomLevel.value=nZoomLevel;
	$get('frmHotels').strLocation.value=strLocation;
	$get('frmHotels').FormAction.value='Location';
	$get('frmHotels').action='/route_planner.asp';
	$get('frmHotels').submit();
}
function fnRouteSearch(){
  document.frmHotels.FormAction.value = '';
	document.frmHotels.action='/route_planner.asp';
	$get('frmHotels').submit();
}
function fnTownSearch(){
	$get('HotelAction').value='TownSearch';
	$get('frmHotels').submit();
}
function fnRegionSearch(){
	$get('HotelAction').value='RegionSearch';
	$get('frmHotels').submit();
}
function fnRegionSearch_Town(){
  showhide('townPleaseWait');
	$get('HotelAction').value='RegionSearch_Town';	
	$get('frmHotels').submit();
}
function fnRegionSearch_Region(){
  showhide('regionPleaseWait');
	$get('HotelAction').value='RegionSearch_Region';
	$get('postcodeOrTown2').value = '';	
	$get('frmHotels').submit();
}
function fnRegionSearch_Country(){  
  showhide('countryPleaseWait');  
	$get('HotelAction').value='RegionSearch_Country';	
	$get('postcodeOrTown2').value = '';      
	$get('frmHotels').submit();	
}
function toggleStandardSearch(id){
  if($get('hideStandardSearch').value!=''){
    $get('hideStandardSearch').value='';
    $get('toggle_standard_search').value='Hide search';
  }else{
    $get('hideStandardSearch').value=true;
    $get('toggle_standard_search').value='Show search';
  }
  //if(document.frmHotels.hideStandardSearch.value!=''){    
  //  document.frmHotels.hideStandardSearch.value='';
  //}else{    
  //  document.frmHotels.hideStandardSearch.value=true;
  //}
  showhide(id);
}
function toggleAdvancedSearch(id){
  if($get('showAdvancedSearch').value=='0'){            
    $get('showAdvancedSearch').value='1';
    $get('toggle_advanced_search').value='Hide advanced search';    
  }else{            
    $get('showAdvancedSearch').value='0';
	  $get('toggle_advanced_search').value='Show advanced search';
  }
  showhide(id);
}
function fnSort(){
	document.frmHotels.sortResults.value=true;
	document.frmHotels.jsessionid.value='';
	$get('frmHotels').submit();	
}
function showhide(id){ 
	if (document.getElementById){ 
		obj = document.getElementById(id); 
		if (obj.style.display == "none"){ 
			obj.style.display = "block"; 
		} else { 
		obj.style.display = "none"; 
		} 
	} 
}
function fnHotelBookNow(lHotelID){
/* go to room selection from hotel results list */
	$get('hotelid').value=lHotelID;
	$get('HotelAction').value='checkavailability';
	$get('frmHotels').action='/hotel_select_rooms.asp';
	$get('frmHotels').submit();
}

function showHotelImage(sFile){
	$get('Hotel_Main_Image').src=sFile;
}
function RoomsWindow(URL){
	var popupWin = window.open(URL, 'HotelRooms','scrollbars=1,width=600,height=600,top=40,left=40');
}
// refresh display if customer changes number of rooms
function updateRoomOccupancy(sUserAction){
	$get('HotelAction').value='checkavailability';
	$get('UserAction').value=sUserAction;
	$get('frmHotels').action='http://www.drive-alive.co.uk/hotel_select_rooms.asp';
	$get('frmHotels').submit();
}
function fnValidateHotelRoomsSelector(sURL){
	var bValid=false;
	var sMessage='';
	var iRoomBlocks=$get('NumberOfRoomBlocks').value;
	if(isNaN(iRoomBlocks)){
	}else{
		for(var i=0;i<iRoomBlocks;i++){					
			var s=$get('txtRooms'+i);
			var iRooms=s.options[s.selectedIndex].text;
			if(iRooms==''){
			}else{
				for(var iRoom=1;iRoom<=iRooms;iRoom++){				
					if($get('txtAdults'+i+'_'+iRoom).value==''){
						bValid=false;
						break;
					}else{
						bValid=true;						
					}
				}			
				if(bValid==false) break;
			}								
		}
	}
	if(bValid==true){	
		$get('frmHotels').action=sURL;
		$get('frmHotels').submit();
	}else{
		sMessage='Please make sure you have selected the correct number of adults for each room.';
		alert(sMessage);
		return false;
	}
}
function fnConfirmReservation(){
	$get('HotelAction').value='bookrooms';
	$get('frmHotels').submit();
}
function viewHotelPolicy(URL){
	var popupWin = window.open(URL, 'HotelPolicy','scrollbars=1,width=600,height=600,top=40,left=40');
}
function CVVWindow(URL){
	var popupWin = window.open(URL, 'CVV','scrollbars=0,width=400,height=240,top=40,left=40');
}
function fnHotelBackToSearch(){
	$get('frmHotels').action='/hotels.asp';
	fnRegionSearch();
}
function fnHotelOtherLocation(disambiguateId){
	$get('disambiguateId').value=disambiguateId;
	$get('frmHotels').submit();
}
function fnWarnHotelSearchNotFound(){
	var strWarn='';
	strWarn+='The destination has not been recognised.\n\n';
	strWarn+='Please check your spelling or type another destination nearby in case\n';
	strWarn+='there are no properties in the requested destination.';
	alert(strWarn);
	return false;
}
function toggleHotelTowns(id){
  if($get('showHotelTowns').value=='0'){            
    $get('showHotelTowns').value='1';
    $get('toggle_hotel_towns').value='Hide hotel town list';    
  }else{            
    $get('showHotelTowns').value='0';
	  $get('toggle_hotel_towns').value='Show hotel town list';
  }
  showhide(id);
}