window.thumbnails = {};
															thumbnails[1766140] = clik.newPhoto({"id":1766140,"src":"roses_thumb.jpg","galleries_id":118459,"server_id":18,"link":"photo_1766140.html","width":130,"caption":"RosesSOLD","height":155});
															thumbnails[1766153] = clik.newPhoto({"id":1766153,"src":"stone roses view 2_thumb.jpg","galleries_id":118459,"server_id":18,"link":"photo_1766153.html","width":130,"caption":"Stone Roses","height":129});
															thumbnails[1766164] = clik.newPhoto({"id":1766164,"src":"sea garden_thumb.JPG","galleries_id":118695,"server_id":18,"link":"photo_1766164.html","width":130,"caption":"Sea Garden","height":109});
															thumbnails[1773953] = clik.newPhoto({"id":1773953,"src":"sea meadow_thumb.jpg","galleries_id":221076,"server_id":18,"link":"photo_1773953.html","width":130,"caption":"SeaScape in Candidasa","height":111});
															thumbnails[1794446] = clik.newPhoto({"id":1794446,"src":"moolight and roses_thumb.jpg","galleries_id":118459,"server_id":18,"link":"photo_1794446.html","width":130,"caption":"moonlight and roses","height":97});
															thumbnails[1815816] = clik.newPhoto({"id":1815816,"src":"sea roses 3_thumb.jpg","galleries_id":118459,"server_id":18,"link":"photo_1815816.html","width":130,"caption":"Stone roses 2","height":130});
															thumbnails[1815828] = clik.newPhoto({"id":1815828,"src":"roses 2_thumb.jpg","galleries_id":118459,"server_id":18,"link":"photo_1815828.html","width":130,"caption":"Roses 2<br>\r\nSOLD","height":108});
															thumbnails[1925208] = clik.newPhoto({"id":1925208,"src":"Cats garden_thumb.JPG","galleries_id":129141,"server_id":18,"link":"photo_1925208.html","width":130,"caption":"Cat's Garden","height":153});
															thumbnails[1961827] = clik.newPhoto({"id":1961827,"src":"Tangle_thumb.JPG","galleries_id":118459,"server_id":18,"link":"photo_1961827.html","width":130,"caption":" TangleSold","height":165});
															thumbnails[1975872] = clik.newPhoto({"id":1975872,"src":"posy_thumb.jpg","galleries_id":159163,"server_id":18,"link":"photo_1975872.html","width":130,"caption":"Posy<br>\r\n<br>\r\nFor Sale","height":173});
															thumbnails[2007513] = clik.newPhoto({"id":2007513,"src":"A Celebration of Life_thumb.JPG","galleries_id":221076,"server_id":18,"link":"photo_2007513.html","width":130,"caption":"A Celebration of Life","height":170});
															thumbnails[2036439] = clik.newPhoto({"id":2036439,"src":"posy 2_thumb.JPG","galleries_id":159163,"server_id":18,"link":"photo_2036439.html","width":130,"caption":"Posy 2","height":198});
															thumbnails[2054923] = clik.newPhoto({"id":2054923,"src":"Passion_thumb.jpg","galleries_id":129141,"server_id":18,"link":"photo_2054923.html","width":130,"caption":"Passion<br>\r\nSOLD","height":119});
															thumbnails[2114067] = clik.newPhoto({"id":2114067,"src":"posy 3_thumb.jpg","galleries_id":159163,"server_id":18,"link":"photo_2114067.html","width":130,"caption":"Posy 3","height":194});
															thumbnails[2126836] = clik.newPhoto({"id":2126836,"src":"fish_thumb.jpg","galleries_id":158986,"server_id":18,"link":"photo_2126836.html","width":130,"caption":"Fish<br>\r\nSOLD","height":84});
															thumbnails[2178334] = clik.newPhoto({"id":2178334,"src":"DSC01271jeannie_thumb.JPG","galleries_id":129141,"server_id":18,"link":"photo_2178334.html","width":130,"caption":"Water Iris","height":102});
															thumbnails[2295842] = clik.newPhoto({"id":2295842,"src":"IMG_1589_thumb.JPG","galleries_id":152719,"server_id":18,"link":"photo_2295842.html","width":87,"caption":"Cow Parsley","height":130});
															thumbnails[2295849] = clik.newPhoto({"id":2295849,"src":"IMG_1590[1]_thumb.JPG","galleries_id":152719,"server_id":18,"link":"photo_2295849.html","width":92,"caption":"Windswept in Portugal","height":130});
															thumbnails[2295853] = clik.newPhoto({"id":2295853,"src":"IMG_1423_thumb.JPG","galleries_id":129141,"server_id":18,"link":"photo_2295853.html","width":130,"caption":"Alliums<br>\r\nSOLD","height":105});
															thumbnails[2343489] = clik.newPhoto({"id":2343489,"src":"meadow Portugal 2008_thumb.jpg","galleries_id":152719,"server_id":18,"link":"photo_2343489.html","width":130,"caption":"Meadow Portugal 2008","height":96});
															thumbnails[2343498] = clik.newPhoto({"id":2343498,"src":"IMG_8792_thumb.jpg","galleries_id":159163,"server_id":18,"link":"photo_2343498.html","width":130,"caption":"Alliums in Vase","height":198});
															thumbnails[2343507] = clik.newPhoto({"id":2343507,"src":"IMG_8790_thumb.jpg","galleries_id":152719,"server_id":18,"link":"photo_2343507.html","width":130,"caption":"Studio at OBRAS","height":87});
															thumbnails[2357543] = clik.newPhoto({"id":2357543,"src":"IMG_8775_thumb.jpg","galleries_id":152719,"server_id":18,"link":"photo_2357543.html","width":130,"caption":"OBRAS Studio","height":87});
															thumbnails[2454465] = clik.newPhoto({"id":2454465,"src":"Meadow_thumb.JPG","galleries_id":152719,"server_id":18,"link":"photo_2454465.html","width":130,"caption":"Cow Parlsey Meadow<br>\r\n<br>\r\nSOLD","height":88});
															thumbnails[2454477] = clik.newPhoto({"id":2454477,"src":"Meadow Portugal_thumb.JPG","galleries_id":152719,"server_id":18,"link":"photo_2454477.html","width":130,"caption":"Summer Meadow Portugal 2008 ","height":95});
															thumbnails[2454484] = clik.newPhoto({"id":2454484,"src":"Roses in June_thumb.JPG","galleries_id":152719,"server_id":18,"link":"photo_2454484.html","width":130,"caption":"Roses \"Tangle\" Portugal 2008","height":274});
															thumbnails[2473795] = clik.newPhoto({"id":2473795,"src":"Angel_thumb.jpg","galleries_id":158986,"server_id":18,"link":"photo_2473795.html","width":130,"caption":"Angel","height":153});
															thumbnails[2473824] = clik.newPhoto({"id":2473824,"src":"Dried Flowers_thumb.JPG","galleries_id":159163,"server_id":18,"link":"photo_2473824.html","width":130,"caption":"Dried Flowers In Vase<br>\r\nSOLD","height":160});
															thumbnails[2473849] = clik.newPhoto({"id":2473849,"src":"Agapanthus_thumb.JPG","galleries_id":129141,"server_id":18,"link":"photo_2473849.html","width":130,"caption":"Agapanthus","height":98});
															thumbnails[2473939] = clik.newPhoto({"id":2473939,"src":"IMG_2013_thumb.JPG","galleries_id":129141,"server_id":18,"link":"photo_2473939.html","width":130,"caption":"Cornflowers 1","height":197});
															thumbnails[2473953] = clik.newPhoto({"id":2473953,"src":"Cornflowers 2_thumb.jpg","galleries_id":129141,"server_id":18,"link":"photo_2473953.html","width":130,"caption":"Cornflowers 2","height":95});
															thumbnails[2476630] = clik.newPhoto({"id":2476630,"src":"IMG_2016_thumb.JPG","galleries_id":159163,"server_id":18,"link":"photo_2476630.html","width":130,"caption":"Mackintosh Roses<br>\r\nSOLD","height":199});
															thumbnails[3612827] = clik.newPhoto({"id":3612827,"src":"exhibition_for_resizingjpg_6_thumb.jpg","galleries_id":221077,"server_id":18,"link":"photo_3612827.html","width":130,"caption":"Cafe Des Artistes Ubud Bali 2008","height":98});
															thumbnails[3612829] = clik.newPhoto({"id":3612829,"src":"exhibition_for_resizingjpg_7_thumb.jpg","galleries_id":221077,"server_id":18,"link":"photo_3612829.html","width":130,"caption":"Cafe Des Artistes Ubud Bali 2008","height":98});
															thumbnails[3612837] = clik.newPhoto({"id":3612837,"src":"exhibition_for_resizingjpg_9_thumb.jpg","galleries_id":221077,"server_id":18,"link":"photo_3612837.html","width":130,"caption":"Cafe Des Artistes Ubud Bali 2008","height":98});
															thumbnails[3612913] = clik.newPhoto({"id":3612913,"src":"for_resizing_1_thumb.jpg","galleries_id":221077,"server_id":18,"link":"photo_3612913.html","width":130,"caption":"Cafe Des Artistes Ubud Bali 2008","height":87});
															thumbnails[3612922] = clik.newPhoto({"id":3612922,"src":"for_resizing_2_thumb.jpg","galleries_id":221077,"server_id":18,"link":"photo_3612922.html","width":130,"caption":"Cafe Des Artistes Ubud Bali 2008","height":87});
															thumbnails[3612974] = clik.newPhoto({"id":3612974,"src":"painting_class_thumb.jpg","galleries_id":221076,"server_id":18,"link":"photo_3612974.html","width":130,"caption":"Half Day Workshop in Ubud Bali","height":98});
															thumbnails[4166874] = clik.newPhoto({"id":4166874,"src":"roses_paintings_001_thumb.JPG","galleries_id":129141,"server_id":18,"link":"photo_4166874.html","width":130,"caption":"Fairy","height":98});
															thumbnails[4166934] = clik.newPhoto({"id":4166934,"src":"roses_paintings_002_thumb.JPG","galleries_id":129141,"server_id":18,"link":"photo_4166934.html","width":130,"caption":"Peace","height":98});
															thumbnails[4166975] = clik.newPhoto({"id":4166975,"src":"roses_paintings_003_thumb.JPG","galleries_id":129141,"server_id":18,"link":"photo_4166975.html","width":130,"caption":"Nevada","height":98});
															thumbnails[4661409] = clik.newPhoto({"id":4661409,"src":"Fritha_1_thumb.jpg","galleries_id":129141,"server_id":18,"link":"photo_4661409.html","width":130,"caption":"Wild roses","height":128});
															thumbnails[4661410] = clik.newPhoto({"id":4661410,"src":"Fritha_2_thumb.jpg","galleries_id":129141,"server_id":18,"link":"photo_4661410.html","width":130,"caption":"Summer Roses","height":128});
															thumbnails[5059864] = clik.newPhoto({"id":5059864,"src":"Black_and_White_001_thumb.JPG","galleries_id":221076,"server_id":18,"link":"photo_5059864.html","width":130,"caption":"","height":134});
															thumbnails[7524367] = clik.newPhoto({"id":7524367,"src":"December_2011_cottage_thumb.jpg","galleries_id":407947,"server_id":18,"link":"photo_7524367.html","width":160,"caption":"Seaside Cottage","height":152});
															thumbnails[7524369] = clik.newPhoto({"id":7524369,"src":"view_from_the_water_thumb.jpg","galleries_id":407947,"server_id":18,"link":"photo_7524369.html","width":160,"caption":"beach 10 meters away","height":120});
															thumbnails[7720701] = clik.newPhoto({"id":7720701,"src":"beach_house_pictures_11_thumb.jpg","galleries_id":407947,"server_id":18,"link":"photo_7720701.html","width":160,"caption":"Beach cottage","height":213});
															thumbnails[7720707] = clik.newPhoto({"id":7720707,"src":"furnishings_4_thumb.jpg","galleries_id":407947,"server_id":18,"link":"photo_7720707.html","width":160,"caption":"Beach cottage","height":213});
															thumbnails[7720968] = clik.newPhoto({"id":7720968,"src":"Kitchen_area_2011_thumb.jpg","galleries_id":407947,"server_id":18,"link":"photo_7720968.html","width":160,"caption":"Beach Cottage","height":120});
															thumbnails[8480316] = clik.newPhoto({"id":8480316,"src":"P1010654_2_thumb.jpg","galleries_id":129141,"server_id":18,"link":"photo_8480316.html","width":160,"caption":"Peace 2","height":160});
															thumbnails[8483460] = clik.newPhoto({"id":8483460,"src":"deck_image_thumb.jpg","galleries_id":158986,"server_id":18,"link":"photo_8483460.html","width":160,"caption":"Tarot Deck","height":155});
															thumbnails[3608120] = clik.newPhoto({"id":3608120,"src":"resized_offering_painting_thumb.jpg","galleries_id":221076,"server_id":18,"link":"photo_3608120.html","width":130,"caption":"Offerings","height":102});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  						galleries[221077] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Exhibitions","link":"gallery_221077.html","maxRecords":0.0,"photoIDs":[3612827.0,3612829.0,3612837.0,3612913.0,3612922.0],"skipIndex":0,"section_code":"gallery","featured_images":"3612922,3612913,3612837,3612829,3612827","id":221077,"singleSection":false});				  						galleries[129141] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Gardens and Flowers","link":"gallery_129141.html","maxRecords":0.0,"photoIDs":[1925208.0,2054923.0,2178334.0,2295853.0,2473849.0,2473939.0,2473953.0,4166874.0,4166934.0,4166975.0,4661409.0,4661410.0,8480316.0],"skipIndex":0,"section_code":"gallery","featured_images":"8480316,4661410,4661409,4166975,4166934,4166874,2473953,2473939,2473849,2295853","id":129141,"singleSection":false});				  						galleries[119400] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"House and Garden in Ubud bali","link":"gallery_119400.html","maxRecords":0.0,"photoIDs":[],"skipIndex":0,"section_code":"gallery","featured_images":"","id":119400,"singleSection":false});				  						galleries[158986] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Miscellaneous","link":"gallery_158986.html","maxRecords":0.0,"photoIDs":[2126836.0,2473795.0,8483460.0],"skipIndex":0,"section_code":"gallery","featured_images":"8483460,2473795,2126836","id":158986,"singleSection":false});				  						galleries[152719] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"OBRAS Portugal 2008","link":"gallery_152719.html","maxRecords":0.0,"photoIDs":[2295842.0,2295849.0,2343489.0,2343507.0,2357543.0,2454465.0,2454477.0,2454484.0],"skipIndex":0,"section_code":"gallery","featured_images":"2454484,2454477,2454465,2357543,2343507,2343489,2295849,2295842","id":152719,"singleSection":false});				  						galleries[221076] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Painting workshops","link":"gallery_221076.html","maxRecords":0.0,"photoIDs":[1773953.0,2007513.0,3612974.0,5059864.0,3608120.0],"skipIndex":0,"section_code":"gallery","featured_images":1773953.0,"id":221076,"singleSection":false});				  						galleries[118695] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Sea Gardens","link":"gallery_118695.html","maxRecords":0.0,"photoIDs":[1766164.0],"skipIndex":0,"section_code":"gallery","featured_images":1766164.0,"id":118695,"singleSection":false});				  						galleries[407947] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Seaside Cottage Candidasa","link":"gallery_407947.html","maxRecords":0.0,"photoIDs":[7524367.0,7524369.0,7720701.0,7720707.0,7720968.0],"skipIndex":0,"section_code":"gallery","featured_images":"7720968,7720707,7720701,7524369,7524367","id":407947,"singleSection":false});				  						galleries[118459] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Stone Roses","link":"gallery_118459.html","maxRecords":0.0,"photoIDs":[1766140.0,1766153.0,1794446.0,1815816.0,1815828.0,1961827.0],"skipIndex":0,"section_code":"gallery","featured_images":1766140.0,"id":118459,"singleSection":false});				  						galleries[159163] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Vases of Flowers","link":"gallery_159163.html","maxRecords":0.0,"photoIDs":[1975872.0,2036439.0,2114067.0,2343498.0,2473824.0,2476630.0],"skipIndex":0,"section_code":"gallery","featured_images":"2476630,2473824,2343498,2114067,2036439,1975872","id":159163,"singleSection":false});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[241668] = '5059864,4166934,2473953,1961827,1766140,3608120';
imageSets[1] = '7524367,3612974,2476630,2473824,2343498';
imageSets[2] = '1773953,1766164,1766140';
imageSets[3] = '7524369,7524367';
imageSets[241565] = '7720968,7720707,7720701,7524369,7524367';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 51:
		val = 'http://www12.clikpic.com/janmerrills/images';
		break;
	}
		switch (server_id) {
		case 0:
		val = 'http://www.clikpic.com/janmerrills/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/janmerrills/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/janmerrills/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/janmerrills/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/janmerrills/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/janmerrills/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/janmerrills/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/janmerrills/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/janmerrills/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/janmerrills/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/janmerrills/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/janmerrills/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/janmerrills/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/janmerrills/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/janmerrills/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/janmerrills/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/janmerrills/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/janmerrills/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/janmerrills/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/janmerrills/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/janmerrills/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/janmerrills/images';
		break;
	}
		switch (server_id) {
		case 53:
		val = 'http://images.clikpic.com/janmerrills/images';
		break;
	}
		switch (server_id) {
		case 52:
		val = 'http://tpc22/clikpic/janmerrills/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/janmerrills/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/janmerrills/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 = 'Jan Merrills: ' + 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="janmerrillstarot@gmail.com">';
					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="janmerrillstarot@gmail.com">';
				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;
	}
}

			

