window.thumbnails = {};
															thumbnails[2379297] = clik.newPhoto({"id":2379297,"src":"_MG_7506_00881_thumb.jpg","galleries_id":153994,"server_id":32,"link":"photo_2379297.html","width":130,"caption":"Ullswater, Winter Morning","height":86});
															thumbnails[2379298] = clik.newPhoto({"id":2379298,"src":"IMG_9802_thumb.jpg","galleries_id":153994,"server_id":32,"link":"photo_2379298.html","width":130,"caption":"Log","height":195});
															thumbnails[2379299] = clik.newPhoto({"id":2379299,"src":"_MG_76931_thumb.jpg","galleries_id":153994,"server_id":32,"link":"photo_2379299.html","width":130,"caption":"Old & Young Trees","height":87});
															thumbnails[2379301] = clik.newPhoto({"id":2379301,"src":"_MG_78295_thumb.jpg","galleries_id":153994,"server_id":32,"link":"photo_2379301.html","width":130,"caption":"Fotheringay, Winter Scene","height":195});
															thumbnails[2379302] = clik.newPhoto({"id":2379302,"src":"_MG_7518_0100toned1_thumb.jpg","galleries_id":153994,"server_id":32,"link":"photo_2379302.html","width":130,"caption":"Water on Rocks","height":87});
															thumbnails[2379305] = clik.newPhoto({"id":2379305,"src":"_MG_7798_thumb.jpg","galleries_id":153994,"server_id":32,"link":"photo_2379305.html","width":130,"caption":"Serene Scene","height":195});
															thumbnails[2379306] = clik.newPhoto({"id":2379306,"src":"_MG_76391_thumb.jpg","galleries_id":153994,"server_id":32,"link":"photo_2379306.html","width":130,"caption":"Morning Light","height":85});
															thumbnails[2379307] = clik.newPhoto({"id":2379307,"src":"_MG_7541_0123bw_thumb.jpg","galleries_id":153994,"server_id":32,"link":"photo_2379307.html","width":130,"caption":"Derwent Water","height":87});
															thumbnails[2379326] = clik.newPhoto({"id":2379326,"src":"_MG_7511_0093_thumb.jpg","galleries_id":153994,"server_id":32,"link":"photo_2379326.html","width":130,"caption":"Aira Beck","height":87});
															thumbnails[2379331] = clik.newPhoto({"id":2379331,"src":"IMG_9832_thumb.jpg","galleries_id":153994,"server_id":32,"link":"photo_2379331.html","width":130,"caption":"Overflow","height":195});
															thumbnails[2379375] = clik.newPhoto({"id":2379375,"src":"triptic b_thumb.jpg","galleries_id":153994,"server_id":32,"link":"photo_2379375.html","width":130,"caption":"North Inch Panoramas","height":184});
															thumbnails[2381361] = clik.newPhoto({"id":2381361,"src":"F1000014_thumb.jpg","galleries_id":153994,"server_id":32,"link":"photo_2381361.html","width":87,"caption":"Snow Study<br>\r\n","height":130});
															thumbnails[2381363] = clik.newPhoto({"id":2381363,"src":"IMG_1183_thumb.jpg","galleries_id":153994,"server_id":32,"link":"photo_2381363.html","width":97,"caption":"Early Morning Scene","height":130});
															thumbnails[2381365] = clik.newPhoto({"id":2381365,"src":"IMG_1469_thumb.jpg","galleries_id":153994,"server_id":32,"link":"photo_2381365.html","width":130,"caption":"Valley View","height":97});
															thumbnails[2381367] = clik.newPhoto({"id":2381367,"src":"ireland038_thumb.jpg","galleries_id":153994,"server_id":32,"link":"photo_2381367.html","width":97,"caption":"Waterside","height":130});
															thumbnails[2381368] = clik.newPhoto({"id":2381368,"src":"ireland0451_thumb.jpg","galleries_id":153994,"server_id":32,"link":"photo_2381368.html","width":130,"caption":"Standing Stones","height":97});
															thumbnails[2381369] = clik.newPhoto({"id":2381369,"src":"P2150008_thumb.jpg","galleries_id":153994,"server_id":32,"link":"photo_2381369.html","width":97,"caption":"Frozen Waterfall","height":130});
															thumbnails[2381371] = clik.newPhoto({"id":2381371,"src":"ScotlandNov04009_thumb.jpg","galleries_id":153994,"server_id":32,"link":"photo_2381371.html","width":130,"caption":"Frozen Rock","height":97});
															thumbnails[2381373] = clik.newPhoto({"id":2381373,"src":"tarn_thumb.jpg","galleries_id":153994,"server_id":32,"link":"photo_2381373.html","width":97,"caption":"Tarn","height":130});
															thumbnails[2381397] = clik.newPhoto({"id":2381397,"src":"pana2a_thumb.jpg","galleries_id":154688,"server_id":32,"link":"photo_2381397.html","width":130,"caption":"Evening View","height":43});
															thumbnails[2381406] = clik.newPhoto({"id":2381406,"src":"Panorama1_2_thumb.jpg","galleries_id":154688,"server_id":32,"link":"photo_2381406.html","width":130,"caption":"River Tay Valley","height":42});
															thumbnails[3787860] = clik.newPhoto({"id":3787860,"src":"IMG_1503_thumb.jpg","galleries_id":153994,"server_id":32,"link":"photo_3787860.html","width":130,"caption":"Get out of my picture !","height":87});
															thumbnails[5854420] = clik.newPhoto({"id":5854420,"src":"_MG_5538_thumb.jpg","galleries_id":154519,"server_id":32,"link":"photo_5854420.html","width":87,"caption":"Early Morning Scene","height":130});
															thumbnails[6710621] = clik.newPhoto({"id":6710621,"src":"_MG_6052_thumb.jpg","galleries_id":154519,"server_id":32,"link":"photo_6710621.html","width":130,"caption":"Scottish Loch Scene","height":130});
															thumbnails[8305479] = clik.newPhoto({"id":8305479,"src":"_MG_6722_copy_thumb.jpg","galleries_id":154519,"server_id":37,"link":"photo_8305479.html","width":87,"caption":"Bluebell Wood, May 2011","height":130});
															thumbnails[5678419] = clik.newPhoto({"id":5678419,"src":"_MG_4045bb_thumb.jpg","galleries_id":154519,"server_id":32,"link":"photo_5678419.html","width":130,"caption":"Tay Bridge at Perth","height":87});
															thumbnails[7492031] = clik.newPhoto({"id":7492031,"src":"_MG_0912_370x270_thumb.jpg","galleries_id":406205,"server_id":32,"link":"photo_7492031.html","width":130,"caption":"Image No 1","height":104});
															thumbnails[5678426] = clik.newPhoto({"id":5678426,"src":"_MG_5457_thumb.jpg","galleries_id":154519,"server_id":32,"link":"photo_5678426.html","width":87,"caption":"Three Trees","height":130});
															thumbnails[7492034] = clik.newPhoto({"id":7492034,"src":"IMG_1127_270x270_thumb.jpg","galleries_id":406205,"server_id":32,"link":"photo_7492034.html","width":130,"caption":"Image No 2","height":104});
															thumbnails[3250781] = clik.newPhoto({"id":3250781,"src":"IMG_1438_thumb.jpg","galleries_id":153994,"server_id":32,"link":"photo_3250781.html","width":130,"caption":"Keen Photographer","height":87});
															thumbnails[5198002] = clik.newPhoto({"id":5198002,"src":"_MG_3188_thumb.jpg","galleries_id":154519,"server_id":32,"link":"photo_5198002.html","width":130,"caption":"Canal","height":65});
															thumbnails[7492041] = clik.newPhoto({"id":7492041,"src":"_MG_4015b_370x122_thumb.jpg","galleries_id":406205,"server_id":32,"link":"photo_7492041.html","width":130,"caption":"Image No 3","height":104});
															thumbnails[5197934] = clik.newPhoto({"id":5197934,"src":"_MG_3261_thumb.jpg","galleries_id":154519,"server_id":32,"link":"photo_5197934.html","width":130,"caption":"Pylon and Rainbow","height":65});
															thumbnails[7492042] = clik.newPhoto({"id":7492042,"src":"De326_270x270_thumb.jpg","galleries_id":406205,"server_id":32,"link":"photo_7492042.html","width":130,"caption":"Image No 4","height":104});
															thumbnails[3250708] = clik.newPhoto({"id":3250708,"src":"IMG_1382_thumb.jpg","galleries_id":153994,"server_id":32,"link":"photo_3250708.html","width":130,"caption":"Flow","height":87});
															thumbnails[4840776] = clik.newPhoto({"id":4840776,"src":"_MG_2094_thumb.jpg","galleries_id":154519,"server_id":32,"link":"photo_4840776.html","width":130,"caption":"Coastal Scene","height":130});
															thumbnails[7492043] = clik.newPhoto({"id":7492043,"src":"_MG_2949a_370x270_thumb.jpg","galleries_id":406205,"server_id":32,"link":"photo_7492043.html","width":130,"caption":"Image No 5","height":104});
															thumbnails[2988663] = clik.newPhoto({"id":2988663,"src":"IMG_1280_thumb.jpg","galleries_id":153994,"server_id":32,"link":"photo_2988663.html","width":130,"caption":"Straw Bale","height":96});
															thumbnails[4815372] = clik.newPhoto({"id":4815372,"src":"_MG_1980_thumb.jpg","galleries_id":154519,"server_id":32,"link":"photo_4815372.html","width":130,"caption":"Log in stream","height":130});
															thumbnails[7492061] = clik.newPhoto({"id":7492061,"src":"De329_370x270_thumb.jpg","galleries_id":406205,"server_id":32,"link":"photo_7492061.html","width":104,"caption":"Image No 6","height":130});
															thumbnails[5198020] = clik.newPhoto({"id":5198020,"src":"_MG_3241_thumb.jpg","galleries_id":154519,"server_id":32,"link":"photo_5198020.html","width":130,"caption":"Gate","height":68});
															thumbnails[7492064] = clik.newPhoto({"id":7492064,"src":"De359a_370x270_thumb.jpg","galleries_id":406205,"server_id":32,"link":"photo_7492064.html","width":130,"caption":"Image No 7","height":104});
															thumbnails[2666035] = clik.newPhoto({"id":2666035,"src":"pana3_thumb.jpg","galleries_id":154688,"server_id":32,"link":"photo_2666035.html","width":130,"caption":"Sidlaw Hills","height":28});
															thumbnails[4185834] = clik.newPhoto({"id":4185834,"src":"_MG_1653_thumb.jpg","galleries_id":153994,"server_id":32,"link":"photo_4185834.html","width":87,"caption":"Lone Tree on Stanton Moor","height":130});
															thumbnails[5854400] = clik.newPhoto({"id":5854400,"src":"_MG_5531_thumb.jpg","galleries_id":154519,"server_id":32,"link":"photo_5854400.html","width":130,"caption":"Lyveden New Bield","height":130});
															thumbnails[7492067] = clik.newPhoto({"id":7492067,"src":"IMG_1425_370x122_thumb.jpg","galleries_id":406205,"server_id":32,"link":"photo_7492067.html","width":130,"caption":"Image No 8","height":104});
															thumbnails[2650713] = clik.newPhoto({"id":2650713,"src":"IMG_1064_thumb.jpg","galleries_id":153994,"server_id":32,"link":"photo_2650713.html","width":130,"caption":"Pebbles","height":87});
															thumbnails[7492073] = clik.newPhoto({"id":7492073,"src":"De232_370x270_thumb.jpg","galleries_id":406205,"server_id":32,"link":"photo_7492073.html","width":130,"caption":"Image No 9","height":104});
															thumbnails[2628376] = clik.newPhoto({"id":2628376,"src":"IMG_1127_thumb.jpg","galleries_id":153994,"server_id":32,"link":"photo_2628376.html","width":130,"caption":"Twilight Rocks","height":130});
															thumbnails[3787816] = clik.newPhoto({"id":3787816,"src":"IMG_1523_thumb.jpg","galleries_id":153994,"server_id":32,"link":"photo_3787816.html","width":130,"caption":"Birks of Aberfeldy","height":87});
															thumbnails[4185839] = clik.newPhoto({"id":4185839,"src":"_MG_1647_thumb.jpg","galleries_id":153994,"server_id":32,"link":"photo_4185839.html","width":130,"caption":"On Stanton Moor","height":46});
															thumbnails[5097681] = clik.newPhoto({"id":5097681,"src":"_MG_2878_thumb.jpg","galleries_id":154519,"server_id":32,"link":"photo_5097681.html","width":87,"caption":"Cyclist in the Woods","height":130});
															thumbnails[7492077] = clik.newPhoto({"id":7492077,"src":"De221_370x270_thumb.jpg","galleries_id":406205,"server_id":32,"link":"photo_7492077.html","width":104,"caption":"Image No 10","height":130});
															thumbnails[6057768] = clik.newPhoto({"id":6057768,"src":"_MG_4015_thumb.jpg","galleries_id":154519,"server_id":32,"link":"photo_6057768.html","width":130,"caption":"Tree and hut by frozen lake","height":43});
															thumbnails[6482876] = clik.newPhoto({"id":6482876,"src":"_MG_5471_copy_thumb.jpg","galleries_id":154519,"server_id":32,"link":"photo_6482876.html","width":130,"caption":"Sunrise - North Berwick","height":87});
															thumbnails[3332108] = clik.newPhoto({"id":3332108,"src":"IMG_1458_thumb.jpg","galleries_id":153994,"server_id":32,"link":"photo_3332108.html","width":32,"caption":"Tower","height":130});
															thumbnails[4662504] = clik.newPhoto({"id":4662504,"src":"IMG_1425_thumb.jpg","galleries_id":154519,"server_id":32,"link":"photo_4662504.html","width":130,"caption":"Derwent Water, winter scene","height":47});
															thumbnails[4031875] = clik.newPhoto({"id":4031875,"src":"IMG_1560_thumb.jpg","galleries_id":154519,"server_id":32,"link":"photo_4031875.html","width":87,"caption":"Wild Garlic","height":130});
															thumbnails[2521390] = clik.newPhoto({"id":2521390,"src":"IMG_1022_thumb.jpg","galleries_id":153994,"server_id":32,"link":"photo_2521390.html","width":130,"caption":"Ferns in forest","height":87});
															thumbnails[3250803] = clik.newPhoto({"id":3250803,"src":"buttermere_thumb.jpg","galleries_id":153994,"server_id":32,"link":"photo_3250803.html","width":130,"caption":"Buttermere","height":87});
															thumbnails[3787744] = clik.newPhoto({"id":3787744,"src":"IMG_1522_thumb.jpg","galleries_id":154519,"server_id":32,"link":"photo_3787744.html","width":130,"caption":"Falls of Bruar","height":130});
															thumbnails[2379386] = clik.newPhoto({"id":2379386,"src":"_MG_0912_thumb.jpg","galleries_id":153994,"server_id":32,"link":"photo_2379386.html","width":130,"caption":"River Tay","height":87});
															thumbnails[2496959] = clik.newPhoto({"id":2496959,"src":"IMG_0992_thumb.jpg","galleries_id":153994,"server_id":32,"link":"photo_2496959.html","width":130,"caption":"Heford River Dusk LF","height":87});
															thumbnails[2496972] = clik.newPhoto({"id":2496972,"src":"IMG_1002_thumb.jpg","galleries_id":153994,"server_id":32,"link":"photo_2496972.html","width":87,"caption":"Hefford River Dusk PF","height":130});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  						galleries[154519] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Latest Images","link":"gallery_154519.html","maxRecords":0.0,"photoIDs":[5854420.0,6710621.0,8305479.0,5678419.0,5678426.0,5198002.0,5197934.0,4840776.0,4815372.0,5198020.0,5854400.0,5097681.0,6057768.0,6482876.0,4662504.0,4031875.0,3787744.0],"skipIndex":0,"section_code":"gallery","featured_images":"6710621,6482876,6057768,5854420,5854400,5198020,5097681,4840776,4815372,3787744","id":154519,"singleSection":false});				  						galleries[153994] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Main Gallery","link":"gallery_153994.html","maxRecords":0.0,"photoIDs":[2379297.0,2379298.0,2379299.0,2379301.0,2379302.0,2379305.0,2379306.0,2379307.0,2379326.0,2379331.0,2379375.0,2381361.0,2381363.0,2381365.0,2381367.0,2381368.0,2381369.0,2381371.0,2381373.0,3787860.0,3250781.0,3250708.0,2988663.0,4185834.0,2650713.0,2628376.0,3787816.0,4185839.0,3332108.0,2521390.0,3250803.0,2379386.0,2496959.0,2496972.0],"skipIndex":0,"section_code":"gallery","featured_images":"4185834,3787816,3332108,3250803,3250708,2379297","id":153994,"singleSection":false});				  						galleries[406205] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"LRPS Panel","link":"gallery_406205.html","maxRecords":0.0,"photoIDs":[7492031.0,7492034.0,7492041.0,7492042.0,7492043.0,7492061.0,7492064.0,7492067.0,7492073.0,7492077.0],"skipIndex":0,"section_code":"gallery","featured_images":"7492077,7492073,7492067,7492064,7492061,7492043,7492042,7492041,7492034,7492031","id":406205,"singleSection":false});				  						galleries[154688] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Panoramic Landscapes","link":"gallery_154688.html","maxRecords":0.0,"photoIDs":[2381397.0,2381406.0,2666035.0],"skipIndex":0,"section_code":"gallery","featured_images":"2666035,2381406,2381397","id":154688,"singleSection":false});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[1] = '8305479,7492077,7492073,7492067,7492064,7492061,7492043,7492042,7492041,7492034,7492031,6710621,6482876,6057768,5854420,5854400,5678419,5198020,5198002,5197934,5097681,4840776,4815372,4185839,4185834,3787816,3787744,3332108,3250803,2988663,2650713,2628376,2521390,2496972,2496959,2381397,2381371,2381367,2379386,2379307,2379306,2379305';
imageSets[2] = '7492077,7492073,7492067,7492064,7492061,7492043,7492042,7492041,7492034,7492031,6710621,6482876,6057768,5854420,5854400,5198020,5097681,4840776,4815372,4185834,3787816,3787744,3332108,3250803,3250708,2379297';
imageSets[3] = '8305479,7492077,7492073,7492067,7492064,7492061,7492043,7492042,7492041,7492034,7492031,6057768,5854420,5854400,5198020';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/bobcraik/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/bobcraik/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/bobcraik/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/bobcraik/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/bobcraik/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/bobcraik/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/bobcraik/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/bobcraik/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/bobcraik/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/bobcraik/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/bobcraik/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/bobcraik/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/bobcraik/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/bobcraik/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/bobcraik/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/bobcraik/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://admin2.clikpic.com/bobcraik/images';
		break;
	}
		switch (server_id) {
		case 33:
		val = 'http://www8.clikpic.com/bobcraik/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/bobcraik/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/bobcraik/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/bobcraik/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/bobcraik/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/bobcraik/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/bobcraik/images';
		break;
	}
		return val;
}

/***************************************************************************
* img = reference to image object in which to show image                   *
***************************************************************************/
function showHomeImage(img) {
	imageID = randomListVal('');
	if (!basic) {
		img.src = photos[imageID].src;
		img.width = photos[imageID].width;
		img.height = photos[imageID].height;
		img.parentNode.title = img.alt = photos[imageID].caption;
	} else {
		newImage = new Image(photos[imageID].width,photos[imageID].height);
		newImage.src = photos[imageID].src;
		document.images[img.name] = newImage;
		
	}
}

function getHomeImageLink(imageID) {
  	var href='', photo = backgrounds && backgrounds[imageID];
	if(photo){
		if (photo && photo.galleries_id != '') {
  			href = photo.fnGalleryLink();
  		}
  		  		else {
  				href += 'gallery.html';
  	  		}
	}
    return href;
}

/***************************************************************************
* Show a random image on home page from featured images                    *
***************************************************************************/
function showHomeImageInline(el, image_sets_id, href) {
	
	var css = {}, imageID,
	    imageSetsId = 1;
	if(image_sets_id){
		imageSetsId = image_sets_id;
	}
	imageID = randomListVal(imageSets[imageSetsId]);
	if (href == null && 'gallery' != '') {
					href = getHomeImageLink(imageID);
	}
	
	updateImage({nextPhoto: backgrounds[imageID], img:el.find('img')[0],
                $photo:el, $title:$('#homeimageTitleContainer'), $detail:$('#homeimageDetailsContainer'),                speed:0, href:href, css:css, onAfter: function(){                  this.closest('.contentsection').doManualAlign({				    inner: 'img',				    crop: 'a'				  });                }              });
}

/***************************************************************************
* Set 'img' to be a new image given its photo() object                     *
***************************************************************************/
function updateImage (options) {
	var defaults = {nextPhoto:'',field:'',img:'',$photo:'',$title:'',$detail:'',$detailContainer:'',
                    updateDocumentTitle:false,speed:0,href:false,css:false,updateHash:false,onAfter:null,onBefore:null},
		op = $.extend({},defaults,options),
		html = '', temp = '',
		photoId = op.nextPhoto.id,
		photoCaption = ''+op.nextPhoto.caption,
		photoSrc = op.nextPhoto.src;
	
	if (op.updateHash && clik.getIDInUrl(location.href,'photo') != op.nextPhoto.id) {
		clik.changeHash('photos_id=' + op.nextPhoto.id, true);
	}
		
	    if (op.$title.length > 0) {
  		op.$title.fadeGalleryDetails(photoCaption, op.speed);
    }
        if (op.updateDocumentTitle) {
						  document.title = 'Bob Craik LRPS - Landscape 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.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="pinbob0@cdams.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="pinbob0@cdams.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({					href: thumbnails[imageID].fnGalleryLink(gallery_id),					title: galleries[gallery_id].title				});
			}
		}
	}
}

/***************************************************************************
* 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;
	}
}

			

