/* YEDT JavaScript Document */

/* COPYRIGHT 2006 SEAN MEHRA sean.mehra@yale.edu Morse College, Yale University '06 */

function bigPikcha(el) {
	var imgsrc = el.src;
	location.href= imgsrc.replace("tn_","");
}

function makePhotos (whichBox,howMany) {
	
	for (i=0;i<howMany;i++) {
		var box = document.getElementById(whichBox);
		
		var photobox = document.createElement("div");
		box.appendChild(photobox);
		
		var image = document.createElement("img");
		photobox.appendChild(image);

		photobox.className = "photo";
		image.className = "link";
		image.src = "photos/tn_" + whichBox + "_" + (i+1) +  ".jpg";
		image.onclick = function() {bigPikcha(this);};
		
	}
	
	var hideBox = document.createElement("p");
	document.getElementById(whichBox).appendChild(hideBox);
	hideBox.style.clear="both";
	
	var hideLink = document.createElement("a");
	hideBox.appendChild(hideLink);
	hideLink.innerHTML = "Hide Pictures";
	hideLink.href = "javascript:void(0)";
	hideLink.onclick = function() {
		toggleShow(whichBox); 
		document.getElementById(whichBox).parentNode.getElementsByTagName("a")[0].innerHTML = "Show Pictures";
	};

}

function toggleShow (whichBox, thisBox) {
	box = document.getElementById(whichBox);
	
	if (box.style.display=="none") {
		box.style.display = "block";
		if(thisBox) {thisBox.innerHTML = "Hide Pictures";};
	}
	else {
		box.style.display = "none";
		if(thisBox) {thisBox.innerHTML = "Show Pictures";};
	}
}
