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

function popUp(winURL) {
	window.open(winURL, "www.diopa.org - External Link");
}

function prepareLinks() {
	//if older browser without getElementsByTagName return false
	if (!document.getElementsByTagName) return false;
	//otherwise carry-on with launching new window with external link
	var links = document.getElementsByTagName("a");
	for (var i=0; i<links.length; i++) {
		if (links[i].getAttribute("class") == "external") {
			links[i].onclick = function() {
				popUp(this.getAttribute("href"));
				return false;
			}
		}
	}
}

/* Show/Hide via Scriptaculous */
function toggleVisible(element) {
	if(window.console) {
		window.console.log("Inside toggleVisible");
	}
    element = $(element);
    if(element.style.display == 'none') { 
         Effect.BlindDown(element, {duration: 0.2});

    } else { 
         Effect.BlindUp(element, {duration: 0.2});
    }
}

addLoadEvent(prepareLinks);
/*
$('searchByNameButton').onKeyPress = checkEnter;
$('searchByDeaneryButton').onKeyPress = checkEnter;
$('searchbyAddress').onKeyPress = checkEnter;
*/
