	function setArrival(a_objElement,a_lngMinBooking,a_bolMulti){
		//a_objElement is the 'arrival' radio object, which fired this function
		//a_lngMinOcc is the minimum occupancy value
		//a_bolMulti identifies if multiple accommodation can be booked
	
		//use the index from the id of the supplied
		//try to split the property value using the supplied delimiter
		var l_strTemp = a_objElement.id.split("_")
		var l_lngResource = parseInt(l_strTemp[0])
		var l_lngStartIndex = parseInt(l_strTemp[1])
		
		//get the hidden starting index for the resource
		var l_objDayCell = $id("max_index" )
		var l_lngMaxIndex = parseInt(l_objDayCell.value)

		///set th class name for the parent cell of the supplied a_objElement
		var l_objDayCell=a_objElement.parentNode
		
		//try to hide purple
		//l_objDayCell.style = ''
		
		switch(l_objDayCell.className){
		case "free-free":
			l_objDayCell.className = "free-select"
			break
		case "book-free":
			l_objDayCell.className = "book-select"
			break
		case "book-x":
			l_objDayCell.className = "book-xselect"
			break
		case "x-free":
			l_objDayCell.className = "x-select"
			break
		case "x-x":
			l_objDayCell.className = "xselect-xselect"
			break
		case "free-x":
			l_objDayCell.className = "free-xselect"
			break
		}
		
		
		
		
		//set the hidden selected resource_id
		l_objDayCell = $id(l_lngResource + "_selected" )
		l_objDayCell.value = l_lngResource
		
		//set the hidden starting index for the resource
		l_objDayCell = $id(l_lngResource + "_startIndex" )
		l_objDayCell.value = l_lngStartIndex
		
		if(a_bolMulti){
			//the booking of multiple accommodation is permitted
			//dO NOTHING
		
		}
		else{
			//the booking of multiple accommodation is not permitted
			//hide 'arrivaal' radios for the other accommodation
			var l_objResources = document.getElementsByName("resource_id")
		
			for (var i=0; i< l_objResources.length;i++){
				
				var l_lngTResource = parseInt(l_objResources[i].value)
				if(isNaN(l_lngTResource)){
					for (var j=1; j<=l_lngMaxIndex;j++){
						//try to get the next cell
						var l_lngCurrentIndex = j
						l_strTemp = l_objResources[i].id.split("_")
						
						var l_objTemp = $id(l_strTemp[0] + "_" + l_lngCurrentIndex + "_A")
						if (l_objTemp!=null){
							//a 'departure' radio has been found
							l_objTemp.style.display="none"
						}
					}
				}			
			}
		}
		
		var l_lngDepartCount = 0
		
		var l_lngCellCount = 1
		var l_lngCurrentIndex = l_lngStartIndex + l_lngCellCount
		
		l_objDayCell = $id(l_lngResource + "_" + l_lngCurrentIndex )
		
		var l_objArrivals = document.getElementsByName(l_lngResource + "_Arrive")
		for (var i = 0; i < l_objArrivals.length; i++){
			l_objArrivals[i].style.display='none'
		}
		
		//alert(l_lngStartIndex)
		
		//starting with the l_lngStartIndex, step through the table cells
		//if the next index cell can be found,
		while(l_objDayCell!=null){
			
			//if(l_lngDepartCount<1){
			//	l_objDayCell.className="select"
			//}
			
			//test if the cell contains a 'departure' radio
			var l_objTemp = $id(l_lngResource + "_" + l_lngCurrentIndex + "_D")
			if (l_objTemp!=null){
				
				//a 'departure' radio has been found
				//increase the departure counter
				l_lngDepartCount += 1
				//display the radio
				if(l_lngDepartCount>=a_lngMinBooking){
				l_objTemp.style.display="block"
				}
				
				if(l_lngDepartCount==a_lngMinBooking){
					l_objTemp.checked=true
					setDepart(l_objTemp)
				}
			}
			
			//try to get the next cell
			l_lngCellCount += 1
			l_lngCurrentIndex = l_lngStartIndex + l_lngCellCount
			l_objDayCell = $id(l_lngResource + "_" + l_lngCurrentIndex )
		}

		//check the minBooking value
		
		
				//if the counter==1, select the departure radio
				//could call the setdeparture function
		//set the class of the cell
		
		/*
		if the distance to the last departure radio is less than the min booking,
		permit it. (allows booking gaps to be filled)
		
		*/
		
		try{
			//setStep(1,3)
		}
		catch(err){
		
		}
		try{
			//setStep(2,1)
		}
		catch(err){
		
		}
		
	}
	
	function setDepart(a_objElement){
		//a_objElement is the 'departure' radio object, which fired this function
		
		//use the index from the id of the supplied
		//try to split the property value using the supplied delimiter
		var l_strTemp = a_objElement.id.split("_")
		var l_lngResource = parseInt(l_strTemp[0])
		var l_lngEndIndex = parseInt(l_strTemp[1])
		
		//get the hidden starting index for the resource
		var l_objDayCell = $id(l_lngResource + "_startIndex" )
		var l_lngStartIndex = parseInt(l_objDayCell.value)
		
		//set the hidden end index for the resource
		var l_objDayCell = $id(l_lngResource + "_endIndex" )
		var l_lngOldEnd = parseInt(l_objDayCell.value)
		if (l_lngOldEnd ==NaN){l_lngOldEnd=1}
		l_objDayCell.value = l_lngEndIndex 
		
		
		//alert('l_lngOldEnd; ' + l_lngOldEnd)
		//alert('l_lngStartIndex; ' + l_lngStartIndex)
		
		//clear back to the arrivaldate
		for (var i = l_lngOldEnd ; l_lngStartIndex <= i ; i--){
			//alert('i; ' + i)
			var l_objDayCell = $id(l_lngResource + "_" + i )
			//alert(l_lngResource + "_" + i )
				if (l_objDayCell!=null){
						switch(l_objDayCell.className){
						case "select-select":
							l_objDayCell.className = "free-free"
							break
						case "select-xselect":
							l_objDayCell.className = "free-x"
							break
						case "xselect-xselect":
							l_objDayCell.className = "x-x"
							break
						case "xselect-select":
							l_objDayCell.className = "x-free"
							break
						case "xselect-x":
							l_objDayCell.className = "x-x"
							break
						case "select-book":
							l_objDayCell.className = "free-book"
							break
						case "xselect-book":
							l_objDayCell.className = "x-book"
							break
						case "select-free":
							l_objDayCell.className = "free-free"
							break
						case "xselect-free":
							l_objDayCell.className = "x-free"
							break
						case "free-xselect":
							l_objDayCell.className = "free-x"
							break
						case "book-select":
							l_objDayCell.className = "book-free"
							break
						case "book-xselect":
							l_objDayCell.className = "book-x"
							break
						}
				}

		
		}
		
		
		for (var i = l_lngStartIndex; i <= l_lngEndIndex; i++){
		
			var l_objDayCell = $id(l_lngResource + "_" + i )
			
			if (i==l_lngEndIndex){
				//its the last cell in the selection
				switch(l_objDayCell.className){
				case "free-free":
					l_objDayCell.className = "select-free"
					break
				case "x-x":
					l_objDayCell.className = "xselect-x"
					break
				case "x-free":
					l_objDayCell.className = "xselect-free"
					break
				case "free-book":
					l_objDayCell.className = "select-book"
					break
				case "x-book":
					l_objDayCell.className = "xselect-book"
					break
				case "book-xselect":
					l_objDayCell.className = "book-x"
					break
				}
			}
			else{
				//not the last cell
				if (l_objDayCell!=null){
					switch(l_objDayCell.className){
					case "book-free":
						l_objDayCell.className = "book-select"
						break
					case "book-x":
						l_objDayCell.className = "book-xselect"
						break
					case "free-free":
						l_objDayCell.className = "select-select"
						break
					case "x-x":
						l_objDayCell.className = "xselect-xselect"
						break
					case "free-x":
						l_objDayCell.className = "select-xselect"
						break
					case "x-free":
						l_objDayCell.className = "xselect-select"
						break
					}
				}
			}
		
		}
		
		i++
		
		try{
			//setStep(2,3)
		}
		catch(err){
		
		}
		try{
			//setStep(3,1)
		}
		catch(err){
		
		}
	}

	function resetBooking(a_objForm){
		
		l_lngCellCount=0
		
		//get the hidden starting index for the resource
		var l_objDayCell = $id("max_index" )
		var l_lngMaxIndex = parseInt(l_objDayCell.value)
		
		var l_objResources = document.getElementsByName("resource_id")
		
		for (var i=0; i< l_objResources.length;i++){
			
			var l_lngResource = parseInt(l_objResources[i].value)
			//if(!isNaN(l_lngResource)){
			if(true){
				for (var j=0; j<=l_lngMaxIndex;j++){
					//try to get the next cell
					l_lngCellCount += 1
					l_lngCurrentIndex = j
					
					l_strTemp = l_objResources[i].id.split("_")
					l_lngResource = l_strTemp[0]
					
					l_objDayCell = $id(l_lngResource + "_" + l_lngCurrentIndex )
					if(l_objDayCell!=null){
						switch(l_objDayCell.className){
						case "select-select":
							l_objDayCell.className = "free-free"
							break
						case "select-xselect":
							l_objDayCell.className = "free-x"
							break
						case "xselect-xselect":
							l_objDayCell.className = "x-x"
							break
						case "xselect-select":
							l_objDayCell.className = "x-free"
							break
						case "xselect-x":
							l_objDayCell.className = "x-x"
							break
						case "select-book":
							l_objDayCell.className = "free-book"
							break
						case "xselect-book":
							l_objDayCell.className = "x-book"
							break
						case "select-free":
							l_objDayCell.className = "free-free"
							break
						case "free-select":
							l_objDayCell.className = "free-free"
							break
						case "xselect-free":
							l_objDayCell.className = "x-free"
							break
						case "free-xselect":
							l_objDayCell.className = "free-x"
							break
						case "book-select":
							l_objDayCell.className = "book-free"
							break
						case "book-xselect":
							l_objDayCell.className = "book-x"
							break
						}
					}
					//test if the cell contains a 'departure' radio
					var l_objTemp = $id(l_lngResource + "_" + l_lngCurrentIndex + "_A")
					if (l_objTemp!=null){
						//a 'departure' radio has been found
						l_objTemp.style.display="block"
					}
					
					
					//test if the cell contains a 'departure' radio
					var l_objTemp = $id(l_lngResource + "_" + l_lngCurrentIndex + "_D")
					if (l_objTemp!=null){
						//a 'departure' radio has been found
						l_objTemp.style.display="none"
					}
			
			
				}
				
				
			}
		}
		
		//a_objForm.reset();
		
	}
	
	
	function swapSelectClass(a_objElement,a_bolStart,a_strType){
		//a_bolStart = true, test for start of select
		//false, test for end of select
		//null, between start & finish select
		
		if (a_bolStart==null){
		
		}
		else{
			if (a_bolStart){
				//test for stating select
			
			}
			else{
			
			}
		
		
		}
			if(l_objDayCell!=null){
				switch(l_objDayCell.className){
				case "select-select":
					l_objDayCell.className = "free-free"
					break
				case "xselect-xselect":
					l_objDayCell.className = "x-x"
					break
				case "xselect-select":
					l_objDayCell.className = "x-free"
					break
				case "xselect-x":
					l_objDayCell.className = "x-x"
					break
				case "select-book":
					l_objDayCell.className = "free-book"
					break
				case "xselect-book":
					l_objDayCell.className = "x-book"
					break
				case "select-free":
					l_objDayCell.className = "free-free"
					break
				case "xselect-free":
					l_objDayCell.className = "x-free"
					break
				case "book-select":
					l_objDayCell.className = "book-free"
					break
				case "book_xselect":
					l_objDayCell.className = "book-x"
					break
				}
			}
	
	}

	

