// 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("gallery/images", "gallery/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(index);
  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>");
  document.write("<tr><td valign='top' width='50%'>");

  var str = "<img";
  str = addAttribute(str, "src", this.image);
  // str = addAttribute(str, "width", 320);
  // str = addAttribute(str, "height", 320);
  str = addAttribute(str, "border", 0);
  str = closetag(str);
  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( "IMG_5977.jpg", "Kelly sings about her ancestors. The Berkeley Front Row Festival, Aug. 2004", "xx", "", "", "", "", "" );

addImageRec( "JoyfulNoiseYouthChoir-450h.jpg", "Kelly with members of the Joyful Noise Youth Choir, Oakland", "xx", "", "", "", "", "" );
addImageRec( "KellySingingShaker3440-450w.jpg", "Kelly singing out at her birthday concert on Nov. 14, 2008. The KTO Project performed with special guests at UTunes Coffeehouse in Oakland.", "xx", "", "", "", "", "" );
addImageRec( "KellyAndSinger3389-450w.jpg", "Kelly and Dr. BAOMI singing out at Kelly's birthday concert on Nov. 14, 2008. The KTO Project performed with special guests at UTunes Coffeehouse in Oakland.", "xx", "", "", "", "", "" );

addImageRec( "GiveItToThePeople-22.jpg", "Kelly plays mbira. CD Release Party, Oakland Box Set, May 2004.", "xx", "", "", "", "", "" );
addImageRec( "GiveItToThePeople-09.jpg", "CD Release, Oakland Box Set, May 2004", "xx", "", "", "", "", "" );
addImageRec( "IMG_5962.jpg", "Silly Face! Berkeley Front Row Festival, Aug. 2004", "xx", "", "", "", "", "" );
addImageRec( "GiveItToThePeople-05.jpg", "Baba Ken Okulolo, who played bass on <i>Give it to the People</i> recording, jumped up on stage to jam with Kelly. Oakland Box Set, May 2004.", "xx", "", "", "", "", "" );
addImageRec( "IMG_5967.jpg", "Elouise Burrell. Berkeley Front Row Festival, Aug. 2004", "xx", "", "", "", "", "" );
addImageRec( "IMG_5938.jpg", "Michelle Jacques. Berkeley Front Row Festival, Aug. 2004", "xx", "", "", "", "", "" );
addImageRec( "IMG_5972.jpg", "Amber Hines, Michelle Jacques, Elouise Burrell. Berkeley Front Row Festival, Aug. 2004", "xx", "", "", "", "", "" );
addImageRec( "IMG_6021.jpg", "Arsenio Kunde jumps up to play. Berkeley Front Row Festival, Aug. 2004", "xx", "", "", "", "", "" );
addImageRec( "IMG_6018.jpg", "Hands. Berkeley Front Row Festival, Aug. 2004", "xx", "", "", "", "", "" );
addImageRec( "IMG_5979.jpg", "Victor Little, bass and Billy Johnson, drums. Berkeley Front Row Festival, Aug. 2004", "xx", "", "", "", "", "" );
addImageRec( "GiveItToThePeople-23.jpg", "Victor Little. Oakland Box Set, May 2004", "xx", "", "", "", "", "" );
addImageRec( "GiveItToThePeople-36.jpg", "Elouise Burrell and Trente Morant. Oakland Box Set, May 2004", "xx", "", "", "", "", "" );
addImageRec( "IMG_5968.jpg", "Amber Hines. Berkeley Front Row Festival, Aug. 2004", "xx", "", "", "", "", "" );
addImageRec( "IMG_5955.jpg", "Amber Hines. Berkeley Front Row Festival, Aug. 2004", "xx", "", "", "", "", "" );
addImageRec( "GiveItToThePeople-40.jpg", "Danjuma Adamu. Oakland Box Set, May 2004", "xx", "", "", "", "", "" );
addImageRec( "GiveItToThePeople-32.jpg", "Guitarist, Capital, who recorded guitar on <i>Give it to the People</i> CD. Oakland Box Set, May 2004", "xx", "", "", "", "", "" );
addImageRec( "IMG_6031.jpg", "Capital's last gig with the band; he moved to Japan! Berkeley Front Row Festival, Aug. 2004", "xx", "", "", "", "", "" );
addImageRec( "IMG_5987.jpg", "Berkeley Front Row Festival, Aug. 2004", "xx", "", "", "", "", "" );
addImageRec( "IMG_5984.jpg", "Berkeley Front Row Festival, Aug. 2004", "xx", "", "", "", "", "" );
addImageRec( "KellyAndFriends450.jpg", "The women of the KTO Project: Amber Hines, Michelle Jacques, Donna Viscuso, Kelly Takunda Orphan. La Pena, Oct. 2005.", "xx", "", "", "", "", "" );
addImageRec( "AshleyDrummingSinging450.jpg", "Amber Hines. La Pena, Oct. 2005.", "xx", "", "", "", "", "" );
addImageRec( "KellyDrummingSinging450.jpg", "Kelly performing and explaining what <i>Percussion</i> means to 1st and 2nd graders at the San Francisco Symphony's AIM Program. Spring 2005.", "xx", "", "", "", "", "" );
addImageRec( "DrawingKellyDrum450.jpg", "An AIM student draws Kelly! Spring 2005.", "xx", "", "", "", "", "" );
addImageRec( "KellyMbiraDuskOrange450.jpg", "Kelly plays mbira. Sistah's Steppin' in Pride Festival. Aug. 2005.", "xx", "", "", "", "", "" );
addImageRec( "KellyAshleyCongas450.jpg", "Kelly and Amber. La Pena, Oct. 2005.", "xx", "", "", "", "", "" );
addImageRec( "KellySinging450.jpg", "Kelly singing at Mujeres series with The KTO Project and Wild Mango. La Pena, July 2005.", "xx", "", "", "", "", "" );
addImageRec( "KellyMbiraDusk2-450.jpg", "Kelly plays mbira. Sistah's Steppin' in Pride Festival. Aug. 2005.", "xx", "", "", "", "", "" );
addImageRec( "AshleySinging450.jpg", "Amber Hines at Mujeres series with The KTO Project and Wild Mango. La Pena, July 2005", "xx", "", "", "", "", "" );
addImageRec( "Vocalist450.jpg", "Michelle Jacques at Mujeres series with The KTO Project and Wild Mango. La Pena, July 2005", "xx", "", "", "", "", "" );
addImageRec( "KellyBandLaPena450.jpg", "Just the girls for this gig. Donna Viscuso, flute, Kelly Takunda Orphan, Amber Hines and Michelle Jacques, vocals. La Pena, Oct. 2005", "xx", "", "", "", "", "" );
addImageRec( "KellyAndFriends2-450.jpg", "Backstage at La Pena, Oct. 2005.", "xx", "", "", "", "", "" );
addImageRec( "KellyZimbabweFriends450.jpg", "Kelly in Zimbabwe, performing with Mhembero Dance Company. Sept. 1994. ", "xx", "", "", "", "", "" );
addImageRec( "MutamaGroup450.jpg", "Amber Hines and Kelly T. Orphan who met and formed the group Mutama. From right: Unity Nguyen, Kelly T. Orphan, Anita Brooks, Amber Hines, Sarah Noll, Jeannie McKenzie. 1999.", "xx", "", "", "", "", "" );
addImageRec( "KellyZimbabweFriend450.jpg", "Kelly's professor from University of Zimbabwe, Dr. Dumisani Maraire. At ZimFest, Victoria, B.C. 1998.", "xx", "", "", "", "", "" );

/*
addImageRec( "IMG_5977.jpg", "", "xx", "", "", "", "", "" );
addImageRec( "GiveItToThePeople-22.jpg", "", "xx", "", "", "", "", "" );
addImageRec( "GiveItToThePeople-09.jpg", "", "xx", "", "", "", "", "" );
addImageRec( "IMG_5962.jpg", "", "xx", "", "", "", "", "" );
addImageRec( "GiveItToThePeople-05.jpg", "", "xx", "", "", "", "", "" );
addImageRec( "GiveItToThePeople-11.jpg", "", "xx", "", "", "", "", "" );
addImageRec( "IMG_5967.jpg", "", "xx", "", "", "", "", "" );
addImageRec( "IMG_5938.jpg", "", "xx", "", "", "", "", "" );
addImageRec( "IMG_5972.jpg", "", "xx", "", "", "", "", "" );
addImageRec( "IMG_6021.jpg", "", "xx", "", "", "", "", "" );
addImageRec( "IMG_6018.jpg", "", "xx", "", "", "", "", "" );
addImageRec( "IMG_5979.jpg", "", "xx", "", "", "", "", "" );
addImageRec( "GiveItToThePeople-23.jpg", "", "xx", "", "", "", "", "" );
addImageRec( "GiveItToThePeople-36.jpg", "", "xx", "", "", "", "", "" );
addImageRec( "IMG_5968.jpg", "", "xx", "", "", "", "", "" );
addImageRec( "IMG_5955.jpg", "", "xx", "", "", "", "", "" );
addImageRec( "GiveItToThePeople-40.jpg", "", "xx", "", "", "", "", "" );
addImageRec( "GiveItToThePeople-32.jpg", "", "xx", "", "", "", "", "" );
addImageRec( "IMG_6031.jpg", "", "xx", "", "", "", "", "" );
addImageRec( "IMG_5987.jpg", "", "xx", "", "", "", "", "" );
addImageRec( "IMG_5984.jpg", "", "xx", "", "", "", "", "" );
addImageRec( "KellyAndFriends450.jpg", "", "xx", "", "", "", "", "" );
addImageRec( "AshleyDrummingSinging450.jpg", "", "xx", "", "", "", "", "" );
addImageRec( "KellyDrummingSinging450.jpg", "", "xx", "", "", "", "", "" );
addImageRec( "DrawingKellyDrum450.jpg", "", "xx", "", "", "", "", "" );
addImageRec( "KellyMbiraDuskOrange450.jpg", "", "xx", "", "", "", "", "" );
addImageRec( "KellyAshleyCongas450.jpg", "", "xx", "", "", "", "", "" );
addImageRec( "KellySinging450.jpg", "", "xx", "", "", "", "", "" );
addImageRec( "KellyMbiraDusk2-450.jpg", "", "xx", "", "", "", "", "" );
addImageRec( "AshleySinging450.jpg", "", "xx", "", "", "", "", "" );
addImageRec( "Vocalist450.jpg", "", "xx", "", "", "", "", "" );
addImageRec( "KellyBandLaPena450.jpg", "", "xx", "", "", "", "", "" );
addImageRec( "KellyAndFriends2-450.jpg", "", "xx", "", "", "", "", "" );
addImageRec( "KellyZimbabweFriends450.jpg", "", "xx", "", "", "", "", "" );
addImageRec( "MutamaGroup450.jpg", "", "xx", "", "", "", "", "" );
addImageRec( "KellyZimbabweFriend450.jpg", "", "xx", "", "", "", "", "" );
*/

// 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>");
}