/*
Filename: external.js
Desc:     Generic script to launch external links and PDFs in a new window
Author:   Relevant Arts Enterprise, Inc. <http://www.relevantarts.com/>
          John A. Lock <jlock@relevantarts.com>
Created:  2003-Dec-07
Modified: 2003-Dec-10 - Modified to ignore PDF's called within javascript
					2005-Jun-02 - Modified frame buster code to preserve history for back button
					2006-May-05 - Added new window override check for domain families
*/

var domain_family = "";
var Ctr = 0;

// Break out of frames, if present, and modify external links and PDF links
function Init(FrameOK) {
	// If we're framed, break out of it, unless a parm is passed saying it's OK or we're inside Web Edit Pro
	if ((!FrameOK) && (self != top) &&
			(window.location.href.indexOf("webedit") == -1) &&
			(window.location.href.indexOf("wep_temp") == -1) &&
			(window.name != "wep_temp")) {
		top.location.replace(window.location.href);
	}
	// Target all PDFs and external links to a new window
	if (!document.NewWindow) {
		var CurrHost = window.location.hostname;
		for (Ctr=0;Ctr<=(document.links.length-1);Ctr++) {
			if ((document.links[Ctr].href.indexOf(".pdf") > -1) &&
					(document.links[Ctr].href.indexOf("javascript") < 0)) {
				document.links[Ctr].target = "NewWin";
			}	else if ((document.links[Ctr].href.indexOf(CurrHost) < 0) &&
								 (document.links[Ctr].href.indexOf("http") == 0) &&
								 (domain_family.indexOf(document.links[Ctr].host) == -1)) {
				document.links[Ctr].target = "NewWin";
			}
		}
	}
}
