// JavaScript Document
// This function automatically connects the script to the page so that you do not need any inline script
// See http://www.scottandrew.com/weblog/articles/cbs-events for more information
function addEvent(obj, eventType, fn, useCapture)
{
	if (obj.addEventListener) {
		obj.addEventListener(eventType, fn, useCapture);
		return true;
	} else {
		if (obj.attachEvent) {
			var r = obj.attachEvent("on"+eventType, fn);
			return r;
		}
	}
}

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

addEvent(window, "load", externalLinks);

function switchImage(imgName, imgSrc) 
{
	if (document.getElementById(imgName)) {
		if (imgSrc != "none") {
			document.getElementById(imgName).src = imgSrc;
		}
	}
}

// Decode URL parameter
function decode(str) {
	return unescape(str.replace(/\+/g, " "));
}

// Name: Popups
// Description: Group of functions to create accessible pop-up links.
// Source: http://www.alistapart.com/articles/popuplinks/
// --------------------------------------------------
var _POPUP_FEATURES = 'location=no,statusbar=no,menubar=no,resizable=yes,width=615,height=560';

function isUndefined(v) { 
   var undef;
   return v===undef;
}

function raw_popup(url, target, features) {
  if (isUndefined(features)) {
    features = _POPUP_FEATURES;
  }
  if (isUndefined(target)) {
    target = '_blank';
  }
  var theWindow = window.open(url, target, features);
  theWindow.focus();
  return theWindow;
}

function link_popup(src, features) {
  return raw_popup(src.getAttribute('href'),
    src.getAttribute('target') || '_blank',
    features);
}

// Name: Request
// Language: JavaScript
// Author: Travis Beckham | squidfingers.com
// Description: Retrieve variables sent through the location search string
// --------------------------------------------------

var Request = new Object ();

(function () {
  if (location.search.length > 0) {
    var s = location.search.substring (1).split ("&");
    for (var i = 0; i < s.length; i++) {
      s[i] = s[i].split ("=");
      Request[s[i][0]] = unescape (s[i][1]);
    }
  }
})();


