window.thumbnails = {};
															thumbnails[1760184] = clik.newPhoto({"id":1760184,"src":"DSCI00031_thumb.jpg","galleries_id":"","server_id":18,"link":"#","width":89,"caption":"","height":100});
															thumbnails[454178] = clik.newPhoto({"id":454178,"src":"5D_007_TIFF_thumb.jpg","galleries_id":36040,"server_id":18,"link":"photo_454178.html","width":160,"caption":"","height":107});
															thumbnails[1106943] = clik.newPhoto({"id":1106943,"src":"5D_044_TIFF_thumb.jpg","galleries_id":36041,"server_id":18,"link":"photo_1106943.html","width":107,"caption":"","height":160});
															thumbnails[454186] = clik.newPhoto({"id":454186,"src":"5D_015_TIFF_thumb.jpg","galleries_id":36040,"server_id":18,"link":"photo_454186.html","width":160,"caption":"","height":107});
															thumbnails[454280] = clik.newPhoto({"id":454280,"src":"5D_013_TIFF_thumb.jpg","galleries_id":36041,"server_id":18,"link":"photo_454280.html","width":107,"caption":"","height":160});
															thumbnails[1844231] = clik.newPhoto({"id":1844231,"src":"5D_055_TIFF_thumb.jpg","galleries_id":36041,"server_id":18,"link":"photo_1844231.html","width":107,"caption":"","height":160});
															thumbnails[454192] = clik.newPhoto({"id":454192,"src":"5D_001_TIFF_thumb.jpg","galleries_id":36040,"server_id":18,"link":"photo_454192.html","width":160,"caption":"","height":107});
															thumbnails[454283] = clik.newPhoto({"id":454283,"src":"5D_017_TIFF_thumb.jpg","galleries_id":36041,"server_id":18,"link":"photo_454283.html","width":107,"caption":"","height":160});
															thumbnails[1844433] = clik.newPhoto({"id":1844433,"src":"5D_054_TIFF_thumb.jpg","galleries_id":36041,"server_id":18,"link":"photo_1844433.html","width":107,"caption":"","height":160});
															thumbnails[454285] = clik.newPhoto({"id":454285,"src":"5D_023_TIFF_thumb.jpg","galleries_id":36041,"server_id":18,"link":"photo_454285.html","width":107,"caption":"","height":160});
															thumbnails[7682944] = clik.newPhoto({"id":7682944,"src":"5D_008_TIFF_thumb.jpg","galleries_id":36040,"server_id":18,"link":"photo_7682944.html","width":160,"caption":"","height":107});
															thumbnails[1198590] = clik.newPhoto({"id":1198590,"src":"5D_071_TIFF_thumb.jpg","galleries_id":36041,"server_id":18,"link":"photo_1198590.html","width":107,"caption":"","height":160});
															thumbnails[454210] = clik.newPhoto({"id":454210,"src":"5D_010_TIFF_thumb.jpg","galleries_id":36040,"server_id":18,"link":"photo_454210.html","width":160,"caption":"","height":107});
															thumbnails[1106864] = clik.newPhoto({"id":1106864,"src":"5D_045_TIFF_thumb.jpg","galleries_id":36041,"server_id":18,"link":"photo_1106864.html","width":105,"caption":"","height":160});
															thumbnails[986348] = clik.newPhoto({"id":986348,"src":"5D_039_TIFF_thumb.jpg","galleries_id":36040,"server_id":18,"link":"photo_986348.html","width":160,"caption":"","height":107});
															thumbnails[454217] = clik.newPhoto({"id":454217,"src":"5D_011_TIFF_thumb.jpg","galleries_id":36040,"server_id":18,"link":"photo_454217.html","width":160,"caption":"","height":107});
															thumbnails[454294] = clik.newPhoto({"id":454294,"src":"5D_022_TIFF_thumb.jpg","galleries_id":36041,"server_id":18,"link":"photo_454294.html","width":107,"caption":"","height":160});
															thumbnails[454227] = clik.newPhoto({"id":454227,"src":"5D_012_TIFF_thumb.jpg","galleries_id":36040,"server_id":18,"link":"photo_454227.html","width":160,"caption":"","height":107});
															thumbnails[653490] = clik.newPhoto({"id":653490,"src":"5D_031_TIFF_thumb.jpg","galleries_id":36041,"server_id":18,"link":"photo_653490.html","width":107,"caption":"","height":160});
															thumbnails[3894742] = clik.newPhoto({"id":3894742,"src":"5D_063_TIFF_thumb.jpg","galleries_id":36041,"server_id":18,"link":"photo_3894742.html","width":107,"caption":"","height":160});
															thumbnails[1658032] = clik.newPhoto({"id":1658032,"src":"5D_052_TIFF_thumb.jpg","galleries_id":36041,"server_id":18,"link":"photo_1658032.html","width":107,"caption":"","height":160});
															thumbnails[454250] = clik.newPhoto({"id":454250,"src":"5D_018_TIFF_thumb.jpg","galleries_id":36040,"server_id":18,"link":"photo_454250.html","width":160,"caption":"","height":107});
															thumbnails[701537] = clik.newPhoto({"id":701537,"src":"5D_032_TIFF_thumb.jpg","galleries_id":36041,"server_id":18,"link":"photo_701537.html","width":107,"caption":"","height":160});
															thumbnails[454268] = clik.newPhoto({"id":454268,"src":"5D_021_TIFF_thumb.jpg","galleries_id":36040,"server_id":18,"link":"photo_454268.html","width":160,"caption":"","height":107});
															thumbnails[1831059] = clik.newPhoto({"id":1831059,"src":"5D_053_TIFF_thumb.jpg","galleries_id":36041,"server_id":18,"link":"photo_1831059.html","width":107,"caption":"","height":160});
															thumbnails[656261] = clik.newPhoto({"id":656261,"src":"5D_029_TIFF_thumb.jpg","galleries_id":36040,"server_id":18,"link":"photo_656261.html","width":160,"caption":"","height":107});
															thumbnails[1255921] = clik.newPhoto({"id":1255921,"src":"5D_048_TIFF_thumb.jpg","galleries_id":36041,"server_id":18,"link":"photo_1255921.html","width":107,"caption":"","height":160});
															thumbnails[7804697] = clik.newPhoto({"id":7804697,"src":"5D_084_TIFF1_thumb.jpg","galleries_id":36041,"server_id":18,"link":"photo_7804697.html","width":107,"caption":"","height":160});
															thumbnails[2204479] = clik.newPhoto({"id":2204479,"src":"5D_037_TIFF_thumb.jpg","galleries_id":36041,"server_id":18,"link":"photo_2204479.html","width":107,"caption":"","height":160});
															thumbnails[2054411] = clik.newPhoto({"id":2054411,"src":"5D_058_TIFF_thumb.jpg","galleries_id":36041,"server_id":18,"link":"photo_2054411.html","width":107,"caption":"","height":160});
															thumbnails[1305081] = clik.newPhoto({"id":1305081,"src":"5D_051_TIFF_thumb.jpg","galleries_id":36041,"server_id":18,"link":"photo_1305081.html","width":107,"caption":"","height":160});
															thumbnails[454277] = clik.newPhoto({"id":454277,"src":"5D_016_TIFF_thumb.jpg","galleries_id":36041,"server_id":18,"link":"photo_454277.html","width":107,"caption":"","height":160});
															thumbnails[1844396] = clik.newPhoto({"id":1844396,"src":"5D_056_TIFF_thumb.jpg","galleries_id":36041,"server_id":18,"link":"photo_1844396.html","width":107,"caption":"","height":160});
															thumbnails[1106838] = clik.newPhoto({"id":1106838,"src":"5D_043_TIFF_thumb.jpg","galleries_id":36040,"server_id":18,"link":"photo_1106838.html","width":160,"caption":"","height":107});
															thumbnails[2204539] = clik.newPhoto({"id":2204539,"src":"5D_041_TIFF_thumb.jpg","galleries_id":36041,"server_id":18,"link":"photo_2204539.html","width":107,"caption":"","height":160});
															thumbnails[454235] = clik.newPhoto({"id":454235,"src":"5D_014_TIFF_thumb.jpg","galleries_id":36040,"server_id":18,"link":"photo_454235.html","width":160,"caption":"","height":107});
															thumbnails[1256337] = clik.newPhoto({"id":1256337,"src":"5D_049_TIFF_thumb.jpg","galleries_id":36040,"server_id":18,"link":"photo_1256337.html","width":160,"caption":"","height":107});
															thumbnails[2204551] = clik.newPhoto({"id":2204551,"src":"5D_026_TIFF_thumb.jpg","galleries_id":36041,"server_id":18,"link":"photo_2204551.html","width":107,"caption":"","height":160});
															thumbnails[2204636] = clik.newPhoto({"id":2204636,"src":"5D_059_TIFF_thumb.jpg","galleries_id":36040,"server_id":18,"link":"photo_2204636.html","width":160,"caption":"","height":107});
															thumbnails[2931465] = clik.newPhoto({"id":2931465,"src":"5D_060_TIFF_thumb.jpg","galleries_id":36041,"server_id":18,"link":"photo_2931465.html","width":107,"caption":"","height":160});
															thumbnails[8463639] = clik.newPhoto({"id":8463639,"src":"5D_097_TIFF12_thumb.jpg","galleries_id":36041,"server_id":18,"link":"photo_8463639.html","width":107,"caption":"","height":160});
															thumbnails[8493732] = clik.newPhoto({"id":8493732,"src":"5D_101_TIFF_thumb.jpg","galleries_id":440951,"server_id":18,"link":"photo_8493732.html","width":107,"caption":"","height":160});
															thumbnails[3501950] = clik.newPhoto({"id":3501950,"src":"5D_062_TIFF_thumb.jpg","galleries_id":440951,"server_id":18,"link":"photo_3501950.html","width":107,"caption":"","height":160});
															thumbnails[8463782] = clik.newPhoto({"id":8463782,"src":"5D_098_TIFF_thumb.jpg","galleries_id":36041,"server_id":18,"link":"photo_8463782.html","width":107,"caption":"","height":160});
															thumbnails[7679257] = clik.newPhoto({"id":7679257,"src":"5D_082_TIFF_thumb.jpg","galleries_id":440951,"server_id":18,"link":"photo_7679257.html","width":107,"caption":"","height":160});
															thumbnails[8463788] = clik.newPhoto({"id":8463788,"src":"5D_099_TIFF_thumb.jpg","galleries_id":36041,"server_id":18,"link":"photo_8463788.html","width":107,"caption":"","height":160});
															thumbnails[3894699] = clik.newPhoto({"id":3894699,"src":"5D_066_TIFF_thumb.jpg","galleries_id":440951,"server_id":18,"link":"photo_3894699.html","width":107,"caption":"","height":160});
															thumbnails[4420463] = clik.newPhoto({"id":4420463,"src":"5D_070_TIFF_thumb.jpg","galleries_id":440951,"server_id":18,"link":"photo_4420463.html","width":107,"caption":"","height":160});
															thumbnails[5943510] = clik.newPhoto({"id":5943510,"src":"5D_079_TIFF_thumb.jpg","galleries_id":440951,"server_id":18,"link":"photo_5943510.html","width":107,"caption":"","height":160});
															thumbnails[7679247] = clik.newPhoto({"id":7679247,"src":"5D_080_TIFF_thumb.jpg","galleries_id":440951,"server_id":18,"link":"photo_7679247.html","width":107,"caption":"","height":160});
															thumbnails[4072623] = clik.newPhoto({"id":4072623,"src":"5D_068_TIFF_thumb.jpg","galleries_id":440951,"server_id":18,"link":"photo_4072623.html","width":107,"caption":"","height":160});
															thumbnails[8108653] = clik.newPhoto({"id":8108653,"src":"5D_095_TIFF_thumb.jpg","galleries_id":440951,"server_id":18,"link":"photo_8108653.html","width":107,"caption":"","height":160});
															thumbnails[4640612] = clik.newPhoto({"id":4640612,"src":"5D_073_TIFF_thumb.jpg","galleries_id":440951,"server_id":18,"link":"photo_4640612.html","width":107,"caption":"","height":160});
															thumbnails[4640683] = clik.newPhoto({"id":4640683,"src":"5D_072_TIFF_thumb.jpg","galleries_id":440951,"server_id":18,"link":"photo_4640683.html","width":107,"caption":"","height":160});
															thumbnails[2204513] = clik.newPhoto({"id":2204513,"src":"5D_027_TIFF_thumb.jpg","galleries_id":440951,"server_id":18,"link":"photo_2204513.html","width":107,"caption":"","height":160});
															thumbnails[3966305] = clik.newPhoto({"id":3966305,"src":"5D_067_TIFF_thumb.jpg","galleries_id":440951,"server_id":18,"link":"photo_3966305.html","width":106,"caption":"","height":160});
															thumbnails[8285669] = clik.newPhoto({"id":8285669,"src":"5D_092_TIFF_thumb.jpg","galleries_id":440951,"server_id":18,"link":"photo_8285669.html","width":107,"caption":"","height":160});
															thumbnails[5943530] = clik.newPhoto({"id":5943530,"src":"5D_078_TIFF_thumb.jpg","galleries_id":440951,"server_id":18,"link":"photo_5943530.html","width":107,"caption":"","height":160});
															thumbnails[3894656] = clik.newPhoto({"id":3894656,"src":"5D_065_TIFF_thumb.jpg","galleries_id":440951,"server_id":18,"link":"photo_3894656.html","width":107,"caption":"","height":160});
															thumbnails[2204450] = clik.newPhoto({"id":2204450,"src":"5D_033_TIFF_thumb.jpg","galleries_id":440951,"server_id":18,"link":"photo_2204450.html","width":107,"caption":"","height":160});
															thumbnails[7679151] = clik.newPhoto({"id":7679151,"src":"5D_081_TIFF_thumb.jpg","galleries_id":440951,"server_id":18,"link":"photo_7679151.html","width":107,"caption":"","height":160});
															thumbnails[5315899] = clik.newPhoto({"id":5315899,"src":"5D_077_TIFF_thumb.jpg","galleries_id":440951,"server_id":18,"link":"photo_5315899.html","width":107,"caption":"","height":160});
															thumbnails[7804651] = clik.newPhoto({"id":7804651,"src":"5D_083_TIFF1_thumb.jpg","galleries_id":440951,"server_id":18,"link":"photo_7804651.html","width":107,"caption":"","height":160});
															thumbnails[7863086] = clik.newPhoto({"id":7863086,"src":"5D_088_TIFF1_thumb.jpg","galleries_id":440951,"server_id":18,"link":"photo_7863086.html","width":107,"caption":"","height":160});
															thumbnails[8108640] = clik.newPhoto({"id":8108640,"src":"5D_091_TIFF_thumb.jpg","galleries_id":440951,"server_id":18,"link":"photo_8108640.html","width":107,"caption":"","height":160});
															thumbnails[4072624] = clik.newPhoto({"id":4072624,"src":"5D_069_TIFF_thumb.jpg","galleries_id":440951,"server_id":18,"link":"photo_4072624.html","width":107,"caption":"","height":160});
															thumbnails[8108649] = clik.newPhoto({"id":8108649,"src":"5D_094_TIFF_thumb.jpg","galleries_id":440951,"server_id":18,"link":"photo_8108649.html","width":107,"caption":"","height":160});
															thumbnails[3501908] = clik.newPhoto({"id":3501908,"src":"5D_061_TIFF_thumb.jpg","galleries_id":440951,"server_id":18,"link":"photo_3501908.html","width":107,"caption":"","height":160});
															thumbnails[8463800] = clik.newPhoto({"id":8463800,"src":"5D_100__TIFF_thumb.jpg","galleries_id":440951,"server_id":18,"link":"photo_8463800.html","width":107,"caption":"","height":160});
															thumbnails[8560801] = clik.newPhoto({"id":8560801,"src":"5D_103_TIFF_thumb.jpg","galleries_id":440951,"server_id":18,"link":"photo_8560801.html","width":107,"caption":"","height":160});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  						galleries[36041] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Gallery 1","link":"gallery_36041.html","maxRecords":0.0,"photoIDs":[1106943.0,454280.0,1844231.0,454283.0,1844433.0,454285.0,1198590.0,1106864.0,454294.0,653490.0,3894742.0,1658032.0,701537.0,1831059.0,1255921.0,7804697.0,2204479.0,2054411.0,1305081.0,454277.0,1844396.0,2204539.0,2204551.0,2931465.0,8463639.0,8463782.0,8463788.0],"skipIndex":0,"section_code":"gallery","featured_images":454280.0,"id":36041,"singleSection":false});				  						galleries[36040] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Gallery 2","link":"gallery_36040.html","maxRecords":0.0,"photoIDs":[454178.0,454186.0,454192.0,7682944.0,454210.0,986348.0,454217.0,454227.0,454250.0,454268.0,656261.0,1106838.0,454235.0,1256337.0,2204636.0],"skipIndex":0,"section_code":"gallery","featured_images":986348.0,"id":36040,"singleSection":false});				  						galleries[440951] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Gallery 3","link":"gallery_440951.html","maxRecords":0.0,"photoIDs":[8493732.0,3501950.0,7679257.0,3894699.0,4420463.0,5943510.0,7679247.0,4072623.0,8108653.0,4640612.0,4640683.0,2204513.0,3966305.0,8285669.0,5943530.0,3894656.0,2204450.0,7679151.0,5315899.0,7804651.0,7863086.0,8108640.0,4072624.0,8108649.0,3501908.0,8463800.0,8560801.0],"skipIndex":0,"section_code":"gallery","featured_images":7679151.0,"id":440951,"singleSection":false});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[1] = '454178,454192,454210,454227,454268,1106838,454235,1256337,2204636';
imageSets[2] = '454280,986348,7679151';
imageSets[3] = '1106943,454280,1844231,454283,1844433,454285,1198590,1106864,986348,454294,653490,3894742,1658032,701537,1831059,454268,1255921,656261,2204479,2054411,1305081,454277,1844396,2204539,1106838,2204551,1256337,2931465,2204636,3501950,7679257,3894699,4420463,5943510,7679247,4072623,4640612,4640683,2204513,3966305,5943530,3894656,2204450,5315899,4072624,3501908';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 51:
		val = 'http://www12.clikpic.com/bedingfield/images';
		break;
	}
		switch (server_id) {
		case 0:
		val = 'http://www.clikpic.com/bedingfield/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/bedingfield/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/bedingfield/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/bedingfield/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/bedingfield/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/bedingfield/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/bedingfield/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/bedingfield/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/bedingfield/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/bedingfield/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/bedingfield/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/bedingfield/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/bedingfield/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/bedingfield/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/bedingfield/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/bedingfield/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/bedingfield/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/bedingfield/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/bedingfield/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/bedingfield/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/bedingfield/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/bedingfield/images';
		break;
	}
		switch (server_id) {
		case 53:
		val = 'http://images.clikpic.com/bedingfield/images';
		break;
	}
		switch (server_id) {
		case 52:
		val = 'http://tpc22/clikpic/bedingfield/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/bedingfield/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/bedingfield/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 = 'Marc Bedingfield Photography: ' + 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.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="Marcbedingfield@live.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="Marcbedingfield@live.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;
	}
}

			

