function liveSearchObj(inputID, resultsID, checkBoxID, suggestURL, targetURL) {

	// SETTINGS & PROPERTIES

	this.enabled = true;
	this.autoFocus = true;
	this.suggestURL = suggestURL;
	this.targetURL = targetURL;
	this.input = document.getElementById(inputID);
	//this.check = document.getElementById(checkBoxID); // If checkbox present
	this.results = document.getElementById(resultsID);

	// OBJECT METHODS

	this.search = function() {
		if (this.enabled) {
			if (trim(this.input.value) != null && trim(this.input.value) != "") {
				var vars = "search=" + escape(this.input.value);
				ajax.post(this.suggestURL, vars, this.update);
			} else {
				this.hideSuggest();
			}
		}
	}

	this.update = function(content) {
		content = eval("(" + content + ")");
		if (content.length > 0) {
			var data = "";
			for (var i in content) {
				data += "<a href='" +
					targetURL + content[i][0] + "' class='result-link'>" +
					"<span class='result' id='result-" + content[i][0] + "'" +
					"onmouseover='overResult(\"result-" + content[i][0] + "\");' " +
					"onmouseout='outResult(\"result-" + content[i][0] + "\");'>" +
					content[i][1] +
					"<br>\n<span class='result-sm'>";
				if (content[i][2] != "") data += content[i][2] + ",&nbsp; ";
				data += content[i][3] + "</span></span></a>\n";
			}
			liveSearch.results.innerHTML = data;
			liveSearch.showSuggest();
		} else {
			liveSearch.hideSuggest();
		}
	}

	this.autoComplete = function(mode) {
		if (mode) {
			this.input.setAttribute("autocomplete", "on");
		} else {
			this.input.setAttribute("autocomplete", "off");
		}
	}

	this.showSuggest = function() {
		this.results.style.display = "block";
	}
	this.hideSuggest = function() {
		this.results.style.display = "none";
	}

	this.enable = function() {
		//this.check.checked = true; // If checkbox present
		this.enabled = true;
		this.autoComplete(false);
	}
	this.disable = function() {
		this.hideSuggest();
		//this.check.checked = false; // If checkbox present
		this.enabled = false;
		this.autoComplete(true);
	}
	this.toggle = function() {
		if (this.enabled) {
			this.disable();
		} else {
			this.enable();
		}
	}

	// INITIALIZE

	if (this.enabled) this.enable();
	if (!this.enabled) this.disable();
	if (this.autoFocus) this.input.focus();

	document.onclick = function(e) {
		var clicked = (e && e.target) || (event && event.srcElement);
		var results = checkParent(clicked, liveSearch.results);
		var input = checkParent(clicked, liveSearch.input);
		if (results && input) {
			liveSearch.hideSuggest();
		} else if (!input && liveSearch.results.style.display == "none"){
			liveSearch.search();
		}
	};
}

// MOUSEOVER EFFECTS

function overResult(resultID) {
	var result = document.getElementById(resultID);
	result.style.color = "#000000";
	result.style.background = "#eeeeee";
}

function outResult(resultID) {
	var result = document.getElementById(resultID);
	result.style.color = "#191919";
	result.style.background = "#ffffff ";
}

