window.thumbnails = new Object();
												thumbnails[6525483] = new thumbnail(6525483,'','Front cover of \'A Visual Journal\'','front_cover_dalai_lama_book_thumb.jpg',130, 130,1,'#');
												thumbnails[1349537] = new thumbnail(1349537,'','Photo: Cally Stockdale','SimonStockdale_thumb.jpg',130, 87,1,'#');
												thumbnails[2613624] = new thumbnail(2613624,'','','Cally-3891_thumb.jpg',130, 173,1,'#');
												thumbnails[2613625] = new thumbnail(2613625,'','','Simon-2574_thumb.jpg',130, 173,1,'#');
												thumbnails[6531345] = new thumbnail(6531345,'','','front_cover-0001-4_thumb.jpg',130, 130,1,'#');
												thumbnails[6531346] = new thumbnail(6531346,'','','front_cover-0001-41_thumb.jpg',130, 130,1,'#');
												thumbnails[5251635] = new thumbnail(5251635,'295820','DL0561','DL0561_thumb.jpg',130, 87,1,'photo_5251635.html');
												thumbnails[5251636] = new thumbnail(5251636,'295820','DL0844','DL0844_thumb.jpg',130, 65,1,'photo_5251636.html');
												thumbnails[5251637] = new thumbnail(5251637,'295820','DL8994','DL8994_thumb.jpg',130, 195,1,'photo_5251637.html');
												thumbnails[5251638] = new thumbnail(5251638,'295820','DL9002','DL9002_thumb.jpg',130, 195,1,'photo_5251638.html');
												thumbnails[5251639] = new thumbnail(5251639,'295820','DL9103','DL9103_thumb.jpg',130, 87,1,'photo_5251639.html');
												thumbnails[1343805] = new thumbnail(1343805,'90341','White-capped Mollymawk','01Whitecappedalbatross_thumb.jpg',130, 87,1,'photo_1343805.html');
												thumbnails[1343806] = new thumbnail(1343806,'90341','Australasian Gannet','02Australasian-Gannet_thumb.jpg',130, 87,1,'photo_1343806.html');
												thumbnails[1343807] = new thumbnail(1343807,'90341','Masked Booby','03MaskedBooby_thumb.jpg',130, 87,1,'photo_1343807.html');
												thumbnails[1343808] = new thumbnail(1343808,'90341','Red-tailed Tropic Bird','04RedTailedTropicBird_thumb.jpg',130, 87,1,'photo_1343808.html');
												thumbnails[1343809] = new thumbnail(1343809,'90341','Blue Penguin','05BluePenguin_thumb.jpg',130, 87,1,'photo_1343809.html');
												thumbnails[1343840] = new thumbnail(1343840,'90341','Pied Shag','06PiedShag_thumb.jpg',130, 87,1,'photo_1343840.html');
												thumbnails[1343841] = new thumbnail(1343841,'90341','White-capped Noddy','07WhitecappedNoddy_thumb.jpg',130, 87,1,'photo_1343841.html');
												thumbnails[1343842] = new thumbnail(1343842,'90341','White-fronted Terns','08WhiteFrontedTerns_thumb.jpg',130, 87,1,'photo_1343842.html');
												thumbnails[1349533] = new thumbnail(1349533,'90674','Kullu Valley Man','08KulluValleyMan_thumb.jpg',130, 195,1,'photo_1349533.html');
												thumbnails[1343858] = new thumbnail(1343858,'90341','White Fronted Terns','09WhiteFrontedTerns_thumb.jpg',130, 87,1,'photo_1343858.html');
												thumbnails[1343843] = new thumbnail(1343843,'90341','White-faced Heron','10WhitefacedHeron_thumb.jpg',130, 87,1,'photo_1343843.html');
												thumbnails[1343844] = new thumbnail(1343844,'90341','Kaka','11Kaka_thumb.jpg',130, 87,1,'photo_1343844.html');
												thumbnails[1343845] = new thumbnail(1343845,'90341','Silvereye','12Silvereye_thumb.jpg',130, 87,1,'photo_1343845.html');
												thumbnails[1343855] = new thumbnail(1343855,'90341','Tui','13Tui_thumb.jpg',130, 87,1,'photo_1343855.html');
												thumbnails[1343846] = new thumbnail(1343846,'90341','Tui bath time','14Tuitailfeathers_thumb.jpg',130, 87,1,'photo_1343846.html');
												thumbnails[1343856] = new thumbnail(1343856,'90341','Pukeko and chick','15Pukekoandchick_thumb.jpg',130, 87,1,'photo_1343856.html');
												thumbnails[1343847] = new thumbnail(1343847,'90341','Fantail','16Fantail_thumb.jpg',130, 87,1,'photo_1343847.html');
												thumbnails[1343848] = new thumbnail(1343848,'90341','Kakapo','17Kakapo_thumb.jpg',130, 88,1,'photo_1343848.html');
												thumbnails[1343859] = new thumbnail(1343859,'90673','Admiralty Bay - Marlborough Sounds','01FrenchPass_thumb.jpg',130, 43,1,'photo_1343859.html');
												thumbnails[1343860] = new thumbnail(1343860,'90673','Trio Islands - Marlborough Sounds','02FrenchPass_thumb.jpg',130, 43,1,'photo_1343860.html');
												thumbnails[1343861] = new thumbnail(1343861,'90673','Rangitoto Island','03Rangitoto_thumb.jpg',130, 65,1,'photo_1343861.html');
												thumbnails[1343862] = new thumbnail(1343862,'90673','Cabbage Tree','04CabbageTree_thumb.jpg',130, 87,1,'photo_1343862.html');
												thumbnails[1343863] = new thumbnail(1343863,'90673','Long Bay','05LongBay_thumb.jpg',130, 87,1,'photo_1343863.html');
												thumbnails[1343864] = new thumbnail(1343864,'90673',' Anson Bay','06AnsonBay_thumb.jpg',130, 65,1,'photo_1343864.html');
												thumbnails[1343869] = new thumbnail(1343869,'90673','Masons Bay','07MasonsBay_thumb.jpg',130, 87,1,'photo_1343869.html');
												thumbnails[1343866] = new thumbnail(1343866,'90673','Pipalbot','08Pipalbot_thumb.jpg',130, 87,1,'photo_1343866.html');
												thumbnails[1343867] = new thumbnail(1343867,'90673',' Lake Louise','09LakeLouise_thumb.jpg',130, 87,1,'photo_1343867.html');
												thumbnails[1343868] = new thumbnail(1343868,'90673','Swayambunath','10Swayambunath_thumb.jpg',130, 35,1,'photo_1343868.html');
												thumbnails[1349388] = new thumbnail(1349388,'93204','Frozen Life','01FrozenLife1_thumb.jpg',130, 87,1,'photo_1349388.html');
												thumbnails[1349389] = new thumbnail(1349389,'93204','Red Manuka','02RedManuka_thumb.jpg',130, 87,1,'photo_1349389.html');
												thumbnails[1349390] = new thumbnail(1349390,'93204','Hypericum','03Hypericum_thumb.jpg',130, 87,1,'photo_1349390.html');
												thumbnails[1349391] = new thumbnail(1349391,'93204','Wetland Grasses','04WetlandGrasses_thumb.jpg',130, 87,1,'photo_1349391.html');
												thumbnails[1349392] = new thumbnail(1349392,'93204','Ferns','05Ferns_thumb.jpg',130, 87,1,'photo_1349392.html');
												thumbnails[1349393] = new thumbnail(1349393,'93204','New Fern Frond','06NewFernFrond_thumb.jpg',130, 195,1,'photo_1349393.html');
												thumbnails[1349394] = new thumbnail(1349394,'93204','Tree Fern Frond','07TreeFernFrond_thumb.jpg',130, 87,1,'photo_1349394.html');
												thumbnails[1349395] = new thumbnail(1349395,'93204',' Tree Fern Koru','08TreeFernKoru_thumb.jpg',130, 87,1,'photo_1349395.html');
												thumbnails[1275988] = new thumbnail(1275988,'90668','Kathesimbhu Stupa','DSC03556_edited-2_thumb.jpg',130, 87,1,'photo_1275988.html');
												thumbnails[1349555] = new thumbnail(1349555,'90668','Hindu Temple Pagoda','02HinduPagoda_thumb.jpg',130, 116,1,'photo_1349555.html');
												thumbnails[1349556] = new thumbnail(1349556,'90668','Kathmandu Street','03KathmanduStreet_thumb.jpg',130, 195,1,'photo_1349556.html');
												thumbnails[1349557] = new thumbnail(1349557,'90668','Kathesimbhu Monastery Door','04MonasteryDoor_thumb.jpg',130, 260,1,'photo_1349557.html');
												thumbnails[1349558] = new thumbnail(1349558,'90668','Kathesimbhu Prayer Wheel','05PrayerWheelDoor_thumb.jpg',130, 195,1,'photo_1349558.html');
												thumbnails[1349559] = new thumbnail(1349559,'90668','Cleaning Duties','06PrayerWheelMonk_thumb.jpg',130, 195,1,'photo_1349559.html');
												thumbnails[1349560] = new thumbnail(1349560,'90668','Cleaning Duties','07MonkCleaning_thumb.jpg',130, 87,1,'photo_1349560.html');
												thumbnails[1349561] = new thumbnail(1349561,'90668','Kathesimbhu Door Detail','08DoorBrass_thumb.jpg',130, 63,1,'photo_1349561.html');
												thumbnails[1349562] = new thumbnail(1349562,'90668','Bath time for Vishnu','09BathtimeforVishnu_thumb.jpg',130, 87,1,'photo_1349562.html');
												thumbnails[1349563] = new thumbnail(1349563,'90668','Dashinkali Offerings','10Dashin_thumb.jpg',130, 195,1,'photo_1349563.html');
												thumbnails[1349564] = new thumbnail(1349564,'90668','Dashinkali Offerings','11Dashin_thumb.jpg',130, 195,1,'photo_1349564.html');
												thumbnails[1349565] = new thumbnail(1349565,'90668','Dashinkali Queue for Sacrifice','12Dashin_thumb.jpg',130, 55,1,'photo_1349565.html');
												thumbnails[1349566] = new thumbnail(1349566,'90668','Bloody Exit','13DashinBlood_thumb.jpg',130, 87,1,'photo_1349566.html');
												thumbnails[1349567] = new thumbnail(1349567,'90668','Upanishads','14DashinBook_thumb.jpg',130, 87,1,'photo_1349567.html');
												thumbnails[1349568] = new thumbnail(1349568,'90668','Blessing','15DashinOffering_thumb.jpg',130, 195,1,'photo_1349568.html');
												thumbnails[1349569] = new thumbnail(1349569,'90668','Tika Mark','16DashinTika_thumb.jpg',130, 195,1,'photo_1349569.html');
												thumbnails[1349570] = new thumbnail(1349570,'90668','Sacred Cow','17SacredCow_thumb.jpg',130, 114,1,'photo_1349570.html');
												thumbnails[1349571] = new thumbnail(1349571,'90668','Sunken Carving','18SunkenCarving_thumb.jpg',130, 65,1,'photo_1349571.html');
												thumbnails[1349572] = new thumbnail(1349572,'90668','Swayambunath Temple','19Swayambunath_thumb.jpg',130, 35,1,'photo_1349572.html');
												thumbnails[1349542] = new thumbnail(1349542,'90674','Sabah Mother & Child','01SabahMother&Child1_thumb.jpg',130, 87,1,'photo_1349542.html');
												thumbnails[1349543] = new thumbnail(1349543,'90674','Hmong Woman','02HmongWoman_thumb.jpg',130, 195,1,'photo_1349543.html');
												thumbnails[1349521] = new thumbnail(1349521,'90674','Hmong Girl','03HmongGirl_thumb.jpg',130, 156,1,'photo_1349521.html');
												thumbnails[1349522] = new thumbnail(1349522,'90674','Red Dzao Women','04RedDzoaWomen_thumb.jpg',130, 188,1,'photo_1349522.html');
												thumbnails[1349523] = new thumbnail(1349523,'90674','Sapa School Boy','05SapaSchoolBoy_thumb.jpg',130, 160,1,'photo_1349523.html');
												thumbnails[1349524] = new thumbnail(1349524,'90674','Thai Dancers','06ThaiDancers_thumb.jpg',130, 87,1,'photo_1349524.html');
												thumbnails[1349525] = new thumbnail(1349525,'90674','Beggar Girl - Kalka, India','07BeggarGirl_thumb.jpg',130, 163,1,'photo_1349525.html');
												thumbnails[1349526] = new thumbnail(1349526,'90674','Buddhist Monk','09BuddhistMonk_thumb.jpg',130, 173,1,'photo_1349526.html');
												thumbnails[1349527] = new thumbnail(1349527,'90674',' Annapurna Girl','10AnnapurnaGirl_thumb.jpg',130, 98,1,'photo_1349527.html');
												thumbnails[1349528] = new thumbnail(1349528,'90674','Kathmandu Orphan','11KathmanduOrphan_thumb.jpg',130, 87,1,'photo_1349528.html');
												thumbnails[1349529] = new thumbnail(1349529,'90674','Three Saddhus - Pashupatinath, Nepal','12ThreeSaddhus_thumb.jpg',130, 65,1,'photo_1349529.html');
												thumbnails[1349530] = new thumbnail(1349530,'90674','Saddhu - Pashupatinath, Nepal','13Saddhu_thumb.jpg',130, 195,1,'photo_1349530.html');
												thumbnails[1349531] = new thumbnail(1349531,'90674','Saddhu - Pashupatinath, Nepal','14Saddhu_thumb.jpg',130, 195,1,'photo_1349531.html');
												thumbnails[1349532] = new thumbnail(1349532,'90674','Saddhu - Pashupatinath, Nepal','15Saddhu_thumb.jpg',130, 195,1,'photo_1349532.html');
												thumbnails[1349534] = new thumbnail(1349534,'90674','Saddhu - Dashinkali, Nepal','16Saddhu_thumb.jpg',130, 195,1,'photo_1349534.html');
												thumbnails[1352779] = new thumbnail(1352779,'90675','Blue-eared Kingfisher - Borneo','01Kingfisher_thumb.jpg',130, 87,1,'photo_1352779.html');
												thumbnails[1352780] = new thumbnail(1352780,'90675','Tree Frog - Borneo','02Frog_thumb.jpg',130, 87,1,'photo_1352780.html');
												thumbnails[1352781] = new thumbnail(1352781,'90675','Snake - Borneo','03Snake_thumb.jpg',130, 87,1,'photo_1352781.html');
												thumbnails[1352782] = new thumbnail(1352782,'90675','Thai Dancers - Bangkok','04ThaiDancers_thumb.jpg',130, 87,1,'photo_1352782.html');
												thumbnails[1352783] = new thumbnail(1352783,'90675','Marble Inlay - Delhi','05MarbleInlay_thumb.jpg',130, 130,1,'photo_1352783.html');
												thumbnails[1352784] = new thumbnail(1352784,'90675','Humayun\'s Tomb Garden - Delhi','06HumayunGarden_thumb.jpg',130, 87,1,'photo_1352784.html');
												thumbnails[1352785] = new thumbnail(1352785,'90675','Hand of Devotion - Manali, India','07HandofDevotion_thumb.jpg',130, 173,1,'photo_1352785.html');
												thumbnails[1352786] = new thumbnail(1352786,'90675','Festival Offerings - Kathmandu','08KathmanduOfferings_thumb.jpg',130, 195,1,'photo_1352786.html');
												thumbnails[1352787] = new thumbnail(1352787,'90675','Butter Lamps - Kathmandu','09ButterLamps_thumb.jpg',130, 87,1,'photo_1352787.html');
												thumbnails[1352788] = new thumbnail(1352788,'90675','Cutting the Mustard - Nepal','10CuttingtheMustard_thumb.jpg',130, 87,1,'photo_1352788.html');
												thumbnails[1352789] = new thumbnail(1352789,'90675','Chitwan Lizard - Nepal','11ChitwanLizard_thumb.jpg',130, 195,1,'photo_1352789.html');
												thumbnails[1352790] = new thumbnail(1352790,'90675','Blue Mosque - Istanbul','12BlueMosque_thumb.jpg',130, 87,1,'photo_1352790.html');
												thumbnails[1352791] = new thumbnail(1352791,'90675','Blue Mosque - Istanbul','13BlueMosque_thumb.jpg',130, 195,1,'photo_1352791.html');
												thumbnails[1352792] = new thumbnail(1352792,'90675','Sufi Dervishes - Ephesus, Turkey','15Dervishes_thumb.jpg',130, 87,1,'photo_1352792.html');
												thumbnails[1352793] = new thumbnail(1352793,'90675','Roman Cistern - Istanbul','16Cistern_thumb.jpg',130, 87,1,'photo_1352793.html');
												thumbnails[1352794] = new thumbnail(1352794,'90675','Catherdral Ceiling Detail - Pisa','17PisaCatherdral_thumb.jpg',130, 130,1,'photo_1352794.html');
												thumbnails[1352795] = new thumbnail(1352795,'90675','Church Door - Garfagnana, Italy','18BargaChurchDoor_thumb.jpg',130, 87,1,'photo_1352795.html');
												thumbnails[1352796] = new thumbnail(1352796,'90675','Palazzo Borromeo - Lake Maggiore, Italy','19PalazzoBorromeo_thumb.jpg',130, 87,1,'photo_1352796.html');
												thumbnails[1352797] = new thumbnail(1352797,'90675','Fountain - Place de la Concorde, Paris','20ParisFountain_thumb.jpg',130, 87,1,'photo_1352797.html');
												thumbnails[1352798] = new thumbnail(1352798,'90675','Maid of the Mist - Niagara Falls','21MaidoftheMist_thumb.jpg',130, 87,1,'photo_1352798.html');
												thumbnails[1352799] = new thumbnail(1352799,'90675','Lake Louise, Alberta','22LakeLouise_thumb.jpg',130, 87,1,'photo_1352799.html');
												thumbnails[1352800] = new thumbnail(1352800,'90675','Bow Lake, Bannf National Park, Alberta','23Lake_thumb.jpg',130, 87,1,'photo_1352800.html');
												thumbnails[1352801] = new thumbnail(1352801,'90675','Aspens - British Columbia','24Aspens_thumb.jpg',130, 195,1,'photo_1352801.html');

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  					galleries[295820] = new gallery(295820,'5251639','Dalai Lama Visit to NZ - Dec 2009','gallery',[5251635,5251636,5251637,5251638,5251639],0, 0, '', 'gallery_295820.html',0,0);
				  					galleries[90341] = new gallery(90341,'1343806','Birds','gallery',[1343805,1343806,1343807,1343808,1343809,1343840,1343841,1343842,1343858,1343843,1343844,1343845,1343855,1343846,1343856,1343847,1343848],0, 0, '', 'gallery_90341.html',0,0);
				  					galleries[90673] = new gallery(90673,'1343862','Landscape','gallery',[1343859,1343860,1343861,1343862,1343863,1343864,1343869,1343866,1343867,1343868],0, 0, '', 'gallery_90673.html',0,0);
				  					galleries[93204] = new gallery(93204,'1349388','Plants','gallery',[1349388,1349389,1349390,1349391,1349392,1349393,1349394,1349395],0, 0, '', 'gallery_93204.html',0,0);
				  					galleries[90668] = new gallery(90668,'1275988','Kathmandu','gallery',[1275988,1349555,1349556,1349557,1349558,1349559,1349560,1349561,1349562,1349563,1349564,1349565,1349566,1349567,1349568,1349569,1349570,1349571,1349572],0, 0, '', 'gallery_90668.html',0,0);
				  					galleries[90674] = new gallery(90674,'1349542','Faces of Asia','gallery',[1349533,1349542,1349543,1349521,1349522,1349523,1349524,1349525,1349526,1349527,1349528,1349529,1349530,1349531,1349532,1349534],0, 0, '', 'gallery_90674.html',0,0);
				  					galleries[90675] = new gallery(90675,'1352793','Around the World','gallery',[1352779,1352780,1352781,1352782,1352783,1352784,1352785,1352786,1352787,1352788,1352789,1352790,1352791,1352792,1352793,1352794,1352795,1352796,1352797,1352798,1352799,1352800,1352801],0, 0, '', 'gallery_90675.html',0,0);
/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = new Object();
imageSets[1] = '1352788,1352782,1349557,1349534,1349522,1349388,1343860,1343859,1343848,1343846,1343842,1343805';
imageSets[2] = '5251639,1352793,1349542,1349388,1343862,1343806,1275988';
imageSets[3] = '5251639';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/simon_stockdale/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/simon_stockdale/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/simon_stockdale/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/simon_stockdale/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/simon_stockdale/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/simon_stockdale/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/simon_stockdale/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/simon_stockdale/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/simon_stockdale/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/simon_stockdale/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/simon_stockdale/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/simon_stockdale/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/simon_stockdale/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/simon_stockdale/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/simon_stockdale/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://admin2.clikpic.com/simon_stockdale/images';
		break;
	}
		switch (server_id) {
		case 33:
		val = 'http://www8.clikpic.com/simon_stockdale/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/simon_stockdale/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/simon_stockdale/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/simon_stockdale/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/simon_stockdale/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/simon_stockdale/images';
		break;
	}
		return val;
}

/***************************************************************************
* img = reference to image object in which to show image                   *
***************************************************************************/
function showHomeImage(img) {

	imageID = randomListVal('');
		if (!basic) {
	img.src = photos[imageID].src;
	img.width = photos[imageID].width;
	img.height = photos[imageID].height;
  img.parentNode.title = img.alt = photos[imageID].caption;
	}
	else {
		newImage = new Image(photos[imageID].width,photos[imageID].height);
		newImage.src = photos[imageID].src;
		document.images[img.name] = newImage;
				
	}
			}

function getHomeImageLink(imageID) {
  	var href='', photo = backgrounds && backgrounds[imageID];
	if(photo){
		if (photo && photo.galleries_id != '') {
  			href = photo.fnGalleryLink();
  		}
  		  		else {
  				href += 'gallery.html';
  	  		}
	}
    return href;
}
/***************************************************************************
* Show a random image on home page from featured images                    *
***************************************************************************/
function showHomeImageInline(el, image_sets_id, href) {
	
  var css = {}, imageID,
	    imageSetsId = 1;
	if(image_sets_id){
		imageSetsId = image_sets_id;
	}
	imageID = randomListVal(imageSets[imageSetsId]);
		if (href == null && 'gallery' != '') {
					href = getHomeImageLink(imageID);
	}
    
  updateImage({nextPhoto: backgrounds[imageID], img:el.find('img')[0],
                $photo:el, $title:$('#homeimageTitleContainer'), $detail:$('#homeimageDetailsContainer'),                speed:0, href:href, css:css, onAfter: function(){                  this.closest('.contentsection').doManualAlign({				    inner: 'img',				    crop: 'a'				  });                }              });
}

/***************************************************************************
* Set 'img' to be a new image given its photo() object                     *
***************************************************************************/
function updateImage (options) {
  var defaults = {nextPhoto:'',field:'',img:'',$photo:'',$title:'',$detail:'',
                    updateDocumentTitle:false,speed:0,href:false,css:false,updateHash:false,onAfter:null,onBefore:null},
      op = $.extend({},defaults,options),
      html = '', temp = '',
      photoId = op.nextPhoto.id,
      photoCaption = op.nextPhoto.caption,
      photoSrc = op.nextPhoto.src;
		
		if (!basic) {
    if (op.updateHash && clik.getIDInUrl(location.href,'photo') != op.nextPhoto.id) {
		clik.changeHash('photos_id=' + op.nextPhoto.id, true);
    }
				
    if (op.$photo.length > 0) {
      html = $('<img/>',{
        'class': 'mainphoto photo',
        src: photoSrc,
        id: 'mainPic',
        name: 'mainPic',
        width: op.nextPhoto.width,
        height: op.nextPhoto.height,
        alt: photoCaption,
        css: op.css || {}
      });
      if (op.href) {
      	if (op.href.match(/<a/)) {
      	  html = $(op.href).append(html);
      	} else {
		  html = $('<a/>', {
			href: op.href,
			title: photoCaption
		  }).append(html);
	    }
      } else {
      	html = $('<a/>', {
			title: photoCaption
		  }).append(html);
      }
      if (op.speed == 0) {        op.$photo.html(html);        if (op.onBefore) {          op.onBefore.apply(op.$photo);        }        if (op.onAfter) {          op.onAfter.apply(op.$photo);        }      } else {        op.$photo.stop(true,true).fadeReplaceWith(html,op.speed,'',function(){            if (op.onAfter) {		    op.onAfter.apply(this);          }		  clik.doColumnResize(false, $(this).add(op.$detail).add(op.$title));		  $('body').trigger('clikUpdate');		}, op.onBefore);
      }    }
    	if (op.field) {
		op.field.value = photoId;
	} else {
		op.$photo.data('image_id', photoId);
    }
	    if (op.$title.length > 0) {
  		op.$title.fadeGalleryDetails(photoCaption, op.speed);
    }
        if (op.updateDocumentTitle) {
						  document.title = 'Spirit & Nature Images: ' + photoCaption;
			    }
        if (op.$detail.length > 0) {
      temp = op.nextPhoto.fnGetImageDetails();
	    op.$detail.fadeGalleryDetails(temp, op.speed, function(){
	    var options = {};	    	      	      resizePhotoInfo(options);
        if (typeof(backgrounds) != 'undefined' && op.nextPhoto == backgrounds[op.nextPhoto.id]) {
  	      toggleAddToCartConfirm(backgrounds);
  	    } else if (typeof(photos) != 'undefined' && op.nextPhoto == photos[op.nextPhoto.id]) {
  	      toggleAddToCartConfirm(photos);
  	    }
	    });
    }
        if (!op.speed) {      clik.doColumnResize(false, op.$photo.add(op.$detail).add(op.$title));      $('body').trigger('clikUpdate');    }        
    return html;			}
	else {
				
		window.location = 'photo_' + nextPhoto.id + '.html';
	}
		
}

/***************************************************************************
* Toggle add to cart confirmation element and set up the click event for   *
* the 'Add to cart' button.                                                *
***************************************************************************/
function toggleAddToCartConfirm(array){
  if (typeof(array) !== 'object') {
    array = photos;
  }
	if($('#paymentConfirm').length > 0){
		$('#paymentConfirm').hide();
		$('#paymentAddButton')
		.unbind()
		.click(function(){
						form = document.getElementById('paymentForm');
			option_id = 0;
			if(form.item_option.value){
				option_id = form.item_option.value;
			}
			if(addItemToBasket(form.item_number.value,array,form.site.value,parseInt(form.quantity.value, 10),option_id)){
				if($.browser.msie){$('#paymentConfirm').text('Item added to cart').show();}
				else{
					$('#paymentConfirm').text('Item added to cart').fadeIn();
					dspOrderDetails(form.site.value);
				}
			}
			else{
				$('#paymentConfirm').text('Item not added - check cookies are enabled in your browser.').fadeIn();
			}
		});
	}
}
/***************************************************************************
* Get payment info for image - add as 'method' to photo object             *
***************************************************************************/
photo.prototype.fnGetImageDetails = function(){
	var temp = '';
	if (this.description != '') {
		temp = temp +  '<p id="imageDescription">' + this.description + '</p>';
	}
		if (this.photo_ref != '') {
		temp = temp + '<p class="imageinfo" id="imageRef"><strong>Ref: </strong>' + this.photo_ref + '</p>';
	}
		if (this.takendate != '') {
				
		temp = temp + '<p class="imageinfo" id="imageDate"><strong>Date: </strong>' + this.takendate + '</p>';
	}
	
	if (this.location != '') {
				
		temp = temp + '<p class="imageinfo" id="imageLocation"><strong>Location: </strong>' +  this.location + '</p>';
	}
	
	if (this.photographer != '') {
				
		temp = temp + '<p class="imageinfo" id="imagePhotographer"><strong>Photographer: </strong>' + this.photographer + '</p>';
	}
					
				if (temp != '') {
		temp = temp + '<div class="spacer"></div>';
	}
	return temp;
};

/***************************************************************************
* Get payment info for image - add as 'method' to photo object             *
***************************************************************************/
photo.prototype.fnGetPaymentInfo = function(){
	var temp = '';
	if (this.item_price !== '') {
				temp = temp + '<p>Order this print:</p>';
				temp = temp + '<p class="imageinfo" id="imagePrice"><strong>' + this.purchase_instruction + '</strong> ' + (this.item_price).toFixed(2) + '</p>';
		var item_name  = this.purchase_instruction;
		var amount = (this.item_price).toFixed(2);
		var item_option  = 0;
	}
	else if (this.payment_groups_id !== '') {
		temp = temp + '<p>Buy this print online:</p>';
				temp = temp + '<form id="paymentOptions" style="margin:0px;border:0px;" name="paymentOptions">';
											temp = temp + '<select class="paymentlink" name="payment_options_id" onchange="updateItemValues(document.forms.paymentForm,this.form.payment_options_id.options[this.form.payment_options_id.options.selectedIndex].value);">';
				
		temp = temp + getPaymentOptions(this.payment_groups_id);
		temp = temp + '</select>';
		temp = temp + '</form>';
				var item_option  = paymentGroups[this.payment_groups_id].options[0];
		if(paymentOptions[item_option]){
			var item_name  = paymentOptions[item_option].payment_option;
			var amount =  paymentOptions[item_option].price;
		}
			}
	else {
				
	}
	if (this.item_price !== '' || this.payment_groups_id !== '') {
			temp = temp + '<div class="clearing">&nbsp;</div>';
	}
	return temp;};

/***************************************************************************
* Pick a photo at random from the featured images of a gallery.            *
* Gallery_id = id of gallery to choose,                                    *
* img = reference to html image in                                         *
* which to show image                                                      *
***************************************************************************/
function showGalleryImage(gallery_id, img, updateLink) {
		
	if(img){
	      if (location.hash.match('galleries_id=' + gallery_id) && (imageID = location.hash.match('.*photos_id=(.+)$'))) {
        imageID = imageID[1];
      } else {
			  imageID = randomListVal(galleries[gallery_id].featured_images);
      }
							
			if (imageID != 0) {
				img.src = thumbnails[imageID].src;
				img.width = thumbnails[imageID].width;
				img.height = thumbnails[imageID].height;
				img.alt = galleries[gallery_id].title;
        if (updateLink) {
          $(img).parent().attr({            href: thumbnails[imageID].fnGalleryLink(gallery_id),            title: galleries[gallery_id].title          });
        }
							}
										}
}

/***************************************************************************
* If we have dynamic HTML, replace the galleries link with a list that     *
* doesn't include thecurrent gallery                                       *
***************************************************************************/
function showGalleries(gallery_id) {
		
	
	if (!basic) {
		temp = '';
		for (i = 0; i < galleries.length; i++) {
						
			
			if (galleries[i].id != gallery_id) {
								
				if (temp != '') {
					temp = temp + ' | ';
				}
				temp = temp + '<a href="' + galleries[i].section_code + '_' + galleries[i].id + '.html">' + galleries[i].title + '</a>';
			}
		}
		document.all.galleryLinks.innerHTML = 'Other galleries: ' + temp;
	}
}

			

