var PicNum
var PicFirst = 100      // <<===NOTE FIRST PICTURE NUMBER===
var PicIncrement = 1  // <<===NOTE PICTURE INCREMENT VALUE===
var LastIndex

var nn4 = (document.layers) ? 1:0 // for JavaScript routines in this window
if (nn4) {
	window.captureEvents(Event.RESIZE)
	window.onresize = handleResize
}

function handleResize() {
	location.reload(1)
	return false
}

function ahemnote() {
	var html = ""
	html += '<h4 class="ahem">'
	html += 'This site will look much better in a browser that supports <a href="../browserupgrade.htm" title="Download a browser that complies with Web standards.">web standards</a>.'
	html += '</h4>'
	return html
}

function ahemnoteHomepage() {
	var html = ""
	html += '<h4 class="ahem">'
	html += 'This site will look much better in a browser that supports <a href="browserupgrade.htm" title="Download a browser that complies with Web standards.">web standards</a>.'
	html += '</h4>'
	return html
}

function bigpic(title, index) {
	var thisPicNum = parent.PicFirst + (parent.PicIncrement * index)
	var html = ""
	html += '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'
	html += '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">'
	html += '<head>'
	html += '<title>' + title + '</title>'
	html += '<link rel="stylesheet" href=",,/css/nn4.css" type="text/css" media="screen" />'
	html += '<!--link before import prevents Flash Of Unstyled Content in ie6pc -->'
	html += '<style type="text/css" media="screen">'
	html += '	@import url("../css/martinduo.css");'
	html += '</style>'
	html += '<style type="text/css" media="screen">'
	html += '	@import url("../css/dropshadow.css");'
	html += '</style>'
	html += '<meta http-equiv="content-type" content="text/html;charset=iso-8859-1" />'
	html += '<meta name="MSSmartTagsPreventParsing" content="TRUE" />'
	html += '<meta http-equiv="expires" content="-1" />'
	html += '<meta http-equiv= "pragma" content="no-cache" />'
	html += '<meta name="author" content="Bruce Martin" />'
	html += '<meta name="description" content="Betsy and Bruce Martin - Martinduo Home Page." />'
	html += '<style type="text/css">'
	html += '   /* div {border: solid 1px #f00;}     /*for pinpointing layout problems*/'
	html += '</style>'
	html += '</head>'
	html += '<body class="bodypopup"'
	html += '>'
	
	// This defines the centered material above the picture
	html += '<div class="popuptitle">'
	html +=  '<h3 class="popup">' + title + '</h3>' + '\n'
	html += ahemnote()
	html += '</div>' //popuptitle
	
	// This defines the main section below the title material
	html += '<div class="popuppage">'
	
   	// This defines the left hand column that holds the navigation links and the descriptive text
	
	// The navigation buttons are positioned absolutely.
	if (index > 0) {
		html += '<div class="popupprev">'
		html += '<a href="javascript:window.opener.PreviousShot();">'
		html += '<img src="../images/back_button.gif" width="21" height="21" border="0"><br />'
		html += 'back</a>'
		html += '</div>'
	}

	if ( index < parent.textArray.length - 1) {
		html += '<div class="popupnext">'
		html += '<a href="javascript:window.opener.NextShot();">'
		html += '<img src="../images/next_button.gif" width="21" height="21" border="0"><br />'
		html += 'next</a>'
		html += '</div>'
	}

	html += '<div class="popupmain">'
	html += '<a href="javascript:window.opener.focus();">'
	html += '<img src="../images/main_button.gif" width="21" height="21" border="0"><br />'
	html += 'main</a>'
	html += '</div>'
		
	// The popupdescription div is positioned absolutely.
	html += '<div class="popupdescription">'
	
	// The popupcaption div is not positioned and flows normally
	if (parent.captionArray && parent.captionArray.length > index && parent.captionArray[index].length > 0 ) {
		html += '<div class="popupcaption">'
		html += '<h5 class="popup">' + parent.captionArray[index] + '</h5>' + '\n'
		html += '</div>' //popupcaption
	}
	
	// The popuptext div is not positioned and flows normally
	html += '<div class="popuptext">'
	html += '<p class="popup">' + parent.textArray[index] + '</p>' + '\n'
	html += '</div>' //popuptext
	
	html += '</div>' //popupdescription
	
	// This defines the picture on the left side
	html += '<div class="popuppicture">'
	html += '<img src="images/' + thisPicNum + '.jpg">' + '\n'
	html += '</div>'
	
	html += '</div>' //popuppage
	
	html += '</body></html>'
	return html
}

function PreviousShot() {
	var i = LastIndex - 1
	ShowShot(i)
}

function NextShot() {
	var i = LastIndex + 1
	ShowShot(i)
}

function ShowShot(index) {
	var attr = "toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,copyhistory=no,scrollbars=yes"
	if (screen.width < 900) {
		myWidth = screen.width - 40
	} else {
		myWidth = 900
	}
	attr += ",width=" + myWidth
	if (screen.height < 650) {
		myHeight = screen.height - 40
	} else {
		myHeight = 650
	}
	attr += ",height=" + myHeight
	
	if (document.all) {
		attr += ",left=" + (screen.width - myWidth) / 4
		attr += ",top=" + (screen.height - myHeight) /4
	} else {
		attr += ",screenX=" + (screen.width - myWidth) / 4
		attr += ",screenY=" + (screen.height - myHeight) / 4
	}
	
	newWindow = window.open("","ss",attr)
	if (!newWindow.opener) {
		newWindow.opener = window
	}
	setTimeout("writeToWindow(" + index + ")", 500) //delay writing until window exists in IE3
}

function writeToWindow(index) {
	var html = bigpic(Title, index)
	newWindow.document.write(html)
	newWindow.document.close()
	LastIndex = index
   	setTimeout("focusWindow()",200) // delay a bit here because IE4 encounters errors when trying to focus a recently opened window
}

function focusWindow() {
	newWindow.focus()
}


function writeDocument(Title, Intro, textArray, captionArray) {
	var firstpart=1;
	var startindex=0;
	var endindex=0;

	if (arguments.length > 2) endindex=textArray.length-1; //textArray specified
	if (arguments.length > 4) { //start index specified
		if (arguments[4] > 0) { //start not at index=0
			firstpart=0; //not the first part
			startindex=arguments[4]; //continue with this start index
		}
		if (arguments.length > 5) endindex=arguments[5]; //end index as specified
	}

	if (firstpart == 1) { //write the initial material
	
		document.write('<div class="popupthumbnailtitle">')
		document.write('<h3 class="popup">' + Title + '</h3>')
		
		if (endindex != 0) {
			document.write('<p class="popupnote">')
			document.write('Click on any small picture to see the large pictures, complete with narrative.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;')
			document.write('<a href="../default.htm">Home</a>')
			document.write('</p>')
		}
		document.write(ahemnote())
		document.write('<h5 class="popup">' + Intro + '</h5>')
		//document.write('<p class="popupnote">')
		//if (endindex != 0) document.write('Click on the small picture to see an enlarged view.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;')
		//document.write('<a href="../default.htm">Home</a>')
		//document.write('</p>')
		document.write('</div>') //popupthumbnailtitle
	}

	if (endindex != 0) { //nonzero length text array

		//var PicFirst = 100    <<===NOTE FIRST PICTURE NUMBER===DEFINED IN martinduo.js
		//var PicIncrement = 1  <<===NOTE PICTURE INCREMENT VALUE===DEFINED IN martinduo.js

		for (var i = startindex; i < endindex+1; i++) {

			PicNum = PicFirst + (PicIncrement * i)
			document.write('<div class="popupthumbnailcontainer">')

			document.write('<div class="popupthumbnailimage">')
			document.write('<div class="popupthumbnailimage2">')
			
			document.write('<a href="../needjavascript.html" target="_blank" onclick="ShowShot(' + i + ');return false;">')
			document.write('<img src="thumbnails/' + PicNum + '.jpg" alt="' + PicNum + '.jpg" title="Click to see big picture" border="0">')
			document.write('</a>')
			
			
			document.write('<br />')
			document.write('<a class="clickhere" title="Click to see big picture" href="../needjavascript.html" target="_blank" onclick="ShowShot(' + i + ');return false;">')
			document.write('click here')
			document.write('</a>')
			
			
			document.write('</div>')
			document.write('</div>')

			document.write('<div class="popupthumbnailtext">')
			if (parent.captionArray && parent.captionArray.length > i && parent.captionArray[i].length > 0 ) {
				document.write('<h5 class="popup">' + parent.captionArray[i] + '</h5>')
			}
			document.write('<p class="popuptext">' + parent.textArray[i] + '</p>')
			document.write('</div>') //popupthumbnailtext
			
			document.write('</div>') //popupthumbnailcontainer
		}
	}
}

function writeDocumentSubHead(Subhead) {
	document.write('<div class="popupsubhead">')
	document.write('<h5 class="popup">' + Subhead + '</h5>')
	document.write('</div>')
}


