// JavaScript Document

/*///////////////////////////////////////////////////////
// This excellent script by Simon Willison             //
// adds window.onload events to a queue so none get    //
// replaced.  http://simon.incutio.com/				   //
///////////////////////////////////////////////////////*/
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}
 
/*just a convenient place to add this script which clears the content of forms when clicked*/			
function clearDefault(el) {
	if (el.defaultValue==el.value){
		el.value = "";
		}
	el.className='changedField';
}

/*///////////////////////////////////////////////////////
// Contact Alex Phillips with any questions or comments//
// Copyright 2006 Commonwealth College				   //
///////////////////////////////////////////////////////*/

function showImages(){
/*gets the div, link, and image elements from the front page by id.  
Make sure ids are kept in place for each picture set*/
if (document.getElementById("topImage")){
var topImage = document.getElementById("topImage");
var topProfileLink = document.getElementById("topProfileLink");
var topProfileImage = document.getElementById("topProfileImage");
}
if (document.getElementById("leftImage")){
var leftImage = document.getElementById("leftImage");
var leftProfileLink = document.getElementById("leftProfileLink");
var leftProfileImage = document.getElementById("leftProfileImage");
}
if (document.getElementById("rightImage")){
var rightImage = document.getElementById("rightImage");
var rightProfileLink = document.getElementById("rightProfileLink");
var rightProfileImage = document.getElementById("rightProfileImage");
}

/*randomNumber multiplier must correspond to the number of elements in each array*/
var randomNumber = Math.round(Math.random()*4);

/*add links to each student's profile as a new item in the appropriate array*/
var topProfileLinkPath = new Array();
topProfileLinkPath[0] = "aboutus/profiles/agomez.html";
topProfileLinkPath[1] = "aboutus/profiles/adeschamps.html";
topProfileLinkPath[2] = "aboutus/profiles/mmattar.html";
topProfileLinkPath[3] = "aboutus/profiles/jnambu.html";
topProfileLinkPath[4] = "aboutus/profiles/rmcgorty.html";

var leftProfileLinkPath = new Array ();
leftProfileLinkPath[0] = "aboutus/profiles/sbejtlich.html";
leftProfileLinkPath[1] = "aboutus/profiles/nbillman.html";
leftProfileLinkPath[2] = "aboutus/profiles/hkilic.html";
leftProfileLinkPath[3] = "aboutus/profiles/kbaldacci.html";
leftProfileLinkPath[4] = "aboutus/profiles/vmoscardelli.html";

var rightProfileLinkPath = new Array();
rightProfileLinkPath[0] = "aboutus/profiles/nnickey.html";
rightProfileLinkPath[1] = "aboutus/profiles/rcookson.html";
rightProfileLinkPath[2] = "aboutus/profiles/mhockstad.html";
rightProfileLinkPath[3] = "aboutus/profiles/ebudd.html";
rightProfileLinkPath[4] = "aboutus/profiles/vvancollie.html";

/*add the path to the image to be displayed that corresponds with the profile link above.  Be sure to use jpgs.  Do not add file extension.  It is added later.*/
var topProfileImagePath = new Array();
topProfileImagePath[0] = "images/indexBottom_02";
topProfileImagePath[1] = "images/indexBottom_02_01";
topProfileImagePath[2] = "images/indexBottom_02_02";
topProfileImagePath[3] = "images/indexBottom_02_03";
topProfileImagePath[4] = "images/indexBottom_02_04";

var leftProfileImagePath = new Array();
leftProfileImagePath[0] = "images/indexBottom_05";
leftProfileImagePath[1] = "images/indexBottom_05_01";
leftProfileImagePath[2] = "images/indexBottom_05_02";
leftProfileImagePath[3] = "images/indexBottom_05_03";
leftProfileImagePath[4] = "images/indexBottom_05_04";

var rightProfileImagePath = new Array();
rightProfileImagePath[0] = "images/indexBottom_06";
rightProfileImagePath[1] = "images/indexBottom_06_01";
rightProfileImagePath[2] = "images/indexBottom_06_02";
rightProfileImagePath[3] = "images/indexBottom_06_03";
rightProfileImagePath[4] = "images/indexBottom_06_04";

/*preload rollovers*/
var preLoadTop = new Array();
for (i=0; i<3; i++) {
	preLoadTop[i] = new Image();
	preLoadTop[i].src = topProfileImagePath[randomNumber] + "_over.jpg";
}
var preLoadLeft = new Array();
for (i=0; i<3; i++) {
	preLoadLeft[i] = new Image();
	preLoadLeft[i].src = leftProfileImagePath[randomNumber] + "_over.jpg";
}
var preLoadRight = new Array();
for (i=0; i<3; i++) {
	preLoadRight[i] = new Image();
	preLoadRight[i].src = rightProfileImagePath[randomNumber] + "_over.jpg";
}


/*Puts transparent gifs in place of the default images on front page*/
topProfileImage.setAttribute("src", "images/spacer.gif");
topProfileImage.setAttribute("height", "98");
topProfileImage.setAttribute("width", "96");
leftProfileImage.setAttribute("src", "images/spacer.gif");
leftProfileImage.setAttribute("height", "152");
rightProfileImage.setAttribute("src", "images/spacer.gif");
rightProfileImage.setAttribute("height", "201");


/*replaces default links and images with those chosen randomly from the arrays*/
topProfileLink.setAttribute("href", topProfileLinkPath[randomNumber]);
topProfileImage.style.background = "url(" + topProfileImagePath[randomNumber] + ".jpg)";
leftProfileLink.setAttribute("href", leftProfileLinkPath[randomNumber]);
leftProfileImage.style.background = "url(" + leftProfileImagePath[randomNumber] + ".jpg)";
rightProfileImage.style.border = "none";
rightProfileLink.setAttribute("href", rightProfileLinkPath[randomNumber]);
rightProfileImage.style.background = "url(" + rightProfileImagePath[randomNumber] + ".jpg)";



/*background image swapping*/
topProfileImage.onmouseover = function() {
	this.style.background = "url(" + topProfileImagePath[randomNumber] + "_over.jpg)";
}
topProfileImage.onmouseout = function() {
	this.style.background = "url(" + topProfileImagePath[randomNumber] + ".jpg)";
}
leftProfileImage.onmouseover = function() {
	this.style.background = "url(" + leftProfileImagePath[randomNumber] + "_over.jpg)";
}
leftProfileImage.onmouseout = function() {
	this.style.background = "url(" + leftProfileImagePath[randomNumber] + ".jpg)";
}
rightProfileImage.onmouseover = function() {
	this.style.background = "url(" + rightProfileImagePath[randomNumber] + "_over.jpg)";
}
rightProfileImage.onmouseout = function() {
	this.style.background = "url(" + rightProfileImagePath[randomNumber] + ".jpg)";
}



/*turns visibility back on*/
if (document.getElementById("topImage")){
topImage.style.display = "block";
}
if (document.getElementById("leftImage")){
	leftImage.style.display = "block";
}
if (document.getElementById("rightImage")){
	rightImage.style.display = "block";
}

}

addLoadEvent(showImages);