// a rel="external"
function externalLinks() {
	if (!document.getElementsByTagName) return;
		var anchors = document.getElementsByTagName('a');
		for (var i=0; i < anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute('href') && anchor.getAttribute('rel') == 'external') anchor.target = '_blank';
	}
}

// IE Opacity fix for png background's
function alphaBackgrounds(){
	var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
	var itsAllGood = (rslt != null && Number(rslt[1]) >= 5.5);
	for (i=0; i<document.all.length; i++){
		var bg = document.all[i].currentStyle.backgroundImage;
		if (itsAllGood && bg){
			if (bg.match(/\.png/i) != null){
				var mypng = bg.substring(5,bg.length-2);
				document.all[i].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+mypng+"', sizingMethod='scale')";
				document.all[i].style.backgroundImage = "url('/images/interface/blank.gif')";
			}
		}
	}
}

// Functions for the map in region.php
function changeRegion(region){
	document.getElementById('map').style.background = 'url(images/map/'+region+'.gif) no-repeat';
	document.getElementById(region).checked = 1;
	document.getElementById(region).className = 'hidden';
}
function removeRegions(go){
	if(go){
		document.getElementById('map').style.background = 'none';
	}
}

// Function for swapping text in what's new
function changeText(text){
	var description = document.getElementById('desc');
	description.innerHTML = text;
}

/*
// Image swap in Organisation
function changeImage(id,img1,img2,startup){
	if(!startup){
		//alert(id + '['+img1 + ' : ' + img2+']');
		var obj = document.getElementById(id);
		
		// Split the src
		var path = obj.src.split('/');
		var src = (path[(path.length-1)]);
		
		// Change the image
		if(src==img1) obj.src='cms/ul/'+img2;
		else if(src==img2) obj.src='cms/ul/'+img1;
	}
	else startup=0;
	setTimeout("changeImage('"+id+"','"+img1+"','"+img2+"',"+startup+")",3000);
	
}
*/

// Multiple onload functionality
function multipleOnload(){
	externalLinks();
	if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && window.attachEvent) {
		//alphaBackgrounds();
	}
}

window.onload = multipleOnload;