
// function to open new window with specific qualities

function openWin (url) {
	// window features
	var status = "0";
	var toolbar = "0";
	var location = "0";
	var menubar = "0";
	var directories = "0";
	var resizeable = "0";
	var scrollbars = "1";
	var height = "610";
	var width = "500";
	
	var features = "status=" + status + ",toolbar=" + toolbar + 
					",location=" + location + ",menubar=" + menubar + 
					",directories=" + directories + ",resizeable=" + resizeable +
					",scrollbars=" + scrollbars + ",height=" + height +
					",width=" + width;

	var newWin = window.open(url, "newWin", features);
	newWin.focus();
}

var banners = 4;

function changeBanner () {
	var randomNum = Math.floor(Math.random() * banners)
	var bannerObj = document.getElementById("banner");
	bannerObj.src = "images/banner-home" + eval(randomNum + 1).toString() + ".jpg";
	return true;
}


/*
	Array for randomly picked FAQ questions.  First item in each inner array 
	is the number of the question for the anchor link.
*/

var faqs = new Array(new Array("1", "What should I do if someone asks me to accept legal papers (such as a summons or subpoena) on behalf of the Institute?"),
	new Array("2", "Who can accept service of process for MIT?"),
	new Array("5", "I have received a request for a student's educational records.  What should I do?"),
	new Array("6", "How do I obtain a liability waiver?"),
	new Array("8", "What insurance is available to me?"),
	new Array("10", "How do I get permission to film or photograph on campus?"),
	new Array("13", "Can my dorm sponsor regular movie nights?"),
	new Array("17", "How can I get assistance with a contract?"),
	new Array("18", "Who can sign a contract on behalf of MIT?"),
	new Array("22", "How can I get a document notarized?"));


function pickFAQs () {
	var randomNum = Math.floor(Math.random() * faqs.length);
	var divObj = document.getElementById("faqbox");

/* remove existing faq links */
	for (var i = divObj.childNodes.length - 1; i > -1 ; i--) {
		thisObj = divObj.childNodes[i];
		divObj.removeChild(thisObj);
	}

/* add links starting from randomly generated index */	
	for (i = 0; i < 3; i++) {
		randomNum = randomNum + i;
		if (randomNum >= faqs.length) {
			randomNum = 0;
		}
		thisFAQ = faqs[randomNum];
		pTag = document.createElement('p');
		aTag = document.createElement('a');
		aTag.setAttribute('href',"faq/index.html#q" + thisFAQ[0]);
		txt = document.createTextNode(thisFAQ[1]);
		aTag.appendChild(txt);
		pTag.appendChild(aTag);
		divObj.appendChild(pTag);
	}
}

window.onload = function() {
	changeBanner();
	pickFAQs();
}