function findExLinks() {
	var linkObjs = document.getElementsByTagName('a');
	for (var i = 0; i < linkObjs.length; i++) {
		link = linkObjs[i].getAttribute('rel');
		if (link == "external") {
			linkObjs[i].onclick = newWin;
		}
	}
}

function newWin () {
	// window features
	var status = "1";
	var toolbar = "1";
	var location = "1";
	var menubar = "1";
	var directories = "0";
	var resizable = "1";
	var scrollbars = "1";	
	var features = "status=" + status + ",toolbar=" + toolbar + ",location=" + location + ",menubar=" + menubar + ",directories=" + directories + ",resizable=" + resizable + ",scrollbars=" + scrollbars;
	var newWin = window.open(this, "newWin", features);

	newWin.focus();	
	return false;
}

// function for non-css subnav 

function startList() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("navigation");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				}
			}
		}
	}
}

function homeInit() {
	startList();
	pickCollage();
}

// total number of photo collage image files
var homeTotal = 10;
var subTotal = 30;

function pickCollage() {
	var imgStart = "";
	var containerObj = document.getElementById("collage");
	if (containerObj != null) {
		total = homeTotal;
		imgStart = "/policies/images/collage";
	}
	else {
		containerObj = document.getElementById("subanner");
		if (containerObj != null) {
			total = subTotal;
			imgStart = "http://web.mit.edu/policies/images/subanner";
		}
	}

	if (imgStart != "") {
		// get random class for background images
		var randomNum = Math.floor(Math.random() * total) + 1;
		containerObj.src = imgStart + randomNum.toString() + ".jpg";
	}
}