// The directory that the images are stored in
var imgDir = "images";

// The number of buttons (NOTE: The buttons must have name="nav1", name="nav2"... etc. in order to work
// 							Extra note: The images must be named nav1.jpg, nav2.jpg (etc) with rollovers
//							nav1_over.jpg, nav2_over.jpg (etc) to work.
var numberNavLinks = 6;

function clickSwap(id) {
			
		// If image is already pressed, unpress it - or set the new image
		if (document[id].src.indexOf("down") != -1) {
			
			document[id].src = imgDir + "/sidebar/" + document[id].name + ".jpg";
			
		} else {
			
			// Unset all images
			// Note: This approached was used in lieu of unsetting just the last clicked image to account
			// 		 for the 'already pressed' button on page startup (which isn't registered as being pressed)
			for (i = 1; i <= numberNavLinks; i++) {
				var toSet = "nav" + i;
				document[toSet].src = imgDir + "/sidebar/" + document[toSet].name + ".jpg";
			}
			
			// Set the new image
			document[id].src = imgDir + "/sidebar/" + document[id].name + "_down.jpg";
			
		}
						
		// Set lastclicked to the present image to untoggle it in the future
		lastClicked = id;
}

function sidebarMouseOver(id) {
	
	// Check to see if the button is pressed, if so, don't change it!
	if (document[id].src.indexOf("down") == -1) {
		document[id].src = imgDir + "/sidebar/" + document[id].name + "_over.jpg";
	}
	
}

function sidebarMouseOut(id) {
	
	// Check to see if the button is pressed, if so, don't change it!
	if (document[id].src.indexOf("down") == -1) {
		document[id].src = imgDir + "/sidebar/" + document[id].name + ".jpg";
	}
	
}

function footerMouseOver(id) {
	
	document[id].src = imgDir + "/footer/" + document[id].name + "_over.jpg";
	
}

function footerMouseOut(id) {
	
	document[id].src = imgDir + "/footer/" + document[id].name + ".jpg";
	
}

// Note: Requires Scriptalicious to be properly initialized prior to use!
function contactTrans(id, writing) {
	new Effect.Opacity('contactPane', { from: 1.0, to: 0.0, duration: 0.4 });
	setTimeout("new Effect.Opacity('contactPane', { from: 0.0, to: 1.0, duration: 0.5 })",400);
	getContactInfo(id, writing);
	setTimeout("padInfo(" + id + ");",00);
}


function padInfo(id){
	document.getElementById("contactPane").style.marginTop= (document.getElementById("contact" + id).offsetTop) - 92 + "px";
}



// Note: Requires Scriptalicious to be properly initialized prior to use!
function changeDept(id) {
	new Effect.Opacity('departmentTitle', { from: 1.0, to: 0.0, duration: 0.4 });
	setTimeout("new Effect.Opacity('departmentTitle', { from: 0.0, to: 1.0, duration: 0.5 })",400);
	
	new Effect.Opacity('contacts', { from: 1.0, to: 0.0, duration: 0.4 });
	setTimeout("new Effect.Opacity('contacts', { from: 0.0, to: 1.0, duration: 0.5 })",400);
	
	buttons = document.getElementById('contactButtonContainer').childNodes;
	for(var i in buttons){
		buttons[i].className='';
	}
	buttons[(id-1)].className='active';

	
	changeContacts(id);
	setTimeout("document.getElementById('contactPane').style.marginTop='0px';",400);
	
}

	function hide(){for(var i=0;i<arguments.length;i++){document.getElementById(arguments[i]).style.display='none';}}
	function showi(){for(var i=0;i<arguments.length;i++){document.getElementById(arguments[i]).style.display='inline';}}
	function show(){for(var i=0;i<arguments.length;i++){document.getElementById(arguments[i]).style.display='block';}}
	function showhide(){
	for(var i=0;i<arguments.length;i++){
		if (document.getElementById(arguments[i]).style.display=='block') {
			document.getElementById(arguments[i]).style.display='none';
		} else if(document.getElementById(arguments[i]).style.display=='none') {
			document.getElementById(arguments[i]).style.display='block';		
		}
	}
}

function fadeSwitch(fadeIn) {
	fdelay=0;
	if (currentDiv){
		new Effect.Opacity(currentDiv, { from: 1.0, to: 0, duration: 0.6 });
		fdelay=600;
		setTimeout("hide('" + currentDiv + "');",fdelay);
	}
	setTimeout("show('" + fadeIn + "');",fdelay);
	setTimeout("new Effect.Opacity('" + fadeIn + "', { from: 0, to: 1.0, duration: 0.3 });", fdelay);
	currentDiv = fadeIn;
}