window.thumbnails = {};
															thumbnails[4977787] = clik.newPhoto({"id":4977787,"src":"galleryexample2_thumb.jpg","galleries_id":"","server_id":18,"link":"#","width":130,"caption":"gallery example","height":63});
															thumbnails[8933361] = clik.newPhoto({"id":8933361,"src":"Sunrise_thumb.jpg","galleries_id":364615,"server_id":18,"link":"photo_8933361.html","width":130,"caption":"Autumn Sunrise ","height":86});
															thumbnails[6623110] = clik.newPhoto({"id":6623110,"src":"sweet_peas_church_thumb.jpg","galleries_id":280149,"server_id":18,"link":"photo_6623110.html","width":130,"caption":"Sweet Peas in the village church","height":96});
															thumbnails[4919280] = clik.newPhoto({"id":4919280,"src":"Sandwich_Tern_thumb.jpg","galleries_id":364648,"server_id":18,"link":"photo_4919280.html","width":130,"caption":"Sandwich Tern","height":83});
															thumbnails[4971535] = clik.newPhoto({"id":4971535,"src":"Foamy_waves_thumb.jpg","galleries_id":364615,"server_id":18,"link":"photo_4971535.html","width":130,"caption":"Foamy waves","height":86});
															thumbnails[4907576] = clik.newPhoto({"id":4907576,"src":"teazles_thumb.jpg","galleries_id":364604,"server_id":18,"link":"photo_4907576.html","width":130,"caption":"Spiky teazels are great fun","height":130});
															thumbnails[4919364] = clik.newPhoto({"id":4919364,"src":"Dainty_delights1_thumb.jpg","galleries_id":280149,"server_id":18,"link":"photo_4919364.html","width":130,"caption":"Dainty summer flowers and grasses. ","height":130});
															thumbnails[4919387] = clik.newPhoto({"id":4919387,"src":"Soft_river_light_thumb.jpg","galleries_id":364615,"server_id":18,"link":"photo_4919387.html","width":130,"caption":"Soft and subtle river light","height":87});
															thumbnails[4919401] = clik.newPhoto({"id":4919401,"src":"4241435562_7218faf109_thumb.jpg","galleries_id":364615,"server_id":18,"link":"photo_4919401.html","width":130,"caption":"Winter layer-cake ","height":130});
															thumbnails[4919560] = clik.newPhoto({"id":4919560,"src":"absract_leaves_thumb.jpg","galleries_id":365304,"server_id":18,"link":"photo_4919560.html","width":130,"caption":"Abstract leaves","height":92});
															thumbnails[4919566] = clik.newPhoto({"id":4919566,"src":"Meadow_daisies_thumb.jpg","galleries_id":280149,"server_id":18,"link":"photo_4919566.html","width":130,"caption":"Meadow daisies","height":130});
															thumbnails[4919570] = clik.newPhoto({"id":4919570,"src":"bird_shaped_thumb.jpg","galleries_id":364598,"server_id":18,"link":"photo_4919570.html","width":130,"caption":"Bird-shaped flock of starlings","height":87});
															thumbnails[4919611] = clik.newPhoto({"id":4919611,"src":"blackbird_in_cherry_tree_thumb.jpg","galleries_id":364604,"server_id":18,"link":"photo_4919611.html","width":130,"caption":"Blackbird in a cherry tree","height":195});
															thumbnails[4925163] = clik.newPhoto({"id":4925163,"src":"At_anchor_at_sunset_thumb.jpg","galleries_id":364615,"server_id":18,"link":"photo_4925163.html","width":130,"caption":"At anchor at sunset","height":86});
															thumbnails[4932519] = clik.newPhoto({"id":4932519,"src":"poppies_thumb.jpg","galleries_id":280149,"server_id":18,"link":"photo_4932519.html","width":130,"caption":"Poppies and red washing","height":91});
															thumbnails[4932616] = clik.newPhoto({"id":4932616,"src":"The_light_on_the_Tyne_thumb.jpg","galleries_id":365304,"server_id":18,"link":"photo_4932616.html","width":130,"caption":"The lights on the Tyne","height":87});
															thumbnails[4932620] = clik.newPhoto({"id":4932620,"src":"seed_heads_thumb.jpg","galleries_id":280149,"server_id":18,"link":"photo_4932620.html","width":130,"caption":"Seed Heads","height":90});
															thumbnails[4932628] = clik.newPhoto({"id":4932628,"src":"Blue_tit_thumb.jpg","galleries_id":364604,"server_id":18,"link":"photo_4932628.html","width":130,"caption":"Blue tit in flight","height":86});
															thumbnails[4973075] = clik.newPhoto({"id":4973075,"src":"Pleasant_pheasant_thumb.jpg","galleries_id":364604,"server_id":18,"link":"photo_4973075.html","width":130,"caption":"Pleasant pheasant","height":130});
															thumbnails[4973076] = clik.newPhoto({"id":4973076,"src":"Daisy_daisy_thumb.jpg","galleries_id":280149,"server_id":18,"link":"photo_4973076.html","width":130,"caption":"Daisy daisy daisy","height":35});
															thumbnails[4973082] = clik.newPhoto({"id":4973082,"src":"Eden_River_thumb.jpg","galleries_id":364615,"server_id":18,"link":"photo_4973082.html","width":130,"caption":"River Eden","height":86});
															thumbnails[4976100] = clik.newPhoto({"id":4976100,"src":"butterfly_thumb.jpg","galleries_id":280149,"server_id":18,"link":"photo_4976100.html","width":130,"caption":"Red Admiral butterfly on white buddleia","height":86});
															thumbnails[5040810] = clik.newPhoto({"id":5040810,"src":"v_geese_thumb.jpg","galleries_id":364604,"server_id":18,"link":"photo_5040810.html","width":130,"caption":"V flying flock formation","height":89});
															thumbnails[5173124] = clik.newPhoto({"id":5173124,"src":"jellyfish_abstract_thumb.jpg","galleries_id":365304,"server_id":18,"link":"photo_5173124.html","width":130,"caption":"Jellyfish","height":90});
															thumbnails[5173155] = clik.newPhoto({"id":5173155,"src":"sheep_graze_copy123456_thumb.jpg","galleries_id":364604,"server_id":18,"link":"photo_5173155.html","width":130,"caption":"Hardy Herdwick sheep","height":130});
															thumbnails[5194290] = clik.newPhoto({"id":5194290,"src":"starlings1_thumb.jpg","galleries_id":364598,"server_id":18,"link":"photo_5194290.html","width":130,"caption":"Flock of starlings","height":87});
															thumbnails[5194291] = clik.newPhoto({"id":5194291,"src":"starlings2_thumb.jpg","galleries_id":364598,"server_id":18,"link":"photo_5194291.html","width":130,"caption":"Flowing like mercury","height":87});
															thumbnails[5223797] = clik.newPhoto({"id":5223797,"src":"St_Michaels_Mount_Cornwall_at_Sunset_thumb.jpg","galleries_id":364615,"server_id":18,"link":"photo_5223797.html","width":130,"caption":"St Michael's Mount, Cornwall, at sunset","height":79});
															thumbnails[6675345] = clik.newPhoto({"id":6675345,"src":"Brixham_Harbour_Devon_England_thumb.jpg","galleries_id":364615,"server_id":18,"link":"photo_6675345.html","width":130,"caption":"Brixham Harbour, Devon","height":86});
															thumbnails[6675738] = clik.newPhoto({"id":6675738,"src":"avocet_thumb.jpg","galleries_id":364648,"server_id":18,"link":"photo_6675738.html","width":130,"caption":"Avocet","height":86});
															thumbnails[6682299] = clik.newPhoto({"id":6682299,"src":"Wasp_on_spiky_bloom_thumb.jpg","galleries_id":280149,"server_id":18,"link":"photo_6682299.html","width":130,"caption":"Wasp on spiky bloom","height":86});
															thumbnails[6682306] = clik.newPhoto({"id":6682306,"src":"Iris_thumb.jpg","galleries_id":280149,"server_id":18,"link":"photo_6682306.html","width":130,"caption":"","height":98});
															thumbnails[6690298] = clik.newPhoto({"id":6690298,"src":"starling_flock_minimal_thumb.jpg","galleries_id":364604,"server_id":18,"link":"photo_6690298.html","width":130,"caption":"Starling flock minimal","height":86});
															thumbnails[7835225] = clik.newPhoto({"id":7835225,"src":"5624097137_69e3198c3d_thumb.jpg","galleries_id":364648,"server_id":18,"link":"photo_7835225.html","width":130,"caption":"Humble sparrow in cherry blossom","height":126});
															thumbnails[4925533] = clik.newPhoto({"id":4925533,"src":"Foxglove_thumb.jpg","galleries_id":280149,"server_id":18,"link":"photo_4925533.html","width":130,"caption":"Foxy foxglove","height":86});
															thumbnails[5194298] = clik.newPhoto({"id":5194298,"src":"red_dawn1_thumb.jpg","galleries_id":364615,"server_id":18,"link":"photo_5194298.html","width":130,"caption":"Vivid and beautiful dawn","height":87});
															thumbnails[4924835] = clik.newPhoto({"id":4924835,"src":"scalesceughrainbow_thumb.jpg","galleries_id":364615,"server_id":18,"link":"photo_4924835.html","width":130,"caption":"Summer storm","height":105});
															thumbnails[4925506] = clik.newPhoto({"id":4925506,"src":"Guitar_and_fairylights1_thumb.jpg","galleries_id":365304,"server_id":18,"link":"photo_4925506.html","width":130,"caption":"Guitar and faiylights","height":87});
															thumbnails[4925522] = clik.newPhoto({"id":4925522,"src":"A_1_bunch_of_tulips_thumb.jpg","galleries_id":280149,"server_id":18,"link":"photo_4925522.html","width":130,"caption":"A £1 bunch of tulips","height":130});
															thumbnails[4977886] = clik.newPhoto({"id":4977886,"src":"Wells_Beach_Huts_thumb.jpg","galleries_id":364615,"server_id":18,"link":"photo_4977886.html","width":130,"caption":"Beach Huts at Wells","height":28});
															thumbnails[4925790] = clik.newPhoto({"id":4925790,"src":"Shining_water_of_Windermere_thumb.jpg","galleries_id":364615,"server_id":18,"link":"photo_4925790.html","width":130,"caption":"Windermere with a shining Morecambe Bay beyond from 5,000 feet","height":87});
															thumbnails[4983121] = clik.newPhoto({"id":4983121,"src":"lapwings_thumb.jpg","galleries_id":365304,"server_id":18,"link":"photo_4983121.html","width":130,"caption":"Lapwings and oak tree","height":93});
															thumbnails[4925921] = clik.newPhoto({"id":4925921,"src":"Long_Meg_at_Sunset_thumb.jpg","galleries_id":364615,"server_id":18,"link":"photo_4925921.html","width":130,"caption":"Long Meg Stone Circle at sunset","height":87});
															thumbnails[4919342] = clik.newPhoto({"id":4919342,"src":"Swan_elegance_thumb.jpg","galleries_id":364648,"server_id":18,"link":"photo_4919342.html","width":130,"caption":"Swan elegance","height":198});
															thumbnails[4919361] = clik.newPhoto({"id":4919361,"src":"hellebore_thumb.jpg","galleries_id":280149,"server_id":18,"link":"photo_4919361.html","width":130,"caption":"The earliest spring flower","height":200});
															thumbnails[4919622] = clik.newPhoto({"id":4919622,"src":"sunlight_on_Lakeland_Fell_thumb.jpg","galleries_id":364615,"server_id":18,"link":"photo_4919622.html","width":130,"caption":"Sunlight on Lake District Mountainside","height":118});
															thumbnails[4925500] = clik.newPhoto({"id":4925500,"src":"Rain_streaks_and_sun_through_leaves__thumb.jpg","galleries_id":365304,"server_id":18,"link":"photo_4925500.html","width":130,"caption":"Rain streaks and sun through leaves ","height":87});
															thumbnails[4924736] = clik.newPhoto({"id":4924736,"src":"5254581064_89047510722_thumb.jpg","galleries_id":364615,"server_id":18,"link":"photo_4924736.html","width":130,"caption":"Every surface frosted","height":90});
															thumbnails[4925610] = clik.newPhoto({"id":4925610,"src":"Pink_tulip_thumb.jpg","galleries_id":280149,"server_id":18,"link":"photo_4925610.html","width":130,"caption":"Pink tulip","height":125});
															thumbnails[4932774] = clik.newPhoto({"id":4932774,"src":"Starling_finger_shape1_thumb.jpg","galleries_id":364598,"server_id":18,"link":"photo_4932774.html","width":130,"caption":"Starling flock in a finger shape","height":80});
															thumbnails[4919552] = clik.newPhoto({"id":4919552,"src":"Flying_over_the_Lake_District_thumb.jpg","galleries_id":364615,"server_id":18,"link":"photo_4919552.html","width":130,"caption":"From 5,000 feet above the Lake District Mountains","height":195});
															thumbnails[4907330] = clik.newPhoto({"id":4907330,"src":"above_waterhead_ambleside_thumb.jpg","galleries_id":364615,"server_id":18,"link":"photo_4907330.html","width":130,"caption":"Above Waterhead, Ambleside.","height":195});
															thumbnails[4924809] = clik.newPhoto({"id":4924809,"src":"Bentley_thumb.jpg","galleries_id":364604,"server_id":18,"link":"photo_4924809.html","width":130,"caption":"Vintage Bentley car","height":122});
															thumbnails[4919554] = clik.newPhoto({"id":4919554,"src":"Norfolk_coastal_creek_thumb.jpg","galleries_id":364615,"server_id":18,"link":"photo_4919554.html","width":130,"caption":"Norfolk coastal creek","height":86});
															thumbnails[4919624] = clik.newPhoto({"id":4919624,"src":"5154326081_e93567f289_thumb.jpg","galleries_id":364615,"server_id":18,"link":"photo_4919624.html","width":130,"caption":"Far Side of Ullswater","height":86});
															thumbnails[5223790] = clik.newPhoto({"id":5223790,"src":"4144975916_138a670c6d_thumb.jpg","galleries_id":364615,"server_id":18,"link":"photo_5223790.html","width":130,"caption":"Mist rising up the Pennines","height":127});
															thumbnails[4925866] = clik.newPhoto({"id":4925866,"src":"from_Sharrow_Bay_thumb.jpg","galleries_id":364615,"server_id":18,"link":"photo_4925866.html","width":130,"caption":"Beautiful winter light at Ullswater","height":195});
															thumbnails[4932643] = clik.newPhoto({"id":4932643,"src":"poppy_and_white1_thumb.jpg","galleries_id":280149,"server_id":18,"link":"photo_4932643.html","width":130,"caption":"Poppy and white flower","height":183});
															thumbnails[4919495] = clik.newPhoto({"id":4919495,"src":"Winter_dawn_thumb.jpg","galleries_id":364615,"server_id":18,"link":"photo_4919495.html","width":130,"caption":"Winter dawn","height":195});
															thumbnails[4972966] = clik.newPhoto({"id":4972966,"src":"Summer_woodland_thumb.jpg","galleries_id":364615,"server_id":18,"link":"photo_4972966.html","width":130,"caption":"Summer woodland","height":87});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  						galleries[365304] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Abstract ","link":"gallery_365304.html","maxRecords":0.0,"photoIDs":[4919560.0,4932616.0,5173124.0,4925506.0,4983121.0,4925500.0],"skipIndex":0,"section_code":"gallery","featured_images":"5173124,4932616,4925506","id":365304,"singleSection":false});				  						galleries[364615] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Landscapes","link":"gallery_364615.html","maxRecords":0.0,"photoIDs":[8933361.0,4971535.0,4919387.0,4919401.0,4925163.0,4973082.0,5223797.0,6675345.0,5194298.0,4924835.0,4977886.0,4925790.0,4925921.0,4919622.0,4924736.0,4919552.0,4907330.0,4919554.0,4919624.0,5223790.0,4925866.0,4919495.0,4972966.0],"skipIndex":0,"section_code":"gallery","featured_images":"5223797,5194298,4977886,4972966,4971535,4925790,4925163,4924736,4919624,4919401","id":364615,"singleSection":false});				  						galleries[280149] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Flora","link":"gallery_280149.html","maxRecords":0.0,"photoIDs":[6623110.0,4919364.0,4919566.0,4932519.0,4932620.0,4973076.0,4976100.0,6682299.0,6682306.0,4925533.0,4925522.0,4919361.0,4925610.0,4932643.0],"skipIndex":0,"section_code":"gallery","featured_images":"6682299,6623110,4925533","id":280149,"singleSection":false});				  						galleries[364648] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Birds","link":"gallery_364648.html","maxRecords":0.0,"photoIDs":[4919280.0,6675738.0,7835225.0,4919342.0],"skipIndex":0,"section_code":"gallery","featured_images":"6675738,4919280","id":364648,"singleSection":false});				  						galleries[364604] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Minimal","link":"gallery_364604.html","maxRecords":0.0,"photoIDs":[4907576.0,4919611.0,4932628.0,4973075.0,5040810.0,5173155.0,6690298.0,4924809.0],"skipIndex":0,"section_code":"gallery","featured_images":"5040810,4973075","id":364604,"singleSection":false});				  						galleries[364598] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Starlings","link":"gallery_364598.html","maxRecords":0.0,"photoIDs":[4919570.0,5194290.0,5194291.0,4932774.0],"skipIndex":0,"section_code":"gallery","featured_images":4919570.0,"id":364598,"singleSection":false});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[237148] = '6690298,5194291,5194290';
imageSets[1] = '8933361,7835225,6682306,5223797,5040810,4925163,4919570,4925533,5194298,4925921,4919622,5223790,4972966';
imageSets[2] = '6682299,6675738,6623110,5223797,5173124,5040810,4973075,4971535,4932616,4925163,4919570,4919401,4919280,4925533,5194298,4925506,4977886,4925790,4924736,4919624,4972966';
imageSets[3] = '4932519,4925921';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 51:
		val = 'http://www12.clikpic.com/fionae/images';
		break;
	}
		switch (server_id) {
		case 0:
		val = 'http://www.clikpic.com/fionae/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/fionae/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/fionae/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/fionae/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/fionae/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/fionae/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/fionae/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/fionae/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/fionae/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/fionae/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/fionae/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/fionae/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/fionae/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/fionae/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/fionae/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/fionae/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/fionae/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/fionae/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/fionae/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/fionae/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/fionae/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/fionae/images';
		break;
	}
		switch (server_id) {
		case 53:
		val = 'http://images.clikpic.com/fionae/images';
		break;
	}
		switch (server_id) {
		case 52:
		val = 'http://tpc22/clikpic/fionae/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/fionae/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/fionae/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 = 'Fiona Exon Photograph Prints: ' + 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="FIONAE">';
			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;
	}
}

			

