window.thumbnails = {};
															thumbnails[3684885] = clik.newPhoto({"id":3684885,"src":"DSC_0105_thumb.JPG","galleries_id":157227,"server_id":5,"link":"photo_3684885.html","width":130,"caption":"Kinross House, Fife","height":163});
															thumbnails[2329289] = clik.newPhoto({"id":2329289,"src":"10_thumb.jpg","galleries_id":151749,"server_id":5,"link":"photo_2329289.html","width":130,"caption":"Haddington, east lothian wedding","height":163});
															thumbnails[2329296] = clik.newPhoto({"id":2329296,"src":"13_thumb.jpg","galleries_id":151749,"server_id":5,"link":"photo_2329296.html","width":130,"caption":"'flowergirl' Balbirnie House Hotel, Fife","height":163});
															thumbnails[2329298] = clik.newPhoto({"id":2329298,"src":"17_thumb.jpg","galleries_id":151749,"server_id":5,"link":"photo_2329298.html","width":130,"caption":"Leith Registry, Edinburgh","height":163});
															thumbnails[2329301] = clik.newPhoto({"id":2329301,"src":"19_thumb.jpg","galleries_id":151749,"server_id":5,"link":"photo_2329301.html","width":130,"caption":"Royal Mile, Edinburgh","height":169});
															thumbnails[2329304] = clik.newPhoto({"id":2329304,"src":"20_thumb.jpg","galleries_id":151749,"server_id":5,"link":"photo_2329304.html","width":130,"caption":"Roman Camp Hotel, Scotland","height":165});
															thumbnails[2329308] = clik.newPhoto({"id":2329308,"src":"21_thumb.jpg","galleries_id":157227,"server_id":5,"link":"photo_2329308.html","width":130,"caption":"midcalder old kirk, West Lothian ","height":163});
															thumbnails[2329310] = clik.newPhoto({"id":2329310,"src":"1022_thumb.jpg","galleries_id":157227,"server_id":5,"link":"photo_2329310.html","width":130,"caption":"Wedding Bouquet & Shoes","height":163});
															thumbnails[2329311] = clik.newPhoto({"id":2329311,"src":"25_thumb.jpg","galleries_id":151749,"server_id":5,"link":"photo_2329311.html","width":130,"caption":"Lennoxlove House, East Lothian","height":163});
															thumbnails[2329313] = clik.newPhoto({"id":2329313,"src":"27_thumb.jpg","galleries_id":157227,"server_id":5,"link":"photo_2329313.html","width":130,"caption":"'Surprise' at Lennoxlove, east lothian","height":163});
															thumbnails[2329314] = clik.newPhoto({"id":2329314,"src":"29_thumb.jpg","galleries_id":151749,"server_id":5,"link":"photo_2329314.html","width":130,"caption":"Linlithgow Palace, west lothian","height":163});
															thumbnails[2329317] = clik.newPhoto({"id":2329317,"src":"30_thumb.jpg","galleries_id":151749,"server_id":5,"link":"photo_2329317.html","width":130,"caption":"Linlithgow Palace, west lothian","height":163});
															thumbnails[2329321] = clik.newPhoto({"id":2329321,"src":"31_thumb.jpg","galleries_id":151749,"server_id":5,"link":"photo_2329321.html","width":130,"caption":"joyous bride before the ceremony","height":163});
															thumbnails[2329339] = clik.newPhoto({"id":2329339,"src":"33_thumb.jpg","galleries_id":157227,"server_id":5,"link":"photo_2329339.html","width":130,"caption":"Linlithgow Palace","height":163});
															thumbnails[2329341] = clik.newPhoto({"id":2329341,"src":"35_thumb.jpg","galleries_id":151749,"server_id":5,"link":"photo_2329341.html","width":130,"caption":"Linlithgow Palace, west lothian","height":163});
															thumbnails[2329343] = clik.newPhoto({"id":2329343,"src":"36_thumb.jpg","galleries_id":151834,"server_id":5,"link":"photo_2329343.html","width":130,"caption":"Hopetoun House, Edinburgh","height":200});
															thumbnails[2329344] = clik.newPhoto({"id":2329344,"src":"38_thumb.jpg","galleries_id":151834,"server_id":5,"link":"photo_2329344.html","width":130,"caption":"Edinburgh Castle","height":163});
															thumbnails[2329346] = clik.newPhoto({"id":2329346,"src":"39_thumb.jpg","galleries_id":151834,"server_id":5,"link":"photo_2329346.html","width":130,"caption":"Lennoxlove House, east Lothian","height":163});
															thumbnails[2329347] = clik.newPhoto({"id":2329347,"src":"40_thumb.jpg","galleries_id":151834,"server_id":5,"link":"photo_2329347.html","width":130,"caption":"Linlithgow Palace, west Lothian","height":163});
															thumbnails[2329348] = clik.newPhoto({"id":2329348,"src":"42_thumb.jpg","galleries_id":151834,"server_id":5,"link":"photo_2329348.html","width":130,"caption":"Lennoxlove House, Haddington.","height":163});
															thumbnails[2329349] = clik.newPhoto({"id":2329349,"src":"44_thumb.jpg","galleries_id":151834,"server_id":5,"link":"photo_2329349.html","width":130,"caption":"Greenbank Gardens, Glasgow","height":163});
															thumbnails[2329355] = clik.newPhoto({"id":2329355,"src":"45_thumb.jpg","galleries_id":151834,"server_id":5,"link":"photo_2329355.html","width":130,"caption":"Lennoxlove, East Lothian","height":163});
															thumbnails[2329358] = clik.newPhoto({"id":2329358,"src":"46_thumb.jpg","galleries_id":151834,"server_id":5,"link":"photo_2329358.html","width":130,"caption":"Great Hall, Lennoxlove, East Lothian","height":163});
															thumbnails[2329364] = clik.newPhoto({"id":2329364,"src":"47_thumb.jpg","galleries_id":151834,"server_id":5,"link":"photo_2329364.html","width":130,"caption":"Balbirnie House Hotel, Fife","height":104});
															thumbnails[2329366] = clik.newPhoto({"id":2329366,"src":"49_thumb.jpg","galleries_id":151834,"server_id":5,"link":"photo_2329366.html","width":130,"caption":"Edinburgh Castle Espanade","height":199});
															thumbnails[2329370] = clik.newPhoto({"id":2329370,"src":"50_thumb.jpg","galleries_id":151834,"server_id":5,"link":"photo_2329370.html","width":130,"caption":"Balbirnie House Hotel, Fife","height":163});
															thumbnails[2329374] = clik.newPhoto({"id":2329374,"src":"52_thumb.jpg","galleries_id":151834,"server_id":5,"link":"photo_2329374.html","width":130,"caption":"Lennoxlove House","height":163});
															thumbnails[2329377] = clik.newPhoto({"id":2329377,"src":"55_thumb.jpg","galleries_id":151834,"server_id":5,"link":"photo_2329377.html","width":130,"caption":"Balbirnie House Hotel, Fife","height":163});
															thumbnails[2329379] = clik.newPhoto({"id":2329379,"src":"56_thumb.jpg","galleries_id":151834,"server_id":5,"link":"photo_2329379.html","width":130,"caption":"Balbirnie House Hotel","height":163});
															thumbnails[2329381] = clik.newPhoto({"id":2329381,"src":"57_thumb.jpg","galleries_id":151834,"server_id":5,"link":"photo_2329381.html","width":130,"caption":"Balbirnie House Hotel","height":163});
															thumbnails[2329392] = clik.newPhoto({"id":2329392,"src":"596_thumb.jpg","galleries_id":151976,"server_id":5,"link":"photo_2329392.html","width":130,"caption":"Guthrie Castle, Angus","height":163});
															thumbnails[2329398] = clik.newPhoto({"id":2329398,"src":"60_thumb.jpg","galleries_id":151976,"server_id":5,"link":"photo_2329398.html","width":130,"caption":"Dunfermline Abbey, Fife","height":163});
															thumbnails[2329405] = clik.newPhoto({"id":2329405,"src":"62_thumb.jpg","galleries_id":157227,"server_id":5,"link":"photo_2329405.html","width":130,"caption":"Corstorphine, Edinburgh","height":163});
															thumbnails[2329502] = clik.newPhoto({"id":2329502,"src":"6310_thumb.jpg","galleries_id":151976,"server_id":5,"link":"photo_2329502.html","width":130,"caption":"'rat-pack' shot, Hopetoun House, West Lothian","height":163});
															thumbnails[2329694] = clik.newPhoto({"id":2329694,"src":"642_thumb.jpg","galleries_id":151976,"server_id":5,"link":"photo_2329694.html","width":130,"caption":"Botanic Gardens, Edinburgh","height":163});
															thumbnails[2329724] = clik.newPhoto({"id":2329724,"src":"65_thumb.jpg","galleries_id":151976,"server_id":5,"link":"photo_2329724.html","width":130,"caption":"'rugby scrum', Botanic Gardens Edinburgh","height":104});
															thumbnails[2329730] = clik.newPhoto({"id":2329730,"src":"67_thumb.jpg","galleries_id":151976,"server_id":5,"link":"photo_2329730.html","width":130,"caption":"Hopetoun House, Edinburgh","height":200});
															thumbnails[2329732] = clik.newPhoto({"id":2329732,"src":"68_thumb.jpg","galleries_id":151976,"server_id":5,"link":"photo_2329732.html","width":130,"caption":"the bride at Hopetoun House","height":200});
															thumbnails[2329736] = clik.newPhoto({"id":2329736,"src":"70_thumb.jpg","galleries_id":151976,"server_id":5,"link":"photo_2329736.html","width":130,"caption":"Edinburgh Castle wedding","height":163});
															thumbnails[2334103] = clik.newPhoto({"id":2334103,"src":"71_thumb.jpg","galleries_id":157227,"server_id":5,"link":"photo_2334103.html","width":130,"caption":"George Heriots wedding, Edinburgh","height":163});
															thumbnails[2334107] = clik.newPhoto({"id":2334107,"src":"73_thumb.jpg","galleries_id":151976,"server_id":5,"link":"photo_2334107.html","width":130,"caption":"love at Edinburgh Castle","height":163});
															thumbnails[2334108] = clik.newPhoto({"id":2334108,"src":"74_thumb.jpg","galleries_id":151976,"server_id":5,"link":"photo_2334108.html","width":130,"caption":"Hopetoun House","height":85});
															thumbnails[2334110] = clik.newPhoto({"id":2334110,"src":"75_thumb.jpg","galleries_id":151976,"server_id":5,"link":"photo_2334110.html","width":130,"caption":"Edinburgh Botanic Gardens","height":163});
															thumbnails[2334111] = clik.newPhoto({"id":2334111,"src":"76_thumb.jpg","galleries_id":151976,"server_id":5,"link":"photo_2334111.html","width":130,"caption":"natural light, Lennoxlove wedding","height":163});
															thumbnails[2334112] = clik.newPhoto({"id":2334112,"src":"77_thumb.jpg","galleries_id":151976,"server_id":5,"link":"photo_2334112.html","width":130,"caption":"wedding, Lennoxlove House, east lothian","height":104});
															thumbnails[2433403] = clik.newPhoto({"id":2433403,"src":"95_thumb.jpg","galleries_id":151976,"server_id":5,"link":"photo_2433403.html","width":130,"caption":"'romantic kiss' at Balbirnie House Hotel, Fife","height":162});
															thumbnails[2433407] = clik.newPhoto({"id":2433407,"src":"96_thumb.jpg","galleries_id":151749,"server_id":5,"link":"photo_2433407.html","width":130,"caption":"Balbirnie House Hotel, Fife","height":162});
															thumbnails[2435778] = clik.newPhoto({"id":2435778,"src":"97_thumb.jpg","galleries_id":157227,"server_id":5,"link":"photo_2435778.html","width":130,"caption":"Dalhousie Castle, Midlothian","height":162});
															thumbnails[2435779] = clik.newPhoto({"id":2435779,"src":"98_thumb.jpg","galleries_id":157227,"server_id":5,"link":"photo_2435779.html","width":130,"caption":"Melville Castle, Midlothian","height":162});
															thumbnails[2435782] = clik.newPhoto({"id":2435782,"src":"99_thumb.jpg","galleries_id":157227,"server_id":5,"link":"photo_2435782.html","width":130,"caption":"Dundas Castle, Edinburgh","height":163});
															thumbnails[2435785] = clik.newPhoto({"id":2435785,"src":"100_thumb.jpg","galleries_id":151976,"server_id":5,"link":"photo_2435785.html","width":130,"caption":"Dundas Castle wedding, Edinburgh","height":162});
															thumbnails[2435786] = clik.newPhoto({"id":2435786,"src":"1011_thumb.jpg","galleries_id":157227,"server_id":5,"link":"photo_2435786.html","width":130,"caption":"'wedding blossom', Norton House Hotel, Edinburgh","height":163});
															thumbnails[2435794] = clik.newPhoto({"id":2435794,"src":"231_thumb.jpg","galleries_id":151749,"server_id":5,"link":"photo_2435794.html","width":130,"caption":"Houston House Hotel, west lothian","height":162});
															thumbnails[2435808] = clik.newPhoto({"id":2435808,"src":"103_thumb.jpg","galleries_id":157227,"server_id":5,"link":"photo_2435808.html","width":130,"caption":"Mansfield Traquair, Edinburgh","height":104});
															thumbnails[2435810] = clik.newPhoto({"id":2435810,"src":"104_thumb.jpg","galleries_id":157227,"server_id":5,"link":"photo_2435810.html","width":130,"caption":"Dundas Castle, near Edinburgh","height":162});
															thumbnails[2591054] = clik.newPhoto({"id":2591054,"src":"105_thumb.jpg","galleries_id":157227,"server_id":5,"link":"photo_2591054.html","width":130,"caption":"Hindi Wedding, Edinburgh","height":91});
															thumbnails[2591064] = clik.newPhoto({"id":2591064,"src":"107_thumb.jpg","galleries_id":157227,"server_id":5,"link":"photo_2591064.html","width":130,"caption":"Hindi wedding, Edinburgh","height":163});
															thumbnails[2855444] = clik.newPhoto({"id":2855444,"src":"DSC_0127_thumb.jpg","galleries_id":157227,"server_id":5,"link":"photo_2855444.html","width":130,"caption":"Melville Castle, Midlothian","height":163});
															thumbnails[3890970] = clik.newPhoto({"id":3890970,"src":"DSC_0101a_thumb.jpg","galleries_id":151749,"server_id":5,"link":"photo_3890970.html","width":130,"caption":"Myres Castle, Auchtermuchty, Fife","height":162});
															thumbnails[4182202] = clik.newPhoto({"id":4182202,"src":"DSC_00761_thumb.jpg","galleries_id":151749,"server_id":5,"link":"photo_4182202.html","width":130,"caption":"Kinross House, Fife","height":91});
															thumbnails[4874081] = clik.newPhoto({"id":4874081,"src":"DSC_0190_thumb.JPG","galleries_id":151749,"server_id":5,"link":"photo_4874081.html","width":130,"caption":"Marine Hotel, North Berwick, east lothian","height":163});
															thumbnails[4874104] = clik.newPhoto({"id":4874104,"src":"DSC_0194_thumb.JPG","galleries_id":151749,"server_id":5,"link":"photo_4874104.html","width":130,"caption":"Marine Hotel, North Berwick, East Lothian","height":163});
															thumbnails[6055141] = clik.newPhoto({"id":6055141,"src":"nicola_andrew_thumb.jpg","galleries_id":151749,"server_id":5,"link":"photo_6055141.html","width":130,"caption":"Bay Hotel, Kinghorn, Fife","height":85});
															thumbnails[7754841] = clik.newPhoto({"id":7754841,"src":"DSC_0112_thumb.JPG","galleries_id":157227,"server_id":5,"link":"photo_7754841.html","width":130,"caption":"Kings Park, Edinburgh","height":163});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  						galleries[151749] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Gallery 1","link":"gallery_151749.html","maxRecords":0.0,"photoIDs":[2329289.0,2329296.0,2329298.0,2329301.0,2329304.0,2329311.0,2329314.0,2329317.0,2329321.0,2329341.0,2433407.0,2435794.0,3890970.0,4182202.0,4874081.0,4874104.0,6055141.0],"skipIndex":0,"section_code":"gallery","featured_images":2329289.0,"id":151749,"singleSection":false});				  						galleries[151834] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Gallery 2","link":"gallery_151834.html","maxRecords":0.0,"photoIDs":[2329343.0,2329344.0,2329346.0,2329347.0,2329348.0,2329349.0,2329355.0,2329358.0,2329364.0,2329366.0,2329370.0,2329374.0,2329377.0,2329379.0,2329381.0],"skipIndex":0,"section_code":"gallery","featured_images":2329381.0,"id":151834,"singleSection":false});				  						galleries[151976] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Gallery 3","link":"gallery_151976.html","maxRecords":0.0,"photoIDs":[2329392.0,2329398.0,2329502.0,2329694.0,2329724.0,2329730.0,2329732.0,2329736.0,2334107.0,2334108.0,2334110.0,2334111.0,2334112.0,2433403.0,2435785.0],"skipIndex":0,"section_code":"gallery","featured_images":2433403.0,"id":151976,"singleSection":false});				  						galleries[157227] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Gallery 4","link":"gallery_157227.html","maxRecords":0.0,"photoIDs":[3684885.0,2329308.0,2329310.0,2329313.0,2329339.0,2329405.0,2334103.0,2435778.0,2435779.0,2435782.0,2435786.0,2435808.0,2435810.0,2591054.0,2591064.0,2855444.0,7754841.0],"skipIndex":0,"section_code":"gallery","featured_images":2329405.0,"id":157227,"singleSection":false});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[1] = '2435794,2433407,2334110,2329736,2329398,2329381,2329379,2329374,2329370,2329344,2329341,2329289';
imageSets[2] = '2433403,2329405,2329381,2329289';
imageSets[3] = '7754841,6055141,4874104,4874081,4182202,3890970,3684885,2855444,2591064,2591054,2435810,2435808,2435794,2435786,2435785,2435782,2435779,2435778,2433407,2433403,2334112,2334111,2334110,2334108,2334107,2334103,2329736,2329732,2329730,2329724,2329694,2329502,2329405,2329398,2329392,2329381,2329379,2329377,2329374,2329370,2329366,2329364,2329358,2329355,2329349,2329348,2329347,2329346,2329344,2329343';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 51:
		val = 'http://www12.clikpic.com/victor1/images';
		break;
	}
		switch (server_id) {
		case 0:
		val = 'http://www.clikpic.com/victor1/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/victor1/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/victor1/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/victor1/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/victor1/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/victor1/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/victor1/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/victor1/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/victor1/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/victor1/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/victor1/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/victor1/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/victor1/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/victor1/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/victor1/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/victor1/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/victor1/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/victor1/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/victor1/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/victor1/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/victor1/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/victor1/images';
		break;
	}
		switch (server_id) {
		case 53:
		val = 'http://images.clikpic.com/victor1/images';
		break;
	}
		switch (server_id) {
		case 52:
		val = 'http://tpc22/clikpic/victor1/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/victor1/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/victor1/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 = 'Wedding Photographer,Edinburgh, Scotland & the UK: ' + photoCaption;
			    }
        if (op.$detail.length > 0) {
      	temp = op.nextPhoto.fnGetImageDetails();
	    op.$detail.fadeGalleryDetails(temp, op.speed, function(){
			if (typeof(backgrounds) != 'undefined' && op.nextPhoto == backgrounds[op.nextPhoto.id]) {
				toggleAddToCartConfirm(backgrounds, op.$detail);
			} else if (typeof(photos) != 'undefined' && op.nextPhoto == photos[op.nextPhoto.id]) {
				toggleAddToCartConfirm(photos, op.$detail);
			}
			$('body').trigger('clikUpdate.popup');
	    });
    }
        $(op.$detailContainer).find('.replaceable[class*=replaceable_photo-]').each(function(){
    	var field = clik.getPrefixedClass(this.className, 'replaceable_photo-');
    	if (field in op.nextPhoto) {
    		$(this).fadeGalleryDetails(op.nextPhoto[field], op.speed);
    	}
    }).end().find('.replaceable.photoPayment').fadeGalleryDetails(op.nextPhoto.fnGetPaymentInfo(), op.speed, function(){
		if (typeof(backgrounds) != 'undefined' && op.nextPhoto == backgrounds[op.nextPhoto.id]) {
			toggleAddToCartConfirm(backgrounds, op.$detailContainer);
		} else if (typeof(photos) != 'undefined' && op.nextPhoto == photos[op.nextPhoto.id]) {
			toggleAddToCartConfirm(photos, op.$detailContainer);
		}
		$('body').trigger('clikUpdate.popup');
	});
		if (op.$photo.length > 0) {
		html = $('<img/>',{
			'class': 'mainphoto photo',
			src: photoSrc,
			id: 'mainPic',
			name: 'mainPic',
			width: op.nextPhoto.width,
			height: op.nextPhoto.height,
			alt: photoCaption,
			css: op.css || {}
		});
		if (op.href) {
			if (op.href.match(/<a/)) {
				html = $(op.href).append(html);
			} else {
				html = $('<a/>', {
					href: op.href,
					title: photoCaption
				}).append(html);
			}
		} else {
			html = $('<a/>', {
				title: photoCaption
			}).append(html);
		}
		if (op.speed == 0) {			op.$photo.html(html);			if (op.onBefore) {			  	op.onBefore.apply(op.$photo);			}			if (op.onAfter) {			  	op.onAfter.apply(op.$photo);			}		} else {			op.$photo.stop(true,true).fadeReplaceWith(html,op.speed,'',function(){  				if (op.onAfter) {				  	op.onAfter.apply(this);				}				clik.doColumnResize(false, $(this).add(op.$detail).add(op.$title));			}, op.onBefore);
		}	}
    if (op.field) {
		op.field.value = photoId;
	} else {
		op.$photo.data('image_id', photoId);
    }
        if (!op.speed) {
      	clik.doColumnResize(false, op.$photo.add(op.$detail).add(op.$title));
    }
        
    return html;
	}

/***************************************************************************
* Toggle add to cart confirmation element and set up the click event for   *
* the 'Add to cart' button.                                                *
***************************************************************************/
function toggleAddToCartConfirm(array, root){
	if (typeof(array) !== 'object' || array === null) {
	  	array = photos;
	}
	if (!$(root).length) {		root = $('body');	}	if($('#paymentConfirm', root).length > 0){
		$('#paymentConfirm', root).hide();
		$('#paymentAddButton', root)
		.unbind()
		.click(function(){
						form = $('#paymentForm', root)[0];
			option_id = 0;
			if(form.item_option.value){
				option_id = form.item_option.value;
			}
			if(addItemToBasket(form.item_number.value,array,form.site.value,parseInt(form.quantity.value, 10),option_id)){
				if($.browser.msie){$('#paymentConfirm', root).text('Item added to cart').show();}
				else{
					$('#paymentConfirm', root).text('Item added to cart').fadeIn();
					dspOrderDetails(form.site.value);
				}
			}
			else{
				$('#paymentConfirm', root).text('Item not added - check cookies are enabled in your browser.').fadeIn();
			}
		});
	}
}

/***************************************************************************
* Get payment info for image - add as 'method' to photo object             *
***************************************************************************/
clik.photo.fnGetImageDetails = function(){
	var temp = '';
	if (this.description != '') {
		temp +=  '<div id="imageDescription">' + this.description + '</div>';
	}
		if (this.photo_ref != '') {
		temp += '<div class="imageinfo" id="imageRef"><strong>Ref: </strong>' + this.photo_ref + '</div>';
	}
		if (this.takendate != '') {
		
		temp += '<div class="imageinfo" id="imageDate"><strong>Date: </strong>' + this.takendate + '</div>';
	}
	
	if (this.location != '') {
		
		temp += '<div class="imageinfo" id="imageLocation"><strong>Location: </strong>' +  this.location + '</div>';
	}
	
	if (this.photographer != '') {
		
		temp += '<div class="imageinfo" id="imagePhotographer"><strong>Photographer: </strong>' + this.photographer + '</div>';
	}
				
				if (temp != '') {
		temp += '<div class="spacer"></div>';
	}
	return temp;
};

/***************************************************************************
* Get payment info for image - add as 'method' to photo object             *
***************************************************************************/
clik.photo.fnGetPaymentInfo = function(){
	var temp = '';
	if (this.item_price !== '') {
				temp += '<p>Order this print:</p>';
				temp += '<div class="imageinfo" id="imagePrice"><strong>' + this.purchase_instruction + '</strong> ' + (this.item_price).toFixed(2) + '</div>';
		var item_name  = this.purchase_instruction;
		var amount = (this.item_price).toFixed(2);
		var item_option  = 0;
	}
		else {
		
	}
	if (this.item_price !== '' || this.payment_groups_id !== '') {
			temp += '<div class="clearing">&nbsp;</div>';
	}
	return temp;};

/***************************************************************************
* Pick a photo at random from the featured images of a gallery.            *
* Gallery_id = id of gallery to choose,                                    *
* img = reference to html image in                                         *
* which to show image                                                      *
***************************************************************************/
function showGalleryImage(gallery_id, img, updateLink) {
	
	if(img){
		if (location.hash.match('galleries_id=' + gallery_id) && (imageID = location.hash.match('.*photos_id=(.+)$'))) {
		  	imageID = imageID[1];
		} else {
		  	imageID = randomListVal(galleries[gallery_id].featured_images);
		}
		
		if (imageID != 0) {
			img.src = thumbnails[imageID].src;
			img.width = thumbnails[imageID].width;
			img.height = thumbnails[imageID].height;
			img.alt = galleries[gallery_id].title;
			if (updateLink) {
				$(img).parent().attr({					title: galleries[gallery_id].title				}).filter(function(){return this.href;}).attr({					href: thumbnails[imageID].fnGalleryLink(gallery_id)				});
			}
		}
	}
}

/***************************************************************************
* If we have dynamic HTML, replace the galleries link with a list that     *
* doesn't include thecurrent gallery                                       *
***************************************************************************/
function showGalleries(gallery_id) {
		
	
	if (!basic) {
		temp = '';
		for (i = 0; i < galleries.length; i++) {
						
			
			if (galleries[i].id != gallery_id) {
								
				if (temp != '') {
					temp += ' | ';
				}
								temp += '<a href="' + galleries[i].section_code + '_' + galleries[i].id + '.html">' + galleries[i].title + '</a>';
							}
		}
		document.all.galleryLinks.innerHTML = 'Other galleries: ' + temp;
	}
}

			

