function clearText(thefield){
	if (thefield.defaultValue==thefield.value)
	thefield.value = ""
}
function submitForm1() {
	var form = document.getElementById("formDestination");
	var startDate = document.getElementById("checkInDate");
	if(startDate.value == "MM/DD/YYYY") {
		startDate.value = "";
	}
	var endDate = document.getElementById("checkOutDate");
	if(endDate.value == "MM/DD/YYYY") {
		endDate.value = "";
	}
	var originalSearchTerm = "<cfif IsDefined('argsSearch.searchSuggest')><cfoutput>#argsSearch.searchSuggest#</cfoutput></cfif>";
	if (originalSearchTerm.value == "") {
		originalSearchTerm = "";
	}

	var currentSearchTerm = document.getElementById("searchTerm");
	if (currentSearchTerm.value == "") {
		window.alert("Please enter a Destination");
		return false;
	}
	// if the user did not change the search term, let the find it page know, so it
	// will use the searchLocId, and not try to use the searchTerm
	if(originalSearchTerm == currentSearchTerm.value) {
		var findItFlag = document.getElementById("fromResPg");
		findItFlag.value = "true";
	}
	form.action = "/fg_find.cfm";
	form.submit();
}
function submitFormText() {
	var form = document.getElementById("formText");
	var currentSearchTerm = document.getElementById("searchParameters");
	if((currentSearchTerm.value == "") || (currentSearchTerm.value==currentSearchTerm.defaultValue)) {
		window.alert("Please enter keywords or phrase");
		return false;
	}
	form.action = "/fg_find.cfm";
	form.submit();
}
function ResetForm(which){
	var pass=true
	var first=-1
	if (document.images){
		for (i=0;i<which.length;i++){
			var tempobj=which.elements[i]
		 	if (tempobj.type=="text"){
		  		eval(tempobj.value="")
		  		if (first==-1) {first=i}
		 	}
		 	else if (tempobj.type=="checkbox") {
			  eval(tempobj.checked=0)
			  if (first==-1) {first=i}
			}
		 	else if (tempobj.type=="select-one") {
			  eval(tempobj.value="0")
			  if (first==-1) {first=i}
			}
			else if (tempobj.col!="") {
			  eval(tempobj.value="")
			if (first==-1) {first=i}
			}
		}
	}
	//which.elements[first].focus()
	return false
}
function screenkey1(e) {
	var whichCode;
	whichCode = (window.Event) ? e.which : e.keyCode;
	if ( whichCode == "13" ) {
		submitForm1();
	}
}
function screenkey2(e) {
	var whichCode;
	whichCode = (window.Event) ? e.which : e.keyCode;
	if ( whichCode == "13" ) {
		submitFormText();
	}
}
function textSearchToggle(toState) {
	var formSearch = document.getElementById("formsearch");
	var textSearch = document.getElementById("textsearch_sublevel");

	if (toState == 'text') {
		formSearch.style.display = "none";
		textSearch.style.display = "block";
	}
	else if (toState == 'destination') {
		formSearch.style.display = "block";
		textSearch.style.display = "none";
	}
	return false;
}

$(document).ready(function() {
	$("#searchTerm").autocomplete("/getSearchSuggestion.cfm", { minChars:3, matchSubset:1, matchContains:1, delay:50, selectOnly:1 });
});

function submitDrilldownForm(locId) {
	var form = document.getElementById("formDestination");
	if(locId != -1) {
		document.getElementById('spCitySelect').value = locId;
		form.submit();
	}
}

