var pageOne = 0;
var pageTwo = 1;

function changeClass( myId, myClass )
{
	document.getElementById(myId).className = myClass;
}

function changeStyle ( myId, myStyle, myValue )
{
	eval( "document.getElementById('" + myId + "').style." + myStyle + " = '" + myValue + "'" );
}

function showText()
{
	changeContent( "questionText", myPages[pageTwo] );
}

function zoomIn( myFileName )
{
	changeClass( "contentContainer", "zoomedView" );
	changeStyle( "zoomInButton", "display", "none" );
	changeStyle( "zoomOutButton", "display", "inline" );
	document.getElementById("leftPageZoom").src = "images/zoom/" + myFileName + "_bio.jpg";
	document.getElementById("rightPageZoom").src = "images/zoom/" + myFileName + "_page01.jpg";
}

function zoomInFeatured( myFileName )
{
	changeClass( "contentContainer", "zoomedView" );
	changeStyle( "zoomInButton", "display", "none" );
	changeStyle( "zoomOutButton", "display", "inline" );
	document.getElementById("leftPageZoom").src = "images/zoom/" + myFileName + "_page" + pageOne + ".jpg";
	document.getElementById("rightPageZoom").src = "images/zoom/" + myFileName + "_page" + pageTwo + ".jpg";
	changeStyle( "buttonBox", "display", "none" );
}

function zoomOut()
{
	changeClass( "contentContainer", "standardView" );
	changeStyle( "zoomInButton", "display", "inline" );
	changeStyle( "zoomOutButton", "display", "none" );
}

function zoomOutFeatured()
{
	changeClass( "contentContainer", "standardView" );
	changeStyle( "zoomInButton", "display", "inline" );
	changeStyle( "zoomOutButton", "display", "none" );
	changeStyle( "buttonBox", "display", "inline" );
}

function previousPage( myFileName )
{
	if ( pageOne >= 2 )
	{
		pageOne = pageOne - 2;
		pageTwo = pageTwo - 2;
		document.getElementById("leftPage").src = "images/" + myFileName + "_page" + pageOne + ".jpg";
		document.getElementById("rightPage").src = "images/" + myFileName + "_page" + pageTwo + ".jpg";
		changeClass('controlPanel','middlePages');
		if ( pageOne == 0 )
			changeClass('controlPanel','firstPage');
	}
	else
	{
		changeClass('controlPanel','firstPage');
	}
	showText();
}

function nextPage( myFileName )
{
	if ( pageOne < ( myPages.length - 2 ) )
	{
		pageOne = pageOne + 2;
		pageTwo = pageTwo + 2;
		document.getElementById("leftPage").src = "images/" + myFileName + "_page" + pageOne + ".jpg";
		document.getElementById("rightPage").src = "images/" + myFileName + "_page" + pageTwo + ".jpg";
		changeClass('controlPanel','middlePages');
		if ( pageOne >= ( myPages.length - 2 ) )
			changeClass('controlPanel','lastPage');
	}
	else
	{
		changeClass('controlPanel','lastPage');
	}
	showText();
}

function showHelp()
{
	alert( "To view the journal larger, simply click on the Journal or select the \"zoom in\" magnifying glass.  To go back to the standard view, click the Journal again or select the \"zoom out\" magnifying glass.\n\nRoll your mouse over an individual's image to learn more about them.\n\nRoll your mouse over their artwork to find out what question inspired them.\n\nFor \"Featured Journals\", you can see more pages by selecting \"next\" and \"previous\".\n\nSelect the Community Album to get back to all the Journals." );
}

function changeContent( id, shtml )
{
   if ( document.getElementById || document.all )
   {
   	var el = document.getElementById ? document.getElementById(id): document.all[id];
   	if ( el && typeof el.innerHTML != "undefined" ) el.innerHTML = shtml;
	}
}

var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])

if ((version >= 5.5) && (document.body.filters)) 
{
   for(var i=0; i<document.images.length; i++)
   {
      var img = document.images[i]
      var imgName = img.src.toUpperCase()
      if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
      {
         var imgID = (img.id) ? "id='" + img.id + "' " : ""
         var imgClass = (img.className) ? "class='" + img.className + "' " : ""
         var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
         var imgStyle = "display:inline-block;" + img.style.cssText 
         if (img.align == "left") imgStyle = "float:left;" + imgStyle
         if (img.align == "right") imgStyle = "float:right;" + imgStyle
         if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
         var strNewHTML = "<span " + imgID + imgClass + imgTitle
         + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
         + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
         + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
         img.outerHTML = strNewHTML
         i = i-1
      }
   }
}