window.thumbnails = {};
															thumbnails[4651224] = clik.newPhoto({"id":4651224,"src":"Triptych-women-2nd-version_thumb.jpg","galleries_id":37113,"server_id":18,"link":"photo_4651224.html","width":130,"caption":"The Triptych Women, 2009.","height":62});
															thumbnails[4684203] = clik.newPhoto({"id":4684203,"src":"Three-Men-and-A-Black-Strip_thumb.jpg","galleries_id":37113,"server_id":18,"link":"photo_4684203.html","width":130,"caption":"Three Men and a Black Stripe, 2009.","height":95});
															thumbnails[5921022] = clik.newPhoto({"id":5921022,"src":"Collage-Nude_thumb.jpg","galleries_id":37116,"server_id":18,"link":"photo_5921022.html","width":130,"caption":"Eve, 2010.","height":175});
															thumbnails[6325271] = clik.newPhoto({"id":6325271,"src":"S_thumb.jpg","galleries_id":350752,"server_id":18,"link":"photo_6325271.html","width":130,"caption":"Relaxing, 2010.","height":91});
															thumbnails[6709506] = clik.newPhoto({"id":6709506,"src":"Untitled-Nude-web_thumb.jpg","galleries_id":37116,"server_id":18,"link":"photo_6709506.html","width":130,"caption":"Female Nude #12, 2010.","height":130});
															thumbnails[6709508] = clik.newPhoto({"id":6709508,"src":"x3_thumb.jpg","galleries_id":37116,"server_id":18,"link":"photo_6709508.html","width":130,"caption":"x3, 2010.","height":97});
															thumbnails[7082220] = clik.newPhoto({"id":7082220,"src":"Man-Sat-Down_thumb.jpg","galleries_id":350752,"server_id":18,"link":"photo_7082220.html","width":130,"caption":"Man Sat Down, 2010.","height":168});
															thumbnails[7082229] = clik.newPhoto({"id":7082229,"src":"Perched_on_the_Edge_thumb.jpg","galleries_id":350752,"server_id":18,"link":"photo_7082229.html","width":130,"caption":"Perched on the Edge, 2010.","height":59});
															thumbnails[7082232] = clik.newPhoto({"id":7082232,"src":"Ready_thumb.jpg","galleries_id":350752,"server_id":18,"link":"photo_7082232.html","width":130,"caption":"Ready, 2010.","height":65});
															thumbnails[7082240] = clik.newPhoto({"id":7082240,"src":"Sitting-Down-Man_thumb.jpg","galleries_id":350752,"server_id":18,"link":"photo_7082240.html","width":130,"caption":"Sitting Down Man, 2010.","height":51});
															thumbnails[7082272] = clik.newPhoto({"id":7082272,"src":"Sleeping-Man_thumb.jpg","galleries_id":350752,"server_id":18,"link":"photo_7082272.html","width":130,"caption":"Sleeping Man, 2010.","height":31});
															thumbnails[7082285] = clik.newPhoto({"id":7082285,"src":"Woman-Lying-Down1_thumb.jpg","galleries_id":350752,"server_id":18,"link":"photo_7082285.html","width":130,"caption":"Woman Lying Down, 2010.","height":45});
															thumbnails[8289507] = clik.newPhoto({"id":8289507,"src":"6-ways-to-stand_thumb.jpg","galleries_id":37116,"server_id":18,"link":"photo_8289507.html","width":130,"caption":"Six Ways, 2011.","height":84});
															thumbnails[8289508] = clik.newPhoto({"id":8289508,"src":"Upwards_thumb.jpg","galleries_id":37116,"server_id":18,"link":"photo_8289508.html","width":130,"caption":"Upwards, 2011.","height":28});
															thumbnails[8289509] = clik.newPhoto({"id":8289509,"src":"Getting-Up_thumb.jpg","galleries_id":37116,"server_id":18,"link":"photo_8289509.html","width":130,"caption":"Getting Up, 2011.","height":41});
															thumbnails[6605573] = clik.newPhoto({"id":6605573,"src":"Collage-4_thumb.jpg","galleries_id":37116,"server_id":18,"link":"photo_6605573.html","width":130,"caption":"Collaged Nude 3, 2010.","height":132});
															thumbnails[6324584] = clik.newPhoto({"id":6324584,"src":"Many-Heads-web_thumb.jpg","galleries_id":37116,"server_id":18,"link":"photo_6324584.html","width":130,"caption":"Many Heads, 2010.","height":129});
															thumbnails[8215173] = clik.newPhoto({"id":8215173,"src":"Books-7_thumb.jpg","galleries_id":438175,"server_id":18,"link":"photo_8215173.html","width":130,"caption":"","height":98});
															thumbnails[6324578] = clik.newPhoto({"id":6324578,"src":"How-do-you-exercise-5-web_thumb.jpg","galleries_id":37116,"server_id":18,"link":"photo_6324578.html","width":130,"caption":"How do you exercise? #5, 2010.","height":136});
															thumbnails[8215178] = clik.newPhoto({"id":8215178,"src":"Book-black-white-flowers_thumb.jpg","galleries_id":438175,"server_id":18,"link":"photo_8215178.html","width":130,"caption":"","height":65});
															thumbnails[6324574] = clik.newPhoto({"id":6324574,"src":"How-do-you-exercise-3-web_thumb.jpg","galleries_id":37116,"server_id":18,"link":"photo_6324574.html","width":130,"caption":"How do you exercise? #3, 2010.","height":124});
															thumbnails[8215182] = clik.newPhoto({"id":8215182,"src":"Book-blue-cream-flowers_thumb.jpg","galleries_id":438175,"server_id":18,"link":"photo_8215182.html","width":130,"caption":"","height":91});
															thumbnails[6324571] = clik.newPhoto({"id":6324571,"src":"How-do-you-exercise-2-web_thumb.jpg","galleries_id":37116,"server_id":18,"link":"photo_6324571.html","width":130,"caption":"How do you exercise? #2, 2010.","height":138});
															thumbnails[6605574] = clik.newPhoto({"id":6605574,"src":"Drawing-of-a-man_thumb.jpg","galleries_id":37117,"server_id":18,"link":"photo_6605574.html","width":130,"caption":"Waiting..... , 2010.","height":181});
															thumbnails[8215185] = clik.newPhoto({"id":8215185,"src":"Book-blue-white-flowers_thumb.jpg","galleries_id":438175,"server_id":18,"link":"photo_8215185.html","width":130,"caption":"","height":90});
															thumbnails[6324521] = clik.newPhoto({"id":6324521,"src":"How-do-you-exercise-1-web_thumb.jpg","galleries_id":37116,"server_id":18,"link":"photo_6324521.html","width":130,"caption":"How do you exercise? #1, 2010.","height":129});
															thumbnails[8215188] = clik.newPhoto({"id":8215188,"src":"Book-green-flower_thumb.jpg","galleries_id":438175,"server_id":18,"link":"photo_8215188.html","width":130,"caption":"","height":97});
															thumbnails[4651225] = clik.newPhoto({"id":4651225,"src":"Ball_thumb.jpg","galleries_id":37117,"server_id":18,"link":"photo_4651225.html","width":130,"caption":"Ball, 2009.","height":91});
															thumbnails[6324493] = clik.newPhoto({"id":6324493,"src":"Figure-Sequence-web_thumb.jpg","galleries_id":37116,"server_id":18,"link":"photo_6324493.html","width":130,"caption":"Figure Sequence, 2010.","height":57});
															thumbnails[8215191] = clik.newPhoto({"id":8215191,"src":"Book-Orange-blue-flowers_thumb.jpg","galleries_id":438175,"server_id":18,"link":"photo_8215191.html","width":130,"caption":"","height":93});
															thumbnails[4097906] = clik.newPhoto({"id":4097906,"src":"Two-Women-Sitting_thumb.jpg","galleries_id":37117,"server_id":18,"link":"photo_4097906.html","width":130,"caption":"Two Women Sitiing, 2009.","height":173});
															thumbnails[8215194] = clik.newPhoto({"id":8215194,"src":"Book-pink-white-flowers_thumb.jpg","galleries_id":438175,"server_id":18,"link":"photo_8215194.html","width":130,"caption":"","height":80});
															thumbnails[4097908] = clik.newPhoto({"id":4097908,"src":"Two-Women-Standing_thumb.jpg","galleries_id":37117,"server_id":18,"link":"photo_4097908.html","width":130,"caption":"Two Women Standing, 2009.","height":185});
															thumbnails[6324488] = clik.newPhoto({"id":6324488,"src":"Bodies-web_thumb.jpg","galleries_id":37116,"server_id":18,"link":"photo_6324488.html","width":130,"caption":"Bodies, 2010.","height":132});
															thumbnails[4097897] = clik.newPhoto({"id":4097897,"src":"Man-Standing_thumb.jpg","galleries_id":37117,"server_id":18,"link":"photo_4097897.html","width":130,"caption":"Man Standing, 2009.","height":217});
															thumbnails[4684190] = clik.newPhoto({"id":4684190,"src":"Male-Leafy-Triptych_thumb.jpg","galleries_id":37116,"server_id":18,"link":"photo_4684190.html","width":130,"caption":"Male Triptcyh, 2009.","height":57});
															thumbnails[4097894] = clik.newPhoto({"id":4097894,"src":"Leaning-Man_thumb.jpg","galleries_id":37117,"server_id":18,"link":"photo_4097894.html","width":130,"caption":"Leaning Man, 2009.","height":179});
															thumbnails[4097914] = clik.newPhoto({"id":4097914,"src":"Woman-Sitting-Down_thumb.jpg","galleries_id":37117,"server_id":18,"link":"photo_4097914.html","width":130,"caption":"Woman Sitting Down, 2009.","height":210});
															thumbnails[4097892] = clik.newPhoto({"id":4097892,"src":"Leaning-Back-Woman_thumb.jpg","galleries_id":37117,"server_id":18,"link":"photo_4097892.html","width":130,"caption":"Leaning Back Woman, 2009.","height":190});
															thumbnails[4097861] = clik.newPhoto({"id":4097861,"src":"Leaning-Back_thumb.jpg","galleries_id":37117,"server_id":18,"link":"photo_4097861.html","width":130,"caption":"Leaning Back, 2009.","height":174});
															thumbnails[4097848] = clik.newPhoto({"id":4097848,"src":"Crossed-Legged_thumb.jpg","galleries_id":37117,"server_id":18,"link":"photo_4097848.html","width":130,"caption":"Crossed Legged, 2009.","height":184});
															thumbnails[4097841] = clik.newPhoto({"id":4097841,"src":"Couple_thumb.jpg","galleries_id":37117,"server_id":18,"link":"photo_4097841.html","width":130,"caption":"Couple, 2009.","height":92});
															thumbnails[4097836] = clik.newPhoto({"id":4097836,"src":"At-Rest_thumb.jpg","galleries_id":37117,"server_id":18,"link":"photo_4097836.html","width":130,"caption":"Resting, 2009.","height":179});
															thumbnails[3846791] = clik.newPhoto({"id":3846791,"src":"Dotty-2-web_thumb.jpg","galleries_id":37113,"server_id":18,"link":"photo_3846791.html","width":130,"caption":"Dotty the Second, 2009.","height":128});
															thumbnails[2832771] = clik.newPhoto({"id":2832771,"src":"Balasana-2_thumb.jpg","galleries_id":37113,"server_id":18,"link":"photo_2832771.html","width":130,"caption":"Balasana, 2009.","height":123});
															thumbnails[2832802] = clik.newPhoto({"id":2832802,"src":"Sleeping-2_thumb.jpg","galleries_id":37113,"server_id":18,"link":"photo_2832802.html","width":130,"caption":"Sleeping, 2009.","height":97});
															thumbnails[2832803] = clik.newPhoto({"id":2832803,"src":"Toes-2_thumb.jpg","galleries_id":37113,"server_id":18,"link":"photo_2832803.html","width":130,"caption":"Toes, 2009.","height":124});
															thumbnails[2808266] = clik.newPhoto({"id":2808266,"src":"Pink-Man-2_thumb.jpg","galleries_id":37113,"server_id":18,"link":"photo_2808266.html","width":130,"caption":"Male Nude (in the pink #1), 2008.","height":188});
															thumbnails[2808267] = clik.newPhoto({"id":2808267,"src":"In The Pink 2_thumb.jpg","galleries_id":37113,"server_id":18,"link":"photo_2808267.html","width":130,"caption":"Male Nude (In The Pink #2), 2008.","height":187});
															thumbnails[2832800] = clik.newPhoto({"id":2832800,"src":"In-The-Pink-3_thumb.jpg","galleries_id":37113,"server_id":18,"link":"photo_2832800.html","width":130,"caption":"Male Nude (In The Pink #3), 2008.","height":176});
															thumbnails[2808269] = clik.newPhoto({"id":2808269,"src":"Shadow 1_thumb.jpg","galleries_id":37113,"server_id":18,"link":"photo_2808269.html","width":130,"caption":"Female Nude (Shadow #1), 2008.","height":187});
															thumbnails[2808272] = clik.newPhoto({"id":2808272,"src":"Shadow 2_thumb.jpg","galleries_id":37113,"server_id":18,"link":"photo_2808272.html","width":130,"caption":"Female Nude (Shadow #2), 2008.","height":190});
															thumbnails[2832673] = clik.newPhoto({"id":2832673,"src":"Shadow-3_thumb.jpg","galleries_id":37113,"server_id":18,"link":"photo_2832673.html","width":130,"caption":"Female Nude (Shadow #3), 2008.","height":163});
															thumbnails[1902823] = clik.newPhoto({"id":1902823,"src":"SC-PR-M2_thumb.jpg","galleries_id":37116,"server_id":18,"link":"photo_1902823.html","width":130,"caption":"Male Nude #2, 2008.","height":93});
															thumbnails[2548670] = clik.newPhoto({"id":2548670,"src":"Sitges I_thumb.jpg","galleries_id":37113,"server_id":18,"link":"photo_2548670.html","width":130,"caption":"Sitges I, 2008.","height":128});
															thumbnails[1902827] = clik.newPhoto({"id":1902827,"src":"SC-PR-M3_thumb.jpg","galleries_id":37116,"server_id":18,"link":"photo_1902827.html","width":130,"caption":"Male Nude #3, 2008.","height":92});
															thumbnails[2548673] = clik.newPhoto({"id":2548673,"src":"Sitges II_thumb.jpg","galleries_id":37113,"server_id":18,"link":"photo_2548673.html","width":130,"caption":"Sitges II, 2008.","height":130});
															thumbnails[2548675] = clik.newPhoto({"id":2548675,"src":"Sitges III_thumb.jpg","galleries_id":37113,"server_id":18,"link":"photo_2548675.html","width":130,"caption":"Stiges III, 2008.","height":130});
															thumbnails[2548677] = clik.newPhoto({"id":2548677,"src":"Sitges IV_thumb.jpg","galleries_id":37113,"server_id":18,"link":"photo_2548677.html","width":130,"caption":"Sitges IV, 2008.","height":122});
															thumbnails[779857] = clik.newPhoto({"id":779857,"src":"SQ-Purple-Nude-I_thumb.jpg","galleries_id":37113,"server_id":18,"link":"photo_779857.html","width":130,"caption":"SQ-Purple Nude I, 2007.","height":126});
															thumbnails[779860] = clik.newPhoto({"id":779860,"src":"SQ-Purple-Nude-II_thumb.jpg","galleries_id":37113,"server_id":18,"link":"photo_779860.html","width":130,"caption":"SQ-Purple Nude II, 2007.","height":130});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  						galleries[37113] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Paintings","link":"gallery_37113.html","maxRecords":0.0,"photoIDs":[4651224.0,4684203.0,3846791.0,2832771.0,2832802.0,2832803.0,2808266.0,2808267.0,2832800.0,2808269.0,2808272.0,2832673.0,2548670.0,2548673.0,2548675.0,2548677.0,779857.0,779860.0],"skipIndex":0,"section_code":"gallery","featured_images":"4684203,4651224,3846791,2832803,2832802,2832800,2832771,2832673,2808272,2808269","id":37113,"singleSection":false});				  						galleries[37116] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Original Prints","link":"gallery_37116.html","maxRecords":0.0,"photoIDs":[5921022.0,6709506.0,6709508.0,8289507.0,8289508.0,8289509.0,6605573.0,6324584.0,6324578.0,6324574.0,6324571.0,6324521.0,6324493.0,6324488.0,4684190.0,1902823.0,1902827.0],"skipIndex":0,"section_code":"gallery","featured_images":5921022.0,"id":37116,"singleSection":false});				  						galleries[37117] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Drawings","link":"gallery_37117.html","maxRecords":0.0,"photoIDs":[6605574.0,4651225.0,4097906.0,4097908.0,4097897.0,4097894.0,4097914.0,4097892.0,4097861.0,4097848.0,4097841.0,4097836.0],"skipIndex":0,"section_code":"gallery","featured_images":6605574.0,"id":37117,"singleSection":false});				  						galleries[350752] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Sculpture","link":"gallery_350752.html","maxRecords":0.0,"photoIDs":[6325271.0,7082220.0,7082229.0,7082232.0,7082240.0,7082272.0,7082285.0],"skipIndex":0,"section_code":"gallery","featured_images":6325271.0,"id":350752,"singleSection":false});				  						galleries[438175] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Handmade Sketch & Note Books","link":"gallery_438175.html","maxRecords":0.0,"photoIDs":[8215173.0,8215178.0,8215182.0,8215185.0,8215188.0,8215191.0,8215194.0],"skipIndex":0,"section_code":"gallery","featured_images":8215173.0,"id":438175,"singleSection":false});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[1] = '8289509,8289507,6709506,6325271,5921022,6605574,6324521,4651225,6324488,4684190,3846791,2808266,2808272,1902827,779857';
imageSets[2] = '6325271,5921022,8215173,6605574';
imageSets[3] = '6709506,6325271,5921022,6605574,6324521,4651225,6324488,4684190,3846791,2808266,2808272,1902827';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 51:
		val = 'http://www12.clikpic.com/KerryDay/images';
		break;
	}
		switch (server_id) {
		case 0:
		val = 'http://www.clikpic.com/KerryDay/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/KerryDay/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/KerryDay/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/KerryDay/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/KerryDay/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/KerryDay/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/KerryDay/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/KerryDay/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/KerryDay/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/KerryDay/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/KerryDay/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/KerryDay/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/KerryDay/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/KerryDay/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/KerryDay/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/KerryDay/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/KerryDay/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/KerryDay/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/KerryDay/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/KerryDay/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/KerryDay/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/KerryDay/images';
		break;
	}
		switch (server_id) {
		case 53:
		val = 'http://images.clikpic.com/KerryDay/images';
		break;
	}
		switch (server_id) {
		case 52:
		val = 'http://tpc22/clikpic/KerryDay/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/KerryDay/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/KerryDay/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 = 'Kerry Day MA: ' + photoCaption;
			    }
        if (op.$detail.length > 0) {
      	temp = op.nextPhoto.fnGetImageDetails();
	    op.$detail.fadeGalleryDetails(temp, op.speed, function(){
			if (typeof(backgrounds) != 'undefined' && op.nextPhoto == backgrounds[op.nextPhoto.id]) {
				toggleAddToCartConfirm(backgrounds, op.$detail);
			} else if (typeof(photos) != 'undefined' && op.nextPhoto == photos[op.nextPhoto.id]) {
				toggleAddToCartConfirm(photos, op.$detail);
			}
			$('body').trigger('clikUpdate.popup');
	    });
    }
        $(op.$detailContainer).find('.replaceable[class*=replaceable_photo-]').each(function(){
    	var field = clik.getPrefixedClass(this.className, 'replaceable_photo-');
    	if (field in op.nextPhoto) {
    		$(this).fadeGalleryDetails(op.nextPhoto[field], op.speed);
    	}
    }).end().find('.replaceable.photoPayment').fadeGalleryDetails(op.nextPhoto.fnGetPaymentInfo(), op.speed, function(){
		if (typeof(backgrounds) != 'undefined' && op.nextPhoto == backgrounds[op.nextPhoto.id]) {
			toggleAddToCartConfirm(backgrounds, op.$detailContainer);
		} else if (typeof(photos) != 'undefined' && op.nextPhoto == photos[op.nextPhoto.id]) {
			toggleAddToCartConfirm(photos, op.$detailContainer);
		}
		$('body').trigger('clikUpdate.popup');
	});
		if (op.$photo.length > 0) {
		html = $('<img/>',{
			'class': 'mainphoto photo',
			src: photoSrc,
			id: 'mainPic',
			name: 'mainPic',
			width: op.nextPhoto.width,
			height: op.nextPhoto.height,
			alt: photoCaption,
			css: op.css || {}
		});
		if (op.href) {
			if (op.href.match(/<a/)) {
				html = $(op.href).append(html);
			} else {
				html = $('<a/>', {
					href: op.href,
					title: photoCaption
				}).append(html);
			}
		} else {
			html = $('<a/>', {
				title: photoCaption
			}).append(html);
		}
		if (op.speed == 0) {			op.$photo.html(html);			if (op.onBefore) {			  	op.onBefore.apply(op.$photo);			}			if (op.onAfter) {			  	op.onAfter.apply(op.$photo);			}		} else {			op.$photo.stop(true,true).fadeReplaceWith(html,op.speed,'',function(){  				if (op.onAfter) {				  	op.onAfter.apply(this);				}				clik.doColumnResize(false, $(this).add(op.$detail).add(op.$title));			}, op.onBefore);
		}	}
    if (op.field) {
		op.field.value = photoId;
	} else {
		op.$photo.data('image_id', photoId);
    }
        if (!op.speed) {
      	clik.doColumnResize(false, op.$photo.add(op.$detail).add(op.$title));
    }
        
    return html;
	}

/***************************************************************************
* Toggle add to cart confirmation element and set up the click event for   *
* the 'Add to cart' button.                                                *
***************************************************************************/
function toggleAddToCartConfirm(array, root){
	if (typeof(array) !== 'object' || array === null) {
	  	array = photos;
	}
	if (!$(root).length) {		root = $('body');	}	if($('#paymentConfirm', root).length > 0){
		$('#paymentConfirm', root).hide();
		$('#paymentAddButton', root)
		.unbind()
		.click(function(){
						form = $('#paymentForm', root)[0];
			option_id = 0;
			if(form.item_option.value){
				option_id = form.item_option.value;
			}
			if(addItemToBasket(form.item_number.value,array,form.site.value,parseInt(form.quantity.value, 10),option_id)){
				if($.browser.msie){$('#paymentConfirm', root).text('Item added to cart').show();}
				else{
					$('#paymentConfirm', root).text('Item added to cart').fadeIn();
					dspOrderDetails(form.site.value);
				}
			}
			else{
				$('#paymentConfirm', root).text('Item not added - check cookies are enabled in your browser.').fadeIn();
			}
		});
	}
}

/***************************************************************************
* Get payment info for image - add as 'method' to photo object             *
***************************************************************************/
clik.photo.fnGetImageDetails = function(){
	var temp = '';
	if (this.description != '') {
		temp +=  '<div id="imageDescription">' + this.description + '</div>';
	}
		if (this.photo_ref != '') {
		temp += '<div class="imageinfo" id="imageRef"><strong>Ref: </strong>' + this.photo_ref + '</div>';
	}
		if (this.takendate != '') {
		
		temp += '<div class="imageinfo" id="imageDate"><strong>Date: </strong>' + this.takendate + '</div>';
	}
	
	if (this.location != '') {
		
		temp += '<div class="imageinfo" id="imageLocation"><strong>Location: </strong>' +  this.location + '</div>';
	}
	
	if (this.photographer != '') {
		
		temp += '<div class="imageinfo" id="imagePhotographer"><strong>Photographer: </strong>' + this.photographer + '</div>';
	}
				
	temp += this.fnGetPaymentInfo();
				if (temp != '') {
		temp += '<div class="spacer"></div>';
	}
	return temp;
};

/***************************************************************************
* Get payment info for image - add as 'method' to photo object             *
***************************************************************************/
clik.photo.fnGetPaymentInfo = function(){
	var temp = '';
	if (this.item_price !== '') {
																		temp += '<p>Buy now using PayPal:</p>';
				temp += '<div class="imageinfo" id="imagePrice"><strong>' + this.purchase_instruction + '</strong> &pound;' + (this.item_price).toFixed(2) + '</div>';
		var item_name  = this.purchase_instruction;
		var amount = (this.item_price).toFixed(2);
		var item_option  = 0;
	}
		else if (this.payment_groups_id !== '') {
		temp += '<p>Buy this print online:</p>';
				temp += '<form id="paymentOptions" style="margin:0px;border:0px;" name="paymentOptions">';
											temp += '<select class="paymentlink" name="payment_options_id" onchange="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 += '<form id="paymentForm" style="margin:0px;border:0px;" name="paymentForm" target="_blank" action="https://www.paypal.com/cgi-bin/webscr" method="post">';
			temp += '<input type="hidden" name="item_name" value="'+item_name+'">';
			ref = '';
			if(this.photo_ref != ''){
				ref = this.photo_ref+' - '+this.caption;
			}
			else{
				ref = this.id+' - '+this.caption;
			}
			price = amount;								temp += '<input type="hidden" name="cmd" value="_cart">';
					temp += '<input type="hidden" name="business" value="kerryday@blueyonder.co.uk">';
					temp += '<input type="hidden" name="currency_code" value="GBP">';
					temp += '<input type="hidden" name="add" value="1">';
													temp += '<input type="hidden" name="amount" value="'+amount+'">';
					temp += '<input type="hidden" name="item_number" value="'+ref+'">';
													temp += '<input type=\"Submit\" value=\"Add to cart\" id=\"paymentAddButton\" class=\"button\" onmouseover=\"this.className=\'buttonHi\';\" onmouseout=\"this.className=\'button\';\">';
										temp += '</form>';
										temp += '<form id="paymentCartForm" style="margin:0px;" name="paymentCartForm" target="_blank" action="https://www.paypal.com/cgi-bin/webscr" method="post">';
				temp += '<input type="hidden" name="cmd" value="_cart">';
				temp += '<input type="hidden" name="business" value="kerryday@blueyonder.co.uk">';
				temp += '<input type="hidden" name="display" value="1">';
				temp += '<input type=\"Submit\" value=\"View cart\" id=\"paymentViewButton\" class=\"button\" onmouseover=\"this.className=\'buttonHi\';\" onmouseout=\"this.className=\'button\';\">';
				temp += '</form>';
						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;
	}
}

		

