window.thumbnails = {};
															thumbnails[7010396] = clik.newPhoto({"id":7010396,"src":"Sat_Superest_thumb.JPG","galleries_id":"","server_id":32,"link":"#","width":130,"caption":"Sat Superest  ","height":173});
															thumbnails[8929543] = clik.newPhoto({"id":8929543,"src":"workshop_thumb.jpg","galleries_id":"","server_id":32,"link":"#","width":130,"caption":"In the workshop","height":130});
															thumbnails[8929572] = clik.newPhoto({"id":8929572,"src":"Hope_thumb.JPG","galleries_id":"","server_id":32,"link":"#","width":130,"caption":"Relief sculpture","height":129});
															thumbnails[8564354] = clik.newPhoto({"id":8564354,"src":"Pembroke3a_thumb.JPG","galleries_id":"","server_id":32,"link":"#","width":130,"caption":"","height":173});
															thumbnails[7381143] = clik.newPhoto({"id":7381143,"src":"a_big_0012635E-1EC9-D45B-1CB68A57DF2E2562_thumb.JPG","galleries_id":459423,"server_id":32,"link":"photo_7381143.html","width":130,"caption":"a","height":190});
															thumbnails[7381148] = clik.newPhoto({"id":7381148,"src":"b_big_thumb.JPG","galleries_id":459423,"server_id":32,"link":"photo_7381148.html","width":130,"caption":"b","height":192});
															thumbnails[7381150] = clik.newPhoto({"id":7381150,"src":"c_big_thumb.JPG","galleries_id":459423,"server_id":32,"link":"photo_7381150.html","width":130,"caption":"c","height":189});
															thumbnails[7380868] = clik.newPhoto({"id":7380868,"src":"d_big_thumb.JPG","galleries_id":459423,"server_id":32,"link":"photo_7380868.html","width":130,"caption":"d","height":193});
															thumbnails[7381196] = clik.newPhoto({"id":7381196,"src":"DSCF3621_thumb.JPG","galleries_id":459423,"server_id":32,"link":"photo_7381196.html","width":130,"caption":"e","height":190});
															thumbnails[7380880] = clik.newPhoto({"id":7380880,"src":"f_big_thumb.JPG","galleries_id":459423,"server_id":32,"link":"photo_7380880.html","width":130,"caption":"f","height":192});
															thumbnails[7380971] = clik.newPhoto({"id":7380971,"src":"g_big_thumb.JPG","galleries_id":459423,"server_id":32,"link":"photo_7380971.html","width":130,"caption":"g","height":189});
															thumbnails[7381185] = clik.newPhoto({"id":7381185,"src":"h_big1_thumb.JPG","galleries_id":459423,"server_id":32,"link":"photo_7381185.html","width":130,"caption":"h","height":190});
															thumbnails[7380989] = clik.newPhoto({"id":7380989,"src":"i_big_thumb.JPG","galleries_id":459423,"server_id":32,"link":"photo_7380989.html","width":130,"caption":"i","height":192});
															thumbnails[7381060] = clik.newPhoto({"id":7381060,"src":"j_big_thumb.JPG","galleries_id":459423,"server_id":32,"link":"photo_7381060.html","width":130,"caption":"j","height":192});
															thumbnails[7381068] = clik.newPhoto({"id":7381068,"src":"k_big_thumb.JPG","galleries_id":459423,"server_id":32,"link":"photo_7381068.html","width":130,"caption":"k","height":191});
															thumbnails[7381082] = clik.newPhoto({"id":7381082,"src":"l_big_thumb.JPG","galleries_id":459423,"server_id":32,"link":"photo_7381082.html","width":130,"caption":"l","height":190});
															thumbnails[7381088] = clik.newPhoto({"id":7381088,"src":"m_big_thumb.JPG","galleries_id":459423,"server_id":32,"link":"photo_7381088.html","width":130,"caption":"m","height":189});
															thumbnails[7381093] = clik.newPhoto({"id":7381093,"src":"n_big_thumb.JPG","galleries_id":459423,"server_id":32,"link":"photo_7381093.html","width":130,"caption":"n","height":190});
															thumbnails[7381097] = clik.newPhoto({"id":7381097,"src":"o_big_thumb.JPG","galleries_id":459423,"server_id":32,"link":"photo_7381097.html","width":130,"caption":"o","height":191});
															thumbnails[7381099] = clik.newPhoto({"id":7381099,"src":"p_big_thumb.JPG","galleries_id":459423,"server_id":32,"link":"photo_7381099.html","width":130,"caption":"p","height":190});
															thumbnails[7381102] = clik.newPhoto({"id":7381102,"src":"q_big_thumb.jpg","galleries_id":459423,"server_id":32,"link":"photo_7381102.html","width":130,"caption":"q","height":190});
															thumbnails[7381111] = clik.newPhoto({"id":7381111,"src":"r_big_thumb.JPG","galleries_id":459423,"server_id":32,"link":"photo_7381111.html","width":130,"caption":"r","height":191});
															thumbnails[7381113] = clik.newPhoto({"id":7381113,"src":"s_big_thumb.JPG","galleries_id":459423,"server_id":32,"link":"photo_7381113.html","width":130,"caption":"s","height":190});
															thumbnails[7381117] = clik.newPhoto({"id":7381117,"src":"t_big_thumb.JPG","galleries_id":459423,"server_id":32,"link":"photo_7381117.html","width":130,"caption":"t","height":191});
															thumbnails[7381119] = clik.newPhoto({"id":7381119,"src":"u_big_thumb.JPG","galleries_id":459423,"server_id":32,"link":"photo_7381119.html","width":130,"caption":"u","height":191});
															thumbnails[7381122] = clik.newPhoto({"id":7381122,"src":"v_big_thumb.JPG","galleries_id":459423,"server_id":32,"link":"photo_7381122.html","width":130,"caption":"v","height":191});
															thumbnails[7381125] = clik.newPhoto({"id":7381125,"src":"w_big_thumb.JPG","galleries_id":459423,"server_id":32,"link":"photo_7381125.html","width":130,"caption":"w","height":189});
															thumbnails[7381151] = clik.newPhoto({"id":7381151,"src":"x_big_thumb.JPG","galleries_id":459423,"server_id":32,"link":"photo_7381151.html","width":130,"caption":"x","height":190});
															thumbnails[7381158] = clik.newPhoto({"id":7381158,"src":"y_big_thumb.JPG","galleries_id":459423,"server_id":32,"link":"photo_7381158.html","width":130,"caption":"y","height":191});
															thumbnails[7381161] = clik.newPhoto({"id":7381161,"src":"z_big_thumb.JPG","galleries_id":459423,"server_id":32,"link":"photo_7381161.html","width":130,"caption":"z","height":190});
															thumbnails[9027945] = clik.newPhoto({"id":9027945,"src":"Phil_Sans_thumb.jpg","galleries_id":356388,"server_id":32,"link":"photo_9027945.html","width":130,"caption":"Phil Sans","height":168});
															thumbnails[9028017] = clik.newPhoto({"id":9028017,"src":"Huw.1jpg_thumb.jpg","galleries_id":356388,"server_id":32,"link":"photo_9028017.html","width":130,"caption":"Christening Gift for Huw","height":127});
															thumbnails[9027968] = clik.newPhoto({"id":9027968,"src":"New_Arts_thumb.JPG","galleries_id":356388,"server_id":32,"link":"photo_9027968.html","width":130,"caption":"New Arts Centre gift boxes","height":173});
															thumbnails[7011524] = clik.newPhoto({"id":7011524,"src":"Thaetre_Royal_Front_thumb.JPG","galleries_id":356388,"server_id":32,"link":"photo_7011524.html","width":130,"caption":"Theatre Royal","height":98});
															thumbnails[7011529] = clik.newPhoto({"id":7011529,"src":"Theatre_Royal_1_thumb.JPG","galleries_id":356388,"server_id":32,"link":"photo_7011529.html","width":130,"caption":"Theatre Royal","height":98});
															thumbnails[7011539] = clik.newPhoto({"id":7011539,"src":"Theatre_Royal2__thumb.JPG","galleries_id":356388,"server_id":32,"link":"photo_7011539.html","width":130,"caption":"Theatre Royal","height":98});
															thumbnails[7011543] = clik.newPhoto({"id":7011543,"src":"TheatreRoyal_thumb.JPG","galleries_id":356388,"server_id":32,"link":"photo_7011543.html","width":130,"caption":"Theatre Royal","height":98});
															thumbnails[7010418] = clik.newPhoto({"id":7010418,"src":"st_Margarets02a_thumb.jpg","galleries_id":356388,"server_id":32,"link":"photo_7010418.html","width":130,"caption":"St Margaret's School, Putney","height":163});
															thumbnails[7011616] = clik.newPhoto({"id":7011616,"src":"St_Brides_thumb.jpg","galleries_id":356388,"server_id":32,"link":"photo_7011616.html","width":130,"caption":"St Brides' Church, London","height":84});
															thumbnails[7010485] = clik.newPhoto({"id":7010485,"src":"Christchurch_thumb.jpg","galleries_id":356388,"server_id":32,"link":"photo_7010485.html","width":130,"caption":"Christ Church, Oxford","height":98});
															thumbnails[6396747] = clik.newPhoto({"id":6396747,"src":"Christ_Church_thumb.jpg","galleries_id":356388,"server_id":32,"link":"photo_6396747.html","width":130,"caption":"Christ Church, Oxford","height":86});
															thumbnails[6757753] = clik.newPhoto({"id":6757753,"src":"Daniel_turner651_thumb.jpg","galleries_id":356388,"server_id":32,"link":"photo_6757753.html","width":130,"caption":"St Thomas' Hospital, London","height":84});
															thumbnails[6757745] = clik.newPhoto({"id":6757745,"src":"St_Bart_detail_thumb.jpg","galleries_id":356388,"server_id":32,"link":"photo_6757745.html","width":130,"caption":"St Bartholomew the Great","height":86});
															thumbnails[6396615] = clik.newPhoto({"id":6396615,"src":"Geological_Soc_thumb.jpg","galleries_id":356388,"server_id":32,"link":"photo_6396615.html","width":130,"caption":"Geological Society, London","height":98});
															thumbnails[7390029] = clik.newPhoto({"id":7390029,"src":"St_Georges_Windsor_thumb.jpeg","galleries_id":356388,"server_id":32,"link":"photo_7390029.html","width":130,"caption":"St Georges' Chapel, Windsor","height":130});
															thumbnails[6469078] = clik.newPhoto({"id":6469078,"src":"Pembroke3_thumb.JPG","galleries_id":356388,"server_id":32,"link":"photo_6469078.html","width":130,"caption":"Wilton House, Wiltshire","height":173});
															thumbnails[6469087] = clik.newPhoto({"id":6469087,"src":"5-Pembroke_thumb.jpg","galleries_id":356388,"server_id":32,"link":"photo_6469087.html","width":130,"caption":"Wilton House, Wiltshire.","height":98});
															thumbnails[6469106] = clik.newPhoto({"id":6469106,"src":"Pembroke_thumb.JPG","galleries_id":356388,"server_id":32,"link":"photo_6469106.html","width":130,"caption":"Wilton House. Wiltshire.","height":98});
															thumbnails[7010403] = clik.newPhoto({"id":7010403,"src":"SiLibenter_copy_thumb.jpg","galleries_id":356388,"server_id":32,"link":"photo_7010403.html","width":130,"caption":"Si Libenter","height":198});
															thumbnails[7010411] = clik.newPhoto({"id":7010411,"src":"TacchiMorris_thumb.jpg","galleries_id":356388,"server_id":32,"link":"photo_7010411.html","width":130,"caption":"Tacchi Morris Standing Stone","height":195});
															thumbnails[6469055] = clik.newPhoto({"id":6469055,"src":"Tertius1JPG_thumb.JPG","galleries_id":356388,"server_id":32,"link":"photo_6469055.html","width":130,"caption":"'For Tertius and the Birds'","height":98});
															thumbnails[6469071] = clik.newPhoto({"id":6469071,"src":"DMercersJPG_thumb.JPG","galleries_id":356388,"server_id":32,"link":"photo_6469071.html","width":130,"caption":"Mercers' Hall","height":98});
															thumbnails[6468940] = clik.newPhoto({"id":6468940,"src":"Lightbox9_thumb.JPG","galleries_id":356388,"server_id":32,"link":"photo_6468940.html","width":130,"caption":"Lightbox Gallery","height":98});
															thumbnails[7011516] = clik.newPhoto({"id":7011516,"src":"Lightbox3_thumb.JPG","galleries_id":356388,"server_id":32,"link":"photo_7011516.html","width":130,"caption":"Lightbox Gallery","height":98});
															thumbnails[6468945] = clik.newPhoto({"id":6468945,"src":"Lightbox8_thumb.JPG","galleries_id":356388,"server_id":32,"link":"photo_6468945.html","width":130,"caption":"Lightbox Gallery","height":98});
															thumbnails[6468982] = clik.newPhoto({"id":6468982,"src":"Lightbox1_thumb.JPG","galleries_id":356388,"server_id":32,"link":"photo_6468982.html","width":130,"caption":"Lightbox Gallery","height":98});
															thumbnails[7011508] = clik.newPhoto({"id":7011508,"src":"Lightbox_thumb.JPG","galleries_id":356388,"server_id":32,"link":"photo_7011508.html","width":130,"caption":"Lightbox Gallery","height":98});
															thumbnails[5934560] = clik.newPhoto({"id":5934560,"src":"Pattern_A-_thumb.JPG","galleries_id":399039,"server_id":32,"link":"photo_5934560.html","width":130,"caption":"Pattern A.","height":173});
															thumbnails[7369003] = clik.newPhoto({"id":7369003,"src":"22.01.2011_001_thumb.jpg","galleries_id":399039,"server_id":32,"link":"photo_7369003.html","width":130,"caption":"b and h","height":195});
															thumbnails[7369507] = clik.newPhoto({"id":7369507,"src":"R-_thumb.jpg","galleries_id":399039,"server_id":32,"link":"photo_7369507.html","width":130,"caption":" 'R'.","height":195});
															thumbnails[7369341] = clik.newPhoto({"id":7369341,"src":"DSCF1621_thumb.JPG","galleries_id":399039,"server_id":32,"link":"photo_7369341.html","width":130,"caption":"Polyphant 'R'.","height":173});
															thumbnails[8537687] = clik.newPhoto({"id":8537687,"src":"Magan_thumb.JPG","galleries_id":399039,"server_id":32,"link":"photo_8537687.html","width":130,"caption":"Headstone","height":173});
															thumbnails[7410214] = clik.newPhoto({"id":7410214,"src":"Magan_CofA__thumb.JPG","galleries_id":399039,"server_id":32,"link":"photo_7410214.html","width":130,"caption":"Coat of Arms","height":173});
															thumbnails[8847095] = clik.newPhoto({"id":8847095,"src":"Yield_thumb.JPG","galleries_id":399039,"server_id":32,"link":"photo_8847095.html","width":130,"caption":"Yield","height":98});
															thumbnails[7876947] = clik.newPhoto({"id":7876947,"src":"Nimbus_thumb.JPG","galleries_id":399039,"server_id":32,"link":"photo_7876947.html","width":130,"caption":"Peper Harow Church","height":77});
															thumbnails[7369410] = clik.newPhoto({"id":7369410,"src":"Gothic_thumb.JPG","galleries_id":399039,"server_id":32,"link":"photo_7369410.html","width":130,"caption":"Gothic lettering.","height":98});
															thumbnails[8539834] = clik.newPhoto({"id":8539834,"src":"P10101212_thumb.JPG","galleries_id":399039,"server_id":32,"link":"photo_8539834.html","width":130,"caption":"Sat Superest (Enough Survives)","height":98});
															thumbnails[6396369] = clik.newPhoto({"id":6396369,"src":"Affairs_of_the_Heart1_thumb.JPG","galleries_id":399039,"server_id":32,"link":"photo_6396369.html","width":130,"caption":"Affairs of the Heart","height":132});
															thumbnails[7369441] = clik.newPhoto({"id":7369441,"src":"UEL_thumb.JPG","galleries_id":399039,"server_id":32,"link":"photo_7369441.html","width":130,"caption":"University of East London","height":98});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  						galleries[459423] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Gallery","link":"section556149.html","maxRecords":0.0,"photoIDs":[7381143.0,7381148.0,7381150.0,7380868.0,7381196.0,7380880.0,7380971.0,7381185.0,7380989.0,7381060.0,7381068.0,7381082.0,7381088.0,7381093.0,7381097.0,7381099.0,7381102.0,7381111.0,7381113.0,7381117.0,7381119.0,7381122.0,7381125.0,7381151.0,7381158.0,7381161.0],"skipIndex":0,"section_code":"section556149","featured_images":"7381196,7381185,7381161,7381158,7381151,7381150,7381148,7381143,7381125,7381122","id":459423,"singleSection":true});				  						galleries[399039] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Latest work","link":"section475215.html","maxRecords":0.0,"photoIDs":[5934560.0,7369003.0,7369507.0,7369341.0,8537687.0,7410214.0,8847095.0,7876947.0,7369410.0,8539834.0,6396369.0,7369441.0],"skipIndex":0,"section_code":"section475215","featured_images":"8847095,8539834,8537687,7876947,7410214,7369507,7369441,7369410,7369341,7369003","id":399039,"singleSection":true});				  						galleries[356388] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Lettering ","link":"section421735.html","maxRecords":0.0,"photoIDs":[9027945.0,9028017.0,9027968.0,7011524.0,7011529.0,7011539.0,7011543.0,7010418.0,7011616.0,7010485.0,6396747.0,6757753.0,6757745.0,6396615.0,7390029.0,6469078.0,6469087.0,6469106.0,7010403.0,7010411.0,6469055.0,6469071.0,6468940.0,7011516.0,6468945.0,6468982.0,7011508.0],"skipIndex":0,"section_code":"section421735","featured_images":"9028017,9027968,9027945,7390029,7011616,7011543,7011539,7011529,7011524,7011516","id":356388,"singleSection":true});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[1] = '8929572,8929543,7010411,8564354';
imageSets[3] = '7381150,7380868,7381196,7380880,7380971,7381185,7380989,7381060,7381068,7381082,7381088,7381093,7381097,7381099,7381102,7381111,7381113,7381117,7381119';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 51:
		val = 'http://www12.clikpic.com/philipsurey/images';
		break;
	}
		switch (server_id) {
		case 0:
		val = 'http://www.clikpic.com/philipsurey/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/philipsurey/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/philipsurey/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/philipsurey/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/philipsurey/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/philipsurey/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/philipsurey/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/philipsurey/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/philipsurey/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/philipsurey/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/philipsurey/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/philipsurey/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/philipsurey/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/philipsurey/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/philipsurey/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/philipsurey/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/philipsurey/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/philipsurey/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/philipsurey/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/philipsurey/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/philipsurey/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/philipsurey/images';
		break;
	}
		switch (server_id) {
		case 53:
		val = 'http://images.clikpic.com/philipsurey/images';
		break;
	}
		switch (server_id) {
		case 52:
		val = 'http://tpc22/clikpic/philipsurey/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/philipsurey/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/philipsurey/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 += 'section556149.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 && 'section556149' != '') {
					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 = 'Philip Surey Sculptor: ' + 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;
	}
}

			

