// Controls the drop down menus at the top of the site
function menuswap(foo) {
	submenus = document.getElementsByTagName('*');
	for (i=0 ; i<submenus.length ; i++) {
		if (submenus[i].className === 'submenu') submenus[i].style.visibility = 'hidden';
	}
	if (foo!=='') document.getElementById('submenu'+foo).style.visibility = 'visible';
}

// 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('votechuckkeiper.org')===-1 && URL.search('http')!==-1 && anchors[i].rel !== 'self') || anchors[i].rel === 'external') anchors[i].target = "_blank";
	}
}

window.onload = setup;