// This page contains the code used for the Case Studies
//	scrolling window.

// You must populate a global variable in the calling page, as follows:
// var numberOfThumbs = 6
// This variable is the number of thumbnails

var block;

function init() {
	if (document.getElementById('blockDiv')) {
		block = document.getElementById('blockDiv').style;
		block.ypos = parseInt(block.top);
		block.active = false;
		for (i=1; i<=numberOfThumbs; i++){
			var img = document.getElementById('thumb'+i);
			img.onmouseover = null;
			img.onmouseout = null;
		}
	}
}

//number of images in the slide show changes is set
//	in the code as a global variable: var numberOfThumbs = 11

function slideUp() {
	// These lines do some math to get the ending ypos correct
	var intAddPixels = 0
	if (numberOfThumbs == 4) {
		intAddPixels = -5
	} else if (numberOfThumbs > 4)  {
		intAddPixels = ((numberOfThumbs - 4) * -27)
	}

	// move the div
	if (block.active) {
		if (numberOfThumbs > 3) {
			if (block.ypos > (((numberOfThumbs - 3) * -60) + intAddPixels)) {
			block.ypos -= 5;
			block.top = block.ypos + "px"
			setTimeout("slideUp()",40)
			}
		}
	}
}


function slideDown() {
	if (block.active) {
		if (numberOfThumbs > 3) {
			if (block.ypos < 30) {
				block.ypos += 5
				block.top = block.ypos + "px"
				setTimeout("slideDown()",40)
			}
		}
	}
}

function updateMedium(index) {
	var img = document.getElementById('mediumImg');
	img.src = 'images/renderings/medium_' + index + '.jpg';
}

function turnAllThumbsOff() {
	for (i=1; i<=numberOfThumbs; i++){
		if (i==2) i++;
		var img = document.getElementById('thumb'+i);
		img.src = 'images/renderings/thumb_' + i + '_off.jpg';
	}
}

function enlargeImg() {
	openBrWindow('large' + enlarge + '.html','enlarge' , 'width=650,scrollbars=1,resizable=1');
}

function thumbClick(index) {
	turnAllThumbsOff();
	imageOn('thumb'+index);
	updateMedium(index);
	enlarge = index;
}

var enlarge = 1;


