document.onmouseover = hideAllMenusTest;
var myMenuArray = new Array('myMenu1');

var menu_0 = new Image;
var menu_1 = new Image;
var menu_2 = new Image;
var menu_3 = new Image;
var menu_4 = new Image;
menu_0.src = 'menu_00.gif';
menu_1.src = 'menu_01.gif';
menu_2.src = 'menu_02.gif';
menu_3.src = 'menu_03.gif';
menu_4.src = 'menu_04.gif';

function buildThumbs() {

	switch (thisArray[0][2]) {

		case "layout1":
		colNum = 6;
		tableBegin = "<table border=\"0\" width=\"100%\"><tr><td>";
		tableEnd = "</td></tr><tr><td colspan=\"" + colNum + "\">";
		tableEnd += "<font class=\"NormalBodyCopy\">" + thisArray[0][1] + "</font>";
		tableEnd += "</td></tr></table>";
		break;

		case "layout2":
		colNum = 3;
		tableBegin = "<table border=\"0\" width=\"560\"><tr valign=\"top\"><td width=\"180\">";
		tableBegin +=  "<font class=\"NormalBodyCopy\">" + thisArray[0][1] + "</font></td><td width=\"380\">"
		tableEnd = "</td></tr></table>";
		break;

		case "layout3":
		colNum = 2;
		tableBegin = "<table border=\"0\" width=\"560\"><tr><td>";
		tableEnd = "</td></tr><tr><td colspan=\"" + colNum + "\">";
		tableEnd += "<font class=\"NormalBodyCopy\">" + thisArray[0][1] + "</font>";
		tableEnd += "</td></tr></table>";
		break;

		case "layout4":
		colNum = 2;
		tableBegin = "<table border=\"0\" width=\"560\"><tr valign=\"top\"><td width=\"180\">";
		tableBegin +=  "<font class=\"NormalBodyCopy\">" + thisArray[0][1] + "</font></td><td width=\"380\">"
		tableEnd = "</td></tr></table>";
		break;

		default:
		break;

	}

	thumbTable = iterateThumbs(colNum);
	document.write("<img src=\"images/" + thmbArray + "_title.gif\">");
	document.write(tableBegin + thumbTable + tableEnd);

}

function iterateThumbs(colNum) {
	returnStr = "<table border=\"0\" cellpadding=\"2\">";
	count = thisArray.length; 
	for (i = 1; i < count; i++) {
		var thisTitle = thisArray[i][0];
		//if (i==1) document.write("<tr><td colspan=\"" + colNum + "\">  <font face=\"Arial, Helvetica, sans-serif\" size=\"1\" color=\"#CEB552\"><b>Click on an image</b></font></td></tr><tr valign=\"top\">")
		if (i==1) returnStr += "<tr>";
		if ((i != 1)&&(parseInt(i - 1) % colNum == 0)) returnStr += "</tr>\n  <tr valign=\"top\">";
		var thisLink = "display.html?thisArray=" + escape(thmbArray) + "&item=" + i
		returnStr += "<td><a href=\"" + thisLink + "\"><img src=\"" + thisArray[i][1] + "\" alt=\"" + thisArray[i][0] + "\" border=\"0\" height=\"75\" width=\"75\" class=\"zeroBorder\" onmouseover=\"this.className='thinBorder'\" onmouseout=\"this.className='zeroBorder'\"></a></td>";
	}
	//make sure we properly finish writing table
	while (parseInt(i - 1) % colNum !=0) {
		i++
		returnStr += "<td>&nbsp;*</td>";
	}
	returnStr += "</tr></table>"
	return returnStr;
}

function displayImage() {
	var nxtItem = (thisItem < thisArray.length - 1)? parseInt(thisItem) + 1:1;
	var prvItem = (thisItem > 1)? thisItem - 1:thisArray.length - 1;
	document.writeln("<table width=\"100%\"><tr><td width=\"5%\"><a href=\"toc.html\"><img src=\"logo.gif\" border=\"0\" alt=\"return to thumbnails\"></a></td>");
	
	document.writeln("<td valign=\"middle\" class=\"HeaderText1\" width=\"80%\">" + thisArray[thisItem][0] + "</td>");
	document.writeln("<td align=\"right\" width=\"10%\">" + generateMenuBar() + "</td>");
	//document.writeln("<td align=\"right\" width=\"5%\"><a href=\"toc.html\" onmouseover=\"document.homearrow.src=homearrow_2.src\" onmouseout=\"document.homearrow.src=homearrow_1.src\"><img src=\"but_home_a.gif\" height=\"29\" width=\"29\" name=\"homearrow\" border=\"0\" alt=\"table of contents\"></a>&nbsp;<a href=\"display.html?thisArray=" + thmbArray + "&item=" + prvItem + "\" onmouseover=\"document.backarrow.src=prevarrow_2.src\" onmouseout=\"document.backarrow.src=prevarrow_1.src\"><img src=\"but_prev_a.gif\" height=\"29\" width=\"29\" name=\"backarrow\" border=\"0\" alt=\"previous image\"></a>&nbsp;<a href=\"display.html?thisArray=" + thmbArray + "&item=" + nxtItem + "\" onmouseover=\"document.nextarrow.src=nextarrow_2.src\" onmouseout=\"document.nextarrow.src=nextarrow_1.src\"><img src=\"but_next_a.gif\" height=\"29\" width=\"29\" name=\"nextarrow\" border=\"0\" alt=\"next image\"></a>");
	document.writeln("<td align=\"right\" width=\"5%\">&nbsp;<a href=\"display.html?thisArray=" + thmbArray + "&item=" + prvItem + "\" onmouseover=\"document.backarrow.src=prevarrow_2.src\" onmouseout=\"document.backarrow.src=prevarrow_1.src\"><img src=\"but_prev_a.gif\" height=\"29\" width=\"29\" name=\"backarrow\" border=\"0\" alt=\"previous image\"></a>&nbsp;<a href=\"display.html?thisArray=" + thmbArray + "&item=" + nxtItem + "\" onmouseover=\"document.nextarrow.src=nextarrow_2.src\" onmouseout=\"document.nextarrow.src=nextarrow_1.src\"><img src=\"but_next_a.gif\" height=\"29\" width=\"29\" name=\"nextarrow\" border=\"0\" alt=\"next image\"></a>");
	document.writeln("</td></tr><tr><td colspan=\"4\" background=\"bkg_line.gif\"><img src=\"spacer.gif\" height=\"5\" width=\"1\"></td></tr></table>");
	document.writeln("<font class=\"NormalBodyCopy\">");
	document.writeln("<img src=\"" + thisArray[thisItem][2] + "\" align=\"left\">")
	document.writeln(thisArray[thisItem][3]);
	document.writeln("</font>");
}


//This generic function will return the value of a QueryString
function getQueryString(Val) {
	thisURLparamStr = document.location.search;
	//chop "?" off thisURLparamStr
	if (thisURLparamStr.charAt(0) == "?") thisURLparamStr = thisURLparamStr.substring(1, thisURLparamStr.length);
	returnStr = "";
	if (thisURLparamStr != "") {
		//Build array out of thisURLparamStr using "&" as delimiter
		divide1=(thisURLparamStr.split("&"))
		for (i=0; i < divide1.length; i++) {
			divide2 = divide1[i].split("=")
			if (unescape(divide2[0]) == Val) {
				returnStr = unescape(divide2[1]);
			}
		}
	}
	return returnStr;
}


function generateMenuBar() {
	
	var menuStr = "";
	menuStr += "<map name=\"menuBar\">";
	menuStr += "<area shape=\"rect\" coords=\"1,1,48,18\" href=\"toc.html\" onmouseover=\"document.menu0.src = menu_1.src\" onmouseout=\"document.menu0.src = menu_0.src\">";
	menuStr += "<area shape=\"rect\" coords=\"50,1,93,18\" href=\"movie.html\" onmouseover=\"document.menu0.src = menu_2.src\" onmouseout=\"document.menu0.src = menu_0.src\">";
	menuStr += "<area shape=\"rect\" coords=\"95,1,143,18\" href=\"#\" onmouseover=\"document.menu0.src = menu_3.src;return !showMenuTest('1', event, 'menu0', 143)\" onmouseout=\"document.menu0.src = menu_0.src\">";
	menuStr += "<area shape=\"rect\" coords=\"145,1,195,18\" href=\"contact.html\" onmouseover=\"document.menu0.src = menu_4.src\" onmouseout=\"document.menu0.src = menu_0.src\">";
	menuStr += "</map>";
	menuStr += "<img src=\"menu_00.gif\" name=\"menu0\" id=\"menu0\" height=\"18\" width=\"197\" border=\"0\" usemap=\"#menuBar\"/>";
	return menuStr;

}

function generateMenus() {

	document.writeln("<div id=\"myMenu1\" style=\"Z-INDEX: 20; VISIBILITY: hidden; WIDTH: 180px; POSITION: absolute; HEIGHT: 52px\" onmouseover=\"event.cancelBubble = true;\">");
	document.writeln("<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" class=\"menuTable\">");
	document.writeln("<tr><td onclick=\"javascript:location.href='behrens_photography.html'\" class=\"menuItem\" onMouseOver=\"this.className='menuItemHilite'\" onMouseOut=\"this.className='menuItem'\">Richard Behrens: The photography of Almost Gone</td></tr>");
	document.writeln("<tr><td onclick=\"javascript:location.href='behrens_film.html'\" class=\"menuItem\" onMouseOver=\"this.className='menuItemHilite'\" onMouseOut=\"this.className='menuItem'\">Richard Behrens: Almost Gone the film</td></tr>");
	document.writeln("<tr><td onclick=\"javascript:location.href='reed_essay.html'\" class=\"menuItem\" onMouseOver=\"this.className='menuItemHilite'\" onMouseOut=\"this.className='menuItem'\">Marc Reed: About Almost Gone</td></tr>");
	document.writeln("<tr><td onclick=\"javascript:location.href='http://money.cnn.com/magazines/fortune/fortune_archive/2004/04/05/366339/index.htm'\" class=\"menuItem\" onMouseOver=\"this.className='menuItemHilite'\" onMouseOut=\"this.className='menuItem'\">Fortune Magazine: The Sinking Of Bethlehem Steel </td></tr>");
	document.writeln("<tr><td onclick=\"javascript:location.href='deraymond.html'\" class=\"menuItem\" onMouseOver=\"this.className='menuItemHilite'\" onMouseOut=\"this.className='menuItem'\">Joe DeRaymond: Requiem for Bethlehem Steel?</td></tr>");
	document.writeln("<tr><td onclick=\"javascript:location.href='homestead.html'\" class=\"menuItem\" onMouseOver=\"this.className='menuItemHilite'\" onMouseOut=\"this.className='menuItem'\">Kathy Kiely: Historic steel town now an economic ghost town</td></tr>");
	document.writeln("</table>");
	document.writeln("</div>");

	//http://www.howtobuyamerican.com
	//http://www.friendsofliberty.com
	//http://www.boycottmadeinchina.org
	//http://www.stillmadeinusa.com/

}

//*********************************
//This function is called for displaying Trailer window
//*********************************
function trailerWindow(thisUrl) {
	var xpos = parseInt(((screen.width)/2) - 260);
	var ypos = parseInt(((screen.height)/2) - 209) - 50;
	winFeatures = "toolbar=no,location=no,scrollbars=yes,resizable=yes,menubar=yes,width=520,height=418,left="+xpos+",top="+ypos
	helpWindow = window.open(thisUrl, 'helpWin', winFeatures)
	helpWindow.focus()
}


//******* BEGIN MENU SCRIPTS ***

function showMenuTest(menuNumber, eventObj, iconID, mapOffSet) {
	//alert(mapOffSet)
    hideAllMenusTest(iconID);
    eventObj.cancelBubble = true;
    var menuId = 'myMenu' + menuNumber;
    if(changeObjectVisibility(menuId, 'visible', iconID, mapOffSet)) {
	return true;
    } else {
	return false;
    }
}

function hideAllMenusTest(iconID) {
    for (i=0; i<myMenuArray.length; i++) {
    	changeObjectVisibility(myMenuArray[i], 'hidden', iconID);
    	
    }
}

function hideMenuTest(eventObj) {
	eventObj.cancelBubble = true;
    if(changeObjectVisibility('myMenu', 'hidden')) {
	return true;
    } else {
	return false;
    }
}


function changeObjectVisibility(objectId, newVisibility, iconID, mapOffSet) {
	

    // get a reference to the cross-browser style object and make sure the object exists
    var styleObject = getStyleObject(objectId);
    if(styleObject) {
    menuTop = 0;
    menuLeft = 0;
    if (!mapOffSet) mapOffSet = 0;
    //alert(document.body.clientWidth)
    if (iconID) {
		//alert(iconID)
		var iconObj = document.getElementById(iconID);
		if (iconObj) {
			//alert(iconID + "," + mapOffSet)
			menuTop = GetElementTop(iconObj) + iconObj.height;
			menuLeft = (GetElementLeft(iconObj) + mapOffSet) - 180;
		}
		
    }
    	//alert(menuTop + ", " + menuLeft)
	styleObject.top = menuTop;
	styleObject.left = menuLeft;
	styleObject.visibility = newVisibility;
	return true;
    } else {
	//we couldn't find the object, so we can't change its visibility
	return false;
    }
} // changeObjectVisibility
  		


// ***********************
// BEGIN POSITIONING STUFF
// ***********************

function getStyleObject(objectId) {
    // cross-browser function to get an object's style object given its id
    if(document.getElementById && document.getElementById(objectId)) {
	// W3C DOM
	return document.getElementById(objectId).style;
    } else if (document.all && document.all(objectId)) {
	// MSIE 4 DOM
	return document.all(objectId).style;
    } else if (document.layers && document.layers[objectId]) {
	// NN 4 DOM.. note: this won't find nested layers
	return document.layers[objectId];
    } else {
	return false;
    }
} // getStyleObject


function GetElementLeft(eElement)
{
   if (!eElement && this)                    // if argument is invalid
   {                                         // (not specified, is null or is 0)
      eElement = this;                       // and function is a method
   }                                         // identify the element as the method owner

   var DL_bIE = document.all ? true : false; // initialize var to identify IE

   var nLeftPos = eElement.offsetLeft;       // initialize var to store calculations
   var eParElement = eElement.offsetParent;  // identify first offset parent element

   while (eParElement != null)
   {                                         // move up through element hierarchy

      if(DL_bIE)                             // if browser is IE, then...
      {
         if( (eParElement.tagName != "TABLE") && (eParElement.tagName != "BODY") )
         {                                   // if parent is not a table or the body, then...
            nLeftPos += eParElement.clientLeft; // append cell border width to calcs
         }
      }
      else                                   // if browser is Gecko, then...
      {
         if(eParElement.tagName == "TABLE")  // if parent is a table, then...
         {                                   // get its border as a number
            var nParBorder = parseInt(eParElement.border);
            if(isNaN(nParBorder))            // if no valid border attribute, then...
            {                                // check the table's frame attribute
               var nParFrame = eParElement.getAttribute('frame');
               if(nParFrame != null)         // if frame has ANY value, then...
               {
                  nLeftPos += 1;             // append one pixel to counter
               }
            }
            else if(nParBorder > 0)          // if a border width is specified, then...
            {
               nLeftPos += nParBorder;       // append the border width to counter
            }
         }
      }
      nLeftPos += eParElement.offsetLeft;    // append left offset of parent
      eParElement = eParElement.offsetParent; // and move up the element hierarchy
   }                                         // until no more offset parents exist
   return nLeftPos;                          // return the number calculated
}

function GetElementTop(eElement)
{
   if (!eElement && this)                    // if argument is invalid
   {                                         // (not specified, is null or is 0)
      eElement = this;                       // and function is a method
   }                                         // identify the element as the method owner

   var DL_bIE = document.all ? true : false; // initialize var to identify IE

   var nTopPos = eElement.offsetTop;         // initialize var to store calculations
   var eParElement = eElement.offsetParent;  // identify first offset parent element

   while (eParElement != null)
   {                                         // move up through element hierarchy
      if(DL_bIE)                             // if browser is IE, then...
      {
         if( (eParElement.tagName != "TABLE") && (eParElement.tagName != "BODY") )
         {                                   // if parent a table cell, then...
            nTopPos += eParElement.clientTop; // append cell border width to calcs
         }
      }
      else                                   // if browser is Gecko, then...
      {
         if(eParElement.tagName == "TABLE")  // if parent is a table, then...
         {                                   // get its border as a number
            var nParBorder = parseInt(eParElement.border);
            if(isNaN(nParBorder))            // if no valid border attribute, then...
            {                                // check the table's frame attribute
               var nParFrame = eParElement.getAttribute('frame');
               if(nParFrame != null)         // if frame has ANY value, then...
               {
                  nTopPos += 1;              // append one pixel to counter
               }
            }
            else if(nParBorder > 0)          // if a border width is specified, then...
            {
               nTopPos += nParBorder;        // append the border width to counter
            }
         }
      }

      nTopPos += eParElement.offsetTop;      // append top offset of parent
      eParElement = eParElement.offsetParent; // and move up the element hierarchy
   }                                         // until no more offset parents exist
   return nTopPos;                           // return the number calculated
}


//******* END POSITIONING STUFF
