window.thumbnails = {};
															thumbnails[6389712] = clik.newPhoto({"id":6389712,"src":"The_Journey_thumb.jpg","galleries_id":350013,"server_id":5,"link":"photo_6389712.html","width":130,"caption":"The Journey","height":87});
															thumbnails[6390024] = clik.newPhoto({"id":6390024,"src":"Misty_Morning_Gower_thumb.jpg","galleries_id":353292,"server_id":5,"link":"photo_6390024.html","width":130,"caption":"Gower","height":78});
															thumbnails[6392783] = clik.newPhoto({"id":6392783,"src":"_0070380_Tenby_Pembrokeshire_Wales_thumb.jpg","galleries_id":353300,"server_id":5,"link":"photo_6392783.html","width":130,"caption":"Tenby, Pembrokeshire. Wales","height":80});
															thumbnails[6392784] = clik.newPhoto({"id":6392784,"src":"F8_206_85_Arthurs_Stone_Reynoldston_Gower_Wales_thumb.jpg","galleries_id":353300,"server_id":5,"link":"photo_6392784.html","width":130,"caption":"Arthur's Stone, Reynoldston, Gower. Wales ","height":85});
															thumbnails[6392786] = clik.newPhoto({"id":6392786,"src":"Dryslyn_Castle_BW_Neg_30_thumb.jpg","galleries_id":353300,"server_id":5,"link":"photo_6392786.html","width":130,"caption":"Dryslyn Castle, Carmarthenshire. Wales","height":86});
															thumbnails[6392790] = clik.newPhoto({"id":6392790,"src":"DSC_2276_Beaumaris_Castle_Ynys_Mon_thumb.jpg","galleries_id":353300,"server_id":5,"link":"photo_6392790.html","width":130,"caption":"Beaumaris Castle, Ynys Mon (Anglesey) Wales","height":85});
															thumbnails[6392826] = clik.newPhoto({"id":6392826,"src":"_06B0628_Pistyll_Rhaeadr_Nr_Llanrhaeadr_ym_Mochant_Denbighshire_Wales_thumb.jpg","galleries_id":353300,"server_id":5,"link":"photo_6392826.html","width":130,"caption":" Pistyll Rhaeadr, Nr Llanrhaeadr ym Mochant, Denbighshire, Wales","height":191});
															thumbnails[6392907] = clik.newPhoto({"id":6392907,"src":"Nicks_Woods_in_Ceri_Valley_Ceredigion_Wales_IR_Duotome_thumb.jpg","galleries_id":353300,"server_id":5,"link":"photo_6392907.html","width":130,"caption":"Na Tri Sidhe (The Three Fairies of the Underworld)","height":176});
															thumbnails[6435228] = clik.newPhoto({"id":6435228,"src":"3CLIFFS_thumb.jpg","galleries_id":353300,"server_id":5,"link":"photo_6435228.html","width":130,"caption":"Three Cliffs Bay, Gower","height":85});
															thumbnails[6435337] = clik.newPhoto({"id":6435337,"src":"_0070015_Newport_Pembrokeshire_Wales_thumb.jpg","galleries_id":353300,"server_id":5,"link":"photo_6435337.html","width":130,"caption":"Newport, Pembrokeshire","height":87});
															thumbnails[6435378] = clik.newPhoto({"id":6435378,"src":"Bardsey_thumb.jpg","galleries_id":353300,"server_id":5,"link":"photo_6435378.html","width":130,"caption":"Bardsey Island from Lyn Peninsula","height":87});
															thumbnails[6435379] = clik.newPhoto({"id":6435379,"src":"Diles_lake_thumb.jpg","galleries_id":353300,"server_id":5,"link":"photo_6435379.html","width":130,"caption":"Diles Lake, Llangennith, Gower","height":83});
															thumbnails[6435595] = clik.newPhoto({"id":6435595,"src":"Worm_from_Cock_st_thumb.jpg","galleries_id":353300,"server_id":5,"link":"photo_6435595.html","width":130,"caption":"Worms Head from Cock Street, Llangennith","height":82});
															thumbnails[6435651] = clik.newPhoto({"id":6435651,"src":"Lighthouse_Gower_thumb.jpg","galleries_id":353300,"server_id":5,"link":"photo_6435651.html","width":130,"caption":"Whitford Lighthouse, Gower, Wales","height":85});
															thumbnails[6435658] = clik.newPhoto({"id":6435658,"src":"Fairy_Glen_S12_thumb.jpg","galleries_id":353300,"server_id":5,"link":"photo_6435658.html","width":130,"caption":"Fairy Glen, Betws y Coed, Wales","height":84});
															thumbnails[6435669] = clik.newPhoto({"id":6435669,"src":"F18_447_81_Early_Morning_at_Burry_Green_Gower_Wales_thumb.jpg","galleries_id":353300,"server_id":5,"link":"photo_6435669.html","width":130,"caption":"Early Morning at Burry Green, Gower","height":86});
															thumbnails[6435676] = clik.newPhoto({"id":6435676,"src":"The_Journey1234_thumb.jpg","galleries_id":353300,"server_id":5,"link":"photo_6435676.html","width":130,"caption":"'The Journey' (taken at Brongest, Wales)","height":87});
															thumbnails[6435920] = clik.newPhoto({"id":6435920,"src":"Cadair_Idris_676-03_thumb.jpg","galleries_id":353300,"server_id":5,"link":"photo_6435920.html","width":130,"caption":"Cadair Idris, North Wales","height":84});
															thumbnails[6435925] = clik.newPhoto({"id":6435925,"src":"F18_480_83_Laugharne_Castle_Wales_thumb.jpg","galleries_id":353300,"server_id":5,"link":"photo_6435925.html","width":130,"caption":"Laugharne Castle, Pembrokeshire, Wales","height":86});
															thumbnails[6435936] = clik.newPhoto({"id":6435936,"src":"Sunset_over_Llangennith_v3_thumb.jpg","galleries_id":353300,"server_id":5,"link":"photo_6435936.html","width":130,"caption":"Sunset over Llangennith, Gower","height":86});
															thumbnails[6435964] = clik.newPhoto({"id":6435964,"src":"Pilgrims_Steps_St_Govans_Chapel_Pembrkeshire_thumb.jpg","galleries_id":353300,"server_id":5,"link":"photo_6435964.html","width":130,"caption":"Pilgrims Steps, St Govans, Pembrokeshire, Wales","height":200});
															thumbnails[6447435] = clik.newPhoto({"id":6447435,"src":"010_0442_Pont_Dolauhirion_thumb.jpg","galleries_id":353300,"server_id":5,"link":"photo_6447435.html","width":130,"caption":"Pont Dolauhirion, Carmarthenshire, Wales","height":86});
															thumbnails[6484253] = clik.newPhoto({"id":6484253,"src":"Roots_thumb.jpg","galleries_id":357156,"server_id":5,"link":"photo_6484253.html","width":130,"caption":"Roots","height":84});
															thumbnails[6499753] = clik.newPhoto({"id":6499753,"src":"Bardsey_8AA63FC0-1D09-001F-9974E1C2968720AB_thumb.jpg","galleries_id":357837,"server_id":5,"link":"photo_6499753.html","width":130,"caption":"Bardsey Island from Llyn Peninsula","height":87});
															thumbnails[6499755] = clik.newPhoto({"id":6499755,"src":"_06B0628_Pistyll_Rhaeadr_Nr_Llanrhaeadr_ym_Mochant_Denbighshire_Wales_55DDEC55-1D09-001F-997CBF7C28C0A9F0_thumb.jpg","galleries_id":357837,"server_id":5,"link":"photo_6499755.html","width":130,"caption":"Pistyll Rhaeadr, Nr Llanrhaeadr ym Mochant, Denbighshire, Wales","height":191});
															thumbnails[6499760] = clik.newPhoto({"id":6499760,"src":"3CLIFFS_55E2650C-1D09-001F-993337EFC5CCFA29_thumb.jpg","galleries_id":353292,"server_id":5,"link":"photo_6499760.html","width":130,"caption":"Three Cliffs Bay, Gower, Wales","height":85});
															thumbnails[6499804] = clik.newPhoto({"id":6499804,"src":"Fairy_Glen_S12_55FDB144-1D09-001F-9970F626C0D64F3B_thumb.jpg","galleries_id":357837,"server_id":5,"link":"photo_6499804.html","width":130,"caption":"Fairy Glen, Betws y Coed, Wales","height":84});
															thumbnails[6499854] = clik.newPhoto({"id":6499854,"src":"Worm_from_Cock_st_56034A5F-1D09-001F-999B6814A6301413_thumb.jpg","galleries_id":353292,"server_id":5,"link":"photo_6499854.html","width":130,"caption":"The Worms Head from Cock street, Llangennith. Gower","height":82});
															thumbnails[6499898] = clik.newPhoto({"id":6499898,"src":"F18_447_81_Early_Morning_at_Burry_Green_Gower_Wales_560E39EF-1D09-001F-990BCDE26F4D16E3_thumb.jpg","galleries_id":353292,"server_id":5,"link":"photo_6499898.html","width":130,"caption":"Early Morning at Burry Green, Gower. Wales","height":86});
															thumbnails[6547817] = clik.newPhoto({"id":6547817,"src":"Pembroke_Castle_Neg_33_thumb.jpg","galleries_id":353300,"server_id":5,"link":"photo_6547817.html","width":130,"caption":"Pembroke Castle, Wales","height":84});
															thumbnails[6547842] = clik.newPhoto({"id":6547842,"src":"Pembroke_Castle_Neg_331_thumb.jpg","galleries_id":359526,"server_id":5,"link":"photo_6547842.html","width":130,"caption":"Pembroke Castle, wales","height":84});
															thumbnails[6547843] = clik.newPhoto({"id":6547843,"src":"_0070015_Newport_Pembrokeshire_Wales_79ACC8DC-24E8-5EC4-4FCAE1937A4C9701_thumb.jpg","galleries_id":359526,"server_id":5,"link":"photo_6547843.html","width":130,"caption":"Newport, Pembrokeshire","height":87});
															thumbnails[6547845] = clik.newPhoto({"id":6547845,"src":"Sunset_over_Llangennith_v3_79AFD268-24E8-5EC4-4FC21A64390717E5_thumb.jpg","galleries_id":353292,"server_id":5,"link":"photo_6547845.html","width":130,"caption":"Sunset over Llangennith, Gower, Wales","height":86});
															thumbnails[6547846] = clik.newPhoto({"id":6547846,"src":"F18_480_83_Laugharne_Castle_Wales_79B29C5B-24E8-5EC4-4FB39E8C962E5D2E_thumb.jpg","galleries_id":359879,"server_id":5,"link":"photo_6547846.html","width":130,"caption":"Laugharne Castle","height":86});
															thumbnails[6556928] = clik.newPhoto({"id":6556928,"src":"Dryslyn_Castle_BW_Neg_30_8074F802-1D09-001F-9910488D7C471DC0_thumb.jpg","galleries_id":359879,"server_id":5,"link":"photo_6556928.html","width":130,"caption":"Dryslyn Castle","height":86});
															thumbnails[6564347] = clik.newPhoto({"id":6564347,"src":"0081551_Aberaeron_Ceredigion_Wales_thumb.jpg","galleries_id":353300,"server_id":5,"link":"photo_6564347.html","width":130,"caption":"Aberaeron","height":81});
															thumbnails[6566528] = clik.newPhoto({"id":6566528,"src":"F6_149_85_Gower_from_Llanstaphan_crop_thumb.jpg","galleries_id":353292,"server_id":5,"link":"photo_6566528.html","width":130,"caption":"Gower","height":88});
															thumbnails[6566531] = clik.newPhoto({"id":6566531,"src":"F6_149_85_Gower_from_Llanstaphan_crop1_thumb.jpg","galleries_id":353300,"server_id":5,"link":"photo_6566531.html","width":130,"caption":"Gower","height":88});
															thumbnails[6571088] = clik.newPhoto({"id":6571088,"src":"F19_458_84_Sarah_Llangennith_Beach_Towards_Worms_Head_Gower_Wales_thumb.jpg","galleries_id":353300,"server_id":5,"link":"photo_6571088.html","width":130,"caption":"Sarah, Worms Head, Gower","height":85});
															thumbnails[6571115] = clik.newPhoto({"id":6571115,"src":"Melin_Court_waterfall1_thumb.jpg","galleries_id":353300,"server_id":5,"link":"photo_6571115.html","width":130,"caption":"Melin Court Waterfall, Neath Valley, South Wales","height":198});
															thumbnails[6571122] = clik.newPhoto({"id":6571122,"src":"F19_454_84_The_Worms_Head_from_Rhossilli_Down_Gower_Wales_16bit_warm_RGB_thumb.jpg","galleries_id":353300,"server_id":5,"link":"photo_6571122.html","width":130,"caption":"Worms Head from Rhosilli Down, Gower, Wales","height":85});
															thumbnails[6571148] = clik.newPhoto({"id":6571148,"src":"Park_Woods_Gower_Wales_1983_thumb.jpg","galleries_id":353300,"server_id":5,"link":"photo_6571148.html","width":130,"caption":"Park Woods, Gower","height":86});
															thumbnails[6590526] = clik.newPhoto({"id":6590526,"src":"Swallow_Falls_BW_neg_28_thumb.jpg","galleries_id":353300,"server_id":5,"link":"photo_6590526.html","width":130,"caption":"Swallow Falls, Betws y Coed, Wales","height":198});
															thumbnails[6615347] = clik.newPhoto({"id":6615347,"src":"Diles_lake_B2B5B9DD-24E8-5EC4-4FA7674CEAF90B0E_thumb.jpg","galleries_id":353292,"server_id":5,"link":"photo_6615347.html","width":130,"caption":"Diles Lake, Llangennith, Gower. Wales","height":83});
															thumbnails[6392654] = clik.newPhoto({"id":6392654,"src":"F18_547_82_The_Wreck_of_the_Helvetia_Worms_Head_Gower_Wales_thumb.jpg","galleries_id":353292,"server_id":5,"link":"photo_6392654.html","width":130,"caption":"The Wreck of the Helvetia<br>\r\nWorms Head<br>\r\nGower","height":85});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  						galleries[359879] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Carmarthenshire","link":"gallery_359879.html","maxRecords":0.0,"photoIDs":[6547846.0,6556928.0],"skipIndex":0,"section_code":"gallery","featured_images":"6556928,6547846","id":359879,"singleSection":false});				  						galleries[359526] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Pembrokeshire","link":"gallery_359526.html","maxRecords":0.0,"photoIDs":[6547842.0,6547843.0],"skipIndex":0,"section_code":"gallery","featured_images":"6547843,6547842","id":359526,"singleSection":false});				  						galleries[353292] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Gower","link":"gallery_353292.html","maxRecords":0.0,"photoIDs":[6390024.0,6499760.0,6499854.0,6499898.0,6547845.0,6566528.0,6615347.0,6392654.0],"skipIndex":0,"section_code":"gallery","featured_images":"6615347,6566528,6547845,6499898,6499760,6392654,6390024","id":353292,"singleSection":false});				  						galleries[357837] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"North Wales","link":"gallery_357837.html","maxRecords":0.0,"photoIDs":[6499753.0,6499755.0,6499804.0],"skipIndex":0,"section_code":"gallery","featured_images":"6499804,6499753","id":357837,"singleSection":false});				  						galleries[350013] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Ceredigion","link":"gallery_350013.html","maxRecords":0.0,"photoIDs":[6389712.0],"skipIndex":0,"section_code":"gallery","featured_images":6389712.0,"id":350013,"singleSection":false});				  						galleries[357156] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Figure","link":"gallery_357156.html","maxRecords":0.0,"photoIDs":[6484253.0],"skipIndex":0,"section_code":"gallery","featured_images":6484253.0,"id":357156,"singleSection":false});				  						galleries[353300] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Cards","link":"gallery_353300.html","maxRecords":0.0,"photoIDs":[6392783.0,6392784.0,6392786.0,6392790.0,6392826.0,6392907.0,6435228.0,6435337.0,6435378.0,6435379.0,6435595.0,6435651.0,6435658.0,6435669.0,6435676.0,6435920.0,6435925.0,6435936.0,6435964.0,6447435.0,6547817.0,6564347.0,6566531.0,6571088.0,6571115.0,6571122.0,6571148.0,6590526.0],"skipIndex":0,"section_code":"gallery","featured_images":"6571148,6571122,6571088,6564347,6447435,6435936,6435925,6435920,6435669,6435651,6435595,6435228,6392790,6392786,6392784,6392783","id":353300,"singleSection":false});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[1] = '6615347,6571122,6566528,6556928,6547845,6547843,6547842,6499898,6499760,6499753,6484253,6435920,6435669,6435651,6435595,6435228,6390024,6389712,6392654';
imageSets[2] = '6615347,6571148,6571122,6571088,6566528,6564347,6556928,6547846,6547845,6547843,6547842,6499898,6499804,6499760,6499753,6484253,6447435,6435936,6435925,6435920,6435669,6435651,6435595,6435228,6392790,6392786,6392784,6392783,6390024,6389712,6392654';
imageSets[3] = '6615347,6590526,6571148,6571122,6571115,6571088,6566531,6566528,6564347,6556928,6547846,6547845,6547843,6547842,6547817,6499898,6499854,6499804,6499760,6499755,6499753,6484253,6447435,6435964,6435936,6435925,6435920,6435676,6435669,6435658,6435651,6435595,6435379,6435378,6435337,6435228,6392907,6392826,6392790,6392786,6392784,6392783,6392654,6390024,6389712';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 51:
		val = 'http://www12.clikpic.com/johnkeatesphoto/images';
		break;
	}
		switch (server_id) {
		case 0:
		val = 'http://www.clikpic.com/johnkeatesphoto/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/johnkeatesphoto/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/johnkeatesphoto/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/johnkeatesphoto/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/johnkeatesphoto/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/johnkeatesphoto/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/johnkeatesphoto/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/johnkeatesphoto/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/johnkeatesphoto/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/johnkeatesphoto/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/johnkeatesphoto/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/johnkeatesphoto/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/johnkeatesphoto/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/johnkeatesphoto/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/johnkeatesphoto/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/johnkeatesphoto/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/johnkeatesphoto/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/johnkeatesphoto/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/johnkeatesphoto/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/johnkeatesphoto/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/johnkeatesphoto/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/johnkeatesphoto/images';
		break;
	}
		switch (server_id) {
		case 53:
		val = 'http://images.clikpic.com/johnkeatesphoto/images';
		break;
	}
		switch (server_id) {
		case 52:
		val = 'http://tpc22/clikpic/johnkeatesphoto/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/johnkeatesphoto/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/johnkeatesphoto/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 Keates Photography: ' + 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="JOHNKEATESPHOTO">';
			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;
	}
}

			

