window.thumbnails = {};
															thumbnails[6775083] = clik.newPhoto({"id":6775083,"src":"BeachWalkersjpg_thumb.jpg","galleries_id":"","server_id":32,"link":"#","width":130,"caption":"'Beach Walkers' Inch Strand, Ireland","height":188});
															thumbnails[6787480] = clik.newPhoto({"id":6787480,"src":"MugshotforwebSmall_thumb.jpg","galleries_id":"","server_id":32,"link":"#","width":130,"caption":"Caricature","height":157});
															thumbnails[6999355] = clik.newPhoto({"id":6999355,"src":"Man_against_the_clouds_1397054B-1D09-001F-99B3F0653DE2B89F_thumb.jpg","galleries_id":"","server_id":32,"link":"#","width":130,"caption":"Man against the sky","height":76});
															thumbnails[7139311] = clik.newPhoto({"id":7139311,"src":"Autumn_in_Harrogate_thumb.jpg","galleries_id":"","server_id":32,"link":"#","width":130,"caption":"Autumn in Harrogate","height":65});
															thumbnails[7241876] = clik.newPhoto({"id":7241876,"src":"Horfield-Common_thumb.jpg","galleries_id":"","server_id":32,"link":"#","width":130,"caption":"Hoar Frosted Trees","height":106});
															thumbnails[7890157] = clik.newPhoto({"id":7890157,"src":"Chartwell_for_Facebook_thumb.jpg","galleries_id":"","server_id":32,"link":"#","width":130,"caption":"Chartwell","height":87});
															thumbnails[8064105] = clik.newPhoto({"id":8064105,"src":"Its-raining_thumb.jpg","galleries_id":"","server_id":32,"link":"#","width":130,"caption":"Getting wet!","height":202});
															thumbnails[8396465] = clik.newPhoto({"id":8396465,"src":"Bikes2_thumb.jpg","galleries_id":"","server_id":32,"link":"#","width":130,"caption":"Growing bicycles","height":68});
															thumbnails[8564291] = clik.newPhoto({"id":8564291,"src":"The-Pier-800-px_thumb.jpg","galleries_id":"","server_id":32,"link":"#","width":130,"caption":"Llandudno Pier","height":89});
															thumbnails[8797410] = clik.newPhoto({"id":8797410,"src":"My-Bowl_thumb.jpg","galleries_id":"","server_id":32,"link":"#","width":130,"caption":"My Bowl","height":89});
															thumbnails[8955627] = clik.newPhoto({"id":8955627,"src":"Triptych_thumb.jpg","galleries_id":"","server_id":32,"link":"#","width":130,"caption":"Lacock Triptych","height":77});
															thumbnails[9084372] = clik.newPhoto({"id":9084372,"src":"peeping-in_thumb.jpg","galleries_id":"","server_id":32,"link":"#","width":130,"caption":"","height":87});
															thumbnails[6970534] = clik.newPhoto({"id":6970534,"src":"Swallow-Falls_thumb.jpg","galleries_id":368890,"server_id":32,"link":"photo_6970534.html","width":130,"caption":"A small section of Swallow Falls at Betws-y-coed","height":75});
															thumbnails[6970539] = clik.newPhoto({"id":6970539,"src":"Man_against_the_clouds_thumb.jpg","galleries_id":368890,"server_id":32,"link":"photo_6970539.html","width":130,"caption":"Man against the Clouds","height":76});
															thumbnails[6970570] = clik.newPhoto({"id":6970570,"src":"Fishing_at_Conway_thumb.jpg","galleries_id":368890,"server_id":32,"link":"photo_6970570.html","width":130,"caption":"Fishing at Conwy","height":90});
															thumbnails[6782027] = clik.newPhoto({"id":6782027,"src":"Artistview_thumb.jpg","galleries_id":368890,"server_id":32,"link":"photo_6782027.html","width":130,"caption":"Artist at Work, Stourhead","height":67});
															thumbnails[6782072] = clik.newPhoto({"id":6782072,"src":"AutumnPolesdenLacey_thumb.jpg","galleries_id":368890,"server_id":32,"link":"photo_6782072.html","width":130,"caption":"Autumn,  Polesden Lacey","height":62});
															thumbnails[6782091] = clik.newPhoto({"id":6782091,"src":"BeechTreeAvenue_thumb.jpg","galleries_id":368890,"server_id":32,"link":"photo_6782091.html","width":130,"caption":"Beech Tree Avenue","height":95});
															thumbnails[6782094] = clik.newPhoto({"id":6782094,"src":"CrossingtheCauseway_thumb.jpg","galleries_id":368890,"server_id":32,"link":"photo_6782094.html","width":130,"caption":"The Marine Lake, Weston-super-Mare, showing the causeway","height":100});
															thumbnails[6782102] = clik.newPhoto({"id":6782102,"src":"EveningFishing_thumb.jpg","galleries_id":368890,"server_id":32,"link":"photo_6782102.html","width":130,"caption":"Evening Fishing, Inch Strand","height":83});
															thumbnails[6782113] = clik.newPhoto({"id":6782113,"src":"StandingStones_thumb.jpg","galleries_id":368890,"server_id":32,"link":"photo_6782113.html","width":130,"caption":"Full Fathom Five - a Sculpture at Portishead","height":93});
															thumbnails[6782119] = clik.newPhoto({"id":6782119,"src":"TheAngel_thumb.jpg","galleries_id":368890,"server_id":32,"link":"photo_6782119.html","width":130,"caption":"The Angel of the North","height":88});
															thumbnails[6782122] = clik.newPhoto({"id":6782122,"src":"BirdWatching_thumb.jpg","galleries_id":368503,"server_id":32,"link":"photo_6782122.html","width":130,"caption":"Cardiff Bay","height":98});
															thumbnails[6782129] = clik.newPhoto({"id":6782129,"src":"BoysandToys_thumb.jpg","galleries_id":368503,"server_id":32,"link":"photo_6782129.html","width":130,"caption":"Boys and Toys!","height":92});
															thumbnails[6782134] = clik.newPhoto({"id":6782134,"src":"Bubbles_thumb.jpg","galleries_id":368503,"server_id":32,"link":"photo_6782134.html","width":130,"caption":"Bubbles!","height":98});
															thumbnails[6782143] = clik.newPhoto({"id":6782143,"src":"HarleyMan_thumb.jpg","galleries_id":368503,"server_id":32,"link":"photo_6782143.html","width":130,"caption":"Harley Man","height":106});
															thumbnails[6782148] = clik.newPhoto({"id":6782148,"src":"Helen_thumb.jpg","galleries_id":368503,"server_id":32,"link":"photo_6782148.html","width":130,"caption":"Helen","height":173});
															thumbnails[6782191] = clik.newPhoto({"id":6782191,"src":"Lea_thumb.jpg","galleries_id":368503,"server_id":32,"link":"photo_6782191.html","width":130,"caption":"Lea","height":189});
															thumbnails[6782306] = clik.newPhoto({"id":6782306,"src":"Nikki_thumb.jpg","galleries_id":368503,"server_id":32,"link":"photo_6782306.html","width":130,"caption":"Nikki","height":98});
															thumbnails[6782400] = clik.newPhoto({"id":6782400,"src":"OilingUp_thumb.jpg","galleries_id":368503,"server_id":32,"link":"photo_6782400.html","width":130,"caption":"Oiling Up","height":94});
															thumbnails[6782473] = clik.newPhoto({"id":6782473,"src":"OntheSteps_thumb.jpg","galleries_id":368503,"server_id":32,"link":"photo_6782473.html","width":130,"caption":"On the Steps","height":126});
															thumbnails[6782476] = clik.newPhoto({"id":6782476,"src":"SwingingAlong_thumb.jpg","galleries_id":368503,"server_id":32,"link":"photo_6782476.html","width":130,"caption":"Swinging Along!","height":108});
															thumbnails[6782481] = clik.newPhoto({"id":6782481,"src":"Tefnut_thumb.jpg","galleries_id":368503,"server_id":32,"link":"photo_6782481.html","width":130,"caption":"Fashion with Tefnut","height":96});
															thumbnails[6782484] = clik.newPhoto({"id":6782484,"src":"TheManWithTheBrasso_thumb.jpg","galleries_id":368503,"server_id":32,"link":"photo_6782484.html","width":130,"caption":"The Man with the Brasso!","height":102});
															thumbnails[6782487] = clik.newPhoto({"id":6782487,"src":"WaterBaby_thumb.jpg","galleries_id":368503,"server_id":32,"link":"photo_6782487.html","width":130,"caption":"Water Baby","height":182});
															thumbnails[6782490] = clik.newPhoto({"id":6782490,"src":"CatOnTheDoorstep_thumb.jpg","galleries_id":368502,"server_id":32,"link":"photo_6782490.html","width":130,"caption":"Cat on the Doorstep","height":176});
															thumbnails[6782493] = clik.newPhoto({"id":6782493,"src":"Classiclines_thumb.jpg","galleries_id":368502,"server_id":32,"link":"photo_6782493.html","width":130,"caption":"Classic Lines","height":85});
															thumbnails[6782494] = clik.newPhoto({"id":6782494,"src":"Eightlegs_thumb.jpg","galleries_id":368502,"server_id":32,"link":"photo_6782494.html","width":130,"caption":"Eight Legs!","height":82});
															thumbnails[6782496] = clik.newPhoto({"id":6782496,"src":"EmptyChair_thumb.jpg","galleries_id":368502,"server_id":32,"link":"photo_6782496.html","width":130,"caption":"The Empty Chair","height":164});
															thumbnails[6782497] = clik.newPhoto({"id":6782497,"src":"Gettingupsmoke_thumb.jpg","galleries_id":368502,"server_id":32,"link":"photo_6782497.html","width":130,"caption":"Getting up Smoke!","height":87});
															thumbnails[6782500] = clik.newPhoto({"id":6782500,"src":"Gothiccottage_thumb.jpg","galleries_id":368502,"server_id":32,"link":"photo_6782500.html","width":130,"caption":"Gothic Cottage, Stourhead","height":108});
															thumbnails[6782502] = clik.newPhoto({"id":6782502,"src":"LampsNorwich_thumb.jpg","galleries_id":368502,"server_id":32,"link":"photo_6782502.html","width":130,"caption":"Lamps in the Arcade, Norwich","height":120});
															thumbnails[6782504] = clik.newPhoto({"id":6782504,"src":"NeighbourhoodWatch_thumb.jpg","galleries_id":368502,"server_id":32,"link":"photo_6782504.html","width":130,"caption":"Neighbourhood Watch!","height":177});
															thumbnails[6782508] = clik.newPhoto({"id":6782508,"src":"NorweigenChurch_thumb.jpg","galleries_id":368502,"server_id":32,"link":"photo_6782508.html","width":130,"caption":"Church, Cardiff Bay","height":97});
															thumbnails[6782514] = clik.newPhoto({"id":6782514,"src":"Panthenon_thumb.jpg","galleries_id":368502,"server_id":32,"link":"photo_6782514.html","width":130,"caption":"In the Panthenon, Stourhead","height":96});
															thumbnails[6782518] = clik.newPhoto({"id":6782518,"src":"PutYourTrustInGod_thumb.jpg","galleries_id":368502,"server_id":32,"link":"photo_6782518.html","width":130,"caption":"Put your trust . . . . . . . ","height":98});
															thumbnails[6782520] = clik.newPhoto({"id":6782520,"src":"Redshoes_thumb.jpg","galleries_id":368502,"server_id":32,"link":"photo_6782520.html","width":130,"caption":"Red Shoes","height":87});
															thumbnails[6782529] = clik.newPhoto({"id":6782529,"src":"TheTrainleaving_thumb.jpg","galleries_id":368502,"server_id":32,"link":"photo_6782529.html","width":130,"caption":"The train just leaving . . . . . ","height":93});
															thumbnails[6782530] = clik.newPhoto({"id":6782530,"src":"Watchingtheworld_thumb.jpg","galleries_id":368502,"server_id":32,"link":"photo_6782530.html","width":130,"caption":"Watching the world go by","height":75});
															thumbnails[6783115] = clik.newPhoto({"id":6783115,"src":"Lakeside_thumb.jpg","galleries_id":368890,"server_id":32,"link":"photo_6783115.html","width":130,"caption":"A serene evening shot taken in Cumbria","height":86});
															thumbnails[6786163] = clik.newPhoto({"id":6786163,"src":"Buranoforweb_thumb.jpg","galleries_id":368890,"server_id":32,"link":"photo_6786163.html","width":130,"caption":"Washday in Burano","height":87});
															thumbnails[6788750] = clik.newPhoto({"id":6788750,"src":"Brunelvisiting_thumb.jpg","galleries_id":368503,"server_id":32,"link":"photo_6788750.html","width":130,"caption":"Isambard Kingdom Brunel visits the s.s.Great Britain!","height":129});
															thumbnails[6788768] = clik.newPhoto({"id":6788768,"src":"Ellena3_thumb.jpg","galleries_id":368503,"server_id":32,"link":"photo_6788768.html","width":130,"caption":"My 8 years old Grandaughter Ellena - snapping me, snapping her!","height":189});
															thumbnails[6788772] = clik.newPhoto({"id":6788772,"src":"AllCutUp_thumb.jpg","galleries_id":368502,"server_id":32,"link":"photo_6788772.html","width":130,"caption":"All cut up!","height":98});
															thumbnails[6788775] = clik.newPhoto({"id":6788775,"src":"BeachArt_thumb.jpg","galleries_id":368502,"server_id":32,"link":"photo_6788775.html","width":130,"caption":"Beach Art","height":89});
															thumbnails[6788776] = clik.newPhoto({"id":6788776,"src":"SmallerWoodNymph_thumb.jpg","galleries_id":368502,"server_id":32,"link":"photo_6788776.html","width":130,"caption":"Smaller Wood Nymph","height":88});
															thumbnails[6788779] = clik.newPhoto({"id":6788779,"src":"Grafitti_thumb.jpg","galleries_id":368502,"server_id":32,"link":"photo_6788779.html","width":130,"caption":"Grafitti - dangerous walkway!","height":75});
															thumbnails[6800929] = clik.newPhoto({"id":6800929,"src":"Reflections2_thumb.jpg","galleries_id":368890,"server_id":32,"link":"photo_6800929.html","width":130,"caption":"Reflections, Stourhead","height":100});
															thumbnails[7405133] = clik.newPhoto({"id":7405133,"src":"Steve1_thumb.jpg","galleries_id":368503,"server_id":32,"link":"photo_7405133.html","width":130,"caption":"Steve Cox ","height":179});
															thumbnails[7468984] = clik.newPhoto({"id":7468984,"src":"Sinister-Stairway_thumb.jpg","galleries_id":368502,"server_id":32,"link":"photo_7468984.html","width":130,"caption":"Sinister Stairway","height":158});
															thumbnails[7597566] = clik.newPhoto({"id":7597566,"src":"The_Dyrham_Cat_thumb.jpg","galleries_id":368502,"server_id":32,"link":"photo_7597566.html","width":130,"caption":"The Dyrham Cat","height":171});
															thumbnails[7720134] = clik.newPhoto({"id":7720134,"src":"Stepping_out_thumb.jpg","galleries_id":368502,"server_id":32,"link":"photo_7720134.html","width":130,"caption":"Striding out","height":102});
															thumbnails[7943597] = clik.newPhoto({"id":7943597,"src":"Stage-A_Colour_thumb.jpg","galleries_id":368503,"server_id":32,"link":"photo_7943597.html","width":130,"caption":"The Biker","height":76});
															thumbnails[8238167] = clik.newPhoto({"id":8238167,"src":"Hank_thumb.jpg","galleries_id":368503,"server_id":32,"link":"photo_8238167.html","width":130,"caption":"Hank","height":181});
															thumbnails[8701757] = clik.newPhoto({"id":8701757,"src":"Waterside-conversations_thumb.jpg","galleries_id":368890,"server_id":32,"link":"photo_8701757.html","width":130,"caption":"Waterside Conversations","height":98});
															thumbnails[8955649] = clik.newPhoto({"id":8955649,"src":"Sharon1_thumb.jpg","galleries_id":368503,"server_id":32,"link":"photo_8955649.html","width":130,"caption":"The Pink Veil","height":152});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  						galleries[368890] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Landscapes","link":"gallery_368890.html","maxRecords":0.0,"photoIDs":[6970534.0,6970539.0,6970570.0,6782027.0,6782072.0,6782091.0,6782094.0,6782102.0,6782113.0,6782119.0,6783115.0,6786163.0,6800929.0,8701757.0],"skipIndex":0,"section_code":"gallery","featured_images":"8701757,6970570,6970539,6970534,6800929,6786163,6783115,6782119,6782113,6782102","id":368890,"singleSection":false});				  						galleries[368502] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"This & That Gallery","link":"gallery_368502.html","maxRecords":0.0,"photoIDs":[6782490.0,6782493.0,6782494.0,6782496.0,6782497.0,6782500.0,6782502.0,6782504.0,6782508.0,6782514.0,6782518.0,6782520.0,6782529.0,6782530.0,6788772.0,6788775.0,6788776.0,6788779.0,7468984.0,7597566.0,7720134.0],"skipIndex":0,"section_code":"gallery","featured_images":"7720134,7597566,7468984,6788779,6788776,6788775,6788772,6782530,6782529,6782520","id":368502,"singleSection":false});				  						galleries[368503] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"People & Portraits","link":"gallery_368503.html","maxRecords":0.0,"photoIDs":[6782122.0,6782129.0,6782134.0,6782143.0,6782148.0,6782191.0,6782306.0,6782400.0,6782473.0,6782476.0,6782481.0,6782484.0,6782487.0,6788750.0,6788768.0,7405133.0,7943597.0,8238167.0,8955649.0],"skipIndex":0,"section_code":"gallery","featured_images":"8955649,8238167,7943597,7405133,6788768,6788750,6782487,6782484,6782481,6782476","id":368503,"singleSection":false});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[1] = '8797410';
imageSets[3] = '9084372,8955649,8955627,8797410,8701757,8564291,8396465,8238167,8064105,7943597,7890157,7720134,7597566,7468984,7405133,7241876,7139311,6999355,6970570,6970539,6970534,6800929,6788779,6788776,6788775,6788772,6788768,6788750,6787480,6786163,6783115,6782530,6782529,6782520,6782518,6782514,6782508,6782504,6782502,6782500,6782497,6782496,6782494,6782493,6782490,6782487,6782484,6782481,6782476,6782473';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 51:
		val = 'http://www12.clikpic.com/JohnL/images';
		break;
	}
		switch (server_id) {
		case 0:
		val = 'http://www.clikpic.com/JohnL/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/JohnL/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/JohnL/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/JohnL/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/JohnL/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/JohnL/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/JohnL/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/JohnL/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/JohnL/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/JohnL/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/JohnL/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/JohnL/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/JohnL/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/JohnL/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/JohnL/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/JohnL/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/JohnL/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/JohnL/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/JohnL/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/JohnL/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/JohnL/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/JohnL/images';
		break;
	}
		switch (server_id) {
		case 53:
		val = 'http://images.clikpic.com/JohnL/images';
		break;
	}
		switch (server_id) {
		case 52:
		val = 'http://tpc22/clikpic/JohnL/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/JohnL/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/JohnL/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 = 'JOHN LONG IMAGES: ' + 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>';
	}
				
				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>Order this print:</p>';
				temp += '<div class="imageinfo" id="imagePrice"><strong>' + this.purchase_instruction + '</strong> ' + (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.item_price !== '') {
			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;
	}
}

			

