function addEvent(obj, type, fn) {
	if (obj.attachEvent) {
		obj['e' + type + fn] = fn;
		obj[type + fn] = function() { obj['e'+type+fn](window.event); }
		obj.attachEvent('on' + type, obj[type + fn]);
	} else
		obj.addEventListener(type, fn, false);
}


function removeEvent(obj, type, fn) {
	if (obj.detachEvent) {
		obj.detachEvent('on' + type, obj[type + fn]);
		obj[type + fn] = null;
	} else
		obj.removeEventListener(type, fn, false);
}


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";
			if (anchor.title.indexOf("new window") == -1) {
				anchor.title = (anchor.title != "") ? anchor.title + " (opens in a new window)" : "opens in a new window";
			}
			anchor.className = (anchor.className != '') ? anchor.className + ' external' : 'external';
			if (anchor.firstChild.nodeName.toLowerCase() == "img" || (anchor.firstChild.nodeName.toLowerCase() == "#text" && (anchor.firstChild.nodeValue == null || anchor.firstChild.nodeValue.toString().replace(/\s*/g, "") == "") && anchor.childNodes[1] && anchor.childNodes[1].nodeName.toLowerCase() == "img")) {
				var elNewWindowIcon = document.createElement('span');
				var elNewWindowText = document.createTextNode("(opens in a new window)");
				elNewWindowIcon.className = "accessibilityLinks accessibilityInfo";
				elNewWindowIcon.appendChild(elNewWindowText);
			} else {
				var elNewWindowIcon = document.createElement('img');
				elNewWindowIcon.setAttribute('alt', '(opens in a new window)');
				elNewWindowIcon.className = "newWindowIcon";
				elNewWindowIcon.setAttribute('src', '/Assets/new-win-icon.gif');
                                                                elNewWindowIcon.removeAttribute('height');
                                                                elNewWindowIcon.removeAttribute('width');
			}
			anchor.appendChild(elNewWindowIcon);
		}
	}
  addEvent(document.getElementById('txtHeadSearch'), "focus", focusSearch);
}

function focusSearch(){
  document.getElementById('txtHeadSearch').select();
}

addEvent(window, "load", externalLinks);