function firstChildFF(child) {
  var child = child.firstChild;
  while (child) {
    if (child.nodeType == 1) return child;
    child = child.nextSibling;
  }
  return null;
}

function searchPageShow(id) {
	var tabs = document.getElementById('searchTabs');	
	while (tabs.tagName != "TR") tabs = firstChildFF(tabs);
	var tab = tabs.firstChild;
	var i = 0;
	do {
		if (tab.tagName == "TD") {
			i++;
			tab.className = (i == id) ? "searchTabOn" : "searchTabOff";
			tab.blur();
		}
	}
	while (tab = tab.nextSibling);

	var pages = document.getElementById('searchTabPages');
	var page = pages.firstChild;
	var i = 0;
	do {
		if (page.className == 'searchTabPage') {
			i++;
			page.style.display = (i == id) ? 'block' : 'none';
		}
	}
	while (page = page.nextSibling);
}

function textareaLength(id, fieldname,  maxlength) {
    if (document.getElementById(id).value.length >= maxlength) {
		alert('The '+fieldname+' field is limited to '+maxlength+' characters or less');
		document.getElementById(id).value = document.getElementById(id).value.substring(0, maxlength);
		document.getElementById(id).focus();
		return false;
	} else {
		return true;
	}
}

function showCalendar(form, field) {
	window.open("/js/calendar.cfm?form=" + form + "&field=" + field, "Calendar", "width=230,height=186,status=no,resizable=no,top=100,left=400");
}

function tabOver(number, color) {
	//showHide(color+'Bar');
	document.getElementById('tabLink'+number).className = 'white f2';	
	document.getElementById('tabTop'+number).className = 'tabTop'+color;
	document.getElementById('tabContent'+number).className = 'tabOver'+color;
}

function tabOff(number, color) {
	//showHide(color+'Bar');
	document.getElementById('tabLink'+number).className = 'white f2';
	document.getElementById('tabTop'+number).className = 'tabTop';
	document.getElementById('tabContent'+number).className = 'tabOff';
}

function openWindow(url,h,w,s) {
	var newWindow = window.open(url,'','menubar=no,toolbar=no,location=no,resizable=yes,scrollbars='+s+',height='+h+',width='+w+',left=200,top=100');
	if (window.focus) {
 		newWindow.focus();
	}
}

function searchToggle(list, url) {
	document.forms[0].action = url + list.options[list.selectedIndex].value + '.search';
}

function showHide(id) {
	if (document.getElementById) {
		var obj = document.getElementById(id);
		if (obj.style.display == "none") {
			obj.style.display = "";
		} else {
			obj.style.display = "none";
		}
	}
}

function openClose(id) {
	var arr = id.getElementsByTagName('img');	
	var obj = arr[0];
	if (obj.src.match('open') == null) {
		obj.src = '/images/arrow_open.gif';
	} else {
		obj.src = '/images/arrow_closed.gif';
	}
}