function isDefined(property) {
	return (typeof property != 'undefined');
}

function externalLinks() {
	if (!document.getElementsByTagName) {
		return;
	}
	var anchors = document.getElementsByTagName("a");
	for (var i=0;i<anchors.length;i++) { 
		var anchor = anchors[i];
		if ((anchor.getAttribute("href")) && (anchor.getAttribute("rel") == "external")) {
			anchor.target = "_blank";
		}
	}
}

function blurLinks() {
	lnks = document.getElementsByTagName("a");
	inpts = document.getElementsByName("input");
	for(i=0;i<lnks.length;i++) {
		if ((lnks[i].getAttribute("rel") == null) || (lnks[i].getAttribute("rel") == "")) {
			lnks[i].onfocus = new Function("this.blur()");
		}
	}
	for(i=0;i<inpts.length;i++) {
		inpts[i].onfocus= new Function("this.blur()");
	}
}

function deleteRecord(ID,title,page,PageA) {
	question  = "Are you sure you want to remove " + title + "?";
	if (confirm(question)) {
		URL  = page + ".php?Action=delete&ID=" + ID + PageA;
		window.location.href= URL;
	}
}

function logOut() {
	question = "Are you sure you wish to logout?";
	if (confirm(question)) {
		URL = "logout.php";
		window.location.href= URL;
	}
}

function runFunctions() {
	externalLinks();
	blurLinks();
	formControls();
}

if (isDefined(window.addEventListener)) {
	window.addEventListener('load', runFunctions, false);
} else if (isDefined(window.attachEvent)) {
	window.attachEvent('onload', runFunctions);
}