// onload events
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			if (oldonload) {
				oldonload();
			}
			func();
		}
	}
}

// insertAfter
function insertAfter(newElement,targetElement) {
	var parent = targetElement.parentNode;
	if (parent.lastChild == targetElement) {
		parent.appendChild(newElement);
	} else {
		parent.insertBefore(newElement,targetElement.nextSibling);
	}
}

// "loading" image
function searchNotify(){
	if (!document.getElementById) return false;
	
	if (!document.getElementById("search_submit")) return false;
	var submitButton = document.getElementById("search_submit");
	submitButton.onclick = function () {
		submitButton.disabled = true;
		submitButton.setAttribute("value","Searching…");
		var searchImage = document.createElement("img");
		searchImage.setAttribute("src","images/site_images/loading.gif");
		searchImage.setAttribute("alt","searching database");
		searchImage.setAttribute("class","search_image");
		insertAfter(searchImage,submitButton);

		return true;
	}
}

// popup windows
function popupWin() {
	if (!document.getElementsByTagName) return false;
	var links=document.getElementsByTagName("a");
	for (var i=0; i < links.length; i++) {
		if (links[i].className.match("popup")) {
			links[i].onclick=function() {	
				window.open(this.href, "", "top=40,left=40,width=600,height=625,resizable=yes");
				return false;
			}
		}
	}
}







// load events
addLoadEvent(searchNotify);
addLoadEvent(popupWin);