window.thumbnails = new Object();
												thumbnails[137904] = new thumbnail(137904,'12682','Alison','Alison 0011_thumb.jpg',130, 190,1,'photo_137904.html');
												thumbnails[137907] = new thumbnail(137907,'12682','Debbie','Debbie 0011_thumb.jpg',130, 195,1,'photo_137907.html');
												thumbnails[173205] = new thumbnail(173205,'12682','Laura','Laura 001_thumb.jpg',130, 195,1,'photo_173205.html');
												thumbnails[173206] = new thumbnail(173206,'12682','Kirsten','Kirsten 001_thumb.jpg',130, 195,1,'photo_173206.html');
												thumbnails[173277] = new thumbnail(173277,'12682','Margaret','Margaret 001_thumb.jpg',130, 195,1,'photo_173277.html');
												thumbnails[182931] = new thumbnail(182931,'15059','','Jonathans Wedding _me_0401_thumb.jpg',130, 168,1,'photo_182931.html');
												thumbnails[191077] = new thumbnail(191077,'12682','Helen','Helen 001_thumb.jpg',130, 191,1,'photo_191077.html');
												thumbnails[191091] = new thumbnail(191091,'12682','Helen','Helen 002_thumb.jpg',130, 188,1,'photo_191091.html');
												thumbnails[196076] = new thumbnail(196076,'12682','Maureen','Maureen 001 (1)_thumb.jpg',130, 188,1,'photo_196076.html');
												thumbnails[199264] = new thumbnail(199264,'12682','Debbie','debbie_thumb.jpg',130, 193,1,'photo_199264.html');
												thumbnails[234751] = new thumbnail(234751,'21142','Ullapool Harbour','Ullapool Harbour_thumb.jpg',130, 88,1,'photo_234751.html');
												thumbnails[236113] = new thumbnail(236113,'21142','Gruinard Bay 1','Gruinard Bay 001 copy_thumb.jpg',120, 74,1,'photo_236113.html');
												thumbnails[246084] = new thumbnail(246084,'12464','Pandora\'s Box','Pandoras-Box_thumb.jpg',120, 91,1,'photo_246084.html');
												thumbnails[268809] = new thumbnail(268809,'12686','Bubbling Mud, Krafla','Bubbling-Mud-Krafla_thumb.jpg',120, 81,1,'photo_268809.html');
												thumbnails[803967] = new thumbnail(803967,'23814','Bow River, Banff, Alberta','Bow-River,-Banff-005_thumb.jpg',120, 80,1,'photo_803967.html');
												thumbnails[804468] = new thumbnail(804468,'23814','Chipmunk, Lake Louise, Alberta','Chipmunk,-Lake-Louise-002_thumb.jpg',120, 80,1,'photo_804468.html');
												thumbnails[804555] = new thumbnail(804555,'23814','Maligne Lake, nr. Banff Alberta','Maligne-Lake-007_thumb.jpg',120, 80,1,'photo_804555.html');
												thumbnails[804608] = new thumbnail(804608,'23814','Evening Fisherman, B.C.','Evening Fisherman 001_resize_thumb.jpg',120, 78,1,'photo_804608.html');
												thumbnails[805592] = new thumbnail(805592,'23814','Vineyard, Okanagan, B.C.','Okanagan 008_resize_thumb.jpg',120, 79,1,'photo_805592.html');
												thumbnails[810843] = new thumbnail(810843,'23814','Butchart Gardens, Victoria','Butchart Gdns 002_resize_thumb.jpg',120, 85,1,'photo_810843.html');
												thumbnails[810849] = new thumbnail(810849,'23814','Victoria Harbour, BC','Victoria 012_resize_thumb.jpg',120, 79,1,'photo_810849.html');
												thumbnails[2066217] = new thumbnail(2066217,'12464','Book of Castles','Book of Castles_thumb.jpg',120, 80,1,'photo_2066217.html');
												thumbnails[2066219] = new thumbnail(2066219,'12464','Global Warning !','GlobalWarning_thumb.jpg',120, 80,1,'photo_2066219.html');
												thumbnails[2066221] = new thumbnail(2066221,'12464','Snow Snapper','SnowSnapper_thumb.jpg',120, 82,1,'photo_2066221.html');
												thumbnails[3928637] = new thumbnail(3928637,'238294','Early Morning, Alcatraz','Early_Morning_Alcatraz_21_thumb.jpg',120, 80,1,'photo_3928637.html');
												thumbnails[3930722] = new thumbnail(3930722,'238294','City Halls, San Francisco','City_Hall_San_Franjpg_thumb.jpg',85, 120,1,'photo_3930722.html');
												thumbnails[5950289] = new thumbnail(5950289,'12696','White Pass Summit','White_Pass_Summit_frame_thumb.jpg',120, 81,1,'photo_5950289.html');
												thumbnails[3971010] = new thumbnail(3971010,'12696','After the Storm, Denali Nat Park','After_the_Storm_Denali_thumb.jpg',120, 87,1,'photo_3971010.html');
												thumbnails[154169] = new thumbnail(154169,'15059','Portstewart','portstewart1_thumb.jpg',130, 85,1,'photo_154169.html');
												thumbnails[238136] = new thumbnail(238136,'12696','Beluga Point, Anchorage','Beluga-Point-001_thumb.jpg',120, 81,1,'photo_238136.html');
												thumbnails[245912] = new thumbnail(245912,'12464','Morning, Eilean Donan Castle','morning__eilean_donan4_thumb.jpg',120, 60,1,'photo_245912.html');
												thumbnails[137914] = new thumbnail(137914,'12682','Gina','Gina 0011_thumb.jpg',130, 199,1,'photo_137914.html');
												thumbnails[237825] = new thumbnail(237825,'12696','Caribou, Denali','Caribou Portage Wildlife Centre 009_2_thumb.jpg',120, 88,1,'photo_237825.html');
												thumbnails[238666] = new thumbnail(238666,'21563','Chenonceau Chateau','Chenonceau-Chateau-001_thumb.jpg',120, 76,1,'photo_238666.html');
												thumbnails[242406] = new thumbnail(242406,'13056','Shop Fronts, Dawson City','Dawson-City-017_2_thumb.jpg',120, 81,1,'photo_242406.html');
												thumbnails[245916] = new thumbnail(245916,'12464','Motion Pictures ','motion_pictures1_thumb.jpg',120, 86,1,'photo_245916.html');
												thumbnails[252290] = new thumbnail(252290,'12686','Krafla Power Station','Krafla-Power-Station-003_thumb.jpg',120, 81,1,'photo_252290.html');
												thumbnails[267843] = new thumbnail(267843,'23814','Downtown Vancouver 1','Downtown-Vancouver-001_thumb.jpg',81, 120,1,'photo_267843.html');
												thumbnails[7633813] = new thumbnail(7633813,'394896','Alpine Trumpeter','Alpine_Trumpeter_thumb.jpg',80, 120,1,'photo_7633813.html');
												thumbnails[3924852] = new thumbnail(3924852,'12696','Creek St, Ketchikan, Alaska','Creek_St_Ketchikan__frame_012_thumb.jpg',120, 82,1,'photo_3924852.html');
												thumbnails[7633903] = new thumbnail(7633903,'394896','Blessing the Bicycles, Salzburg','Blessing_the_Bicycles_thumb.jpg',84, 120,1,'photo_7633903.html');
												thumbnails[137206] = new thumbnail(137206,'12464','Meeting Point','meeting_point_thumb.jpg',130, 89,1,'photo_137206.html');
												thumbnails[137916] = new thumbnail(137916,'12682','Jane','Jane 001_thumb.jpg',130, 195,1,'photo_137916.html');
												thumbnails[238141] = new thumbnail(238141,'12696','Denali Nat Park 1','Denali Nat Park 213 _thumb.jpg',120, 81,1,'photo_238141.html');
												thumbnails[239151] = new thumbnail(239151,'13056','Dawson Shopfront, Yukon','Dawson-City-020_thumb.jpg',120, 81,1,'photo_239151.html');
												thumbnails[246064] = new thumbnail(246064,'21563','Annecy Architecture','Annecy-001_thumb.jpg',120, 81,1,'photo_246064.html');
												thumbnails[252292] = new thumbnail(252292,'12686','Krafla Power Station','Krafla-Power-Station-004_thumb.jpg',120, 81,1,'photo_252292.html');
												thumbnails[267847] = new thumbnail(267847,'23814','Downtown Vancouver 3','Downtown-Vancouver-003_thumb.jpg',81, 120,1,'photo_267847.html');
												thumbnails[238504] = new thumbnail(238504,'12696','Denali Nat Park 2','Denali-Nat-Park-001-copy_thumb.jpg',120, 81,1,'photo_238504.html');
												thumbnails[239148] = new thumbnail(239148,'13056','St Andrew\'s Church, Dawson City, Yukon','Dawson-City-007_thumb.jpg',120, 81,1,'photo_239148.html');
												thumbnails[242808] = new thumbnail(242808,'12696','Evening, Denali Nat Park','Evening,-Denali-Nat-Park-00_thumb.jpg',120, 81,1,'photo_242808.html');
												thumbnails[254447] = new thumbnail(254447,'12686','Jokulsarlon Glacial Lake 1','Jokulsarlon-007_thumb.jpg',120, 80,1,'photo_254447.html');
												thumbnails[256470] = new thumbnail(256470,'21563','Annecy 2','Annecy-002_thumb.jpg',78, 120,1,'photo_256470.html');
												thumbnails[267845] = new thumbnail(267845,'23814','Downtown Vancouver 2','Downtown-Vancouver-002_thumb.jpg',81, 120,1,'photo_267845.html');
												thumbnails[3971020] = new thumbnail(3971020,'12696','Harbour, Sitka, Alaska','Sitka_Alaska_014_copyjpg_thumb.jpg',120, 86,1,'photo_3971020.html');
												thumbnails[3949856] = new thumbnail(3949856,'12696','Hubbard Glacier','Hubbard_Glacier_031_copy_2_thumb.jpg',120, 81,1,'photo_3949856.html');
												thumbnails[3971011] = new thumbnail(3971011,'12696','Juneau From Mt Roberts','Juneau_Mt_Roberts_007_copy_2_thumb.jpg',120, 81,1,'photo_3971011.html');
												thumbnails[3971016] = new thumbnail(3971016,'12696','Mendenhall Glacier, Juneau','Mendenhall_Glacier_Juneau_003_thumb.jpg',120, 79,1,'photo_3971016.html');
												thumbnails[242814] = new thumbnail(242814,'12696','Morning Berth, Skagway','Morning-Berth,-Skagway_thumb.jpg',120, 83,1,'photo_242814.html');
												thumbnails[267854] = new thumbnail(267854,'23814','Stanley Park, Vancouver','Stanley-Park,-Vancouver_thumb.jpg',120, 81,1,'photo_267854.html');
												thumbnails[137209] = new thumbnail(137209,'12464','Midnight at Vimy Ridge','midnight_at_vimy_ridge_thumb.jpg',130, 94,1,'photo_137209.html');
												thumbnails[240329] = new thumbnail(240329,'13056','Sternwheeler Keno, Dawson city','Keno_Dawson-City-025_2-copy_thumb.jpg',120, 81,1,'photo_240329.html');
												thumbnails[254455] = new thumbnail(254455,'12686','Jokulsarlon glacial Lake 2','Jokulsarlon-002_thumb.jpg',120, 81,1,'photo_254455.html');
												thumbnails[267717] = new thumbnail(267717,'23814','Parliament Buildings, Victoria, BC','Victoria-BC-007_thumb.jpg',120, 78,1,'photo_267717.html');
												thumbnails[267954] = new thumbnail(267954,'12696','Portage Glacier 1, Anchorage','Portage-Glacier-001_thumb.jpg',120, 81,1,'photo_267954.html');
												thumbnails[267956] = new thumbnail(267956,'12696','Portage Glacier 2, Anchorage','Portage-Glacier-002_thumb.jpg',120, 81,1,'photo_267956.html');
												thumbnails[240402] = new thumbnail(240402,'13056','Miles Canyon, Yukon River','Miles-Canyon-002_thumb.jpg',120, 81,1,'photo_240402.html');
												thumbnails[254628] = new thumbnail(254628,'12686','Jokulsarlon Glacial Lake 3','Jokulsarlon-018_thumb.jpg',120, 81,1,'photo_254628.html');
												thumbnails[268653] = new thumbnail(268653,'12696','Prince William Sound','Prince-William-Sound-001_thumb.jpg',120, 78,1,'photo_268653.html');
												thumbnails[3949879] = new thumbnail(3949879,'12696','Stern wheeler on the River Chena, Fairbanks','Stern_Wheeler_on_the_Chena_River1_thumb.jpg',120, 82,1,'photo_3949879.html');
												thumbnails[242413] = new thumbnail(242413,'13056','Miles Canyon, Yukon River','Miles-Canyon-014_thumb.jpg',120, 81,1,'photo_242413.html');
												thumbnails[254654] = new thumbnail(254654,'12686','Jokulsarlon Glacial Lake 4','Jokulsarlon-009_thumb.jpg',120, 81,1,'photo_254654.html');
												thumbnails[3924933] = new thumbnail(3924933,'12696','WPYR through the White Pass, Skagway','WPYR_Skagway-3_copy_thumb.jpg',120, 81,1,'photo_3924933.html');
												thumbnails[237823] = new thumbnail(237823,'12696','Young Caribou, Denali','Young Caribou Portage Wildlife Centre 009_thumb.jpg',120, 88,1,'photo_237823.html');
												thumbnails[137204] = new thumbnail(137204,'12464','Arran Boats','arran_shore3_thumb.jpg',130, 97,1,'photo_137204.html');
												thumbnails[240387] = new thumbnail(240387,'13056','Dempster Highway, nr Dawson City','Dempster-Highway-013_thumb.jpg',120, 84,1,'photo_240387.html');
												thumbnails[254660] = new thumbnail(254660,'12686','Godafoss 1','Godafoss-002_thumb.jpg',120, 67,1,'photo_254660.html');
												thumbnails[241696] = new thumbnail(241696,'13056','Dempster Highway, nr Dawson City','Dempster-Hway-006_2-copy_thumb.jpg',120, 81,1,'photo_241696.html');
												thumbnails[238511] = new thumbnail(238511,'12464','Conspiring with Rape','Conspiring-with-Rape_thumb.jpg',81, 120,1,'photo_238511.html');
												thumbnails[239303] = new thumbnail(239303,'13056','Dempster Highway, nr Dawson City','Dempster-Hway-003_2-copy_thumb.jpg',120, 81,1,'photo_239303.html');
												thumbnails[241109] = new thumbnail(241109,'12464','Blue Evening, Venice','venice eveneing_thumb.jpg',80, 120,1,'photo_241109.html');
												thumbnails[242435] = new thumbnail(242435,'13056','Yukon River, Whitehorse, Yukon','Yukon-River,Whitehorse_thumb.jpg',120, 81,1,'photo_242435.html');
												thumbnails[242799] = new thumbnail(242799,'13056','Lake Laberge, nr Whitehorse','Lake-Laberge-001_thumb.jpg',120, 80,1,'photo_242799.html');
												thumbnails[805608] = new thumbnail(805608,'23814','Vancouver Reflections','Vancouver  017_resize_thumb.jpg',120, 82,1,'photo_805608.html');
												thumbnails[242454] = new thumbnail(242454,'13056','Five Finger Rapids, Yukon River','Five-Finger-Rapids-002_thumb.jpg',120, 81,1,'photo_242454.html');
												thumbnails[246069] = new thumbnail(246069,'12464','Red Umbrella','Red-Umbrella1_thumb.jpg',80, 120,1,'photo_246069.html');
												thumbnails[805611] = new thumbnail(805611,'23814','Peyto Lake, Alberta','Peyto Lake 001_resize_thumb.jpg',120, 81,1,'photo_805611.html');
												thumbnails[243099] = new thumbnail(243099,'12464','Venetian Glass Rose','venetian_glass_rose_thumb.jpg',85, 120,1,'photo_243099.html');
												thumbnails[245091] = new thumbnail(245091,'12464','Textures, patterns and Colours','Textures,-patterns-and-colo_thumb.jpg',80, 120,1,'photo_245091.html');

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  					galleries[12696] = new gallery(12696,'268653,267956,267954,242814,242808,238504,238141,238136,237825,237823','Faraway Places : Alaska','gallery',[5950289,3971010,238136,237825,3924852,238141,238504,242808,3971020,3949856,3971011,3971016,242814,267954,267956,268653,3949879,3924933,237823],0, 0, '', 'gallery_12696.html',0,0);
				  					galleries[394896] = new gallery(394896,'7633903,7633813','Faraway Places : Austria','gallery',[7633813,7633903],0, 0, '', 'gallery_394896.html',0,0);
				  					galleries[238294] = new gallery(238294,'3930722,3928637','Faraway Places : California','gallery',[3928637,3930722],0, 0, '', 'gallery_238294.html',0,0);
				  					galleries[23814] = new gallery(23814,'805608,267854,267847,267845,267843,267717','Faraway Places :Canada','gallery',[803967,804468,804555,804608,805592,810843,810849,267843,267847,267845,267854,267717,805608,805611],0, 0, '', 'gallery_23814.html',0,0);
				  					galleries[12686] = new gallery(12686,'268809,254660,254654,254628,254455,254447,252292,252290','Faraway Places : Iceland','gallery',[268809,252290,252292,254447,254455,254628,254654,254660],0, 0, '', 'gallery_12686.html',0,0);
				  					galleries[13056] = new gallery(13056,'242799,242454,242435,242413,242406,241696,240402,240387,240329,239303,239151,239148','Faraway Places : Yukon, Canada','gallery',[242406,239151,239148,240329,240402,242413,240387,241696,239303,242435,242799,242454],0, 0, '', 'gallery_13056.html',0,0);
				  					galleries[21142] = new gallery(21142,'236113,234751','Nearer Home: Scotland','gallery',[234751,236113],0, 0, '', 'gallery_21142.html',0,0);
				  					galleries[21563] = new gallery(21563,'256470,246064,238666','Nearer Home: France','gallery',[238666,246064,256470],0, 0, '', 'gallery_21563.html',0,0);
				  					galleries[12464] = new gallery(12464,'246084,246069,245912,245091,243099,241109,238511','Digital Gallery 1','gallery',[246084,2066217,2066219,2066221,245912,245916,137206,137209,137204,238511,241109,246069,243099,245091],0, 0, '', 'gallery_12464.html',0,0);
				  					galleries[12682] = new gallery(12682,'199264,196076,191091,191077,173277,137916,137914,137904','Portrait Gallery','gallery',[137904,137907,173205,173206,173277,191077,191091,196076,199264,137914,137916],0, 0, '', 'gallery_12682.html',0,0);
				  					galleries[15059] = new gallery(15059,'182931','Miscellaneous','gallery',[182931,154169],0, 0, '', 'gallery_15059.html',0,0);
/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = new Object();
imageSets[1] = '154169';
imageSets[2] = '805608,268809,268653,267956,267954,267854,267847,267845,267843,267717,256470,254660,254654,254628,254455,254447,252292,252290,246084,246069,246064,245912,245091,243099,242814,242808,242799,242454,242435,242413,242406,241696,241109,240402,240387,240329,239303,239151,239148,238666,238511,238504,238141,238136,237825,237823,236113,234751,199264,196076,191091,191077,182931,173277,137916,137914,137904';
imageSets[3] = '7633903,7633813,5950289,3971020,3971016,3971011,3971010,3949879,3949856,3930722,3928637,3924933,3924852,2066221,2066219,2066217,810849,810843,805611,805608,805592,804608,804555,804468,803967,268809,268653,267956,267954,267854,267847,267845,267843,267717,256470,254660,254654,254628,254455,254447,252292,252290,246084,246069,246064,245916,245912,245091,243099,242814';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/akphoto/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/akphoto/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/akphoto/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/akphoto/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/akphoto/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/akphoto/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/akphoto/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/akphoto/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/akphoto/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/akphoto/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/akphoto/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/akphoto/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/akphoto/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/akphoto/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/akphoto/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://admin2.clikpic.com/akphoto/images';
		break;
	}
		switch (server_id) {
		case 33:
		val = 'http://www8.clikpic.com/akphoto/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/akphoto/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/akphoto/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/akphoto/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/akphoto/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/akphoto/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 = 'CLONEEN DIGITAL: ' + 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>';
	}
					
	temp = temp + this.fnGetPaymentInfo();
				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>Buy now using PayPal:</p>';
				temp = temp + '<p class="imageinfo" id="imagePrice"><strong>' + this.purchase_instruction + '</strong> &pound;' + (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 + '<form id="paymentForm" style="margin:0px;border:0px;" name="paymentForm" target="_blank" action="https://www.paypal.com/cgi-bin/webscr" method="post">';
	temp = temp + '<input type="hidden" name="item_name" value="'+item_name+'">';
								ref = '';
				if(this.photo_ref != ''){
					ref = this.photo_ref+' - '+this.caption;
				}
				else{
					ref = this.id+' - '+this.caption;
				}
				price = amount;					temp = temp + '<input type="hidden" name="cmd" value="_cart">';
	temp = temp + '<input type="hidden" name="business" value="akphoto@btinternet.com">';
	temp = temp + '<input type="hidden" name="currency_code" value="GBP">';
	temp = temp + '<input type="hidden" name="add" value="1">';
					temp = temp + '<input type="hidden" name="amount" value="'+amount+'">';
	temp = temp + '<input type="hidden" name="item_number" value="'+ref+'">';
					temp = temp + '<input type=\"Submit\" value=\"Add to cart\" id=\"paymentAddButton\" class=\"button\" onmouseover=\"this.className=\'buttonHi\';\" onmouseout=\"this.className=\'button\';\">';
									temp = temp + '</form>';
								temp = temp + '<form id="paymentCartForm" style="margin:0px;" name="paymentCartForm" target="_blank" action="https://www.paypal.com/cgi-bin/webscr" method="post">';
	temp = temp + '<input type="hidden" name="cmd" value="_cart">';
	temp = temp + '<input type="hidden" name="business" value="akphoto@btinternet.com">';
	temp = temp + '<input type="hidden" name="display" value="1">';
	temp = temp + '<input type=\"Submit\" value=\"View cart\" id=\"paymentViewButton\" class=\"button\" onmouseover=\"this.className=\'buttonHi\';\" onmouseout=\"this.className=\'button\';\">';
	temp = temp + '</form>';
							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;
	}
}

		

