if ( window.attachEvent )
{
	window.attachEvent('onload', InitPopups);
	window.attachEvent('onload', InitGallery);
}
else if ( window.addEventListener )
{
	window.addEventListener('load', InitPopups, false);
	window.addEventListener('load', InitGallery, false);
}

function InitPopups()
{
	if ( document.getElementById )
	{
		var anchors = document.getElementById("content").getElementsByTagName("a");

		for ( var i=0; i < anchors.length; i++ )
		{
			if ( anchors[i].className=="didYouKnow" 
			  || anchors[i].className=="ownWords"
			  || anchors[i].className=="wordsOfOthers" )
			{
				anchors[i].onclick = function()
				{
					// (Unfortunately, as is, does nothing
					// to resize already opened windows.  Fix this.)
					OpenPopup(420, 620, this.href, "popup");
					/* prevents the href from firing onclick */
					return false;
				};
			}
		}
	}
}

function OpenPopup(intHeight, intWidth, strURL, strWinName, strFeatures)
{
	/* +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+
	   | Creates a scrollbar-less, navigation-less, un-resize-able      |
	   | window that pops up centered, in front of your current window. |
	   +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ */

	/* use the height & width to center the new window */
	var  intTop = parseInt( ( screen.height - intHeight ) / 2 );
	var intLeft = parseInt( ( screen.width - intWidth  ) / 2 );

	var strPosition = "WIDTH="+intWidth+",HEIGHT="+intHeight+",LEFT="+intLeft+",TOP="+intTop;

	if ( strFeatures )
		strPosition += "," + strFeatures;

	var winNew;
	winNew = window.open(strURL, strWinName, strPosition);
	winNew.focus();
}

function InitGallery()
{
	if ( document.getElementById )
	{
		var layers = document.getElementById("content").getElementsByTagName("div");

		for ( var i=0; i < layers.length; i++ )
		{
			if ( layers[i].className=="picLeft" 
			  || layers[i].className=="picRight"
			  || layers[i].className=="picFull" )
			{
				var anchors = layers[i].getElementsByTagName("a");

				for ( var j=0; j < anchors.length; j++ )
				{
					anchors[j].onclick = function()
					{
						// (Unfortunately, as is, does nothing
						// to resize already opened windows.  Fix this.)
						OpenPopup(525, 787, this.href, "gallery", "scrollbars=yes");
						/* prevents the href from firing onclick */
						return false;
					};
				}
			}
		}
	}
}
