var SEARCH_FIELD_TEXT = "Enter therapy, name or location here";

function hover(itemId){
	document.getElementById(itemId).style.backgroundImage = "url('img/menu_hover.png')";
}

function dehover(itemId){
	document.getElementById(itemId).style.backgroundImage = "url('img/menu.png')";
}

function hoverTab(itemId){
	document.getElementById(itemId).style.backgroundImage = "url('img/divider_tab_hover.png')";
}

function dehoverTab(itemId){
	document.getElementById(itemId).style.backgroundImage = "url('img/divider_tab.png')";
}

function clearText(itemId){
	document.getElementById(itemId).value = "";
}

function highlight(itemId) {
	highlightElement(document.getElementById(itemId));
}

function highlightElement(element) {
	if(element.style != undefined)
		element.style.textDecoration = "underline";

	var children = element.childNodes;
	var i = 0;
	while(i < children.length) {
		highlightElement(children[i]);
		i++;
	}
}

function deHighlight(itemId) {
	deHighlightElement(document.getElementById(itemId));
}

function deHighlightElement(element) {
	if(element.style != undefined)
		element.style.textDecoration = "none";

	var children = element.childNodes;
	var i = 0;
	while(i < children.length) {
		deHighlightElement(children[i]);
		i++;
	}
}

function show(therapistId) {
	window.location = "therapist.php?id=" + therapistId;
}

function showTherapy(therapyId) {
	window.location = "therapy.php?id=" + therapyId;
}

function checkForm(fieldId, formId) {
	var form = document.getElementById(formId);
	var field = document.getElementById(fieldId);

	if(field.value == undefined || field.value == null || field.value == "" || field.value == SEARCH_FIELD_TEXT) {
		alert("You did not enter any search terms.\n\n Please enter a therapy, therapist name or location and try again.");
		return false;
	}
	else {
		form.submit();
	}
	return true;
}


