// JavaScript Document

/* To use this file, add this line to the html page, just after the <body> tag
<script type='text/javascript' src="javascript/jsBodyPictFuncDeptPages.js"></script>
*/

/* The variables and functions in this file use the variables in jsHeadPictDept-<XXX>Vars.js
	too (where XXX is a department name). Together, they put up 4 pictures on the left border 
	of a page. There is also variable with the number of pictures available in the folder, called 
	deptFolderLen.
	
	This file is included via the page templates. It is a separate js file so that
	the code can be changed without the template having to be changed.
*/

// These variables are used in the creation of the path name to the
// picture that will be displayed, and in figuring out what picture
// in a folder to print next.
var picN = 0;
var picName = "";
var pictureIndex = 0;

// We want 4 pictures for the border. Change this number if the number of
// pictures desired changes.

// We will pull pictures for the border from the department folder. 
// Since each folder has a bunch of 
// pictures in it, we also have to choose which picture to use. We do this 
// by starting at a random picture in the folder (using picNum), then
// picking the next 4 pictures. If we get to the last picture, we cycle 
// back around to the first.
for (picN = 0; picN < 4; picN++) {

	// We need to add 1 to the index into the picture folder since the names are of
	// the form 1_150x113.jpg to X_150x113.jpg where X is the number of pictures in
	// the folder. Since deptArray[folderIndex][1] is 0-based, we have to add 1 to it
	// in order to get the right picture name.
	if (picNum == deptFolderLen)
		picNum = 0;
	pictureIndex = picNum + 1;
	
	picName = "http://schoolweb.psdschools.org/kinard/images/departments/" 
				+ deptFolderNames + "/deptPagesPics/" + pictureIndex + "_150x113.jpg";
	
	// Now increment the index into the folder that will pick the next picture to
	// be used. If we have reached the last picture in the folder, then go back
	// to the first picture in the folder.
	picNum++;
	if (picNum == deptFolderLen)
		picNum = 0;
	
	document.writeln(("<img name=borderNum" + picN + " src=" + picName + " width=150 height=113><p>"));
}
