window.thumbnails = {};
															thumbnails[9045536] = clik.newPhoto({"id":9045536,"src":"18.08.11.Roadracer_2012_-1_46B78D23-24E8-5EC4-4FB8D147C346167B_thumb.jpg","galleries_id":"","server_id":15,"link":"#","width":130,"caption":"18.08.11.Roadracer 2012 -1","height":92});
															thumbnails[7247417] = clik.newPhoto({"id":7247417,"src":"redwingrobin_017_thumb.jpg","galleries_id":204318,"server_id":15,"link":"photo_7247417.html","width":130,"caption":"Xmas Robin","height":195});
															thumbnails[7247419] = clik.newPhoto({"id":7247419,"src":"redw_165_thumb.jpg","galleries_id":204318,"server_id":15,"link":"photo_7247419.html","width":130,"caption":"Red Wing","height":87});
															thumbnails[7563850] = clik.newPhoto({"id":7563850,"src":"1_edited-1_thumb.jpg","galleries_id":204318,"server_id":15,"link":"photo_7563850.html","width":130,"caption":"Busy bee","height":87});
															thumbnails[7603800] = clik.newPhoto({"id":7603800,"src":"Buzzard_1_thumb.jpg","galleries_id":204318,"server_id":15,"link":"photo_7603800.html","width":130,"caption":"Buzzard","height":87});
															thumbnails[7603803] = clik.newPhoto({"id":7603803,"src":"Buzzard_thumb.jpg","galleries_id":204318,"server_id":15,"link":"photo_7603803.html","width":130,"caption":"Buzzard","height":87});
															thumbnails[7603806] = clik.newPhoto({"id":7603806,"src":"Maple_1_thumb.jpg","galleries_id":204318,"server_id":15,"link":"photo_7603806.html","width":130,"caption":"Canadian Long Eared Owl","height":87});
															thumbnails[7603809] = clik.newPhoto({"id":7603809,"src":"Raptor_Rescue_498_edited-1_copy_thumb.jpg","galleries_id":204318,"server_id":15,"link":"photo_7603809.html","width":130,"caption":"Barn Owl & Lunch","height":195});
															thumbnails[9045466] = clik.newPhoto({"id":9045466,"src":"Bruce_Anstey_Superstock_The_Gooseneck_464C16F3-24E8-5EC4-4F60F6CD785A264C_thumb.jpg","galleries_id":392045,"server_id":15,"link":"photo_9045466.html","width":130,"caption":"Bruce Anstey Superstock The Gooseneck","height":87});
															thumbnails[9046961] = clik.newPhoto({"id":9046961,"src":"Adrian_Archibald_Scarborough_629F7209-1EC9-DFB6-0905FCF136C5C5B6_thumb.jpg","galleries_id":476804,"server_id":15,"link":"photo_9046961.html","width":130,"caption":"Adrian Archibald Scarborough","height":87});
															thumbnails[9047012] = clik.newPhoto({"id":9047012,"src":"Closer_640005C8-1EC9-DFB6-0966EFDB645732F6_thumb.jpg","galleries_id":476804,"server_id":15,"link":"photo_9047012.html","width":130,"caption":"Closer","height":87});
															thumbnails[9045467] = clik.newPhoto({"id":9045467,"src":"Gary_Johnson_Practice_Greeba_Castle_464C9CC3-24E8-5EC4-4F2166F82DA4755F_thumb.jpg","galleries_id":392045,"server_id":15,"link":"photo_9045467.html","width":130,"caption":"Gary Johnson Practice Greeba Castle","height":87});
															thumbnails[9046962] = clik.newPhoto({"id":9046962,"src":"Dave_Hewson_Spring_National_Scarborough_62A00C4B-1EC9-DFB6-09A2328D921DCEDE_thumb.jpg","galleries_id":476804,"server_id":15,"link":"photo_9046962.html","width":130,"caption":"Dave Hewson Spring National Scarborough","height":87});
															thumbnails[9047013] = clik.newPhoto({"id":9047013,"src":"David_Allingham_Thundersport_GB_64008E4E-1EC9-DFB6-09D928E48313BB3F_thumb.jpg","galleries_id":476804,"server_id":15,"link":"photo_9047013.html","width":130,"caption":"David Allingham Thundersport GB","height":87});
															thumbnails[9045468] = clik.newPhoto({"id":9045468,"src":"John_McGuinness_Practice_Greeba_Castle_464D9977-24E8-5EC4-4F5159FE902B92CB_thumb.jpg","galleries_id":392045,"server_id":15,"link":"photo_9045468.html","width":130,"caption":"John McGuinness Practice Greeba Castle","height":87});
															thumbnails[9046963] = clik.newPhoto({"id":9046963,"src":"Ian_Lougher_Scarborough_62A0A2F4-1EC9-DFB6-09BE73506383F7E2_thumb.jpg","galleries_id":476804,"server_id":15,"link":"photo_9046963.html","width":130,"caption":"Ian Lougher Scarborough","height":87});
															thumbnails[9047014] = clik.newPhoto({"id":9047014,"src":"Ian_Mackamn_The_Esses_Scarborough_6401322B-1EC9-DFB6-09B31EBC77BE2D65_thumb.jpg","galleries_id":476804,"server_id":15,"link":"photo_9047014.html","width":130,"caption":"Ian Mackamn The Esses Scarborough","height":87});
															thumbnails[9045470] = clik.newPhoto({"id":9045470,"src":"Michael_Dunlop_Superstock_The_Gooseneck_464E6E3B-24E8-5EC4-4F6CE470EC913AB7_thumb.jpg","galleries_id":392045,"server_id":15,"link":"photo_9045470.html","width":130,"caption":"Michael Dunlop Superstock The Gooseneck","height":87});
															thumbnails[9046964] = clik.newPhoto({"id":9046964,"src":"Ian_Mackman_Scarborough_62A12E0E-1EC9-DFB6-098225FA0EC9E4A3_thumb.jpg","galleries_id":476804,"server_id":15,"link":"photo_9046964.html","width":130,"caption":"Ian Mackman Scarborough","height":87});
															thumbnails[9047015] = clik.newPhoto({"id":9047015,"src":"Jamie_Hamilton_The_Esses_Scarborough_6401B113-1EC9-DFB6-09848E6AEBA86C9E_thumb.jpg","galleries_id":476804,"server_id":15,"link":"photo_9047015.html","width":130,"caption":"Jamie Hamilton The Esses Scarborough","height":87});
															thumbnails[9045471] = clik.newPhoto({"id":9045471,"src":"William_Dunlop_Practice_Greeba_Castle_464EFF4F-24E8-5EC4-4FF3E9257D67FDDA_thumb.jpg","galleries_id":392045,"server_id":15,"link":"photo_9045471.html","width":130,"caption":"William Dunlop Practice Greeba Castle","height":87});
															thumbnails[9046966] = clik.newPhoto({"id":9046966,"src":"Paul_Owen_Scarborough_62A1D14F-1EC9-DFB6-0914B1215625B0F1_thumb.jpg","galleries_id":476804,"server_id":15,"link":"photo_9046966.html","width":130,"caption":"Paul Owen Scarborough","height":87});
															thumbnails[9047016] = clik.newPhoto({"id":9047016,"src":"Michael_Dunlop_Scarborough_64025BE9-1EC9-DFB6-093A23E0A79D06ED_thumb.jpg","galleries_id":476804,"server_id":15,"link":"photo_9047016.html","width":130,"caption":"Michael Dunlop Scarborough","height":87});
															thumbnails[9046967] = clik.newPhoto({"id":9046967,"src":"Ryan_Farquahr_Spring_National_Scarborough_62A25CB6-1EC9-DFB6-0913C763E5E0859E_thumb.jpg","galleries_id":476804,"server_id":15,"link":"photo_9046967.html","width":130,"caption":"Ryan Farquhar Spring National Scarborough","height":87});
															thumbnails[9047017] = clik.newPhoto({"id":9047017,"src":"Paul_Owem_The_Esses_Scarborough_6402EBB4-1EC9-DFB6-09F92A3FDD2E1AA5_thumb.jpg","galleries_id":476804,"server_id":15,"link":"photo_9047017.html","width":130,"caption":"Paul Owem The Esses Scarborough","height":87});
															thumbnails[9047018] = clik.newPhoto({"id":9047018,"src":"Richard_McNeil_Anglesey_640357E0-1EC9-DFB6-09534C73EAC2073B_thumb.jpg","galleries_id":476804,"server_id":15,"link":"photo_9047018.html","width":130,"caption":"Richard McNeil Anglesey","height":87});
															thumbnails[9047019] = clik.newPhoto({"id":9047019,"src":"Ryan_Farquhar__Jamie_Hamilton_Mere_Scarborough_6403D4D1-1EC9-DFB6-09A0631A71D561D9_thumb.jpg","galleries_id":476804,"server_id":15,"link":"photo_9047019.html","width":130,"caption":"Ryan Farquhar & Jamie Hamilton Mere Scarborough","height":163});
															thumbnails[9047022] = clik.newPhoto({"id":9047022,"src":"Thundersport_GB_Ian_Mackman_leads_Phil_Crowe_6408BEE0-1EC9-DFB6-0930B12EBAB54817_thumb.jpg","galleries_id":476804,"server_id":15,"link":"photo_9047022.html","width":130,"caption":"Thundersport GB Ian Mackman leads Phil Crowe","height":87});
															thumbnails[9047023] = clik.newPhoto({"id":9047023,"src":"Thundersport_GB_Ian_Mackman_640956D4-1EC9-DFB6-09B0E43CEEB393BA_thumb.jpg","galleries_id":476804,"server_id":15,"link":"photo_9047023.html","width":130,"caption":"Thundersport GB Ian Mackman","height":87});
															thumbnails[9047024] = clik.newPhoto({"id":9047024,"src":"Thundersport_GB_Mallory_Park_504_6409E31D-1EC9-DFB6-09526DCC64332AF0_thumb.jpg","galleries_id":476804,"server_id":15,"link":"photo_9047024.html","width":130,"caption":"Thundersport GB Mallory ","height":87});
															thumbnails[9047025] = clik.newPhoto({"id":9047025,"src":"Thundersport_GB_Mallory_Park_640A6997-1EC9-DFB6-093E0A49624CE1A5_thumb.jpg","galleries_id":476804,"server_id":15,"link":"photo_9047025.html","width":130,"caption":"Thundersport GB Mallory Park","height":87});
															thumbnails[9047026] = clik.newPhoto({"id":9047026,"src":"Thundersport_GB_Michael_Robertson_640AF3EB-1EC9-DFB6-09524D598E7E65B9_thumb.jpg","galleries_id":476804,"server_id":15,"link":"photo_9047026.html","width":130,"caption":"Thundersport GB Michael Robertson","height":87});
															thumbnails[3493650] = clik.newPhoto({"id":3493650,"src":"documenst1_thumb.jpg","galleries_id":213623,"server_id":15,"link":"photo_3493650.html","width":130,"caption":"Special edition of the Triple Echo commemorating the Trident and Rocket 3 Owners Club Annual Rally, Beezumph 17, at Cadwell Park","height":93});
															thumbnails[3493659] = clik.newPhoto({"id":3493659,"src":"documenst 001_thumb.jpg","galleries_id":213623,"server_id":15,"link":"photo_3493659.html","width":130,"caption":"Brit Iron aplenty","height":72});
															thumbnails[3493661] = clik.newPhoto({"id":3493661,"src":"documenst 002_thumb.jpg","galleries_id":213623,"server_id":15,"link":"photo_3493661.html","width":130,"caption":"Even a Norton Rotary made an appearance on the track but the race prepared yellow Norton, top left, had all the style.","height":74});
															thumbnails[7564724] = clik.newPhoto({"id":7564724,"src":"001_thumb.jpg","galleries_id":213623,"server_id":15,"link":"photo_7564724.html","width":130,"caption":"Runcorn Weekly News","height":178});
															thumbnails[7564725] = clik.newPhoto({"id":7564725,"src":"1199709_Calendar-1_thumb.jpg","galleries_id":213623,"server_id":15,"link":"photo_7564725.html","width":130,"caption":"roadracingsupporters 2010 Calendar","height":93});
															thumbnails[7564727] = clik.newPhoto({"id":7564727,"src":"calcover_001_thumb.jpg","galleries_id":213623,"server_id":15,"link":"photo_7564727.html","width":130,"caption":"roadracingsupporters 2011 Calendar","height":95});
															thumbnails[7564729] = clik.newPhoto({"id":7564729,"src":"cal2009_001_thumb.jpg","galleries_id":213623,"server_id":15,"link":"photo_7564729.html","width":130,"caption":"roadracingsupporters 2009 Calendar","height":178});
															thumbnails[7564737] = clik.newPhoto({"id":7564737,"src":"1199722_A01_thumb.jpg","galleries_id":213623,"server_id":15,"link":"photo_7564737.html","width":130,"caption":"roadracingsupporters poster 2009","height":92});
															thumbnails[7564774] = clik.newPhoto({"id":7564774,"src":"S100July2010_001_thumb.jpg","galleries_id":213623,"server_id":15,"link":"photo_7564774.html","width":130,"caption":"Duke: Southern 100 DVD 2009","height":87});
															thumbnails[7564793] = clik.newPhoto({"id":7564793,"src":"S100DVD2010_001_thumb.jpg","galleries_id":213623,"server_id":15,"link":"photo_7564793.html","width":130,"caption":"Duke: Southern 100 DVD 2010","height":87});
															thumbnails[9045537] = clik.newPhoto({"id":9045537,"src":"18.08.11.Roadracer_2012_-10_46BA22D7-24E8-5EC4-4F8DDBA38807EEFE_thumb.jpg","galleries_id":213623,"server_id":15,"link":"photo_9045537.html","width":130,"caption":"18.08.11.Roadracer 2012 -10","height":92});
															thumbnails[9045539] = clik.newPhoto({"id":9045539,"src":"18.08.11.Roadracer_2012_-12_46BB02C5-24E8-5EC4-4F74B9B2D6C8C051_thumb.jpg","galleries_id":213623,"server_id":15,"link":"photo_9045539.html","width":130,"caption":"18.08.11.Roadracer 2012 -12","height":92});
															thumbnails[9045540] = clik.newPhoto({"id":9045540,"src":"18.08.11.Roadracer_2012_-18_46BBA1F3-24E8-5EC4-4F8E94585FA400E6_thumb.jpg","galleries_id":213623,"server_id":15,"link":"photo_9045540.html","width":130,"caption":"18.08.11.Roadracer 2012 -18","height":92});
															thumbnails[9045545] = clik.newPhoto({"id":9045545,"src":"18.08.11.Roadracer_2012_-1_46C27E2A-24E8-5EC4-4FD8946F4382521F_thumb.jpg","galleries_id":213623,"server_id":15,"link":"photo_9045545.html","width":130,"caption":"18.08.11.Roadracer 2012 -1","height":92});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  						galleries[476804] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"2011 Season Review","link":"gallery_476804.html","maxRecords":0.0,"photoIDs":[9046961.0,9047012.0,9046962.0,9047013.0,9046963.0,9047014.0,9046964.0,9047015.0,9046966.0,9047016.0,9046967.0,9047017.0,9047018.0,9047019.0,9047022.0,9047023.0,9047024.0,9047025.0,9047026.0],"skipIndex":0,"section_code":"gallery","featured_images":"9047026,9047025,9047024,9047023,9047022,9047019,9047018,9047017,9047016,9047015","id":476804,"singleSection":false});				  						galleries[392045] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"IOM TT 2011","link":"gallery_392045.html","maxRecords":0.0,"photoIDs":[9045466.0,9045467.0,9045468.0,9045470.0,9045471.0],"skipIndex":0,"section_code":"gallery","featured_images":"9045471,9045470,9045468,9045467,9045466","id":392045,"singleSection":false});				  						galleries[476805] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Oliver's Mount Scarborough 2012","link":"gallery_476805.html","maxRecords":0.0,"photoIDs":[],"skipIndex":0,"section_code":"gallery","featured_images":"","id":476805,"singleSection":false});				  						galleries[476806] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Thundersport GB 2012","link":"gallery_476806.html","maxRecords":0.0,"photoIDs":[],"skipIndex":0,"section_code":"gallery","featured_images":"","id":476806,"singleSection":false});				  						galleries[204318] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Other Stuff","link":"gallery_204318.html","maxRecords":0.0,"photoIDs":[7247417.0,7247419.0,7563850.0,7603800.0,7603803.0,7603806.0,7603809.0],"skipIndex":0,"section_code":"gallery","featured_images":"7603809,7603806,7603803,7603800,7563850,7247419,7247417","id":204318,"singleSection":false});				  						galleries[213623] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Tear sheets","link":"section262611.html","maxRecords":0.0,"photoIDs":[3493650.0,3493659.0,3493661.0,7564724.0,7564725.0,7564727.0,7564729.0,7564737.0,7564774.0,7564793.0,9045537.0,9045539.0,9045540.0,9045545.0],"skipIndex":0,"section_code":"section262611","featured_images":"9045545,9045540,9045539,9045537,7564793,7564774,7564737,7564729,7564727,7564725","id":213623,"singleSection":true});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[1] = '9047012,9045536,9045466,9045539,9045468,9045470,9046966,9045471,9047018,9047019,9047022,9047024';
imageSets[3] = '9047026,9047025,9047024,9047023,9047022,9047019,9047018,9047017,9047016,9047015,9047014,9047013,9047012,9046967,9046966,9046964,9046963,9046962,9046961,9045545,9045540,9045539,9045537,9045536,9045471,9045470,9045468,9045467,9045466,7603809,7603806,7603803,7603800,7564793,7564774,7564737,7564729,7564727,7564725,7564724,7563850,7247419,7247417,3493661,3493659,3493650';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 51:
		val = 'http://www12.clikpic.com/andyfi/images';
		break;
	}
		switch (server_id) {
		case 0:
		val = 'http://www.clikpic.com/andyfi/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/andyfi/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/andyfi/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/andyfi/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/andyfi/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/andyfi/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/andyfi/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/andyfi/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/andyfi/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/andyfi/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/andyfi/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/andyfi/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/andyfi/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/andyfi/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/andyfi/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/andyfi/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/andyfi/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/andyfi/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/andyfi/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/andyfi/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/andyfi/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/andyfi/images';
		break;
	}
		switch (server_id) {
		case 53:
		val = 'http://images.clikpic.com/andyfi/images';
		break;
	}
		switch (server_id) {
		case 52:
		val = 'http://tpc22/clikpic/andyfi/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/andyfi/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/andyfi/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 = 'alf-foto.co.uk: ' + 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="ANDYFI">';
			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;
	}
}

			

