window.thumbnails = {};
															thumbnails[627415] = clik.newPhoto({"id":627415,"src":"DSCF0020_2_thumb.JPG","galleries_id":"","server_id":18,"link":"#","width":130,"caption":"","height":163});
															thumbnails[1910143] = clik.newPhoto({"id":1910143,"src":"circus_thumb.jpg","galleries_id":"","server_id":18,"link":"#","width":130,"caption":"","height":97});
															thumbnails[6903780] = clik.newPhoto({"id":6903780,"src":"DSC0410_thumb.jpg","galleries_id":"","server_id":18,"link":"#","width":130,"caption":"","height":86});
															thumbnails[6903792] = clik.newPhoto({"id":6903792,"src":"DSC0463_thumb.jpg","galleries_id":"","server_id":18,"link":"#","width":130,"caption":"The Jade Earring","height":129});
															thumbnails[6903906] = clik.newPhoto({"id":6903906,"src":"DSC0131_thumb.jpg","galleries_id":"","server_id":18,"link":"#","width":130,"caption":"","height":181});
															thumbnails[6903912] = clik.newPhoto({"id":6903912,"src":"DSC0141_thumb.jpg","galleries_id":"","server_id":18,"link":"#","width":130,"caption":"","height":119});
															thumbnails[627475] = clik.newPhoto({"id":627475,"src":"DSCF00171_thumb.JPG","galleries_id":103433,"server_id":18,"link":"photo_627475.html","width":130,"caption":"The Opening of the Mersey Tunnel","height":98});
															thumbnails[632045] = clik.newPhoto({"id":632045,"src":"DSCF0016_thumb.JPG","galleries_id":103433,"server_id":18,"link":"photo_632045.html","width":130,"caption":"God Bless the King and His Wife Mary","height":98});
															thumbnails[632050] = clik.newPhoto({"id":632050,"src":"New-York_thumb.jpg","galleries_id":103433,"server_id":18,"link":"photo_632050.html","width":130,"caption":"The Arrival of the Queen in New York on her Maiden Voyage from Southampton","height":86});
															thumbnails[632202] = clik.newPhoto({"id":632202,"src":"Red-Polly-Yellow-Polly_thumb.jpg","galleries_id":48260,"server_id":18,"link":"photo_632202.html","width":130,"caption":"Red Polly, Yellow Polly<br>\r\n<br>\r\nSOLD","height":106});
															thumbnails[632211] = clik.newPhoto({"id":632211,"src":"DSCF0009_thumb.JPG","galleries_id":103433,"server_id":18,"link":"photo_632211.html","width":130,"caption":"Sheena Queen of the Lions","height":141});
															thumbnails[644366] = clik.newPhoto({"id":644366,"src":"DSC01492_1_thumb.JPG","galleries_id":49130,"server_id":18,"link":"photo_644366.html","width":130,"caption":"Two Eagles","height":98});
															thumbnails[681351] = clik.newPhoto({"id":681351,"src":"Sheena-colour_thumb.jpg","galleries_id":103433,"server_id":18,"link":"photo_681351.html","width":130,"caption":"Sheena Queen of the Lions","height":196});
															thumbnails[681474] = clik.newPhoto({"id":681474,"src":"Who's-a-pretty-boy,-then-_thumb.jpg","galleries_id":48260,"server_id":18,"link":"photo_681474.html","width":130,"caption":"Who's a pretty boy, then?<br>\r\n<br>\r\nSOLD","height":135});
															thumbnails[681496] = clik.newPhoto({"id":681496,"src":"The-arrival_thumb.jpg","galleries_id":48260,"server_id":18,"link":"photo_681496.html","width":130,"caption":"The Arrival of The Queen Mary in New York on her maiden voyage from Southampton","height":87});
															thumbnails[772326] = clik.newPhoto({"id":772326,"src":"Lyre-Bird_thumb.jpg","galleries_id":49130,"server_id":18,"link":"photo_772326.html","width":130,"caption":"Lyre Bird","height":173});
															thumbnails[772407] = clik.newPhoto({"id":772407,"src":"Cockatoo_thumb.jpg","galleries_id":49130,"server_id":18,"link":"photo_772407.html","width":130,"caption":"Cockatoo","height":196});
															thumbnails[772418] = clik.newPhoto({"id":772418,"src":"Bird-of-Paradise-II_thumb.jpg","galleries_id":49130,"server_id":18,"link":"photo_772418.html","width":130,"caption":"Bird of Paradise II","height":86});
															thumbnails[772443] = clik.newPhoto({"id":772443,"src":"Frog_thumb.jpg","galleries_id":49130,"server_id":18,"link":"photo_772443.html","width":130,"caption":"Frog","height":86});
															thumbnails[772455] = clik.newPhoto({"id":772455,"src":"Frogs_thumb.jpg","galleries_id":49130,"server_id":18,"link":"photo_772455.html","width":130,"caption":"Frogs","height":79});
															thumbnails[772470] = clik.newPhoto({"id":772470,"src":"Leopards_thumb.jpg","galleries_id":49130,"server_id":18,"link":"photo_772470.html","width":130,"caption":"Leopards","height":86});
															thumbnails[772496] = clik.newPhoto({"id":772496,"src":"Eagle_thumb.jpg","galleries_id":49130,"server_id":18,"link":"photo_772496.html","width":130,"caption":"Eagle","height":177});
															thumbnails[795217] = clik.newPhoto({"id":795217,"src":"5_thumb.Davies-arsenal.jpg","galleries_id":103433,"server_id":18,"link":"photo_795217.html","width":130,"caption":"The Gunners' Last Game at Highbury","height":86});
															thumbnails[921583] = clik.newPhoto({"id":921583,"src":"DSC_0124_thumb.JPG","galleries_id":103433,"server_id":18,"link":"photo_921583.html","width":130,"caption":"","height":86});
															thumbnails[925237] = clik.newPhoto({"id":925237,"src":"DSC_0133_thumb.JPG","galleries_id":48260,"server_id":18,"link":"photo_925237.html","width":130,"caption":"","height":86});
															thumbnails[925632] = clik.newPhoto({"id":925632,"src":"DSC_0118_thumb.jpg","galleries_id":70476,"server_id":18,"link":"photo_925632.html","width":130,"caption":"","height":202});
															thumbnails[925693] = clik.newPhoto({"id":925693,"src":"roundabout_thumb.jpg","galleries_id":103433,"server_id":18,"link":"photo_925693.html","width":130,"caption":"","height":89});
															thumbnails[925706] = clik.newPhoto({"id":925706,"src":"golf2_thumb.jpg","galleries_id":103433,"server_id":18,"link":"photo_925706.html","width":130,"caption":"","height":107});
															thumbnails[925754] = clik.newPhoto({"id":925754,"src":"flowers1_thumb.jpg","galleries_id":70476,"server_id":18,"link":"photo_925754.html","width":130,"caption":"","height":89});
															thumbnails[925768] = clik.newPhoto({"id":925768,"src":"flower-detail_thumb.jpg","galleries_id":70476,"server_id":18,"link":"photo_925768.html","width":130,"caption":"Detail","height":86});
															thumbnails[1502574] = clik.newPhoto({"id":1502574,"src":"sailor-leopard-stars_thumb.jpg","galleries_id":48260,"server_id":18,"link":"photo_1502574.html","width":130,"caption":"SOLD","height":105});
															thumbnails[1502661] = clik.newPhoto({"id":1502661,"src":"dentist_thumb.jpg","galleries_id":70476,"server_id":18,"link":"photo_1502661.html","width":130,"caption":"","height":150});
															thumbnails[1504446] = clik.newPhoto({"id":1504446,"src":"Clown_thumb.jpg","galleries_id":103433,"server_id":18,"link":"photo_1504446.html","width":130,"caption":"","height":149});
															thumbnails[1504447] = clik.newPhoto({"id":1504447,"src":"Cossack_thumb.jpg","galleries_id":70476,"server_id":18,"link":"photo_1504447.html","width":130,"caption":"","height":151});
															thumbnails[1504448] = clik.newPhoto({"id":1504448,"src":"couple-and-tigers_thumb.jpg","galleries_id":48260,"server_id":18,"link":"photo_1504448.html","width":130,"caption":"","height":143});
															thumbnails[1504451] = clik.newPhoto({"id":1504451,"src":"flying-man_thumb.jpg","galleries_id":70476,"server_id":18,"link":"photo_1504451.html","width":130,"caption":"<br>\r\nSOLD","height":194});
															thumbnails[1504452] = clik.newPhoto({"id":1504452,"src":"girl-and-parrot_thumb.jpg","galleries_id":48260,"server_id":18,"link":"photo_1504452.html","width":130,"caption":"SOLD","height":155});
															thumbnails[1504456] = clik.newPhoto({"id":1504456,"src":"tattooist_thumb.jpg","galleries_id":48260,"server_id":18,"link":"photo_1504456.html","width":130,"caption":"SOLD","height":117});
															thumbnails[1504457] = clik.newPhoto({"id":1504457,"src":"swiming-pool_thumb.jpg","galleries_id":70476,"server_id":18,"link":"photo_1504457.html","width":130,"caption":"","height":128});
															thumbnails[1505063] = clik.newPhoto({"id":1505063,"src":"Redparasoll2_thumb.jpg","galleries_id":48260,"server_id":18,"link":"photo_1505063.html","width":130,"caption":"The Red Parasoll","height":116});
															thumbnails[1505083] = clik.newPhoto({"id":1505083,"src":"TigerHunt_thumb.jpg","galleries_id":103433,"server_id":18,"link":"photo_1505083.html","width":130,"caption":"The Last Tiger Hunt of the British Raj - the one that got away","height":81});
															thumbnails[1505087] = clik.newPhoto({"id":1505087,"src":"singapore_thumb.jpg","galleries_id":48260,"server_id":18,"link":"photo_1505087.html","width":130,"caption":"Singapore Sling #3<br>\r\n<br>\r\nSOLD","height":128});
															thumbnails[1541705] = clik.newPhoto({"id":1541705,"src":"parrot-circus_thumb.jpg","galleries_id":48260,"server_id":18,"link":"photo_1541705.html","width":130,"caption":"SOLD","height":98});
															thumbnails[1541706] = clik.newPhoto({"id":1541706,"src":"Stick-or-Twist1_thumb.jpg","galleries_id":48260,"server_id":18,"link":"photo_1541706.html","width":130,"caption":"Stick or Twist?<br>\r\n<br>\r\nSOLD","height":87});
															thumbnails[1541718] = clik.newPhoto({"id":1541718,"src":"Arsenal11_thumb.jpg","galleries_id":48260,"server_id":18,"link":"photo_1541718.html","width":130,"caption":"The Gunners' Last Game at Highbury","height":75});
															thumbnails[2243425] = clik.newPhoto({"id":2243425,"src":"TrebleGloryManU_thumb.jpg","galleries_id":103433,"server_id":18,"link":"photo_2243425.html","width":130,"caption":"Man U Treble Celebrations, Albert Square 1999","height":98});
															thumbnails[2243709] = clik.newPhoto({"id":2243709,"src":"DSCF0015_thumb.JPG","galleries_id":49130,"server_id":18,"link":"photo_2243709.html","width":130,"caption":"Hand coloured etching","height":162});
															thumbnails[2711451] = clik.newPhoto({"id":2711451,"src":"manDSC_0096_thumb.jpg","galleries_id":48260,"server_id":18,"link":"photo_2711451.html","width":130,"caption":"Man U fans celebrate the Treble","height":87});
															thumbnails[4030229] = clik.newPhoto({"id":4030229,"src":"Suspendergirl_thumb.jpg","galleries_id":48260,"server_id":18,"link":"photo_4030229.html","width":130,"caption":"The English Maid<br>\r\n<br>\r\n","height":196});
															thumbnails[6901264] = clik.newPhoto({"id":6901264,"src":"DSC0148_thumb.jpg","galleries_id":48260,"server_id":18,"link":"photo_6901264.html","width":130,"caption":"The Appalling Mauling of Major Spawling","height":155});
															thumbnails[6901271] = clik.newPhoto({"id":6901271,"src":"DSC0364_thumb.jpg","galleries_id":70476,"server_id":18,"link":"photo_6901271.html","width":130,"caption":"Thomas Hatcher Mermaid Catcher and His Dog Dick","height":123});
															thumbnails[6901596] = clik.newPhoto({"id":6901596,"src":"Yipee_thumb.jpg","galleries_id":103433,"server_id":18,"link":"photo_6901596.html","width":130,"caption":"Yipee-Kai-Yay <br>\r\n<br>\r\n","height":85});
															thumbnails[6901601] = clik.newPhoto({"id":6901601,"src":"opwife_thumb.jpg","galleries_id":48260,"server_id":18,"link":"photo_6901601.html","width":130,"caption":"","height":92});
															thumbnails[6901607] = clik.newPhoto({"id":6901607,"src":"Cantsee_thumb.jpg","galleries_id":48260,"server_id":18,"link":"photo_6901607.html","width":130,"caption":"","height":95});
															thumbnails[6901609] = clik.newPhoto({"id":6901609,"src":"Allez_thumb.jpg","galleries_id":103433,"server_id":18,"link":"photo_6901609.html","width":130,"caption":"Allez-Oops<br>\r\n<br>\r\n","height":85});
															thumbnails[6903782] = clik.newPhoto({"id":6903782,"src":"DSC0424_thumb.jpg","galleries_id":103433,"server_id":18,"link":"photo_6903782.html","width":130,"caption":"Looking for the Lutino","height":178});
															thumbnails[6903784] = clik.newPhoto({"id":6903784,"src":"DSC0429_thumb.jpg","galleries_id":103433,"server_id":18,"link":"photo_6903784.html","width":130,"caption":"Cat & Mouse","height":200});
															thumbnails[6903787] = clik.newPhoto({"id":6903787,"src":"DSC0434_thumb.jpg","galleries_id":70476,"server_id":18,"link":"photo_6903787.html","width":130,"caption":"Untitled","height":135});
															thumbnails[6903795] = clik.newPhoto({"id":6903795,"src":"DSC0467_thumb.jpg","galleries_id":48260,"server_id":18,"link":"photo_6903795.html","width":130,"caption":"Long Live our Glorious Leader, his lady and his parrot","height":200});
															thumbnails[6903916] = clik.newPhoto({"id":6903916,"src":"DSC0268_thumb.jpg","galleries_id":48260,"server_id":18,"link":"photo_6903916.html","width":130,"caption":"","height":176});
															thumbnails[6903919] = clik.newPhoto({"id":6903919,"src":"DSC0359_thumb.jpg","galleries_id":48260,"server_id":18,"link":"photo_6903919.html","width":130,"caption":"","height":196});
															thumbnails[6903920] = clik.newPhoto({"id":6903920,"src":"DSC0361_thumb.jpg","galleries_id":70476,"server_id":18,"link":"photo_6903920.html","width":130,"caption":"","height":181});
															thumbnails[6903921] = clik.newPhoto({"id":6903921,"src":"DSC0363_thumb.jpg","galleries_id":48260,"server_id":18,"link":"photo_6903921.html","width":130,"caption":"","height":165});
															thumbnails[6903960] = clik.newPhoto({"id":6903960,"src":"master_thumb.jpg","galleries_id":48260,"server_id":18,"link":"photo_6903960.html","width":130,"caption":"","height":202});
															thumbnails[6945074] = clik.newPhoto({"id":6945074,"src":"Emirates_thumb.jpg","galleries_id":103433,"server_id":18,"link":"photo_6945074.html","width":130,"caption":"The Gunners' first league game at the Emirates<br>\r\n<br>\r\n<br>\r\n<br>\r\n","height":83});
															thumbnails[8984696] = clik.newPhoto({"id":8984696,"src":"DSC_0032_thumb.JPG","galleries_id":103433,"server_id":18,"link":"photo_8984696.html","width":130,"caption":"MRS SCHRODINGER'S CAT","height":123});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  						galleries[103433] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Printmaking","link":"gallery_103433.html","maxRecords":0.0,"photoIDs":[627475.0,632045.0,632050.0,632211.0,681351.0,795217.0,921583.0,925693.0,925706.0,1504446.0,1505083.0,2243425.0,6901596.0,6901609.0,6903782.0,6903784.0,6945074.0,8984696.0],"skipIndex":0,"section_code":"gallery","featured_images":"1505083,1504446,925706,925693,921583,795217,681351,632211,632050,632045,627475","id":103433,"singleSection":false});				  						galleries[70476] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Drawings","link":"gallery_70476.html","maxRecords":0.0,"photoIDs":[925632.0,925754.0,925768.0,1502661.0,1504447.0,1504451.0,1504457.0,6901271.0,6903787.0,6903920.0],"skipIndex":0,"section_code":"gallery","featured_images":"6903920,6903787,6901271,1504457,1504451,1504447,1502661,925768,925754,925632","id":70476,"singleSection":false});				  						galleries[48260] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Paintings","link":"gallery_48260.html","maxRecords":0.0,"photoIDs":[632202.0,681474.0,681496.0,925237.0,1502574.0,1504448.0,1504452.0,1504456.0,1505063.0,1505087.0,1541705.0,1541706.0,1541718.0,2711451.0,4030229.0,6901264.0,6901601.0,6901607.0,6903795.0,6903916.0,6903919.0,6903921.0,6903960.0],"skipIndex":0,"section_code":"gallery","featured_images":"1505087,1505063,1502574","id":48260,"singleSection":false});				  						galleries[49130] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Miki Davies","link":"gallery_49130.html","maxRecords":0.0,"photoIDs":[644366.0,772326.0,772407.0,772418.0,772443.0,772455.0,772470.0,772496.0,2243709.0],"skipIndex":0,"section_code":"gallery","featured_images":644366.0,"id":49130,"singleSection":false});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[1] = '627415';
imageSets[2] = '1505087,1505083,1505063,1504446,1502574,925706,925693,921583,795217,681351,644366,632211,632050,632045,627475';
imageSets[3] = '8984696,6945074,6903960,6903921,6903920,6903919,6903916,6903912,6903906,6903795,6903792,6903787,6903784,6903782,6903780,6901609,6901607,6901601,6901596,6901271,6901264,4030229,2711451,2243709,2243425,1910143,1541718,1541706,1541705,1505087,1505083,1505063,1504457,1504456,1504452,1504451,1504448,1504447,1504446,1502661,1502574,925768,925754,925706,925693,925632,925237,921583,795217,772496';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 51:
		val = 'http://www12.clikpic.com/mickfdavies/images';
		break;
	}
		switch (server_id) {
		case 0:
		val = 'http://www.clikpic.com/mickfdavies/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/mickfdavies/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/mickfdavies/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/mickfdavies/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/mickfdavies/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/mickfdavies/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/mickfdavies/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/mickfdavies/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/mickfdavies/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/mickfdavies/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/mickfdavies/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/mickfdavies/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/mickfdavies/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/mickfdavies/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/mickfdavies/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/mickfdavies/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/mickfdavies/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/mickfdavies/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/mickfdavies/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/mickfdavies/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/mickfdavies/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/mickfdavies/images';
		break;
	}
		switch (server_id) {
		case 53:
		val = 'http://images.clikpic.com/mickfdavies/images';
		break;
	}
		switch (server_id) {
		case 52:
		val = 'http://tpc22/clikpic/mickfdavies/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/mickfdavies/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/mickfdavies/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 = 'Mick Davies RBA: ' + 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;
	}
}

			

