	var typeTimeout = false;
	var prevKeyTyped = false;
	
	function FindHeadings(formStr) {
		//document.forms.ypsearch.headingLike.value="";
		formStr = formStr.replace("'","\\'");
		if (CheckQuickTimeout("FindHeadings","headingMatches",formStr)) {
			if (formStr) {
				document.getElementById("headingMatches").innerHTML = "Loading Descriptions....";
				retVal = RSExecute (rsPage, "get_headings", formStr);
				if (retVal.return_value) {
					compStr = retVal.return_value;
				} else {
					compStr = "&nbsp; &nbsp; Could not find descriptions for your text value (possibly due to there being too many to find in the time alloted)";
				}
				document.getElementById("headingMatches").innerHTML = compStr;
			} else {
				document.getElementById("headingMatches").innerHTML = "";
			}
		}
	}
	
	function FindHeadingsYP(formStr) {
		//document.forms.ypsearch.headingLike.value="";
		formStr = formStr.replace("'","\\'");
		if (CheckQuickTimeout("FindHeadingsYP","headingMatchesYP",formStr)) {
			if (formStr) {
				document.getElementById("headingMatchesYP").innerHTML = "&nbsp; &nbsp; Loading Descriptions....";
				retVal = RSExecute (rsPage, "get_headingsYP", formStr);
				if (retVal.return_value) {
					compStr = retVal.return_value;
				} else {
					compStr = "&nbsp; &nbsp; Could not find descriptions for your text value";
				}
				document.getElementById("headingMatchesYP").innerHTML = compStr;
			} else {
				document.getElementById("headingMatchesYP").innerHTML = "";
			}
		}
	}
	
	function FindCities(formStr) {
		if (CheckQuickTimeout("FindCities","cityMatches",formStr)) {
			list = document.forms.ypsearch.citySelect; 
			if (formStr) {
				retVal = RSExecute (rsPage, "get_cities", formStr);
				if (retVal.return_value) {
					returnVal = retVal.return_value.split(",");

					listLength = returnVal.length;
					for (index = list.length - 1; index >= 0; index--) list.options[index] = null;
						list.options[list.length] = new Option (listLength+" found. Click arrow to view","")

					for (stepIndex = 0; stepIndex < listLength; stepIndex++) {
						list.options[list.length] = new Option (returnVal[stepIndex], returnVal[stepIndex]);
					}		
				} else {
					for (index = list.length - 1; index >= 0; index--) list.options[index] = null;
					list.options[list.length] = new Option ("0 Cities Found","");
				}
			} else {
					for (index = list.length - 1; index >= 0; index--) list.options[index] = null;
					list.options[list.length] = new Option ("Type city to show matches","");
			}
		}
	}
	
	function CheckQuickTimeout(funcName,cellName,formStr) {
		clearTimeout(typeTimeout);
		if (!prevKeyTyped) prevKeyTyped = new Date();
		curKeyTyped = new Date();
		timeDelayed = (curKeyTyped.getTime() - prevKeyTyped.getTime()) / 1000;
		if (timeDelayed < 1) { 
			document.getElementById(cellName).innerHTML = "";
			typeTimeout = setTimeout(funcName+"('"+formStr+"')",1000);
			return false;
		} else {
			prevKeyTyped = false;
			return true;
		}
		
	}

	function ShowAllHeadings(formStr) {
		//window.open ('head
	}

	function AddStrToList(str) {
		document.forms.ypsearch.heading.value = str;
		document.forms.ypsearch.submit();
	}

	function SetCity() {
		frm = document.forms.ypsearch;
		fromVal = frm.citySelect.options[frm.citySelect.selectedIndex].value;
		if (fromVal) {
			document.forms.ypsearch.city.value = fromVal;
		}
	}

	function ClearForm(frmName) {
		frm = document.forms[frmName];
		for (x = 0; x < frm.length-3; x++) {
			if (frm[x].type != ("button")) {
				frm[x].value = "";
			}
		}
		document.all.headingMatches.innerHTML = "Typing in a description will bring up a brief list of possibilities";
		document.all.headingMatchesYP.innerHTML = "Typing in a description will bring up a brief list of possibilities";
		document.all.compmatches.innerHTML = "Typing in a company will bring up a brief list of possibilities";
	}
