function subnav(foo) {
	var bar = '';
	body = document.getElementsByTagName('body');
	if(body[0].className === 'ministry') bar = 'topnavLink1';
	if(body[0].className === 'aboutnyp') bar = 'topnavLink2';
	if(body[0].className === 'servenyp') bar = 'topnavLink3';
	menus = document.getElementsByTagName('*');
	for (i=0 ; i<menus.length ; i++) {
		if(menus[i].className === 'subnav') {
			menus[i].style.visibility = 'hidden';
			menus[i].style.display = 'none';
		}
		if(menus[i].className === 'toplink') {
			menus[i].style.background = 'none';
			menus[i].style.color = '#253141';
		}
		if(bar !== '') document.getElementById(bar).style.background = 'url(../images/bg_topnavh.png) top left repeat-x';
	}
	if (foo !== '') {
		document.getElementById('subnav').style.visibility = 'visible';
		document.getElementById('subnav'+foo).style.visibility = 'visible';
		document.getElementById('subnav').style.display = 'block';
		document.getElementById('subnav'+foo).style.display = 'block';
		document.getElementById('topnavLink'+foo).style.background = '#91BECC url(../images/bg_topnavh.png) top left repeat-x';
		document.getElementById('topnavLink'+foo).style.color = '#AE0B17';
	}
}

function popup(file,wide,high) {
	window.open(file,'popup','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=1,resizable=yes,copyhistory=no,width='+wide+',height='+high)
}

// THIS FUNCTION ACTIVATES EMAIL FORMS
function activate(brillig) {
	document.getElementById('config').name = "config";
	document.getElementById('config').value = brillig;
}

function setup() {
	// OUTBOUND LINKS OPEN IN A NEW WINDOW UNLESS EXPLICITLY TOLD OTHERWISE
	// FORCE SAME WINDOW: rel="self" in anchor
	// FORCE EXTERNAL WINDOW: rel="external" in anchor 
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
		var URL = anchors[i].href;
		if ((URL.search('northernyouthprograms')===-1 && URL.search('http')!==-1 && anchors[i].rel !== 'self') || anchors[i].rel === 'external') anchors[i].target = "_blank";
	}
}

window.onload = setup;
