
          function setSelectValue(obj, value)
          {
			var i = 0
			foundText = false
			
			for (i = 0; i < obj.options.length; i++)
			{
				if (obj.options[i].value == value)
				{
					obj.selectedIndex = i
					foundText = true
					break
				}
			}
			
			if (!foundText)
				obj.options[0].selected
			
          }
          
          function setSelectText(obj, value)
          {
			var i = 0
			foundText = false
			
			//alertDebug("-" +value +"-")
			for (i = 0; i < obj.options.length; i++)
			{
				if (obj.options[i].text == value)
				{
					obj.selectedIndex = i
					foundText = true
					break
				}
			}
			
			if (!foundText)
				obj.options[0].selected
			
          }
          
          function updateCityLabel()
          {
			var searchMode = document.forms.fineavail.hdnCurrentSearchMode.value
			
			alertDebug("ucl-searchMode:" +searchMode +"---ac:" +autoComplete)
			if (searchMode == "nightly")
			{
				// nightly
				document.getElementById("searchHelpLink").style.display = "block"
				
				if (autoComplete == 0)
					document.getElementById("destinationCityLabel").innerHTML = "City List"
				else
					document.getElementById("destinationCityLabel").innerHTML = "City Entry"
			}
			else 
			{
				if (searchMode == "packages")
				{
					document.getElementById("searchHelpLink").style.display = "block"
				
					if (autoComplete == 0)
						document.getElementById("destinationCityLabel").innerHTML = "City List"
					else
						document.getElementById("destinationCityLabel").innerHTML = "City Entry"
				}
				else
				{
					// weekly
					document.getElementById("searchHelpLink").style.display = "block"
					
					if (autoComplete == 0)
						document.getElementById("destinationCityLabel").innerHTML = "City List"
					else
						document.getElementById("destinationCityLabel").innerHTML = "City Entry"
						
				}
			}
			
			setAutoCompleteDisplay()
			updateComboDropDown()
			
          }
          
          
          function updateComboDropDown()
          {
			//oImage = document.getElementById("RadComboBox1_Image")
			
			// disable functionality for now
			
			if (autoComplete == 0 )
			{
				//document.getElementById("RadComboBox1_Image").src = "/resortime/RadControls/ComboBox/Skins/WindowsXP/DropArrow.gif"
				//oImage.src = "/RadControls/ComboBox/Skins/WindowsXP/DropArrow.gif"
				//oImage.style.width = "16px"
				//oImage.style.height = "20px"
				
				combo = RadComboBox1;
				combo.SetText("Please Select a City")
				combo.SetValue("")
				
			}
			else
			{
				//document.getElementById("RadComboBox1_Image").src = "images/spacer.gif"
				//oImage.src = "images/spacer.gif"
				//oImage.style.width = "0px"
				//oImage.style.height = "0px"
				
				combo = RadComboBox1;
				combo.SetText("Please Type in a City")
				combo.SetValue("")
			}
          }
          
          var prevSearchMode = ""
          var tabClicks = 0;
          
          function selectPackages()
          {
			alertDebug("start packages")
			//ClearComboEntries()
          
            alertDebug("status")
          
			// change tab image src's
			document.getElementById("availability").src = "images/homepage/btnNightly_Off.jpg"
			document.getElementById("Packages").src = "images/homepage/btnPackages_On.jpg"
			//document.getElementById("Weekly").src = "images/homepage/btnWeekly_Off.jpg"
			
			document.forms[0].searchMode.value = "packages"
			document.forms.fineavail.hdnCurrentSearchMode.value = "packages"
			
			alertDebug("csm:" +document.forms.fineavail.hdnCurrentSearchMode.value)
			
			updateCityLabel()
						
			var CalendarArrival
			
			CalendarArrival = document.getElementById("uixCalendarArrival")
			CalendarArrival.onclick = function()
			{ 
				show_calendar('fineavail.arrival',null,null,'MM/DD/YYYY', null, null, 'fineavail.departdate', 3);
				return false;
			}
			
			// get the cities
			if (prevSearchMode == "weekly" || tabClicks == 0)
			    resortime.indexHome.GetAllCities(LoadCities_CallBack);
			
						
			displayRegionFields(false)
			displayPackageAdditionalFields(true)
			
			prevSearchMode = "packages"
			tabClicks++
          }
          
          function selectResorts()
          {
			alertDebug("start nightly");
			
			//ClearComboEntries()
			
			// change tab image src's
			document.getElementById("availability").src = "images/homepage/btnNightly_On.jpg"
			document.getElementById("Packages").src = "images/homepage/btnPackages_Off.jpg"
			//document.getElementById("Weekly").src = "images/homepage/btnWeekly_Off.jpg"
			
			var CalendarArrival
			
			CalendarArrival = document.getElementById("uixCalendarArrival")
			CalendarArrival.onclick = function()
			{ 
				show_calendar('fineavail.arrival',null,null,'MM/DD/YYYY', null, null, 'fineavail.departdate', 3);
				return false;
			}
			
			// set the search mode
			document.forms.fineavail.searchMode.value = "nightly"
			document.forms.fineavail.hdnCurrentSearchMode.value = "nightly"
			
			// get the cities
			//if (prevSearchMode == "weekly" || tabClicks == 0)
			if (prevSearchMode == "weekly")
			{
			    resortime.indexHome.GetAllCities(LoadCities_CallBack);
			 }
			
			// update city label and help link
			updateCityLabel()
			
			//alertDebug("displayRegionFields")
			displayRegionFields(false)
			
			//alertDebug("displayPackageAdditionalFields")
			displayPackageAdditionalFields(false)
			
			prevSearchMode = "nightly"
			tabClicks++
          }
          
          function selectWeekly()
          {
			
			ClearComboEntries()
			
			// change tab image src's
			document.getElementById("availability").src = "images/homepage/btnNightly_Off.jpg"
			document.getElementById("Packages").src = "images/homepage/btnPackages_Off.jpg"
			document.getElementById("Weekly").src = "images/homepage/btnWeekly_On.jpg"
			
			var CalendarArrival;
			
			CalendarArrival = document.getElementById("uixCalendarArrival");
			CalendarArrival.onclick = function()
			{ 
				show_calendar('fineavail.arrival',null,null,'MM/DD/YYYY', null, null, 'fineavail.departdate', 7);
				return false;
			}
		
			// set the search mode
			document.forms.fineavail.searchMode.value = "weekly"
			document.forms.fineavail.hdnCurrentSearchMode.value = "weekly"
			
			// update the city label and help link
			updateCityLabel()
			
			alertDebug("ac:" +autoComplete)
			if (autoComplete == 1)
				displayRegionFields(false)
			else
				displayRegionFields(true)
			
			displayPackageAdditionalFields(false)
			
			oRegion = document.getElementById("region")
			if (oRegion.selectedIndex > 0)
			{
			    loadCities(oRegion)
			}
			
			// set the arrival and departure dates
			with (document.forms.fineavail)
			{
				var startdate = new Date(document.getElementById("arrival").value);
				var today = new Date();
			    
				//alertDebug(dateDiff(startdate, today) )
				
				if (dateDiff(startdate, today) < 3)
				{
					arrival.value = dateAdd(today, 3);
				}
				
				departdate.value = dateAdd(arrival.value, 7);
				
				// Format the dates for presentation
				var ad = new Date(document.getElementById("arrival").value);
				arrival.value = ad.formatDate("m/d/Y");
				
				var dd = new Date(document.getElementById("departdate").value);
				departdate.value = dd.formatDate("m/d/Y");
				
			}
			
			prevSearchMode = "weekly"
			tabClicks++
          }
          
          function checkWeeklyDate()
          {
			with (document.forms.fineavail)
			{
				if (searchMode.value == "weekly")
					departdate = dateAdd(arrival.value, 7)
			}
          }
          
          function displayRegionFields(display)
          {
			if (display)
			{
				
				// show the region drop-down
				document.getElementById("regionSelect").style.display = "inline"
				//regionSelect.style.display = 'inline'
				
				// filter city list
				with (document.forms[0])
				{
					
					// if a region is selected
					if (region.selectedIndex > 0)
					{
						var regionCode
	
						regionCode = region.options[region.selectedIndex].value;
						//getCityList(regionCode)
					}
					else
					{
						// clear city list
						cityZip.options.length = 0
					}
					
				}
				
			}
			else
			{
				// hide the drop-down
				//regionSelect.style.display = 'none'
				document.getElementById("regionSelect").style.display = "none"
				
				with (document.forms[0])
				{	
					//alertDebug("czsi:" +cityZip.selectedIndex)
					if (cityZip.selectedIndex > 0)
					{
						// get the current city
						varCity = cityZip.options[cityZip.selectedIndex].value	
						
						//alertDebug("city:" +city)
						//alertDebug("cityZip:" +varCity)	
					
						// load all the cities
						//getCityList('')
						//alertDebug(cityZip.options.length)
						
						// set the drop-down city value
						setSelectValue(cityZip, varCity)
					}
					else
					{
						// load all the cities
						//getCityList('')
					}
				}
			}
          }
          
          function displayRegionFields2(display)
          {
			if (display)
			{
				// show the region drop-down
				regionSelect.style.display = 'inline'
				
				with (document.forms[0])
				{
					
					// if a city is selected
					if (cityZip.selectedIndex > 0)
					{
						// set the region to the current city's state
						//alertDebug(cityZip.selectedIndex)
						varCityState = document.forms[0].cityZip.options[document.forms[0].cityZip.selectedIndex].text
												
						//alertDebug(varCityState)
						arrText = varCityState.split(" ")
						//alertDebug(arrText[0])
					
						setSelectText(region, arrText[0])
						
						//getCityList(arrText[0])
						
						setSelectText(city, varCityState)
					}
					else
					{
						//alertDebug(region.selectedIndex)
						if (region.selectedIndex > 0)
						{
							// set the region to the current region value
							//getCityList(region.options[region.selectedIndex].value)
						}
						else
						{
							// just empty the city list
							cityZip.options.length = 0
						}	
						
					}
				}
			}
			else
			{
				// hide the drop-down
				regionSelect.style.display = 'none'
				
				with (document.forms[0])
				{
					//alertDebug(cityZip.selectedIndex)
					
					if (cityZip.selectedIndex > -1)
					{
						// get the current city
						varCity = cityZip.options[cityZip.selectedIndex].value	
						
						//alertDebug(varCity)	
					
						// load all the cities
						//getCityList('')
						
						// set the drop-down city value
						setSelectValue(city, varCity)
					}
					else
					{
						// load all the cities
						//getCityList('')
					}
				}
				
			}
          }
          
          
          function displayPackageAdditionalFields(display)
          {
			
			if (display)
			{
				document.getElementById("divGuests").style.display = "inline"
				//divGuests.style.display = 'inline'
			}
			else
			{
				document.getElementById("divGuests").style.display = "none"
				//divGuests.style.display = 'none'
			}
          }
          
          var theCurrentCityState = ""
          
          function LoadCities_CallBack(response)
          {           
            //if the server side code threw an exception
            if (response.error != null)
            {    
	            alert("Error:" +response.error); //we should probably do better than this
	            return;
            }  
            
            var citiesList = document.getElementById("cityZip");
            
            //if we couldn't find the states drop down
            if (citiesList == null)
            {
	            return; //couldn't find the cities dropdown...
            }
        	
            var cities = response.value;  
            //if the response wasn't what we expected  
            if (cities == null || typeof(cities) != "object")
            {
	            return;  
            }
            
            var currentCityState = ""
            var currentCityZip = ""

        	
            //alert("cityState:" +currentCityState)
        	
            currentCity = ""
            arrCityState = theCurrentCityState.split(" -- ")
            currentState = arrCityState[0]
        	
            //alert("len:" +arrCityState.length)
            if (arrCityState.length >1)
	            currentCity = arrCityState[1]
        	
            currentZip = ""
            arrCityZip = currentCityZip.split("--")
            currentCity = arrCityZip[0]
        	
            //alert(currentCityZip +":" +arrCityZip.length)
            if (arrCityZip.length > 1)
	            currentZip = arrCityZip[1]
        	
        	
        	citiesList.options[citiesList.options.length] = new Option("Please Select a City", "");  
        	
            if (!isNaN(parseInt(cities.length)))
            {
	            for (var i = 0; i < cities.length; ++i)
	            {
		            citiesList.options[citiesList.options.length] = new Option(Text.trim(cities[i].state) +" -- " + Text.trim(cities[i].city), Text.trim(cities[i].city) +"--" +Text.trim(cities[i].zip));       
        			
		            if (currentZip == cities[i].zip && currentCity == cities[i].city)
		            {
			            citiesList.options[i].selected = true
		            }
	            }
            }
            else
            {
	            //alert(!isNaN(parseInt(cities.Rows.length)))
	            for (var i = 0; i < cities.Rows.length; ++i)
	            {
		            citiesList.options[citiesList.options.length] = new Option(Text.trim(cities.Rows[i].state) +" -- " + Text.trim(cities.Rows[i].city), Text.trim(cities.Rows[i].city) +"--" +Text.trim(cities.Rows[i].zip));       
        			
		            if (currentZip == cities.Rows[i].zip && currentCity == cities.Rows[i].city)
		            {
			            citiesList.options[i].selected = true
		            }
	            }
            }
            
            //setSelectText(citiesList, currentCityState)
            setSelectText(citiesList, theCurrentCityState)
            theCurrentCityState = citiesList.options[citiesList.selectedIndex].text	
          }
          
          
			
			function channelMileRound(miles)
			{
				if (miles <=5)
					{ miles = 5 }
				else if (miles <= 10)
					{ miles = 10 }
				else if (miles <= 25)
					{ miles = 25 }
				else if (miles <= 50)
					{ miles = 50 }
				else if (miles <= 100)
					{ miles = 100 }
				else if (miles <= 200)
					{ miles = 200 }
				else
					{ miles = 300 }
				
				return miles
			}
					
			