// imaja-slideshow.js

// scriptmaster=greg@imaja.com
// This script is Copyright © 2001-2005 Greg Jalbert
// Copying or using this script is expressly forbidden. 
// For licensing information, contact greg@imaja.com.
// functions: 
//   picscanprefs getparam addAttribute getSearchAsArray loadFrame 
// displayThumbnail displayListview displayFullSize makeEntryForm
// getFormData getformascommaseparatedvalues displayThumbnailTable
// URL?viewas=list
// URL?viewas=thumbnails
// URL?viewas=entryform

var columns = 14;
var currentImage = 0;
var thumbnailsize = 40;
var paramstr = window.document.location.search;

baseurl = window.document.location.href;
if (baseurl.indexOf("?") > 0)
    baseurl = baseurl.substring(0, baseurl.indexOf("?"));

function picscanprefs(imageDirectory, thumbnailDirectory, thumbnailwidth, thumbnailheight) {
  this.imageDirectory = imageDirectory;
  this.thumbnailDirectory = thumbnailDirectory;
  this.thumbnailwidth = thumbnailwidth;
  this.thumbnailheight = thumbnailheight;
}

var picscanprefs = new picscanprefs("images", "thumbnails", thumbnailsize, thumbnailsize);

function getparam(name) {
  var paramlist = window.document.location.search;
  var pos = paramlist.indexOf(name + "=");
  if (pos > 0) {
    return paramlist.substring(pos+paramlist.length(), paramlist.indexOf('&', pos));
  }
}

function addAttribute(tagstring, attrname, attrvalue) {
  tagstring = tagstring + " " + attrname + "='" + attrvalue + "'";
  return tagstring;
}

function closetag(str) {
  return str + ">";
}

function getSearchAsArray() {
   var minNav3 = (navigator.appName == "Netscape" && 
      parseInt(navigator.appVersion) >= 3)
   var minIE4 = (navigator.appName.indexOf("Microsoft") >= 0 && 
      parseInt(navigator.appVersion) >= 4)
   var minDOM = minNav3 || minIE4   // Baseline DOM required  for this function
   var results = new Array()
   if (minDOM) {
      location
      var input = unescape(location.search.substr(1))
      if (input) {
         var srchArray = input.split("&")
         var tempArray = new Array()
         for (i = 0; i < srchArray.length; i++) {
            tempArray = srchArray[i].split("=")
            results[tempArray[0]] = tempArray[1]
         }
      }
   }
   return results
}

function loadFrame() {
   if (location.search) {
      var srchArray = getSearchAsArray()
      if (srchArray["content"]) {
         self.content.location.href = srchArray["content"]
      }
   }
}

function displayThumbnail(index) {
  var str = "<img";
  str = addAttribute(str, "src", this.thumbnail);
  str = addAttribute(str, "width", picscanprefs.thumbnailwidth);
  str = addAttribute(str, "height", picscanprefs.thumbnailheight);
  str = addAttribute(str, "border", 0);
  str = closetag(str);
  linkurl = baseurl + "?cur=" + index + "&" + "viewas=thumbnails&";
  document.write(str.link(linkurl));
  if (false) {
  	document.write("<br>");
  	// document.write("<br>baseurl=" + baseurl);
 	trunctitle = this.title.substring(0, 10) + "...";
  	document.write(trunctitle.link(linkurl));
  }
}

function displayListview(index) {

  document.write("<tr><td valign='top'>");
  var imagestr = "<img";
  imagestr = addAttribute(imagestr, "src", this.thumbnail);
  imagestr = addAttribute(imagestr, "width", picscanprefs.thumbnailwidth);
  imagestr = addAttribute(imagestr, "height", picscanprefs.thumbnailheight);
  imagestr = addAttribute(imagestr, "border", 0);
  imagestr = closetag(imagestr);
  linkurl = baseurl + "?cur=" + index + "&";
  document.write(parseInt(index)+1);
  document.write("</td><td valign='top'>");

  if (false) { // disable this code
  document.write(imagestr.link(linkurl));
  } // end disable
  document.write("</td><td valign='top'>");
  if (this.title == "") {
  document.write(this.image);
  }
  else {
  document.write(this.title.link(linkurl));
  }
  document.write("</td><td valign='top'>");
  document.write(this.size);
  document.write("</td><td valign='top'>");
  document.write(this.price);
  document.write("</td><td valign='top'>");
  document.write(this.medium);
  document.write("</td></tr>");

 // document.write("<br>");
  // document.write("<br>baseurl=" + baseurl);
 // trunctitle = this.title.substring(0, 10) + "...";
//  document.write(trunctitle.link(linkurl));
}

function displayFullSize() {

  document.write("<table width='100%' cellpadding=4 cellspacing=0 border=0 align='center'>");
  document.write("<tr><td valign='top' width='50%'>");

  var imagestr = "<img";
  imagestr = addAttribute(imagestr, "src", this.image);
  // imagestr = addAttribute(str, "width", 320);
  // imagestr = addAttribute(str, "height", 320);
  imagestr = addAttribute(imagestr, "border", 0);
  imagestr = closetag(imagestr);
 
   var nextindex = parseInt(currentImage)+1;
  if (nextindex > gImageRecCount-1)
    nextindex = gImageRecCount-1;
  var linkurl;
  linkurl = baseurl + "?cur=" + nextindex + "&";
  document.write(imagestr.link(linkurl));

 // document.write(str);
  // document.write("<br>");
  // document.write(this.image);

  document.write("</td><td valign='top' width='50%'>");

  document.write("<br>");
  // this.title.link(this.thumbnail)
  document.write("<h4>" + this.title + "</h4>");
  document.write("<p>");
  document.write("<table width='120' border='0'><tr><td>");  // width='320' height='240'  
  document.write(this.description);
  document.write("</td></tr></table>");
  // document.write(this.title.link(this.thumbnail));
  document.write("<p>");
  if (false) {
// disable the following
  document.write(this.image);
  document.write(this.medium + ", " + this.size + ", $" + this.price + " ");
  document.write("<p>");
document.write('<form action="https://www.paypal.com/cgi-bin/webscr" method="post">');
document.write('<input type="hidden" name="business" value="greg@imaja.com">');
document.write('<input type="hidden" name="return" value="http://www.imaja.com/store/paymentsuccess.html">');
document.write('<input type="hidden" name="undefined_quantity" value="1">');
document.write('<input type="hidden" name="item_name" value="' + this.title + '">');
// document.write('<input type="hidden" name="item_number" value="XXXXX">');
document.write('<input type="hidden" name="amount" value="' + this.price + '">');
// document.write('<input type="hidden" name="no_shipping" value="1">');
document.write('<input type="hidden" name="cancel_return" value="http://www.imaja.com/store/paymentcancelled.html">');
document.write('<input type="hidden" name="image_url" value="https://secure.us.com/imaja/secure/logo-imaja-paypal.jpg">');
document.write('<input type="hidden" name="no_note" value="0">');
document.write('<input type="hidden" name="cn" value="Comments">');
document.write('<input type="image" src="../images/AddToCart.jpg" name="submit" alt="Buy Now">');
document.write('</form>');

document.write('<form name="_xclick" target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">');
document.write('<input type="hidden" name="cmd" value="_cart">');
document.write('<input type="hidden" name="business" value="greg@imaja.com">');
document.write('<input type="image" src="../images/ViewCart.jpg" border="0" name="submit" alt="View Cart">');
document.write('<input type="hidden" name="display" value="1">');
document.write('</form>');
} // end disable

  document.write("</td></tr></table>");

  document.write("<p>");
}

function makeEntryForm() {
  document.write('<form name="imageInfoEntryForm" action="browser.html" method="Get">');
  document.write('image:<input type="text" name="image" size="50" maxlength="200"><br>');
  document.write('title:<input type="text" name="title" size="50" maxlength="200"><br>');
  document.write('thumbnail:<input type="text" name="image" size="50" maxlength="200"><br>');
  document.write('medium:<input type="text" name="medium" size="50" maxlength="200"><br>');
  document.write('size:<input type="text" name="size" size="50" maxlength="200"><br>');
  document.write('frame:<input type="text" name="frame" size="50" maxlength="200"><br>');
  document.write('price:<input type="text" name="price" size="50" maxlength="200"><br>');
  document.write('description:<textarea name="description" cols="80" rows="8"></textarea><br>');
  document.write('datastatement:<textarea name="datastatement" cols="80" rows="8"></textarea><br>');
  document.write('<input type="submit" value="Submit" name="submit">&nbsp;&nbsp;<input type="reset" value="Reset">');
  document.write('<INPUT type="button" VALUE="comma separated values" onClick="makedatastatement(this.form)">');
  document.write('</form>');
}

// Browser and Document Object Model version variables
var minNav3 = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) >= 3)
var minIE4 = (navigator.appName.indexOf("Microsoft") >= 0 && parseInt(navigator.appVersion) >= 4)
var minDOM = minNav3 || minIE4   // baseline DOM required for this function

// Generic function converts form element name-value pairs
// into a URL search string.
function getFormData(form) {
	var searchString = "?"
	var element, onePair
	// Harvest values for each type of form element
	for (var i = 0; i < form.elements.length; i++) {
		element = form.elements[i]
		if (element.type == "text" || element.type == "textarea") {
			onePair = escape(element.name) + "="
			onePair += escape(element.value)
		} else if (element.type.indexOf("select") != -1) {
			onePair = escape(element.name) + "="
			onePair += escape(element.options[element.selectedIndex].value)
		} else if (element.type == "radio" || element.type == "checkbox") {
			if (element.checked) {
				onePair = escape(element.name) + "="
				onePair += escape(element.value)
			} else continue
		} else continue
		searchString += onePair + "&"
	}
	return searchString
}

// Generic function converts form element name-value pairs
// into a URL search string.
function getformascommaseparatedvalues(form) {
	var recordstring = '';
	var element, datavalue
	// Harvest values for each type of form element
	for (var i = 0; i < form.elements.length; i++) {
		element = form.elements[i]
		if (element.name == "datastatement") { 
			continue
		} else if (element.type == "text" || element.type == "textarea") {
			datavalue = element.value
		} else if (element.type.indexOf("select") != -1) {
			datavalue = element.options[element.selectedIndex].value
		} else if (element.type == "radio" || element.type == "checkbox") {
			if (element.checked) {
				datavalue = element.value
			} else continue;
		} else continue;
		recordstring += '"' + datavalue + '"';
		if (form.elements[i+1].name != "datastatement") { 
		  recordstring += ', ';
		}
	}
	// recordstring += '"';
	return recordstring;
}

// Invoked by button to format form data and navigate
// to new page and pass data as URL search string.
function assembleAndGo(form) {
	if (minDOM) {
		var formData = getFormData(form)
		location.href = form.action + formData
	}
}

var lineterminator = "\n";

function makedatastatement(form) {
	if (minDOM) {
		var formData = getformascommaseparatedvalues(form);
// 	form.datastatement.value = form.datastatement.value + "addImageRec( " + formData + " );" + lineterminator + lineterminator;
    form.datastatement.value = "addImageRec( " + formData + " );" + lineterminator + lineterminator;
	}

}

// Create the object
function makeImageInfo(image, title, thumbnail, medium, size, frame, price, description) {
  this.image = picscanprefs.imageDirectory + "/" + image;
  if (title == "")
    title = image;
  if (thumbnail == "")
    thumbnail = image;
  this.title = title; 
  this.thumbnail = picscanprefs.thumbnailDirectory + "/" + thumbnail;
  this.medium = medium;
  this.size = size;
  this.frame = frame;
  this.price = price;
  this.description =  description;
  this.displayListview = displayListview;
  this.displayThumbnail = displayThumbnail;
  this.displayFullSize = displayFullSize;
  this.makeEntryForm = makeEntryForm;
}



var gImageRecs = new Array(40);
var gImageRecCount = 0;

function addImageRec(image, title, thumbnail, medium, size, frame, price, description)
{
	gImageRecs[gImageRecCount] = new makeImageInfo(image, title, thumbnail, medium, size, frame, price, description);
	gImageRecCount++;
}

function displayThumbnailTable() {
	var contentIndex = (0 % gImageRecCount);
	var dispCnt = gImageRecCount; // gImageRecCount or 3;
	var columnIndex = 0;

	document.write("<table cellpadding='2'>");
	document.write("<tr>");
	while (dispCnt > 0) {
		if (columnIndex >= columns) {
			columnIndex = 0;
			document.write("</tr><tr>");
		}
		dispCnt--;
		document.write("<td align=center valign='top'");
		if (contentIndex == currentImage)
		document.write("bgcolor='#FFFF00'");
		else
		document.write("bgcolor='#FFFFFF'"); 
		document.write(">");
		
		gImageRecs[contentIndex].displayThumbnail(contentIndex);
		document.write("</td>");
		contentIndex = (contentIndex + 1) % gImageRecCount;
		columnIndex ++;
	}
	document.write("</tr></table>");
}

// load database of images
// addImageRec(image, title, thumbnail, medium, size, frame, price, description)

addImageRec( "China-Hali-Hammer-156.jpg", "Bing-entertaining and informative as always", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-001.jpg", "Security checkpoint you must pass through before entering the Square", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-002.jpg", "View of the Square", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-003.jpg", "Map of Tiananman Square", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-004.jpg", "People’s Monument", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-006.jpg", "Hali near statues in the Square", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-008.jpg", "Mao’s Mausoleum", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-012.jpg", "Lion guarding the Forbidden City", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-013.jpg", "Inside the Forbidden City", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-014.jpg", "Crane statue", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-015.jpg", "Walking on the original ancient paths", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-019.jpg", "Corridor of the concubines", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-020.jpg", "Writing was generally in 3 languages.jpg: Chinese, Mandarin and Mongolian", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-022.jpg", "If you can’t find a phone booth, come to cities in China - they’re everywhere!", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-026.jpg", "Man-made lake at the Summer Palace was dug for the emperor’s pleasure", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-027.jpg", "Everywhere you look there is beauty - beams on the covered walkway", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-028.jpg", "We took a boat like this across the lake", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-030.jpg", "This huge stone boat is a dock for boats that cruise the lake", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-029.jpg", "At the Summer Palace", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-032.jpg", "The 250 year old replica of the bridge Marco Polo crossed into Beijing", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-034.jpg", "Walking across the Marco Polo Bridge", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-036.jpg", "A building replica of the Olympic Torch", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-035.jpg", "The “Bird’s Nest”, used for athletic events", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-037.jpg", "The “Water Cube”, where Olympic swim competitions were held", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-040.jpg", "Entrance to Zen Buddhist Temple in Beijing", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-041.jpg", "Walking from the gateway to the Temple", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-042.jpg", "Ceremonial decoration at the Temple", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-043.jpg", "Blue line path for Olympic runners passed through grounds of Temple of Heaven", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-044.jpg", "Temple of Heaven", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-048.jpg", "The long walk to the Temple was taken by the emperors", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-049.jpg", "Temple of Heaven", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-050.jpg", "Rickshaw drivers in the hutong", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-061.jpg", "Narrow street barely fit two rickshaws", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-052.jpg", "Zen in the hutong", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-053.jpg", "Passing through the hutong", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-056.jpg", "Hutong construction is constant", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-065.jpg", "Mrs. Shen and her bird", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-018.jpg", "A clean place to squat", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-051.jpg", "Hali at the entrance to the Great Wall", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-054.jpg", "Ascending the Great Wall", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-064.jpg", "Going up!", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-063.jpg", "The Great Climb", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-059.jpg", "Pat and I pause for a break", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-057.jpg", "I made it!!!", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-072.jpg", "View of a turret", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-070.jpg", "Now we have to go down", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-068.jpg", "The Wall looking down…", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-069.jpg", "And down…it’s steep!", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-071.jpg", "All I can say is WOW!!!", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-074.jpg", "Stone dragon guarding the Ming Tombs", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-077.jpg", "Marco Polo statue in the lobby of his hotel", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-076.jpg", "Rooms with altars for ancestor worship are common atop buildings", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-079.jpg", "Lush terraced hills of tea", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-080.jpg", "A fountain in the Tea Garden", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-081.jpg", "Window in a building at Tiger Springs", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-082.jpg", "Boat on West Lake", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-084.jpg", "At West Lake during the day", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-085.jpg", "A flower caught my eye", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-088.jpg", "The once disguised Happy Buddha", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-094.jpg", "Narrow alley in Xitang", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-097.jpg", "The view across the river", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-102.jpg", "Walking the streets of Xitang", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-104.jpg", "Shopping street in Xitang", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-106.jpg", "Xitang looking downriver", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-110.jpg", "The Che Store", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-111.jpg", "Xitang candy store sign", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-114.jpg", "A game of Go in Xitang", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-115.jpg", "Crossing over a bridge in Xitang", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-116.jpg", "Xong Mei Ling", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-117.jpg", "Translations can be a problem", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-118.jpg", "Fred was often mistaken for Buddha and had his stomach rubbed a few times too many", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-120.jpg", "Bamboo was used before paper for writing - sometimes hung in trees like this", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-121.jpg", "Doors came in many shapes - I especially liked the round hobbit effect", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-122.jpg", "Symbol for harmony in the household - his wives and concubines got along well", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-123.jpg", "Okay... lost in translation!", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-126.jpg", "Silkworms on mulberry leaves", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-127.jpg", "Silkworm eggs and braids of silk", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-129.jpg", "Culling silkworm eggs at the factory", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-131.jpg", "Paddling and peddling edible lotus pods at the Lingering Garden", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-133.jpg", "Gorgeous lotus blossoms everywhere!", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-136.jpg", "Peeking under the Grand Canal bridge", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-137.jpg", "Statues of monks guard the Buddha", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-138.jpg", "Sifting wax from the water", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-139.jpg", "Wax candles for prayer", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-141.jpg", "A large pillar of bright Buddhas", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-142.jpg", "Closeup of one of the pillar’s Buddhas", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-144.jpg", "A stone pillar at the temple steps", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-145.jpg", "Three huge Buddhas", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-132.jpg", "Are these humidifiers?", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-140.jpg", "Hali and Hai Bao (baby Shanghai)", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-143.jpg", "Shanghai at night", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-147.jpg", "It’s a long way down!", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-148.jpg", "Standing on this was really cool!", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-149.jpg", "Looking up at the top of the TV tower in the clouds", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-151.jpg", "At the top of the stairs in the Shanghai Museum", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-152.jpg", "Ancient money came in many shapes", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-154.jpg", "Our bus in Shanghai", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-157.jpg", "I’m cool with that…", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-158.jpg", "Bing walked us through this park on our last day", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-159.jpg", "A plaque in three languages at the Shanghai Jewish Museum", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-160.jpg", "Inside the old temple", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-161.jpg", "Honoring those who saved lives", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-162.jpg", "From the rear courtyard of the Jewish Museum", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-163.jpg", "A door to the exhibits", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-165.jpg", "The hero who granted visas to Jews when many other countries wouldn’t", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-167.jpg", "A passport out of Germany saved you from the camps", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-155.jpg", "A street in the Cheng Houng Temple shopping area", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-168.jpg", "Lots of washers but no dryers", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-170.jpg", "Eileen and Tess at our table in the Old Chang Huang Temple Snack Square", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-171.jpg", "A block square eatery", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-172.jpg", "A Chinese mailbox on the street", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-173.jpg", "Map of People’s Park", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-174.jpg", "A closeup of words on the map", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-175.jpg", "Peace in People’s Park!", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-176.jpg", "I don’t know what the problem is, but this poster guy doesn’t look happy", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-177.jpg", "Underground walkways are necessary at busy intersections", "", "", "", "", "", "" );
addImageRec( "China-Hali-Hammer-178.jpg", "A dozen of us outside the railway station", "", "", "", "", "", "" );


// addImageRec( "xxx", "xxx", "xxx", "xxx", "xxx in.", "frame", "200", "xxx.");

function displayNextPrevLinks() {
  // create next and previous links
  var previndex = parseInt(currentImage)-1;
  if (previndex < 0)
    previndex = 0;
  var linkurl = baseurl + "?cur=" + previndex + "&";
  var str = "previous";
  document.write(str.link(linkurl) + "  | ");

  var nextindex = parseInt(currentImage)+1;
  if (nextindex > gImageRecCount-1)
    nextindex = gImageRecCount-1;
  linkurl = baseurl + "?cur=" + nextindex + "&";
  str = "next";
  document.write(str.link(linkurl));
  document.write(" | " + (parseInt(currentImage)+1) + " of " + gImageRecCount + " images");

  if (false) {
  linkurl = baseurl + "?viewas=thumbnails&cur=" + currentImage + "&";
  str="thumbnails";
  document.write(" | " + str.link(linkurl));
  }
  
  linkurl = baseurl + "?viewas=list&";
  str="list";
  document.write(" | " + str.link(linkurl));
}

function viewaslist() {
  var contentIndex = (0 % gImageRecCount);
  var dispCnt = gImageRecCount; // gImageRecCount or 3;

  document.write("<table border='0' cellspacing='0' cellpadding='1' width='550'>");
  while (dispCnt > 0) {
     dispCnt--;
     gImageRecs[contentIndex].displayListview(contentIndex);
     contentIndex = (contentIndex + 1) % gImageRecCount;
    //  document.write("<br>");
  }
  document.write("</table>");
}

pos = paramstr.indexOf("cur=");
if (pos > 0)
  currentImage = paramstr.substring(pos+4, paramstr.indexOf('&', pos));

//    currentImage = getparam("cur");

pos = paramstr.indexOf("thumbnailsize=");
if (pos > 0)
  thumbnailsize = paramstr.substring(pos+14, paramstr.indexOf('&', pos));

// thumbnailsize = getparam("thumbnailsize");

picscanprefs.thumbnailwidth = thumbnailsize;
picscanprefs.thumbnailheight = thumbnailsize;


document.write("<p align='left'>");
displayNextPrevLinks();
document.write("<p>");

if (paramstr.indexOf("viewas=list") > 0)  {
  document.write("<p align='left'>");
  viewaslist();
}
else if (paramstr.indexOf("viewas=thumbnails") > 0)  {
  displayThumbnailTable();
  document.write("<p>");
  document.write("<center>");
  gImageRecs[currentImage].displayFullSize();
  document.write("</center>");

}
else if (paramstr.indexOf("viewas=entryform") > 0)  {
  gImageRecs[currentImage].makeEntryForm();
  document.write("<p>");
  document.write("<center>");
  // gImageRecs[currentImage].displayFullSize();
  document.write("</center>");

}
else {
  document.write("<center>");
  gImageRecs[currentImage].displayFullSize();
  document.write("</center>");
}