// JavaScript Document
function manageSelectionsObject(xmyId, xmyGalleryObjects) {
	this.myId = xmyId;
	this.myGalleryObjects = xmyGalleryObjects;
	this.count = 0;
	this.appendAllItems = appendItems;
	initNewGallery(this.myGalleryObjects[0]);
}
function galleryJumpTo(selMenu, myObjectQueue, galleryFunction) {
	for (var i=0; i<myObjectQueue.length; i++) {
		if (document.getElementById(selMenu).options[i].selected) {
			try {
			document.getElementById("categoryHeader").innerHTML = myObjectQueue[i].title;
			} catch (e) {}
			eval(galleryFunction + "(" + "categoryObject[" + document.getElementById(selMenu).options[i].value + "])");
		}
	}
}
function removeChildrenFromNode(node)
{
	try {
		var len = node.childNodes.length;
		while (node.hasChildNodes())
		{
		  node.removeChild(node.firstChild);
		}
	} catch (e) {
		alert(e);
	}
}
function initNewGallery(passedObject) {
	var parent = document.getElementById("photoGallery");
	removeChildrenFromNode(parent);
	var thumbsplaceholder = document.createElement("table");
	var thumbsplaceholder_body = document.createElement("tbody");
	thumbsplaceholder.setAttribute("id", "photoGalleryTable");
	thumbsplaceholder_row = new Array();
	thumbsplaceholder_row[0] = document.createElement("tr");
	thumbsplaceholder_cell = new Array();
	thumbsplaceholder_thumb = new Array();
	document.images["galleryExhibit"].src = passedObject.largeStack[0].src;
	var pos = 0;
	do {
		thumbsplaceholder_cell[pos] = document.createElement("td");
		thumbsplaceholder_thumb[pos] = document.createElement("img");
		thumbsplaceholder_thumb[pos].src = passedObject.outStack[pos].src;
		thumbsplaceholder_thumb[pos].exhibit = passedObject.largeStack[pos].src;
		thumbsplaceholder_thumb[pos].overState = passedObject.overStack[pos].src;
		thumbsplaceholder_thumb[pos].outState = passedObject.outStack[pos].src;
		thumbsplaceholder_thumb[pos].onclick = function() {
			document.images["galleryExhibit"].src = this.exhibit;
		}
		thumbsplaceholder_thumb[pos].onmouseover = function() {
			this.src = this.overState;
		}
		thumbsplaceholder_thumb[pos].onmouseout = function() {
			this.src = this.outState;
		}
		thumbsplaceholder_cell[pos].appendChild(thumbsplaceholder_thumb[pos]); 
		thumbsplaceholder_row[thumbsplaceholder_row.length-1].appendChild(thumbsplaceholder_cell[pos]);
		pos++;
		if (pos%passedObject.rows === 0) {
			thumbsplaceholder_row[thumbsplaceholder_row.length] = document.createElement("tr");
		}
	} while (pos<passedObject.overStack.length);
	while (pos%passedObject.rows) {
		thumbsplaceholder_cell[pos] = document.createElement("td");
		thumbsplaceholder_row[thumbsplaceholder_row.length-1].appendChild(thumbsplaceholder_cell[pos]);
		pos++;			
	}
	for (var i =0; i<thumbsplaceholder_row.length; i++) {
		thumbsplaceholder_body.appendChild(thumbsplaceholder_row[i]);
	}
	thumbsplaceholder.appendChild(thumbsplaceholder_body);
	try {
		parent.appendChild(thumbsplaceholder);
	} catch (e) {
		alert(e);
	}
}
function appendItems()
{
	var parent = document.getElementById(this.myId);
	removeChildrenFromNode(parent);
	var elSel = document.createElement("select");
	elSel.setAttribute("id", "selectPullDown");
	elSel.myObjectQueue = this.myGalleryObjects;
	elSel.onchange = function() {
		galleryJumpTo(this.getAttribute("id"), this.myObjectQueue, "initNewGallery");
	}
	for (var i = 0; i<this.myGalleryObjects.length; i++) {
		var elOptNew = document.createElement('option');
		elOptNew.text = categoryObject[i].title;
		elOptNew.value = i;
		try {
			elSel.add(elOptNew, null); // standards compliant; doesn't work in IE
		}
		catch(ex) {
			elSel.add(elOptNew); // IE only
		}
	}
	parent.appendChild(elSel);
}

var categoryObject = new Array();
function galleryobject(title, desc, large, over, out, rows){
	this.title = title;
	this.descStack = desc;
	this.largeStack = new Array();
	for (var i = 0; i<large.length; i++) {
		this.largeStack[i] = new Image();
		this.largeStack[i].src = large[i];
	}
	this.overStack = new Array();
	for (var i = 0; i<over.length; i++) {
		this.overStack[i] = new Image();
		this.overStack[i].src = over[i];
	}
	this.outStack = new Array();
	for (var i = 0; i<out.length; i++) {
		this.outStack[i] = new Image();
		this.outStack[i].src = out[i];
	}
	this.rows = rows;
}
categoryObject[0] = new galleryobject(
	"Site Plans, Maps, & Renderings",
	[
	"Image Description",
	"Image Description",
	"Image Description",
	"Image Description",
	"Image Description",
	"Image Description"
	],
	[
	"/images/photo_gallery/exhibits/aerial-1-lg.jpg",
	"/images/photo_gallery/exhibits/aerial-2-lg.jpg",
	"/images/photo_gallery/exhibits/aerial-3-lg.jpg",
	"/images/photo_gallery/exhibits/aerial-4-lg.jpg",
	"/images/photo_gallery/exhibits/aerial-5-lg.jpg"
	],
	[
	"/images/photo_gallery/thumbs/aerial-1-sm.jpg",
	"/images/photo_gallery/thumbs/aerial-2-sm.jpg",
	"/images/photo_gallery/thumbs/aerial-3-sm.jpg",
	"/images/photo_gallery/thumbs/aerial-4-sm.jpg",
	"/images/photo_gallery/thumbs/aerial-5-sm.jpg"
	],
	[
	"/images/photo_gallery/thumbs/aerial-1-sm-overlay.jpg",
	"/images/photo_gallery/thumbs/aerial-2-sm-overlay.jpg",
	"/images/photo_gallery/thumbs/aerial-3-sm-overlay.jpg",
	"/images/photo_gallery/thumbs/aerial-4-sm-overlay.jpg",
	"/images/photo_gallery/thumbs/aerial-5-sm-overlay.jpg"
	],
	4
);
categoryObject[1] = new galleryobject(
	"Parties & People",
	[
	"Image Description",
	"Image Description",
	"Image Description",
	"Image Description",
	"Image Description",
	"Image Description"
	],
	[
	"/images/photo_gallery/exhibits/parties-arbor-day-1-lg.jpg",
	"/images/photo_gallery/exhibits/parties-arbor-day-2-lg.jpg",
	"/images/photo_gallery/exhibits/parties-pool-1-lg.jpg",
	"/images/photo_gallery/exhibits/parties-pool-2-lg.jpg",
	"/images/photo_gallery/exhibits/parties-pool-3-lg.jpg",
	"/images/photo_gallery/exhibits/parties-pool-4-lg.jpg"
	],
	[
	"/images/photo_gallery/thumbs/parties-arbor-day-1-sm.jpg",
	"/images/photo_gallery/thumbs/parties-arbor-day-2-sm.jpg",
	"/images/photo_gallery/thumbs/parties-pool-1-sm.jpg",
	"/images/photo_gallery/thumbs/parties-pool-2-sm.jpg",
	"/images/photo_gallery/thumbs/parties-pool-3-sm.jpg",
	"/images/photo_gallery/thumbs/parties-pool-4-sm.jpg"
	],
	[
	"/images/photo_gallery/thumbs/parties-arbor-day-1-sm-overlay.jpg",
	"/images/photo_gallery/thumbs/parties-arbor-day-2-sm-overlay.jpg",
	"/images/photo_gallery/thumbs/parties-pool-1-sm-overlay.jpg",
	"/images/photo_gallery/thumbs/parties-pool-2-sm-overlay.jpg",
	"/images/photo_gallery/thumbs/parties-pool-3-sm-overlay.jpg",
	"/images/photo_gallery/thumbs/parties-pool-4-sm-overlay.jpg"
	],
	4
);
categoryObject[2] = new galleryobject(
	"Community",
	[
	"Image Description",
	"Image Description",
	"Image Description",
	"Image Description",
	"Image Description",
	"Image Description"
	],
	[
	"/images/photo_gallery/exhibits/community-arboretum-entrance-lg.jpg",
	"/images/photo_gallery/exhibits/community-arboretum-exterior-lg.jpg",
	"/images/photo_gallery/exhibits/community-arboretum-foyer-lg.jpg",
	"/images/photo_gallery/exhibits/community-arboretum-interior-lg.jpg",
	"/images/photo_gallery/exhibits/community-geology-park-1-lg.jpg",
	"/images/photo_gallery/exhibits/community-geology-park-2-lg.jpg",
	"/images/photo_gallery/exhibits/community-pool-1-lg.jpg",
	"/images/photo_gallery/exhibits/community-pool-2-lg.jpg"
	],
	[
	"/images/photo_gallery/thumbs/community-arboretum-entrance-sm.jpg",
	"/images/photo_gallery/thumbs/community-arboretum-exterior-sm.jpg",
	"/images/photo_gallery/thumbs/community-arboretum-foyer-sm.jpg",
	"/images/photo_gallery/thumbs/community-arboretum-interior-sm.jpg",
	"/images/photo_gallery/thumbs/community-geology-park-1-sm.jpg",
	"/images/photo_gallery/thumbs/community-geology-park-2-sm.jpg",
	"/images/photo_gallery/thumbs/community-pool-1-sm.jpg",
	"/images/photo_gallery/thumbs/community-pool-2-sm.jpg"
	],
	[
	"/images/photo_gallery/thumbs/community-arboretum-entrance-sm-overlay.jpg",
	"/images/photo_gallery/thumbs/community-arboretum-exterior-sm-overlay.jpg",
	"/images/photo_gallery/thumbs/community-arboretum-foyer-sm-overlay.jpg",
	"/images/photo_gallery/thumbs/community-arboretum-interior-sm-overlay.jpg",
	"/images/photo_gallery/thumbs/community-geology-park-1-sm-overlay.jpg",
	"/images/photo_gallery/thumbs/community-geology-park-2-sm-overlay.jpg",
	"/images/photo_gallery/thumbs/community-pool-1-sm-overlay.jpg",
	"/images/photo_gallery/thumbs/community-pool-2-sm-overlay.jpg"
	],
	4
);

var selectBox = new manageSelectionsObject('galleryDropDown', categoryObject);
selectBox.appendAllItems();