/*
 In order to comply with XHTML strict doctype the target attribute must not exist on an <a> tag.
 Instead wea re using the [rel] attribute to flag anchors we want to open new windows and then inject the target attribute into the DOM
*/

(function externalLinks() {
	if (document.getElementsByTagName) {
		var anchors = document.getElementsByTagName("a");
		for (var i=0, l=anchors.length; i<l; i++) {
			var anchor = anchors[i];
			if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") {
				anchor.target = "_blank";
			}
		}
		
	}
})()



/*
	 This function will launch a new browser window or pop-up window for any links 
	 contained within the XHTML that have titles that match the title variable.
*/


function launchWindow(title, name, width, height, scrollbars, resizable, left, top) {
	if (!document.getElementsByTagName) 
		return false;
	var links = document.getElementsByTagName("a");
	if (links.length < 1) 
		return false;
	for (var i = 0; i < links.length; i++) {
		var linkTitle = links[i].getAttribute("title");
		if (linkTitle == title && width != null) {			// Launches "pop-up" style windows.
			links[i].onclick = function() {
				var newPopUp = window.open(this.getAttribute("href"), name, "width=" + width + ",height=" + height + ",scrollbars=" + scrollbars + ",resizable=" + resizable + ",left=" + left + ",top=" + top);
				return false;
			}
		}
		else if (linkTitle == title && width == null) {	// Launches normal browser windows.
			links[i].onclick = function() {
				var newWindow = window.open(this.getAttribute("href"), name);
				return false;
			}
		}
	}
}
/*
	Set the title of the links that you want to launch new browser windows for (and 
	the names of their windows) in launchWindow() below, and call lWArgs into 
	loadFuncs() in the header of the XHTML page(s).
*/
function lWArgs() {
	// Use the following function call to launch normal browser windows.
	// launchWindow("Apply Now. Link opens a new browser window.", "applyNow");
	 launchWindow("Privacy &amp; Security. Link opens in a new window.", "privacySecurity");
	// Use the following function call to launch "pop-up" style windows.
	launchWindow("Equal Housing Lender. Link opens a new pop-up window.", "newwinopened", 750, 500, "yes", "yes", 35, 161);				
}