DefaultSearch = "Search Directory...";

function InitializeSearchField() {
	ResetSearchText(document.getElementById('SearchText'));
}

function SortList(field) {
	document.getElementById('frmMain').submit();
}

function SetTopic(field) {
	tag = field[field.selectedIndex].value;
	sort = document.getElementById('Sort').value;

	if (sort == "N") {
		if (tag != "") {
			location.href="/topic/" + tag;
		} else {
			location.href="/";
		}
	} else {
		document.getElementById('SearchText').value = "";
		form = document.getElementById('frmMain');
		if (tag != "") {
			form.action="/topic/" + tag;
		} else {
			form.action="/";
		}
		form.submit();
		
	}
}

function ClearSearchText(field) {
	if (field.value == DefaultSearch) {
		field.value = "";
		field.style.color = '#000000';
	}
}

function ResetSearchText(field) {
	if (field.value == "") {
		field.value = DefaultSearch;
		field.style.color = '#AAAAAA';
	}
}

function ValidateSearch() {
	field = document.getElementById('SearchText').value;
	if (field == DefaultSearch) field = "";
	if (field != "") {
		if (field.length < 4) {
			alert("You must enter at least four characters to search directory.");
			return false;
		}
		form = document.getElementById('frmMain');
		form.action="/";
	}
	return true;
}

function GoHome() {
	location.href="/";
}
