function clickHandlers() { // runs at window.onload...
	
	thumbPics = getElementsByClass("floater"); // pass target class name and return array of classed divs...	
	for (var i = 0; i<thumbPics.length; i++) {
		thumbPics[i].onclick = showPic; // set onclick handler on all divs with target class 
	}
}
// The getElementsByClass() function requires the target class to be on divs only.
// thumbPics is not declared var, making it available to showPic().


function showPic() { // showPic() is called every time a div.floater or its children are clicked...

	var screenwidth = document.body.clientWidth; // get window width...
	var screenheight = document.body.clientHeight; // get window height...
	var imgs = this.getElementsByTagName("img"); // get image array inside clicked div...

	// send popup img width and height to variables... 
	var imgwidth = imgs[1].width; 
	var imgheight = imgs[1].height; 

	// carry out division on dimensions and store results in variables...
	var ratiowidth = imgwidth/screenwidth;
	var ratioheight = imgheight/screenheight;

	// algorithm decides when/if to change one img dimension to proportionally size img for user's window size...
	if (ratiowidth > ratioheight && imgwidth > screenwidth - 95)	imgs[1].width = screenwidth - 95;
	if (ratioheight >= ratiowidth && imgheight > screenheight - 110) imgs[1].height = screenheight - 110;
	// the number fudging above accounts for the CSS dimensions of the "frame" borders on the big popups.
	
	// a popup appears when a .floater div gets a dynamic class 
	// of "showpic" added or removed, via the code below...

	if (this.className == "floater") { // if thumb has no popup open...
			for (var i = 0; i < thumbPics.length; i++) {
				thumbPics[i].className = "floater"; // loop all clickers to make sure old popups are removed... 
				}
					this.className = "floater showpic"; // show popup for clicked div by adding "showpic" class...
	} else {
			for (var i = 0; i < thumbPics.length; i++) {
				thumbPics[i].className = "floater"; // if clicked div has popup open, loop/hide all clickers.
				}
	}

} // end showPic()


clickHandlers(); // sets onclick event handlers on all instances of div.(targetclass)...
