window.thumbnails = {};
															thumbnails[8587220] = clik.newPhoto({"id":8587220,"src":"Fronts03_thumb.jpg","galleries_id":"","server_id":18,"link":"#","width":130,"caption":"The fronts of our two 2012 calendars","height":71});
															thumbnails[8587236] = clik.newPhoto({"id":8587236,"src":"Back01_thumb.jpg","galleries_id":"","server_id":18,"link":"#","width":130,"caption":"Showing the reverse of our two calendars","height":61});
															thumbnails[7154670] = clik.newPhoto({"id":7154670,"src":"IMG_0766_1_thumb.JPG","galleries_id":386751,"server_id":18,"link":"photo_7154670.html","width":130,"caption":"Rockpooling","height":173});
															thumbnails[7233341] = clik.newPhoto({"id":7233341,"src":"DSCF1472_at_72dpi_for_web_thumb.jpg","galleries_id":390877,"server_id":18,"link":"photo_7233341.html","width":130,"caption":"White rose with gold rings","height":177});
															thumbnails[7233345] = clik.newPhoto({"id":7233345,"src":"DSCF1476_at_72dpi_for_web_thumb.jpg","galleries_id":390877,"server_id":18,"link":"photo_7233345.html","width":130,"caption":"White Rose with gold rings (soft focus)","height":184});
															thumbnails[7239286] = clik.newPhoto({"id":7239286,"src":"DSCF2132_at_72_dpi_for_web_thumb.jpg","galleries_id":391296,"server_id":18,"link":"photo_7239286.html","width":130,"caption":"Rissa tridactyla. The Kittiwake and Chicks","height":177});
															thumbnails[7239476] = clik.newPhoto({"id":7239476,"src":"DSCF0224_at_72dpi_for_web_thumb.jpg","galleries_id":386741,"server_id":18,"link":"photo_7239476.html","width":130,"caption":"The Rialto Bridge, Venice.","height":85});
															thumbnails[7239513] = clik.newPhoto({"id":7239513,"src":"DSCF1998_at_72dpi_for_web_thumb.jpg","galleries_id":386751,"server_id":18,"link":"photo_7239513.html","width":130,"caption":"Kirkwall Beach Pebbles","height":87});
															thumbnails[7242874] = clik.newPhoto({"id":7242874,"src":"DSCF0882_at_72dpi_for_web_thumb.jpg","galleries_id":391496,"server_id":18,"link":"photo_7242874.html","width":130,"caption":"The Balaliaka Player","height":200});
															thumbnails[7242888] = clik.newPhoto({"id":7242888,"src":"DSCN0920_at_72_dpi_for_web_thumb.jpg","galleries_id":391496,"server_id":18,"link":"photo_7242888.html","width":130,"caption":"Deep in Thought","height":157});
															thumbnails[7242930] = clik.newPhoto({"id":7242930,"src":"DSCF1487_as_72dpi_for_web_thumb.jpg","galleries_id":391286,"server_id":18,"link":"photo_7242930.html","width":130,"caption":"Study of three Calla Lily's","height":225});
															thumbnails[7272648] = clik.newPhoto({"id":7272648,"src":"DSCF1946_Sparrow_on_log_thumb.jpg","galleries_id":391296,"server_id":18,"link":"photo_7272648.html","width":130,"caption":"Passer domesticus. The house Sparrow at lunch","height":87});
															thumbnails[7272658] = clik.newPhoto({"id":7272658,"src":"DSCF2367_Zebra_Monochrome_thumb.jpg","galleries_id":391296,"server_id":18,"link":"photo_7272658.html","width":130,"caption":"Monochrome Zebra","height":191});
															thumbnails[7272715] = clik.newPhoto({"id":7272715,"src":"410100_Tractor_Tracks_thumb.jpg","galleries_id":391286,"server_id":18,"link":"photo_7272715.html","width":130,"caption":"A route through the bluebells","height":76});
															thumbnails[7272754] = clik.newPhoto({"id":7272754,"src":"411400_Panoramic_format_thumb.jpg","galleries_id":391286,"server_id":18,"link":"photo_7272754.html","width":130,"caption":"A panoramic view of the bluebell woods","height":39});
															thumbnails[7272762] = clik.newPhoto({"id":7272762,"src":"DSCF0588_panoramic_format_thumb.jpg","galleries_id":391286,"server_id":18,"link":"photo_7272762.html","width":130,"caption":"Close view of wild bluebells","height":314});
															thumbnails[7272770] = clik.newPhoto({"id":7272770,"src":"DSCN0179_Poppy_Gails_Garden_thumb.jpg","galleries_id":391286,"server_id":18,"link":"photo_7272770.html","width":130,"caption":"An English Country Garden with poppies","height":98});
															thumbnails[7272783] = clik.newPhoto({"id":7272783,"src":"_DSC1749._Seaside_and_waves_thumb.jpg","galleries_id":386751,"server_id":18,"link":"photo_7272783.html","width":130,"caption":"A walk along the beach","height":198});
															thumbnails[7272794] = clik.newPhoto({"id":7272794,"src":"DSCF2477_Leaves_and_snow_thumb.jpg","galleries_id":386751,"server_id":18,"link":"photo_7272794.html","width":130,"caption":"Winter in the hedgerow","height":173});
															thumbnails[7272813] = clik.newPhoto({"id":7272813,"src":"DSCF2221_Nordfjord_near_Olden_Norway_thumb.jpg","galleries_id":386741,"server_id":18,"link":"photo_7272813.html","width":130,"caption":"A view over Nordfjord, Nr Olden, Norway","height":87});
															thumbnails[7272867] = clik.newPhoto({"id":7272867,"src":"2335A00_v2_All_Saints_Winter_thumb.jpg","galleries_id":393393,"server_id":18,"link":"photo_7272867.html","width":130,"caption":"A winter view of All Saints Church, Shillington, Bedfordshire","height":82});
															thumbnails[7281717] = clik.newPhoto({"id":7281717,"src":"_DSC0084_Barbary_Ape_Gibraltar_thumb.jpg","galleries_id":391296,"server_id":18,"link":"photo_7281717.html","width":130,"caption":"Barbary Ape, Gibraltar","height":178});
															thumbnails[7281733] = clik.newPhoto({"id":7281733,"src":"_DSC0289_Woodpecker_thumb.jpg","galleries_id":391296,"server_id":18,"link":"photo_7281733.html","width":130,"caption":"Picus viridis, the Woodpecker","height":203});
															thumbnails[7281760] = clik.newPhoto({"id":7281760,"src":"DSCN2483_Anomoly_cat_Dubrovnik__thumb.jpg","galleries_id":391296,"server_id":18,"link":"photo_7281760.html","width":130,"caption":"The confused cat","height":93});
															thumbnails[7281775] = clik.newPhoto({"id":7281775,"src":"DSCF1947_Robin_on_log_thumb.jpg","galleries_id":391296,"server_id":18,"link":"photo_7281775.html","width":130,"caption":"Erithacus rubecula. The Robin at lunch on a log","height":193});
															thumbnails[7297675] = clik.newPhoto({"id":7297675,"src":"DSCN2484_Lady_with_dolls_Dubrovnik_thumb.jpg","galleries_id":391496,"server_id":18,"link":"photo_7297675.html","width":130,"caption":"Souvenier Doll Maker","height":100});
															thumbnails[7297687] = clik.newPhoto({"id":7297687,"src":"_DSC1567_Poppy_in_cinder_path_thumb.jpg","galleries_id":391286,"server_id":18,"link":"photo_7297687.html","width":130,"caption":"Poppies in a farm field, Shillington, Bedfordshire","height":87});
															thumbnails[7297691] = clik.newPhoto({"id":7297691,"src":"Dscn0073_Purple_Aqulegia_thumb.jpg","galleries_id":391286,"server_id":18,"link":"photo_7297691.html","width":130,"caption":"Purple Aqulegia","height":127});
															thumbnails[7297695] = clik.newPhoto({"id":7297695,"src":"Dscn0066_Pink_Aqulegia_thumb.jpg","galleries_id":391286,"server_id":18,"link":"photo_7297695.html","width":130,"caption":"Pink Aqulegia","height":124});
															thumbnails[7297813] = clik.newPhoto({"id":7297813,"src":"DSCF1505_Red_and_Pink_Celosia1_thumb.jpg","galleries_id":391286,"server_id":18,"link":"photo_7297813.html","width":130,"caption":"Red and Pink Celosia","height":87});
															thumbnails[7297832] = clik.newPhoto({"id":7297832,"src":"NP0198_Storm_Clouds_Gibraltar_thumb.jpg","galleries_id":394848,"server_id":18,"link":"photo_7297832.html","width":130,"caption":"Storm Clouds","height":64});
															thumbnails[7297855] = clik.newPhoto({"id":7297855,"src":"17631A00_Sunset_thumb.jpg","galleries_id":394848,"server_id":18,"link":"photo_7297855.html","width":130,"caption":"Sunset","height":77});
															thumbnails[7298571] = clik.newPhoto({"id":7298571,"src":"Westonbirt_15821A00_thumb.jpg","galleries_id":394848,"server_id":18,"link":"photo_7298571.html","width":130,"caption":"Autumn Trees, Westonbirt Arboretum","height":223});
															thumbnails[7298578] = clik.newPhoto({"id":7298578,"src":"Westonbirt_15833A00._thumb.jpg","galleries_id":394848,"server_id":18,"link":"photo_7298578.html","width":130,"caption":"Autumn Trees","height":76});
															thumbnails[7298654] = clik.newPhoto({"id":7298654,"src":"DSCF1502_Celosia_close_up_as_monochrome_thumb.jpg","galleries_id":386751,"server_id":18,"link":"photo_7298654.html","width":130,"caption":"Celosia","height":84});
															thumbnails[7298712] = clik.newPhoto({"id":7298712,"src":"5306A07_Denali_National_Park_Alaska_thumb.jpg","galleries_id":396903,"server_id":18,"link":"photo_7298712.html","width":130,"caption":"Denali National Park, Alaska.","height":87});
															thumbnails[7298800] = clik.newPhoto({"id":7298800,"src":"ALAS_96_181_Glacier_Fjord_thumb.jpg","galleries_id":396903,"server_id":18,"link":"photo_7298800.html","width":130,"caption":"Glacier Bay, Alaska.","height":80});
															thumbnails[7299942] = clik.newPhoto({"id":7299942,"src":"_DSC0610_Dubrovnik_from_the_city_wall_thumb.jpg","galleries_id":386741,"server_id":18,"link":"photo_7299942.html","width":130,"caption":"Dubrovnik, Croatia","height":87});
															thumbnails[7308020] = clik.newPhoto({"id":7308020,"src":"_DSC0672_Gondolas_in_Venice_thumb.jpg","galleries_id":386741,"server_id":18,"link":"photo_7308020.html","width":130,"caption":"Gondola's in Venice","height":84});
															thumbnails[7312306] = clik.newPhoto({"id":7312306,"src":"_DSC1768_Large_card_complete_thumb.jpg","galleries_id":390877,"server_id":18,"link":"photo_7312306.html","width":130,"caption":"A4 Wedding Card.","height":180});
															thumbnails[7324304] = clik.newPhoto({"id":7324304,"src":"DSCF2055_Reykjavik_thumb.jpg","galleries_id":386741,"server_id":18,"link":"photo_7324304.html","width":130,"caption":"An early morning approach to Reykjavik, Iceland.","height":56});
															thumbnails[7324326] = clik.newPhoto({"id":7324326,"src":"DSCN1788_Pingvillier_Reykjavik_thumb.jpg","galleries_id":386741,"server_id":18,"link":"photo_7324326.html","width":130,"caption":"Pingvellir, Reykjavik, Iceland.","height":98});
															thumbnails[7324351] = clik.newPhoto({"id":7324351,"src":"16832A00_Spitzbergen_Norway_thumb.jpg","galleries_id":386741,"server_id":18,"link":"photo_7324351.html","width":130,"caption":"In the Spitzbergen Archipelago, north of Norway.","height":81});
															thumbnails[7324459] = clik.newPhoto({"id":7324459,"src":"DSCF2088_Stokkur_Geyser_Iceland_thumb.jpg","galleries_id":386741,"server_id":18,"link":"photo_7324459.html","width":130,"caption":"Strokkur (The Churn) Geysir. Reykjavik, Iceland.","height":194});
															thumbnails[7324469] = clik.newPhoto({"id":7324469,"src":"_DSC0657_Venice_canal_thumb.jpg","galleries_id":386741,"server_id":18,"link":"photo_7324469.html","width":130,"caption":"Venice, Italy","height":195});
															thumbnails[7334797] = clik.newPhoto({"id":7334797,"src":"_DSC0681_Venice_by_night_thumb.jpg","galleries_id":386741,"server_id":18,"link":"photo_7334797.html","width":130,"caption":"A night view of the Campanille and the Doges Palace, Venice, Italy","height":82});
															thumbnails[7334809] = clik.newPhoto({"id":7334809,"src":"DSCN1925_Bergen_thumb.jpg","galleries_id":386741,"server_id":18,"link":"photo_7334809.html","width":130,"caption":"The waterfront buildings in Bergen, Norway","height":98});
															thumbnails[7239253] = clik.newPhoto({"id":7239253,"src":"DSCN0629_at_72_dpi_for_web_thumb.jpg","galleries_id":391286,"server_id":18,"link":"photo_7239253.html","width":130,"caption":"Snowdrops","height":98});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  						galleries[386741] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Travel within Europe","link":"gallery_386741.html","maxRecords":0.0,"photoIDs":[7239476.0,7272813.0,7299942.0,7308020.0,7324304.0,7324326.0,7324351.0,7324459.0,7324469.0,7334797.0,7334809.0],"skipIndex":0,"section_code":"gallery","featured_images":"7334809,7334797,7324469,7324459,7324351,7324326,7324304,7308020,7299942,7272813","id":386741,"singleSection":false});				  						galleries[396903] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Travel Outside Europe","link":"gallery_396903.html","maxRecords":0.0,"photoIDs":[7298712.0,7298800.0],"skipIndex":0,"section_code":"gallery","featured_images":"7298800,7298712","id":396903,"singleSection":false});				  						galleries[391286] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Flora","link":"gallery_391286.html","maxRecords":0.0,"photoIDs":[7242930.0,7272715.0,7272754.0,7272762.0,7272770.0,7297687.0,7297691.0,7297695.0,7297813.0,7239253.0],"skipIndex":0,"section_code":"gallery","featured_images":"7297813,7297695,7297691,7297687,7272770,7272762,7272754,7272715,7242930,7239253","id":391286,"singleSection":false});				  						galleries[391296] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Fauna","link":"gallery_391296.html","maxRecords":0.0,"photoIDs":[7239286.0,7272648.0,7272658.0,7281717.0,7281733.0,7281760.0,7281775.0],"skipIndex":0,"section_code":"gallery","featured_images":"7281775,7281760,7281733,7281717,7272658,7272648,7239286","id":391296,"singleSection":false});				  						galleries[391496] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Character Studies","link":"gallery_391496.html","maxRecords":0.0,"photoIDs":[7242874.0,7242888.0,7297675.0],"skipIndex":0,"section_code":"gallery","featured_images":"7297675,7242888,7242874","id":391496,"singleSection":false});				  						galleries[386751] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Modern and Still Life","link":"gallery_386751.html","maxRecords":0.0,"photoIDs":[7154670.0,7239513.0,7272783.0,7272794.0,7298654.0],"skipIndex":0,"section_code":"gallery","featured_images":"7298654,7272794,7272783,7239513,7154670","id":386751,"singleSection":false});				  						galleries[390877] = clik.newGallery({"parentGallery":390876,"usePopups":false,"title":"Images for Wedding Stationery","link":"gallery_390877.html","maxRecords":0.0,"photoIDs":[7233341.0,7233345.0,7312306.0],"skipIndex":0,"section_code":"gallery","featured_images":"7312306,7233345,7233341","id":390877,"singleSection":false});				  						galleries[394848] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Landscape","link":"gallery_394848.html","maxRecords":0.0,"photoIDs":[7297832.0,7297855.0,7298571.0,7298578.0],"skipIndex":0,"section_code":"gallery","featured_images":"7298578,7298571,7297855,7297832","id":394848,"singleSection":false});				  						galleries[393393] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"In and around Shillington, Bedfordshire","link":"gallery_393393.html","maxRecords":0.0,"photoIDs":[7272867.0],"skipIndex":0,"section_code":"gallery","featured_images":7272867.0,"id":393393,"singleSection":false});				  						galleries[390876] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Wedding ","link":"gallery_390876.html","maxRecords":0.0,"photoIDs":[],"skipIndex":0,"section_code":"gallery","featured_images":"7312306,7233345,7233341","id":390876,"singleSection":false});				  						galleries[386750] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Antique and Vintage","link":"gallery_386750.html","maxRecords":0.0,"photoIDs":[],"skipIndex":0,"section_code":"gallery","featured_images":"","id":386750,"singleSection":false});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[1] = '7334809,7334797,7324469,7324459,7324351,7324326,7324304,7312306,7308020,7299942,7298800,7298712,7298654,7298578,7298571,7297855,7297832,7297813,7297695,7297691,7297687,7297675,7281775,7281760,7281733,7281717,7272867,7272813,7272794,7272762,7272754,7272715,7272658,7272648,7242930,7242888,7242874,7239513,7239476,7239286,7233345,7233341,7154670,7239253';
imageSets[3] = '7334809,7334797,7324469,7324459,7324351,7324326,7324304,7312306,7308020,7299942,7298800,7298712,7298654,7298578,7298571,7297855,7297832,7297813,7297695,7297691,7297687,7297675,7281775,7281760,7281733,7281717,7272867,7272813,7272794,7272762,7272754,7272715,7272658,7272648,7242930,7242888,7242874,7239513,7239476,7239286,7233345,7233341,7154670,7239253';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 51:
		val = 'http://www12.clikpic.com/pinpointprints/images';
		break;
	}
		switch (server_id) {
		case 0:
		val = 'http://www.clikpic.com/pinpointprints/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/pinpointprints/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/pinpointprints/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/pinpointprints/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/pinpointprints/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/pinpointprints/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/pinpointprints/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/pinpointprints/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/pinpointprints/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/pinpointprints/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/pinpointprints/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/pinpointprints/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/pinpointprints/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/pinpointprints/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/pinpointprints/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/pinpointprints/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/pinpointprints/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/pinpointprints/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/pinpointprints/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/pinpointprints/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/pinpointprints/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/pinpointprints/images';
		break;
	}
		switch (server_id) {
		case 53:
		val = 'http://images.clikpic.com/pinpointprints/images';
		break;
	}
		switch (server_id) {
		case 52:
		val = 'http://tpc22/clikpic/pinpointprints/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/pinpointprints/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/pinpointprints/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 || photos || {})[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:'',$detailContainer:'',
                    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 (op.updateHash && clik.getIDInUrl(location.href,'photo') != op.nextPhoto.id) {
		clik.changeHash('photos_id=' + op.nextPhoto.id, true);
	}
		
	    if (op.$title.length > 0) {
  		op.$title.fadeGalleryDetails(photoCaption, op.speed);
    }
        if (op.updateDocumentTitle) {
						  document.title = 'PinPointPrints: ' + photoCaption;
			    }
        if (op.$detail.length > 0) {
      	temp = op.nextPhoto.fnGetImageDetails();
	    op.$detail.fadeGalleryDetails(temp, op.speed, function(){
			if (typeof(backgrounds) != 'undefined' && op.nextPhoto == backgrounds[op.nextPhoto.id]) {
				toggleAddToCartConfirm(backgrounds, op.$detail);
			} else if (typeof(photos) != 'undefined' && op.nextPhoto == photos[op.nextPhoto.id]) {
				toggleAddToCartConfirm(photos, op.$detail);
			}
			$('body').trigger('clikUpdate.popup');
	    });
    }
        $(op.$detailContainer).find('.replaceable[class*=replaceable_photo-]').each(function(){
    	var field = clik.getPrefixedClass(this.className, 'replaceable_photo-');
    	if (field in op.nextPhoto) {
    		$(this).fadeGalleryDetails(op.nextPhoto[field], op.speed);
    	}
    }).end().find('.replaceable.photoPayment').fadeGalleryDetails(op.nextPhoto.fnGetPaymentInfo(), op.speed, function(){
		if (typeof(backgrounds) != 'undefined' && op.nextPhoto == backgrounds[op.nextPhoto.id]) {
			toggleAddToCartConfirm(backgrounds, op.$detailContainer);
		} else if (typeof(photos) != 'undefined' && op.nextPhoto == photos[op.nextPhoto.id]) {
			toggleAddToCartConfirm(photos, op.$detailContainer);
		}
		$('body').trigger('clikUpdate.popup');
	});
		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));			}, op.onBefore);
		}	}
    if (op.field) {
		op.field.value = photoId;
	} else {
		op.$photo.data('image_id', photoId);
    }
        if (!op.speed) {
      	clik.doColumnResize(false, op.$photo.add(op.$detail).add(op.$title));
    }
        
    return html;
	}

/***************************************************************************
* Toggle add to cart confirmation element and set up the click event for   *
* the 'Add to cart' button.                                                *
***************************************************************************/
function toggleAddToCartConfirm(array, root){
	if (typeof(array) !== 'object' || array === null) {
	  	array = photos;
	}
	if (!$(root).length) {		root = $('body');	}	if($('#paymentConfirm', root).length > 0){
		$('#paymentConfirm', root).hide();
		$('#paymentAddButton', root)
		.unbind()
		.click(function(){
						form = $('#paymentForm', root)[0];
			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', root).text('Item added to cart').show();}
				else{
					$('#paymentConfirm', root).text('Item added to cart').fadeIn();
					dspOrderDetails(form.site.value);
				}
			}
			else{
				$('#paymentConfirm', root).text('Item not added - check cookies are enabled in your browser.').fadeIn();
			}
		});
	}
}

/***************************************************************************
* Get payment info for image - add as 'method' to photo object             *
***************************************************************************/
clik.photo.fnGetImageDetails = function(){
	var temp = '';
	if (this.description != '') {
		temp +=  '<div id="imageDescription">' + this.description + '</div>';
	}
		if (this.photo_ref != '') {
		temp += '<div class="imageinfo" id="imageRef"><strong>Ref: </strong>' + this.photo_ref + '</div>';
	}
		if (this.takendate != '') {
		
		temp += '<div class="imageinfo" id="imageDate"><strong>Date: </strong>' + this.takendate + '</div>';
	}
	
	if (this.location != '') {
		
		temp += '<div class="imageinfo" id="imageLocation"><strong>Location: </strong>' +  this.location + '</div>';
	}
	
	if (this.photographer != '') {
		
		temp += '<div class="imageinfo" id="imagePhotographer"><strong>Photographer: </strong>' + this.photographer + '</div>';
	}
				
	temp += this.fnGetPaymentInfo();
				if (temp != '') {
		temp += '<div class="spacer"></div>';
	}
	return temp;
};

/***************************************************************************
* Get payment info for image - add as 'method' to photo object             *
***************************************************************************/
clik.photo.fnGetPaymentInfo = function(){
	var temp = '';
	if (this.item_price !== '') {
																		temp += '<p>Buy now using PayPal:</p>';
				temp += '<div class="imageinfo" id="imagePrice"><strong>' + this.purchase_instruction + '</strong> &pound;' + (this.item_price).toFixed(2) + '</div>';
		var item_name  = this.purchase_instruction;
		var amount = (this.item_price).toFixed(2);
		var item_option  = 0;
	}
		else if (this.payment_groups_id !== '') {
		temp += '<p>Buy this print online:</p>';
				temp += '<form id="paymentOptions" style="margin:0px;border:0px;" name="paymentOptions">';
		 									temp += '<select class="paymentlink" name="payment_options_id" onchange="updateCartValue($(this.form).next(\'#paymentForm\')[0],this.form.payment_options_id.options[this.form.payment_options_id.options.selectedIndex].value); if(divShowing(\'paymentConfirm\')){fadeOut(\'paymentConfirm\', 3)};">';
		
		temp += getPaymentOptions(this.payment_groups_id);
		temp += '</select>';
		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 += '<form id="paymentForm" style="margin:0px;border:0px;" name="paymentForm">';
			temp += '	<input type="hidden" name="item_option" value="' + item_option + '">';
			temp += '	<input type="hidden" name="site" value="PINPOINTPRINTS">';
			temp += '	<input type="hidden" name="item_number" value="'+ this.id +'">';
			temp += '	<input type="hidden" name="quantity" value="1">';
						temp += '	<input value="Add to cart" id="paymentAddButton" class="button" onmouseover="this.className=\'buttonHi\'\;" onmouseout="this.className=\'button\'\;" type="Button">';
							temp += '	<input value="View cart" id="paymentViewButton" class="button" onmouseover="this.className=\'buttonHi\';" onmouseout="this.className=\'button\';" type="Button" onclick="javascript:window.location=\'cart.html\'">';
			temp += '</form>';
						temp += '<div class="clearing">&nbsp;</div>';
			temp += '<div id="confirmContainer">';
			temp += '<div id="paymentConfirm">Item added to cart</div>';
			temp += '</div>';
			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({					title: galleries[gallery_id].title				}).filter(function(){return this.href;}).attr({					href: thumbnails[imageID].fnGalleryLink(gallery_id)				});
			}
		}
	}
}

/***************************************************************************
* 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 += '<a href="' + galleries[i].section_code + '_' + galleries[i].id + '.html">' + galleries[i].title + '</a>';
							}
		}
		document.all.galleryLinks.innerHTML = 'Other galleries: ' + temp;
	}
}

			

