/* ---------------------------------
		External Link Functions
--------------------------------- */
function init() {

	// Fetch all the a elements in the document.
	var links = document.getElementsByTagName('a');

	// Loop through the a elements in reverse order
	// for speed.
	for (var i = links.length; i != 0; i--) {
		
		// Pull out the element for this iteration.
		var a = links[i-1];
		
		// If the element doesn't have an href, skip it.
		if (!a.href) continue;

		// If the element has an href that contains "http://" then attach the onclick handler.			
		if (a.href.indexOf('http:\/\/') >= 0 && a.href.indexOf('http:\/\/www.carlinplace.ca/') < 0 && a.href.indexOf('http:\/\/carlinplace.ca/') < 0 && a.href.indexOf('http:\/\/sitemanager.scottbuckingham.com/cms/rss/') < 0 && a.href.indexOf('http:\/\/sitemanager.scottbuckingham.com/liveImages/') < 0) {
			// Set this link to open in a new window
			a.target = '_blank';
			a.className = 'linkExternal';

			if (a.title != ''){
				a.title = a.title + ' (Opens in New Window)';
			} else {
				var aText = a.innerHTML;
				if(aText.substr(0,4) != '<img'){
					a.title = a.innerHTML + ' (Opens in New Window)';
				}
			}
		} else if(a.href.indexOf('mailto:') >= 0) {
			a.className = "linkEmail";
			a.title = 'Send an email to ' + a.innerHTML;
		} else {
			a.className = a.className + " linkInternal";
		}
	}
}

function PopWin(e) {
	if (!e) var e = window.event;
	var a = e.target ? e.target : e.srcElement;
	var newwin = window.open(a.href);
	return !newwin;
}
