/*
Programmer: Darryl Ballard
Date created: 2008-09-16
Last updated: 2008-12-23
Version: 1.0.0

Requires:
	Prototype 1.6
	
Version History:
*/

var GST_External_Links = {
	class_to_activate:"external",
	
	trigger:function(obj)
	{
		if (obj.hasClassName(GST_External_Links.class_to_activate)) {
			window.open(obj.href, "externalWindow");
		} else {
			window.location = obj.href;
		}
	},
	
	activate:function()
	{
		// Get all the external links
		var external_links = $$("a." + GST_External_Links.class_to_activate);
		
		for (var i = 0; i < external_links.length; i++) {
			// Only do it to links with an href
			// (No idea why this works, but it does, on FF/IE/GC)
			if (external_links[i].href) {
				external_links[i].observe("click", function(e) {
					GST_External_Links.trigger(this);
					
					// Stop event bubbling and any default browser actions
					e.stop();
				});
			}
		} // end for(i)
	} // end activate()
};

// Require that Prototype is available
if (typeof Prototype == "undefined") {
	alert("GST External Links 2.0 requires the Prototype javascript framework.\n\nPlease check that it is included.");
} else {
	document.observe("dom:loaded", GST_External_Links.activate);
}
