//<![CDATA[

function synchTab(frameName)
{
	var elList, i; // Initialize variables.

	// Exit if no frame name was given.
	if (frameName == null)
	{
		return;
	} // end if frameName == null

	// Check all links.
	elList = document.getElementsByTagName("A");

	for (i = 0; i < elList.length; i++)
	{
		// Check if the link target matches the frame being loaded.
		if (elList[i].target == frameName)
		{
			// If the link URL matches the page being loaded, activate it.
			// Otherwise, make sure the tab is deactivated.

			if (elList[i].href == window.frames[frameName].location.href)
			{
				elList[i].className += " activeTab";
				elList[i].blur();
			}
			else
			{
				removeName(elList[i], "activeTab");
			} // end if hrefs match
		} // end if elList[i].target == frameName
	} // end for i < elList.length
}// end function synchTab

function removeName(el, name)
{
	var i, curList, newList;

	if (el.className == null)
	{
		return;
	} // end if el.className == null

	// Remove the given class name from the elements className property.
	newList = new Array();
	curList = el.className.split(" ");

	for (i = 0; i < curList.length; i++)
	{
		if (curList[i] != name)
		{
			newList.push(curList[i]);
		} // end if curList[i] != name
	} // end for i< curList.length

	el.className = newList.join(" ");
} // end function removeName()

// define object 'trinket'
function trinket(photo,desc,id,qty,price)
{
	this.photo=photo;
	this.desc=desc;
	this.id=id;
	this.qty=qty;
	this.price=price;
} // end function trinket

// define array
var forsale = new Array();

// fill array
forsale[0]= new trinket("tvguide.jpg","A TV directory from the winter of 2108. (5 million channels and nothing good is going to be on.)","0","1","78.46");
forsale[1]= new trinket("hurricanelamp.jpg","A hurricane lamp: a lamp which generates a windstorm, duh. Plans for a larger version, to be used in lighthouses, are included with the lamp.","1","1","342.63");
forsale[2]= new trinket("bloodpen.jpg","A fountain pen designed to write in blood - for those really important contracts (magically drains users blood)","2","2","46.67");
forsale[3]= new trinket("teslanotebook.jpg","Lost notebook of  of Nicola Tesla: A large, leather-bound folio containing detailed technical instructions for building...wonders. (Signed by Tesla himself, nice chap.)","3","1","107.30");
forsale[4]= new trinket("crosskey.jpg","A fragment of the True Cross, fashioned into the likeness of a cheerful looking, chubby cheeked man. The wooden relic hangs from the end of a keychain. At the other end, there is a single key. (Looks like a key to one of those old bus station lockers)","4","1","528.76");
forsale[5]= new trinket("saucermodel","A very heavy model of a flying saucer, about 18 inches across, incredibly detailed. Light-blue fog is visible through the portsholes. Resists every effort to gain entry.","5","1","167.18");
forsale[6]= new trinket("trilobiterecipies.jpg","A small booklet of trilobite recipes. (Tastes a bit like chicken)","6","1","37.81");
forsale[7]= new trinket("runesword.jpg","A beautiful, engraved, bejeweled, well-forged runesword. It even glows. Because it's highly radioactive. (Buyer pays extra for lead shipping container.)","7","2","150.02");
forsale[8]= new trinket("chocmoose.jpg","1:1 scale chocolate moose. (Don't ask.)","8","1","313.46");
forsale[9]= new trinket("spamcan.jpg","A small, rusty metal canister with a brass clasp. Contents: a few sheets of yellowed paper detailing the actual ingredients of stadium hot dogs, Spam, and cafeteria meatloaf. (Same adventure as above. Again, don't ask, please.)","9","1","316.80");
forsale[10]= new trinket("captlog.jpg","Captain's log of one Black Dog Sitting, an Iroquois sea captain and occasional pirate. Believed to date from the 15th century. (Don't bother with the map, you're too late.)","10","1","593.80");
forsale[11]= new trinket("rubyslipper.jpg","One ruby slipper. Size 9. Left. (I'd also be willing to trade for the matching right slipper.)","11","1","243.05");
forsale[12]= new trinket("rockpaperscissors.jpg","A large granite rock wrapped in vellum and a shattered pair of Victorian scissors. (Let's just say the pahja got a little carried away.)","12","1","144.98");
forsale[13]= new trinket("echidna.jpg","A lime-green plush toy of an Australian spiny echidna.","13","7","25.90");
forsale[14]= new trinket("amberclock.jpg","A small battery-powered digital clock, embedded in fossilized amber. The clock is still running, but appears to be displaying a countdown for some time in the future. (I'd be willing to negotiate on the price if you can get this thing off my hands fast!)","14","1","301.10");
forsale[15]= new trinket("protectivering.jpg","A softly glowing ring. When put on it doesn't come off again. That finger is now impervious to all attacks. (You wouldn't believe the trouble I had with this one. The previous owner was 'attached' to it.)","15","3","38.95");
forsale[16]= new trinket("broompasol.jpg","An old-fashioned woman's parasol, and a straw broom with candle wax drippings on the straw. (To paraphrase the old song: 'What a woman, What a night.')","16","1","359.86");
forsale[17]= new trinket("peoplechow.jpg","People Chow - Formulated to meet the nutritional needs of adult Homo sapiens. Tastes like chicken. (Not bad. Try it with Tabasco.)","17","25","15.42");
forsale[18]= new trinket("embalming.jpg","A wax rubbing of a large panel of ancient Egyptian hieroglyphs depicting the embalming process.","18","1","574.78");
forsale[19]= new trinket("secretphone.jpg","A phone book listing over ten thousand secret phone numbers in the USA and Luxemburg. (A word to the wise: The Secret Service just do not have a sense of humor when it comes to prank calls.)","19","5","101.17");
forsale[20]= new trinket("nonmagfe.jpg","An ingot of non-magnetic iron. (You try figuring that one out. Just about drove my alchemist buddy 'round the bend. Not that he was exactly on an even keel to begin with.)","20","8","11.53");
forsale[21]= new trinket("actatetra.jpg","A stack of scientific magazines. Called 'Acta Teratologica Germanica', they contain articles on the taxonomy, biology, physiology, and ecology of many creatures that are commonly thought to be mythological or nonexistent. The articles are written in German with French and Russian abstracts. The issues run from 1943 to 1955 and were published in Wolfenbuettel, Germany. (Love the wildlife photography, but boy did they get the jackalopes all wrong.)","21","12","26.93");
forsale[22]= new trinket("emergblood.jpg","A small glass ampule with gold caps at each end, affixed to a gold chain. The ampule appears to contain a small quantity of blood. One of the caps ends in a small circular knob, while the other has a tiny golden skull attached. (And I bet you were wondering why I would have a Vampire Hunter's Kit.)","22","1","328.09");
forsale[23]= new trinket("russiannecro.jpg","A superbly well-conserved vinyl record. Cyrillic characters on the label read, 'Play backwards at half speed.' (But if you play it backwards at double speed, the voices come out all funny and high-pitched.)","23","1","197.03");
forsale[24]= new trinket("froggrenades.jpg","A case of 24 frog grenades. Five seconds after pulling the pin, a grenade will disintegrate in a green flash, hurling frogs in all directions. (Let that be a lession kids, just because you're an evil mad scientist, doesn't necessarily mean you're cut out to conquer the world.)","24","3","39.15");
forsale[25]= new trinket("toiletseats.jpg","Several 15,000 toilet seats. (But good luck selling them.)","25","4","360.53");
forsale[26]= new trinket("cokescuba.jpg","A fluidic breathing system. The liquid is New Coke. (Remember what I said about mad scientists?)","26","1","152.39");
forsale[27]= new trinket("lois.jpg","The gospel according to Lois. It tells the story of a woman from the village of Nazareth during the early Roman Empire. She is a friend and rival of a local carpenter's son. (Saddly, it's not what you're thinking. Found out that one the hard way. PS this lois didn't recognize his alter ego either; coincidence?)","27","1","472.63");
forsale[28]= new trinket("stomach.jpg","A glass jar containing a clear fluid and what appears to be a stomach. The labels says 'Stomach of goat found in fishing net off coast of Alexandria.' (But the real excitement was what we pulled out of the stomach)","28","1","36.77");
forsale[29]= new trinket("likepotion.jpg","Several dozen vials of Like Potion. The drinker will want to enter a moderate, platonic friendship with the first person of the opposite sex seen. (Just the thing for breakups.)","29","42","13.83");
forsale[30]= new trinket("gobstopper.jpg","A folder of documents, which gives details on the history of the legendary Everlasting Gobstopper, which has been passed down through the years since at least 3000 B.C. (It was tasty, but you ever happen to come across it, be sure to rinse it off first.)","30","1","97.14");
forsale[31]= new trinket("vests.jpg","A dozen high-quality bulletproof vests. They have no manufacturer's info other than the all-seeing pyramid on a small tag.","31","12","26.46");
forsale[32]= new trinket("antiquarter.jpg","A quarter. A 1938, somewhat worn, U.S. quarter dollar. When you reach for it your hand is deflected, in the same way the like poles of two magnets repel each other. (And they said Merlin has no sense of humor.)","32","1","61.75");
forsale[33]= new trinket("birdstatues.jpg","A matched set of 12 large statue of a stylized bird of prey perching on a pedestal. The craftsmanship appears to be very fine, but the details are obscured by a thick coat of black paint. Based on the size and weight, believed to be made of lead or some similar heavy metal.","33","11","24.37");
forsale[34]= new trinket("donotdisturb.jpg","A simple 'Do Not Disturb' sign commonly found in hotel rooms. (Oh, you would not believe the story behind this one!)","34","1","466.04");
forsale[35]= new trinket("blank.jpg","An old and delicate scrap of parchment. Hand-lettered on the front is the phrase 'This page intentionally left blank.' The back says the same thing. (Oh, the irony. Heh, those old time monks; you'll never guess where we found this one)","35","1","108.11");
forsale[36]= new trinket("branch.jpg","A foot-long tree branch. It has no bark; the wood has a silky texture and a medium red color. It was cut off at an angle, presenting an interesting grain. The leaves are green and alive, and will stay that way indefinitely. (Best guess: the plant is somehow subsisting on moisture and nutrients from the air. All of the botanists, arborists, gardeners, and druids I've asked about this swear up and down that the species is not similar to anything known on Earth.)","36","1","45.77");
forsale[37]= new trinket("zennotebook.jpg","A spiral-bound manual entitled 'Advanced Meditational Techniques'. (Every page is blank. But the guru I bought it off of swore he could the secrets of the universe in it. Very Zen.)","37","1","358.33");
forsale[38]= new trinket("deskpmm.jpg","A desk-model Perpetual Motion Machine. (It makes a good paperweight and an interesting sputtering noise.)","38","1","63.22");

function buildGallery(page)
{
	var items_per_page = 9; // number of items to display on each page of the gallery

	total_pages = Math.ceil(forsale.length / items_per_page); // calculate length of gallery

	if (isNaN(page)) // if a page has not been defined
	{
		page = 1;
	}
	else
	{
		page = Math.round(page); // round to the nearist whole number
	} // end if (page)

	if (page < 1) // fix page location in the event you are out of bounds
	{
		page = 1;
	}
	else if (page > total_pages)
	{
		page = total_pages;
	} // end if (page)

	var start_index = items_per_page * (page - 1);	// starts at index 0
	var imageHTML;

	//Display the images for this page
	for (i = 0; i < items_per_page; i++)
	{
		image_index = start_index + i; // starts at index 0

		if (forsale[image_index] == TRUE) // if the image at index exists, use that
		{
			imageHTML = forsale[image_index];
		}
		else // else if the pic is not there, use a whitespace place-holder
		{
			imageHTML = '&nbsp;';
		}

		document.getElementById('t'+i).innerHTML = imageHTML;
	} // end for (items per page)

	//Display the links for changing the page
	if (page > 1) // if this is not the first page
	{
		prevHTML = '<a href="#" onclick="showImages('+(page-1)+')">Previous<\/a>'; // link to the previoius page
	}
	else // this is the first page
	{
		prevHTML = '&nbsp;'; // no previous page, so use a whitespace place-holder
	} // end if (not the first page)

	pageofHTML = 'Showing page '+page+' of ' + total_pages;

	if (page < total_pages) // if not at the last page in the gallery
	{
		nextHTML = '<a href="#" onclick="showImages('+(page+1)+')">Next<\/a>'; // link to next page
	}
	else // this is the last page
	{
		nextHTML = '&nbsp;'; // no next page, so use a whitespace place-holder
	} // end if (not the last page

	document.getElementById('prev').innerHTML = prevHTML;
	document.getElementById('pageof').innerHTML = pageofHTML;
	document.getElementById('next').innerHTML = nextHTML;

} // end function buildGallery()

//]]>