window.thumbnails = {};
															thumbnails[187884] = clik.newPhoto({"id":187884,"src":"Fruitbowl 1 - website size_thumb.jpg","galleries_id":17213,"server_id":18,"link":"photo_187884.html","width":130,"caption":"Fruit Bowl","height":131});
															thumbnails[188157] = clik.newPhoto({"id":188157,"src":"rape field - website_thumb.jpg","galleries_id":17212,"server_id":18,"link":"photo_188157.html","width":130,"caption":"Rape field","height":126});
															thumbnails[188170] = clik.newPhoto({"id":188170,"src":"whitby up river - website_thumb.jpg","galleries_id":17240,"server_id":18,"link":"photo_188170.html","width":130,"caption":"Whitby up River","height":130});
															thumbnails[212905] = clik.newPhoto({"id":212905,"src":"Early Morning Light web_thumb.jpg","galleries_id":17212,"server_id":18,"link":"photo_212905.html","width":130,"caption":"Early Morning Light","height":129});
															thumbnails[402471] = clik.newPhoto({"id":402471,"src":"Cornflower Blue, Poppy Red- - web_thumb.jpg","galleries_id":17213,"server_id":18,"link":"photo_402471.html","width":130,"caption":"Still life with cornflowers and poppies<br>\r\n<br>\r\n","height":172});
															thumbnails[988942] = clik.newPhoto({"id":988942,"src":"birdsongweb_thumb.jpg","galleries_id":17240,"server_id":18,"link":"photo_988942.html","width":130,"caption":"Listen to the birdsong","height":129});
															thumbnails[1052446] = clik.newPhoto({"id":1052446,"src":"Sunshine_thumb.jpg","galleries_id":17240,"server_id":18,"link":"photo_1052446.html","width":130,"caption":"Sunlight and Shadow","height":130});
															thumbnails[1308478] = clik.newPhoto({"id":1308478,"src":"Ingleton2a_thumb.jpg","galleries_id":17240,"server_id":18,"link":"photo_1308478.html","width":130,"caption":"Woodland Stream<br>\r\n","height":132});
															thumbnails[1308699] = clik.newPhoto({"id":1308699,"src":"Blue Cast Shadow,jpg_thumb.jpg","galleries_id":17212,"server_id":18,"link":"photo_1308699.html","width":130,"caption":"Blue Cast Shadow","height":130});
															thumbnails[1308708] = clik.newPhoto({"id":1308708,"src":"Portrait of a Spruce_thumb.jpg","galleries_id":17212,"server_id":18,"link":"photo_1308708.html","width":130,"caption":"Portrait of a Larch","height":130});
															thumbnails[1308743] = clik.newPhoto({"id":1308743,"src":"Standing Proud_thumb.jpg","galleries_id":17212,"server_id":18,"link":"photo_1308743.html","width":130,"caption":"Standing Proud","height":130});
															thumbnails[1308770] = clik.newPhoto({"id":1308770,"src":"Spring Morning1_thumb.jpg","galleries_id":17212,"server_id":18,"link":"photo_1308770.html","width":130,"caption":"Spring Morning","height":132});
															thumbnails[1908328] = clik.newPhoto({"id":1908328,"src":"Fall 1 web_thumb.jpg","galleries_id":17240,"server_id":18,"link":"photo_1908328.html","width":130,"caption":"Beezley Falls, Ingleton","height":131});
															thumbnails[1908365] = clik.newPhoto({"id":1908365,"src":"Landfillweb_thumb.jpg","galleries_id":17212,"server_id":18,"link":"photo_1908365.html","width":130,"caption":"Landfill<br>\r\nWINNER OF THE TONY WILKINSON PRIZE<br>\r\n12TH OPEN AUTUMN EXHIBITION<br>\r\nTHORESBY GALLERY 2008","height":129});
															thumbnails[3086007] = clik.newPhoto({"id":3086007,"src":"YESTERDAY'S PAPER_thumb.JPG","galleries_id":189561,"server_id":18,"link":"photo_3086007.html","width":130,"caption":"Yesterday's Paper<br>\r\n","height":130});
															thumbnails[3087962] = clik.newPhoto({"id":3087962,"src":"Poolofsunlight_thumb.jpg","galleries_id":17240,"server_id":18,"link":"photo_3087962.html","width":130,"caption":"Pool of Light<br>\r\n","height":131});
															thumbnails[3096763] = clik.newPhoto({"id":3096763,"src":"Face of Rwanda_thumb.jpg","galleries_id":189561,"server_id":18,"link":"photo_3096763.html","width":130,"caption":"The Face of Rwanda","height":129});
															thumbnails[4425724] = clik.newPhoto({"id":4425724,"src":"web3_thumb.jpg","galleries_id":259067,"server_id":18,"link":"photo_4425724.html","width":130,"caption":"Dad","height":150});
															thumbnails[4425731] = clik.newPhoto({"id":4425731,"src":"girlsweb_thumb.jpg","galleries_id":259067,"server_id":18,"link":"photo_4425731.html","width":130,"caption":"Katelin and Chloe, my grandchildren","height":106});
															thumbnails[4425733] = clik.newPhoto({"id":4425733,"src":"web1_thumb.jpg","galleries_id":259067,"server_id":18,"link":"photo_4425733.html","width":130,"caption":"example portrait style","height":128});
															thumbnails[6224711] = clik.newPhoto({"id":6224711,"src":"wharfe-web1_thumb.jpg","galleries_id":17240,"server_id":18,"link":"photo_6224711.html","width":130,"caption":"'River Wharfe' (sold)","height":130});
															thumbnails[6224717] = clik.newPhoto({"id":6224717,"src":"tulip-800_thumb.jpg","galleries_id":17213,"server_id":18,"link":"photo_6224717.html","width":130,"caption":"'Dancing Tulips'","height":130});
															thumbnails[6224718] = clik.newPhoto({"id":6224718,"src":"bluespot-web_thumb.jpg","galleries_id":17213,"server_id":18,"link":"photo_6224718.html","width":130,"caption":"'Blue Spotted Tea-cup'","height":130});
															thumbnails[6256429] = clik.newPhoto({"id":6256429,"src":"rapefieldwebcomp_thumb.jpg","galleries_id":17212,"server_id":18,"link":"photo_6256429.html","width":130,"caption":"Rapefield 1","height":130});
															thumbnails[6256441] = clik.newPhoto({"id":6256441,"src":"tofirst_web_thumb.jpg","galleries_id":346843,"server_id":18,"link":"photo_6256441.html","width":130,"caption":"'To the First'<br>\r\n","height":165});
															thumbnails[6256504] = clik.newPhoto({"id":6256504,"src":"bluejugwebcomp_thumb.jpg","galleries_id":189561,"server_id":18,"link":"photo_6256504.html","width":130,"caption":"'Turquoise Jug'","height":133});
															thumbnails[6256532] = clik.newPhoto({"id":6256532,"src":"turquoise_tablecloth_web_thumb.jpg","galleries_id":189561,"server_id":18,"link":"photo_6256532.html","width":130,"caption":"'Turquoise Tablecloth'","height":131});
															thumbnails[9051080] = clik.newPhoto({"id":9051080,"src":"Birchtrees-web_thumb.jpg","galleries_id":346843,"server_id":18,"link":"photo_9051080.html","width":130,"caption":"Autumn Colour","height":132});
															thumbnails[9051087] = clik.newPhoto({"id":9051087,"src":"coolspringwater-web_thumb.jpg","galleries_id":346843,"server_id":18,"link":"photo_9051087.html","width":130,"caption":"Moor Tops","height":130});
															thumbnails[9051121] = clik.newPhoto({"id":9051121,"src":"frostycalm-web_thumb.jpg","galleries_id":346843,"server_id":18,"link":"photo_9051121.html","width":130,"caption":"Crisp Underfoot","height":130});
															thumbnails[9051125] = clik.newPhoto({"id":9051125,"src":"winterwalk-web_thumb.jpg","galleries_id":346843,"server_id":18,"link":"photo_9051125.html","width":130,"caption":"Winter Walk","height":131});
															thumbnails[6224702] = clik.newPhoto({"id":6224702,"src":"winter-800_thumb.jpg","galleries_id":346843,"server_id":18,"link":"photo_6224702.html","width":130,"caption":"'Colours of Winter'","height":131});
															thumbnails[8513974] = clik.newPhoto({"id":8513974,"src":"rob2webcompressed_thumb.jpeg","galleries_id":259067,"server_id":18,"link":"photo_8513974.html","width":130,"caption":"The model","height":173});
															thumbnails[4608646] = clik.newPhoto({"id":4608646,"src":"breakweb_thumb.jpg","galleries_id":346843,"server_id":18,"link":"photo_4608646.html","width":130,"caption":"'A Break in the Clouds'","height":129});
															thumbnails[8513983] = clik.newPhoto({"id":8513983,"src":"rob5webcompressed_thumb.jpeg","galleries_id":259067,"server_id":18,"link":"photo_8513983.html","width":130,"caption":"oil on canvas","height":151});
															thumbnails[3096694] = clik.newPhoto({"id":3096694,"src":"Strid_thumb.jpg","galleries_id":17240,"server_id":18,"link":"photo_3096694.html","width":130,"caption":"The Strid, River Wharfe","height":130});
															thumbnails[8513975] = clik.newPhoto({"id":8513975,"src":"rob1compressed_thumb.jpeg","galleries_id":259067,"server_id":18,"link":"photo_8513975.html","width":130,"caption":"model","height":182});
															thumbnails[1908338] = clik.newPhoto({"id":1908338,"src":"Ingleton 4 web_thumb.jpg","galleries_id":17240,"server_id":18,"link":"photo_1908338.html","width":130,"caption":"Thornton Falls, Ingleton","height":129});
															thumbnails[8513980] = clik.newPhoto({"id":8513980,"src":"rob3webcompressed_thumb.jpeg","galleries_id":259067,"server_id":18,"link":"photo_8513980.html","width":130,"caption":"pastel drawing","height":151});
															thumbnails[3831364] = clik.newPhoto({"id":3831364,"src":"hangingweb_thumb.jpg","galleries_id":17240,"server_id":18,"link":"photo_3831364.html","width":130,"caption":"Never Ending Journey Down<br>\r\n<br>\r\n","height":105});
															thumbnails[8513981] = clik.newPhoto({"id":8513981,"src":"rob4webcompressed_thumb.jpeg","galleries_id":259067,"server_id":18,"link":"photo_8513981.html","width":130,"caption":"oil sketch of model","height":173});
															thumbnails[3831443] = clik.newPhoto({"id":3831443,"src":"Mainstreamweb_thumb.jpg","galleries_id":17240,"server_id":18,"link":"photo_3831443.html","width":130,"caption":"Into the Mainstream","height":154});
															thumbnails[8513977] = clik.newPhoto({"id":8513977,"src":"rob6webcompressed_thumb.jpeg","galleries_id":259067,"server_id":18,"link":"photo_8513977.html","width":130,"caption":"oil from sitting model","height":169});
															thumbnails[3096643] = clik.newPhoto({"id":3096643,"src":"Fastrunning_thumb.jpg","galleries_id":17240,"server_id":18,"link":"photo_3096643.html","width":130,"caption":"Fast Running","height":129});
															thumbnails[1308701] = clik.newPhoto({"id":1308701,"src":"Down Stream_thumb.jpg","galleries_id":17240,"server_id":18,"link":"photo_1308701.html","width":130,"caption":"Rival Falls, Ingleton","height":131});
															thumbnails[6224706] = clik.newPhoto({"id":6224706,"src":"granada-web1_thumb.jpg","galleries_id":17212,"server_id":18,"link":"photo_6224706.html","width":130,"caption":"'Granada from the Palace'","height":130});
															thumbnails[4608675] = clik.newPhoto({"id":4608675,"src":"shoreweb_thumb.jpg","galleries_id":17240,"server_id":18,"link":"photo_4608675.html","width":130,"caption":"'Where Land meets Sea'","height":131});
															thumbnails[1052436] = clik.newPhoto({"id":1052436,"src":"Sunlightshadow_thumb.jpg","galleries_id":17212,"server_id":18,"link":"photo_1052436.html","width":130,"caption":"Bring Me Sunshine<br>\r\n<br>\r\nCALDER GRAPHICS PRIZE WINNER AT \"HOLMFIRTH ART WEEK' 2007","height":132});
															thumbnails[1052581] = clik.newPhoto({"id":1052581,"src":"GhostlyCoast_thumb.jpg","galleries_id":17212,"server_id":18,"link":"photo_1052581.html","width":130,"caption":"Ghostly coast(winner of the Daler-Rowney 'Make your Mark' competition 2010)","height":130});
															thumbnails[1052585] = clik.newPhoto({"id":1052585,"src":"Isolation_thumb.jpg","galleries_id":17212,"server_id":18,"link":"photo_1052585.html","width":130,"caption":"Isolation","height":128});
															thumbnails[1052577] = clik.newPhoto({"id":1052577,"src":"lilies,jpg_thumb.jpg","galleries_id":17173,"server_id":18,"link":"photo_1052577.html","width":130,"caption":"LILIES","height":129});
															thumbnails[188151] = clik.newPhoto({"id":188151,"src":"love in the mist reworked -website_thumb.jpg","galleries_id":17173,"server_id":18,"link":"photo_188151.html","width":130,"caption":"Love-in-the-Mist","height":128});
															thumbnails[188163] = clik.newPhoto({"id":188163,"src":"sunflowers - website_thumb.jpg","galleries_id":17173,"server_id":18,"link":"photo_188163.html","width":130,"caption":"Sunflowers","height":130});
															thumbnails[187882] = clik.newPhoto({"id":187882,"src":"Calla 1-website size_thumb.jpg","galleries_id":17173,"server_id":18,"link":"photo_187882.html","width":130,"caption":"Calla","height":130});
															thumbnails[187360] = clik.newPhoto({"id":187360,"src":"Lazy Daisy Days_thumb.JPG","galleries_id":17173,"server_id":18,"link":"photo_187360.html","width":130,"caption":"Lazy Daisy Days","height":130});
															thumbnails[187359] = clik.newPhoto({"id":187359,"src":"Dancing Daisies_thumb.JPG","galleries_id":17173,"server_id":18,"link":"photo_187359.html","width":130,"caption":"Dancing Daisies","height":130});
															thumbnails[187358] = clik.newPhoto({"id":187358,"src":"buzzie lizzie_thumb.JPG","galleries_id":17173,"server_id":18,"link":"photo_187358.html","width":130,"caption":"Busy Lizzie<br>\r\n<br>\r\n","height":130});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  						galleries[346843] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"NEW WORK","link":"gallery_346843.html","maxRecords":0.0,"photoIDs":[6256441.0,9051080.0,9051087.0,9051121.0,9051125.0,6224702.0,4608646.0],"skipIndex":0,"section_code":"gallery","featured_images":"6256441,6224702,4608646","id":346843,"singleSection":false});				  						galleries[259067] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"PORTRAITS","link":"gallery_259067.html","maxRecords":0.0,"photoIDs":[4425724.0,4425731.0,4425733.0,8513974.0,8513983.0,8513975.0,8513980.0,8513981.0,8513977.0],"skipIndex":0,"section_code":"gallery","featured_images":"8513983,8513981,8513980,8513977,8513975,8513974,4425733,4425731,4425724","id":259067,"singleSection":false});				  						galleries[17212] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Landscapes","link":"gallery_17212.html","maxRecords":0.0,"photoIDs":[188157.0,212905.0,1308699.0,1308708.0,1308743.0,1308770.0,1908365.0,6256429.0,6224706.0,1052436.0,1052581.0,1052585.0],"skipIndex":0,"section_code":"gallery","featured_images":"6256429,6224706,1052436","id":17212,"singleSection":false});				  						galleries[17240] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Water","link":"gallery_17240.html","maxRecords":0.0,"photoIDs":[188170.0,988942.0,1052446.0,1308478.0,1908328.0,3087962.0,6224711.0,3096694.0,1908338.0,3831364.0,3831443.0,3096643.0,1308701.0,4608675.0],"skipIndex":0,"section_code":"gallery","featured_images":3831443.0,"id":17240,"singleSection":false});				  						galleries[17213] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Still life","link":"gallery_17213.html","maxRecords":0.0,"photoIDs":[187884.0,402471.0,6224717.0,6224718.0],"skipIndex":0,"section_code":"gallery","featured_images":"6224718,6224717,402471,187884","id":17213,"singleSection":false});				  						galleries[17173] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Flowers","link":"gallery_17173.html","maxRecords":0.0,"photoIDs":[1052577.0,188151.0,188163.0,187882.0,187360.0,187359.0,187358.0],"skipIndex":0,"section_code":"gallery","featured_images":"1052577,188163","id":17173,"singleSection":false});				  						galleries[189561] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"OTHER","link":"gallery_189561.html","maxRecords":0.0,"photoIDs":[3086007.0,3096763.0,6256504.0,6256532.0],"skipIndex":0,"section_code":"gallery","featured_images":"6256532,6256504","id":189561,"singleSection":false});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[1] = '6256532,6256504,6256441,6256429,3086007,1908328,1308770,1308743,1308708,1308699,1308478,1052446,402471,188170,6224702,4608646,3096694,3831364,3831443,1308701,6224706,1052436,1052581,1052577,187358';
imageSets[2] = '6256532,6256504,6256441,6256429,6224702,4608646,3831443,6224706,1052436,1052577,188163';
imageSets[3] = '9051125,9051121,9051087,9051080,8513983,8513981,8513980,8513977,8513975,8513974,6256532,6256504,6256441,6256429,6224718,6224717,6224711,6224706,6224702,4608675,4608646,4425733,4425731,4425724,3831443,3831364,3096763,3096694,3096643,3087962,3086007,1908365,1908338,1908328,1308770,1308743,1308708,1308701,1308699,1308478,1052585,1052581,1052577,1052446,1052436,988942,402471,212905,188170,188163';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 51:
		val = 'http://www12.clikpic.com/helibor/images';
		break;
	}
		switch (server_id) {
		case 0:
		val = 'http://www.clikpic.com/helibor/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/helibor/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/helibor/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/helibor/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/helibor/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/helibor/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/helibor/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/helibor/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/helibor/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/helibor/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/helibor/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/helibor/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/helibor/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/helibor/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/helibor/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/helibor/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/helibor/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/helibor/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/helibor/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/helibor/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/helibor/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/helibor/images';
		break;
	}
		switch (server_id) {
		case 53:
		val = 'http://images.clikpic.com/helibor/images';
		break;
	}
		switch (server_id) {
		case 52:
		val = 'http://tpc22/clikpic/helibor/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/helibor/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/helibor/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 = 'HELEN CASSIDY FINE ART GALLERY: ' + photoCaption;
			    }
        if (op.$detail.length > 0) {
      	temp = op.nextPhoto.fnGetImageDetails();
	    op.$detail.fadeGalleryDetails(temp, op.speed, function(){
			if (typeof(backgrounds) != 'undefined' && op.nextPhoto == backgrounds[op.nextPhoto.id]) {
				toggleAddToCartConfirm(backgrounds, op.$detail);
			} else if (typeof(photos) != 'undefined' && op.nextPhoto == photos[op.nextPhoto.id]) {
				toggleAddToCartConfirm(photos, op.$detail);
			}
			$('body').trigger('clikUpdate.popup');
	    });
    }
        $(op.$detailContainer).find('.replaceable[class*=replaceable_photo-]').each(function(){
    	var field = clik.getPrefixedClass(this.className, 'replaceable_photo-');
    	if (field in op.nextPhoto) {
    		$(this).fadeGalleryDetails(op.nextPhoto[field], op.speed);
    	}
    }).end().find('.replaceable.photoPayment').fadeGalleryDetails(op.nextPhoto.fnGetPaymentInfo(), op.speed, function(){
		if (typeof(backgrounds) != 'undefined' && op.nextPhoto == backgrounds[op.nextPhoto.id]) {
			toggleAddToCartConfirm(backgrounds, op.$detailContainer);
		} else if (typeof(photos) != 'undefined' && op.nextPhoto == photos[op.nextPhoto.id]) {
			toggleAddToCartConfirm(photos, op.$detailContainer);
		}
		$('body').trigger('clikUpdate.popup');
	});
		if (op.$photo.length > 0) {
		html = $('<img/>',{
			'class': 'mainphoto photo',
			src: photoSrc,
			id: 'mainPic',
			name: 'mainPic',
			width: op.nextPhoto.width,
			height: op.nextPhoto.height,
			alt: photoCaption,
			css: op.css || {}
		});
		if (op.href) {
			if (op.href.match(/<a/)) {
				html = $(op.href).append(html);
			} else {
				html = $('<a/>', {
					href: op.href,
					title: photoCaption
				}).append(html);
			}
		} else {
			html = $('<a/>', {
				title: photoCaption
			}).append(html);
		}
		if (op.speed == 0) {			op.$photo.html(html);			if (op.onBefore) {			  	op.onBefore.apply(op.$photo);			}			if (op.onAfter) {			  	op.onAfter.apply(op.$photo);			}		} else {			op.$photo.stop(true,true).fadeReplaceWith(html,op.speed,'',function(){  				if (op.onAfter) {				  	op.onAfter.apply(this);				}				clik.doColumnResize(false, $(this).add(op.$detail).add(op.$title));			}, op.onBefore);
		}	}
    if (op.field) {
		op.field.value = photoId;
	} else {
		op.$photo.data('image_id', photoId);
    }
        if (!op.speed) {
      	clik.doColumnResize(false, op.$photo.add(op.$detail).add(op.$title));
    }
        
    return html;
	}

/***************************************************************************
* Toggle add to cart confirmation element and set up the click event for   *
* the 'Add to cart' button.                                                *
***************************************************************************/
function toggleAddToCartConfirm(array, root){
	if (typeof(array) !== 'object' || array === null) {
	  	array = photos;
	}
	if (!$(root).length) {		root = $('body');	}	if($('#paymentConfirm', root).length > 0){
		$('#paymentConfirm', root).hide();
		$('#paymentAddButton', root)
		.unbind()
		.click(function(){
						form = $('#paymentForm', root)[0];
			option_id = 0;
			if(form.item_option.value){
				option_id = form.item_option.value;
			}
			if(addItemToBasket(form.item_number.value,array,form.site.value,parseInt(form.quantity.value, 10),option_id)){
				if($.browser.msie){$('#paymentConfirm', root).text('Item added to cart').show();}
				else{
					$('#paymentConfirm', root).text('Item added to cart').fadeIn();
					dspOrderDetails(form.site.value);
				}
			}
			else{
				$('#paymentConfirm', root).text('Item not added - check cookies are enabled in your browser.').fadeIn();
			}
		});
	}
}

/***************************************************************************
* Get payment info for image - add as 'method' to photo object             *
***************************************************************************/
clik.photo.fnGetImageDetails = function(){
	var temp = '';
	if (this.description != '') {
		temp +=  '<div id="imageDescription">' + this.description + '</div>';
	}
		if (this.photo_ref != '') {
		temp += '<div class="imageinfo" id="imageRef"><strong>Ref: </strong>' + this.photo_ref + '</div>';
	}
		if (this.takendate != '') {
		
		temp += '<div class="imageinfo" id="imageDate"><strong>Date: </strong>' + this.takendate + '</div>';
	}
	
	if (this.location != '') {
		
		temp += '<div class="imageinfo" id="imageLocation"><strong>Location: </strong>' +  this.location + '</div>';
	}
	
	if (this.photographer != '') {
		
		temp += '<div class="imageinfo" id="imagePhotographer"><strong>Photographer: </strong>' + this.photographer + '</div>';
	}
				
				if (temp != '') {
		temp += '<div class="spacer"></div>';
	}
	return temp;
};

/***************************************************************************
* Get payment info for image - add as 'method' to photo object             *
***************************************************************************/
clik.photo.fnGetPaymentInfo = function(){
	var temp = '';
	if (this.item_price !== '') {
				temp += '<p>Order this print:</p>';
				temp += '<div class="imageinfo" id="imagePrice"><strong>' + this.purchase_instruction + '</strong> ' + (this.item_price).toFixed(2) + '</div>';
		var item_name  = this.purchase_instruction;
		var amount = (this.item_price).toFixed(2);
		var item_option  = 0;
	}
		else {
		
	}
	if (this.item_price !== '') {
			temp += '<div class="clearing">&nbsp;</div>';
	}
	return temp;};

/***************************************************************************
* Pick a photo at random from the featured images of a gallery.            *
* Gallery_id = id of gallery to choose,                                    *
* img = reference to html image in                                         *
* which to show image                                                      *
***************************************************************************/
function showGalleryImage(gallery_id, img, updateLink) {
	
	if(img){
		if (location.hash.match('galleries_id=' + gallery_id) && (imageID = location.hash.match('.*photos_id=(.+)$'))) {
		  	imageID = imageID[1];
		} else {
		  	imageID = randomListVal(galleries[gallery_id].featured_images);
		}
		
		if (imageID != 0) {
			img.src = thumbnails[imageID].src;
			img.width = thumbnails[imageID].width;
			img.height = thumbnails[imageID].height;
			img.alt = galleries[gallery_id].title;
			if (updateLink) {
				$(img).parent().attr({					title: galleries[gallery_id].title				}).filter(function(){return this.href;}).attr({					href: thumbnails[imageID].fnGalleryLink(gallery_id)				});
			}
		}
	}
}

/***************************************************************************
* If we have dynamic HTML, replace the galleries link with a list that     *
* doesn't include thecurrent gallery                                       *
***************************************************************************/
function showGalleries(gallery_id) {
		
	
	if (!basic) {
		temp = '';
		for (i = 0; i < galleries.length; i++) {
						
			
			if (galleries[i].id != gallery_id) {
								
				if (temp != '') {
					temp += ' | ';
				}
								temp += '<a href="' + galleries[i].section_code + '_' + galleries[i].id + '.html">' + galleries[i].title + '</a>';
							}
		}
		document.all.galleryLinks.innerHTML = 'Other galleries: ' + temp;
	}
}

			

