var External = function()
{
	// Dirst store all anchor elements in an array
	var a = document.getElementsByTagName('a');
	
	// Store array length in variable for optimised loop
	var len = a.length;
	
	// Loop through the array checking for any A elements with an "rel" attribute that equals "external"
	for (var i=0; i<len; i++) {
		if (a[i].getAttribute( 'rel' ) == 'external') {
			a[i].onclick = function() {
				popup( this.href, screen.availWidth, screen.availHeight, 1 ); return false; 
			};
		}
	}
	
	// Private method for opening a popup window
	var popup = function() 
	{
		var url = arguments[0];
		var w = arguments[1];
		var h = arguments[2];
		var toggle = arguments[3];
		
		// Set x and y positions of new window
		x = screen.width / 2 - ( w / 2 );
		y = screen.height / 2 - ( h / 2 );
		
		// Open window to specific
		window.open( url, 'popup', 'location=yes, resizable=yes, width=' + w + ',height=' + h + ',scrollbars=' + toggle + ',left=' + x + ',top=' + y );
	};
};

/**
 * When the DOM has finished loading...
 */
$(function(){	
	var IE6 = /MSIE 6.0/.test(navigator.userAgent);
	if (IE6) {
		var nav = document.getElementById("top_nav");
		var li = nav.getElementsByTagName("li")[0];
		li.className = "IE6";
	}
	
	// Insert rotating globe animation
	if ($('#flash')) {
		swfobject.embedSWF("/Assets/Flash/Globe.swf", "fallback", "332", "197", "9.0.0", "Assets/Flash/expressInstall.swf", {}, { wmode: "opaque" });
	}
	
	// Makes all links with rel="external" open in a popup window
	External();
});