window.thumbnails = {};
thumbnails[7807686] = clik.newPhoto({"link":"#","caption":"","height":98,"id":7807686,"server_id":21,"src":"crop_one_thumb.jpg","galleries_id":"","width":130});
thumbnails[8344083] = clik.newPhoto({"link":"#","caption":"","height":81,"id":8344083,"server_id":21,"src":"jilly_on_road_thumb.jpg","galleries_id":"","width":130});
thumbnails[8394312] = clik.newPhoto({"link":"#","caption":"","height":78,"id":8394312,"server_id":21,"src":"178_correct_address_thumb.jpg","galleries_id":"","width":130});
thumbnails[8403552] = clik.newPhoto({"link":"#","caption":"","height":130,"id":8403552,"server_id":21,"src":"Jilly_Morris_stitch_and_think_work_in_progress_thumb.jpg","galleries_id":"","width":130});
thumbnails[8403554] = clik.newPhoto({"link":"#","caption":"","height":130,"id":8403554,"server_id":21,"src":"drawing_jilly_morris_work_inprogress_thumb.jpg","galleries_id":"","width":130});
thumbnails[8481874] = clik.newPhoto({"link":"#","caption":"","height":52,"id":8481874,"server_id":21,"src":"178_jilly_morris_contact_thumb.jpg","galleries_id":"","width":130});
thumbnails[7815256] = clik.newPhoto({"link":"photo_7815256.html","caption":"","height":130,"id":7815256,"server_id":21,"src":"P1010035_thumb.JPG","galleries_id":438347,"width":130});
thumbnails[7815370] = clik.newPhoto({"link":"photo_7815370.html","caption":"","height":130,"id":7815370,"server_id":21,"src":"DSCF9271_thumb.JPG","galleries_id":421908,"width":130});
thumbnails[7815373] = clik.newPhoto({"link":"photo_7815373.html","caption":"","height":130,"id":7815373,"server_id":21,"src":"ice_wheel_thumb.jpg","galleries_id":421908,"width":130});
thumbnails[7815378] = clik.newPhoto({"link":"photo_7815378.html","caption":"","height":130,"id":7815378,"server_id":21,"src":"gibshiel_thumb.jpg","galleries_id":421908,"width":130});
thumbnails[7815381] = clik.newPhoto({"link":"photo_7815381.html","caption":"","height":130,"id":7815381,"server_id":21,"src":"DSCF8125_thumb.JPG","galleries_id":421908,"width":130});
thumbnails[8218594] = clik.newPhoto({"link":"photo_8218594.html","caption":"","height":130,"id":8218594,"server_id":21,"src":"176_thumb.jpg","galleries_id":438312,"width":130});
thumbnails[8218596] = clik.newPhoto({"link":"photo_8218596.html","caption":"","height":130,"id":8218596,"server_id":21,"src":"177_thumb.jpg","galleries_id":438312,"width":130});
thumbnails[8218597] = clik.newPhoto({"link":"photo_8218597.html","caption":"","height":130,"id":8218597,"server_id":21,"src":"178_thumb.jpg","galleries_id":438312,"width":130});
thumbnails[8218606] = clik.newPhoto({"link":"photo_8218606.html","caption":"","height":130,"id":8218606,"server_id":21,"src":"DSCF1319_thumb.JPG","galleries_id":438312,"width":130});
thumbnails[8218609] = clik.newPhoto({"link":"photo_8218609.html","caption":"","height":130,"id":8218609,"server_id":21,"src":"DSCF1323_thumb.JPG","galleries_id":438312,"width":130});
thumbnails[8218623] = clik.newPhoto({"link":"photo_8218623.html","caption":"","height":130,"id":8218623,"server_id":21,"src":"DSCF1340_thumb.JPG","galleries_id":438312,"width":130});
thumbnails[8218625] = clik.newPhoto({"link":"photo_8218625.html","caption":"","height":81,"id":8218625,"server_id":21,"src":"179_thumb.jpg","galleries_id":438312,"width":130});
thumbnails[8218626] = clik.newPhoto({"link":"photo_8218626.html","caption":"","height":81,"id":8218626,"server_id":21,"src":"longdrwaingsptone_thumb.jpg","galleries_id":438312,"width":130});
thumbnails[8218627] = clik.newPhoto({"link":"photo_8218627.html","caption":"","height":81,"id":8218627,"server_id":21,"src":"studio_2_thumb.jpg","galleries_id":438312,"width":130});
thumbnails[8218628] = clik.newPhoto({"link":"photo_8218628.html","caption":"","height":130,"id":8218628,"server_id":21,"src":"drawing_75E5E5D2-1E4F-37DC-71CE9479A065DB93_thumb.jpg","galleries_id":438312,"width":130});
thumbnails[8218629] = clik.newPhoto({"link":"photo_8218629.html","caption":"","height":130,"id":8218629,"server_id":21,"src":"P1010476_thumb.JPG","galleries_id":438312,"width":130});
thumbnails[8218630] = clik.newPhoto({"link":"photo_8218630.html","caption":"","height":130,"id":8218630,"server_id":21,"src":"P1010492_thumb.JPG","galleries_id":438312,"width":130});
thumbnails[8218638] = clik.newPhoto({"link":"photo_8218638.html","caption":"","height":130,"id":8218638,"server_id":21,"src":"snowy_tracks_thumb.jpg","galleries_id":421908,"width":130});
thumbnails[8218639] = clik.newPhoto({"link":"photo_8218639.html","caption":"","height":130,"id":8218639,"server_id":21,"src":"twigs_thumb.jpg","galleries_id":421908,"width":130});
thumbnails[8218658] = clik.newPhoto({"link":"photo_8218658.html","caption":"","height":130,"id":8218658,"server_id":21,"src":"DSCF2301_thumb.JPG","galleries_id":421908,"width":130});
thumbnails[8218660] = clik.newPhoto({"link":"photo_8218660.html","caption":"","height":130,"id":8218660,"server_id":21,"src":"DSCF8383_thumb.JPG","galleries_id":421908,"width":130});
thumbnails[8218672] = clik.newPhoto({"link":"photo_8218672.html","caption":"","height":130,"id":8218672,"server_id":21,"src":"horses_thumb.jpg","galleries_id":421908,"width":130});
thumbnails[8220859] = clik.newPhoto({"link":"photo_8220859.html","caption":"","height":130,"id":8220859,"server_id":21,"src":"P1010037_thumb.JPG","galleries_id":438347,"width":130});
thumbnails[8220860] = clik.newPhoto({"link":"photo_8220860.html","caption":"","height":130,"id":8220860,"server_id":21,"src":"12_nov_thumb.jpg","galleries_id":438347,"width":130});
thumbnails[8220876] = clik.newPhoto({"link":"photo_8220876.html","caption":"","height":130,"id":8220876,"server_id":21,"src":"53_two_thumb.jpg","galleries_id":438347,"width":130});
thumbnails[8220879] = clik.newPhoto({"link":"photo_8220879.html","caption":"","height":130,"id":8220879,"server_id":21,"src":"DSCF1084_thumb.JPG","galleries_id":438347,"width":130});
thumbnails[8220881] = clik.newPhoto({"link":"photo_8220881.html","caption":"","height":130,"id":8220881,"server_id":21,"src":"72_thumb.jpg","galleries_id":438347,"width":130});
thumbnails[8220895] = clik.newPhoto({"link":"photo_8220895.html","caption":"","height":130,"id":8220895,"server_id":21,"src":"walking_772DF8AC-1E4F-37DC-7109D74C764DFCD8_thumb.jpg","galleries_id":438347,"width":130});
thumbnails[8220899] = clik.newPhoto({"link":"photo_8220899.html","caption":"","height":130,"id":8220899,"server_id":21,"src":"115_thumb.jpg","galleries_id":438347,"width":130});
thumbnails[8220901] = clik.newPhoto({"link":"photo_8220901.html","caption":"","height":130,"id":8220901,"server_id":21,"src":"118_thumb.jpg","galleries_id":438347,"width":130});
thumbnails[8220908] = clik.newPhoto({"link":"photo_8220908.html","caption":"","height":130,"id":8220908,"server_id":21,"src":"alan_wallace_dec_1_thumb.JPG","galleries_id":438347,"width":130});
thumbnails[8220913] = clik.newPhoto({"link":"photo_8220913.html","caption":"","height":130,"id":8220913,"server_id":21,"src":"DSCF6961_thumb.JPG","galleries_id":438347,"width":130});
thumbnails[8222631] = clik.newPhoto({"link":"photo_8222631.html","caption":"","height":130,"id":8222631,"server_id":21,"src":"detail_panel_pins_thumb.jpg","galleries_id":438357,"width":130});
thumbnails[8229390] = clik.newPhoto({"link":"photo_8229390.html","caption":"","height":130,"id":8229390,"server_id":21,"src":"DSCF1037_thumb.JPG","galleries_id":438357,"width":130});
thumbnails[8229391] = clik.newPhoto({"link":"photo_8229391.html","caption":"","height":130,"id":8229391,"server_id":21,"src":"panel6_thumb.jpg","galleries_id":438357,"width":130});
thumbnails[8229392] = clik.newPhoto({"link":"photo_8229392.html","caption":"","height":204,"id":8229392,"server_id":21,"src":"wrinkly_panel1_thumb.jpg","galleries_id":438357,"width":130});
thumbnails[7815254] = clik.newPhoto({"link":"photo_7815254.html","caption":"","height":130,"id":7815254,"server_id":21,"src":"the_writing_on_the_wall_3_thumb.jpg","galleries_id":438324,"width":130});
thumbnails[8222636] = clik.newPhoto({"link":"photo_8222636.html","caption":"","height":130,"id":8222636,"server_id":21,"src":"P1010511_again_thumb.jpg","galleries_id":438356,"width":130});
thumbnails[8220821] = clik.newPhoto({"link":"photo_8220821.html","caption":"","height":130,"id":8220821,"server_id":21,"src":"10_thumb.jpg","galleries_id":438324,"width":130});
thumbnails[8343050] = clik.newPhoto({"link":"photo_8343050.html","caption":"","height":130,"id":8343050,"server_id":21,"src":"enamel_2_jilly_morris_thumb.jpg","galleries_id":438356,"width":130});
thumbnails[7815241] = clik.newPhoto({"link":"photo_7815241.html","caption":"","height":130,"id":7815241,"server_id":21,"src":"eight_fold_path_part_two_thumb.jpg","galleries_id":438324,"width":130});
thumbnails[8343053] = clik.newPhoto({"link":"photo_8343053.html","caption":"","height":130,"id":8343053,"server_id":21,"src":"enamel_jilly_morris_13_thumb.JPG","galleries_id":438356,"width":130});
thumbnails[8220824] = clik.newPhoto({"link":"photo_8220824.html","caption":"","height":130,"id":8220824,"server_id":21,"src":"P10100291_thumb.JPG","galleries_id":438324,"width":130});
thumbnails[8343058] = clik.newPhoto({"link":"photo_8343058.html","caption":"","height":130,"id":8343058,"server_id":21,"src":"enamel_5_jilly_morris_thumb.jpg","galleries_id":438356,"width":130});
thumbnails[8220816] = clik.newPhoto({"link":"photo_8220816.html","caption":"","height":130,"id":8220816,"server_id":21,"src":"portunes_shower_thumb.jpg","galleries_id":438324,"width":130});
thumbnails[8229396] = clik.newPhoto({"link":"photo_8229396.html","caption":"","height":204,"id":8229396,"server_id":21,"src":"panel2_thumb.jpg","galleries_id":438357,"width":130});
thumbnails[8343930] = clik.newPhoto({"link":"photo_8343930.html","caption":"","height":130,"id":8343930,"server_id":21,"src":"enamel_4_jilly_morris_thumb.jpg","galleries_id":438356,"width":130});
thumbnails[8220825] = clik.newPhoto({"link":"photo_8220825.html","caption":"","height":130,"id":8220825,"server_id":21,"src":"showertwo_thumb.jpg","galleries_id":438324,"width":130});
thumbnails[8229397] = clik.newPhoto({"link":"photo_8229397.html","caption":"","height":130,"id":8229397,"server_id":21,"src":"square_panel_hairy_thumb.jpg","galleries_id":438357,"width":130});
thumbnails[8229402] = clik.newPhoto({"link":"photo_8229402.html","caption":"","height":130,"id":8229402,"server_id":21,"src":"Square_panel_crosses_thumb.jpg","galleries_id":438357,"width":130});
thumbnails[8343933] = clik.newPhoto({"link":"photo_8343933.html","caption":"","height":130,"id":8343933,"server_id":21,"src":"enamel_6_jilly_morris_thumb.jpg","galleries_id":438356,"width":130});
thumbnails[8220840] = clik.newPhoto({"link":"photo_8220840.html","caption":"","height":130,"id":8220840,"server_id":21,"src":"113_thumb.jpg","galleries_id":438324,"width":130});
thumbnails[8343983] = clik.newPhoto({"link":"photo_8343983.html","caption":"","height":81,"id":8343983,"server_id":21,"src":"jilly_morris_enamel_3again_thumb.jpg","galleries_id":438356,"width":130});
thumbnails[8220841] = clik.newPhoto({"link":"photo_8220841.html","caption":"","height":130,"id":8220841,"server_id":21,"src":"102_thumb.jpg","galleries_id":438324,"width":130});
thumbnails[8229393] = clik.newPhoto({"link":"photo_8229393.html","caption":"","height":81,"id":8229393,"server_id":21,"src":"b_thumb.JPG","galleries_id":438357,"width":130});
thumbnails[8343117] = clik.newPhoto({"link":"photo_8343117.html","caption":"","height":81,"id":8343117,"server_id":21,"src":"buddha_skin_enamel_jilly_morris_thumb.jpg","galleries_id":438356,"width":130});
thumbnails[8220844] = clik.newPhoto({"link":"photo_8220844.html","caption":"","height":130,"id":8220844,"server_id":21,"src":"12_thumb.jpg","galleries_id":438324,"width":130});
thumbnails[8343073] = clik.newPhoto({"link":"photo_8343073.html","caption":"","height":81,"id":8343073,"server_id":21,"src":"playing_with_fire_jilly_morris_thumb.jpg","galleries_id":438356,"width":130});
thumbnails[8220846] = clik.newPhoto({"link":"photo_8220846.html","caption":"","height":130,"id":8220846,"server_id":21,"src":"DSCF2703_thumb.JPG","galleries_id":438324,"width":130});
thumbnails[8343085] = clik.newPhoto({"link":"photo_8343085.html","caption":"","height":130,"id":8343085,"server_id":21,"src":"closeup_cell_enamel_thumb.jpg","galleries_id":438356,"width":130});
thumbnails[8220848] = clik.newPhoto({"link":"photo_8220848.html","caption":"","height":130,"id":8220848,"server_id":21,"src":"Grem_thumb.jpg","galleries_id":438324,"width":130});
thumbnails[8343093] = clik.newPhoto({"link":"photo_8343093.html","caption":"","height":130,"id":8343093,"server_id":21,"src":"jilly_morris_enamel_9_thumb.jpg","galleries_id":438356,"width":130});
thumbnails[8220849] = clik.newPhoto({"link":"photo_8220849.html","caption":"","height":130,"id":8220849,"server_id":21,"src":"d_thumb.jpg","galleries_id":438324,"width":130});
thumbnails[8343109] = clik.newPhoto({"link":"photo_8343109.html","caption":"","height":130,"id":8343109,"server_id":21,"src":"enamel_jilly_morris_8_thumb.jpg","galleries_id":438356,"width":130});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
galleries[438324] = clik.newGallery({"photoIDs":[7815254,8220821,7815241,8220824,8220816,8220825,8220840,8220841,8220844,8220846,8220848,8220849],"link":"gallery_438324.html","skipIndex":0,"section_code":"gallery","id":438324,"parentGallery":"","featured_images":7815254,"maxRecords":0,"usePopups":true,"singleSection":false,"title":"site specific \/ installations"});galleries[438347] = clik.newGallery({"photoIDs":[7815256,8220859,8220860,8220876,8220879,8220881,8220895,8220899,8220901,8220908,8220913],"link":"gallery_438347.html","skipIndex":0,"section_code":"gallery","id":438347,"parentGallery":"","featured_images":7815256,"maxRecords":0,"usePopups":true,"singleSection":false,"title":"documentation artworks"});galleries[438312] = clik.newGallery({"photoIDs":[8218594,8218596,8218597,8218606,8218609,8218623,8218625,8218626,8218627,8218628,8218629,8218630],"link":"gallery_438312.html","skipIndex":0,"section_code":"gallery","id":438312,"parentGallery":"","featured_images":8218594,"maxRecords":0,"usePopups":true,"singleSection":false,"title":"Drawings"});galleries[421908] = clik.newGallery({"photoIDs":[7815370,7815373,7815378,7815381,8218638,8218639,8218658,8218660,8218672],"link":"gallery_421908.html","skipIndex":0,"section_code":"gallery","id":421908,"parentGallery":"","featured_images":7815370,"maxRecords":0,"usePopups":true,"singleSection":false,"title":"photographs"});galleries[438356] = clik.newGallery({"photoIDs":[8222636,8343050,8343053,8343058,8343930,8343933,8343983,8343117,8343073,8343085,8343093,8343109],"link":"gallery_438356.html","skipIndex":0,"section_code":"gallery","id":438356,"parentGallery":"","featured_images":8222636,"maxRecords":0,"usePopups":true,"singleSection":false,"title":"enamel artwork"});galleries[438357] = clik.newGallery({"photoIDs":[8222631,8229390,8229391,8229392,8229396,8229397,8229402,8229393],"link":"gallery_438357.html","skipIndex":0,"section_code":"gallery","id":438357,"parentGallery":"","featured_images":8222631,"maxRecords":0,"usePopups":true,"singleSection":false,"title":"porcelain paper clay artworks"});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[3] = '8344083,8229402,8229397,8229396,8229393,8229392,8229391,8229390,8222636,8222631,8220913,8220908,8220901,8220899,8220895,8220881,8220879,8220876,8220860,8220859,8220849,8220848,8220846,8220844,8220841,8220840,8220825,8220824,8220821,8220816,8218672,8218660,8218658,8218639,8218638,8218630,8218629,8218628,8218627,8218626,8218625,8218623,8218609,8218606,8218597,8218596,8218594,7815381,7815378,7815373,7815370,7815256,7815254,7815241';
imageSets[2] = '8222636,8222631,8218594,7815370,7815256,7815254';
imageSets[1] = '7807686';
imageSets[242153] = '7807686';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/jellybabe/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/jellybabe/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/jellybabe/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/jellybabe/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/jellybabe/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/jellybabe/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/jellybabe/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/jellybabe/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/jellybabe/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/jellybabe/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/jellybabe/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/jellybabe/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/jellybabe/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/jellybabe/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/jellybabe/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/jellybabe/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/jellybabe/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/jellybabe/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/jellybabe/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/jellybabe/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/jellybabe/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/jellybabe/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/jellybabe/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 && backgrounds[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 = 'Jilly Morris                                Artist: ' + 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.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="updateItemValues($(this.form).next(\'#paymentForm\')[0],this.form.payment_options_id.options[this.form.payment_options_id.options.selectedIndex].value);">';
		
		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 += '<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;
	}
}

		

