/* hacked from http://www.netlobo.com/div_hiding.html */

function toggleLayer(whichIMG, whichArray, aryCount, theTitle) {
	//document.getElementById('openingInfo').childNodes[0].nodeValue = whichIMG+' : '+whichArray+' : '+aryCount;

	var whichAryStr = whichArray;
	
	if (!window[whichArray]) {
		window[whichArray] = new Array();
	}

	// check for the image in the array
	var aryCheck = -1;
	for (var i = 0; i < window[whichArray].length; i++) {
		if (whichIMG == window[whichArray][i]) {
			aryCheck = i;
		}
	}
	// if image is not in array, add it, else, delete it
	if (aryCheck == -1) {
		window[whichArray].splice(0,0,whichIMG);
		// weirdness to get around associative array limits
		window[whichArray][whichIMG] = theTitle;
	} else {
		window[whichArray].splice(aryCheck,1);
	}
	//document.getElementById('openingInfo').childNodes[0].nodeValue = window[whichArray].toString();


	for (var i = 0; i < aryCount; i++) {
		var elemImg, elemTitle, elemDiv, vis, imgNum;
		imgNum = whichAryStr+'Img'+(i+1).toString();
		titleNum = whichAryStr+'Info'+(i+1).toString();
		divNum = whichAryStr+'Div'+(i+1).toString();
		anchorNum = whichAryStr+'Anchor'+(i+1).toString();
		if (document.getElementById) { // this is the way the standards work
			elemImg = document.getElementById(imgNum);
			elemTitle = document.getElementById(titleNum);
			elemDiv = document.getElementById(divNum);
			elemAnchor = document.getElementById(anchorNum);
		} else if (document.all) { // this is the way old msie versions work
			elemImg = document.all[imgNum];
			elemTitle = document.all[titleNum];
			elemDiv = document.all[divNum];
			elemAnchor = document.all[anchorNum];
		} else if (document.layers) { // this is the way nn4 works
			elemImg = document.layers[imgNum];
			elemTitle = document.layers[titleNum];
			elemDiv = document.layers[divNum];
			elemAnchor = document.layers[anchorNum];
		}
		vis = elemDiv.style;
		if (i < window[whichArray].length) {
			elemImg.src = 'images/blank-286.gif';
			elemImg.src = 'images/'+window[whichArray][i].toString()+'-286.jpg';
			elemAnchor.href = 'javascript:toggleLayer("'+window[whichArray][i].toString()+'","'+whichArray+'", '+aryCount+', "'+window[whichArray][window[whichArray][i]]+'");'
			elemTitle.childNodes[0].nodeValue = window[whichArray][window[whichArray][i]];
			vis.display = 'block';
		} else {
			elemImg.src = 'images/blank-286.gif';
			elemTitle.childNodes[0].nodeValue = ' ';
			vis.display = 'none';
		}
	}
}

/* from http://www.alistapart.com/articles/imagegallery */

function showPic(whichPic, whichAry) {
	if (!window[whichAry]) {
		window[whichAry] = new Array();
	}
	// check for the image in the array
	var aryCheck = -1;
	for (var i = 0; i < window[whichAry].length; i++) {
		if (whichPic == window[whichAry][i]) {
			aryCheck = i;
		}
	}
	// if image is not in array, add it, else, delete it
	if (aryCheck == -1) {
		window[whichAry].splice(0,0,whichPic)
	} else {
		window[whichAry].splice(aryCheck,1)
	}
	document.getElementById('openingInfo').childNodes[0].nodeValue = window[whichAry].length;

	if (document.getElementById) {
		document.getElementById('placeholder1').src = whichPic.href;
		if (whichPic.title) {
			document.getElementById('caption1').childNodes[0].nodeValue = whichPic.title;
		} else {
			document.getElementById('caption1').childNodes[0].nodeValue = whichPic.childNodes[0].nodeValue;
		}
		return false;
	} else {
		return true;
	}
}

function initpage( ) {
//	setHandler( 'tr', 'toggle', 'onclick', 'toggleColor' );
//	setHandler( 'span', 'heading', 'onmouseover', 'toggleColor' );
//	setHandler( 'span', 'heading', 'onmouseout', 'toggleColor' );
//	externalLinks( );
}

if (top.location != self.location) {
	top.location = self.location;
}

window.onload = initpage;
