window.thumbnails = {};
															thumbnails[9011153] = clik.newPhoto({"id":9011153,"src":"159_scan66v2_thumb.jpg","galleries_id":188580,"server_id":32,"link":"photo_9011153.html","width":130,"caption":"Kinloch Castle ","height":64});
															thumbnails[7521239] = clik.newPhoto({"id":7521239,"src":"barra4_thumb.jpg","galleries_id":188580,"server_id":32,"link":"photo_7521239.html","width":130,"caption":"","height":86});
															thumbnails[3075902] = clik.newPhoto({"id":3075902,"src":"aytonchcopy1_thumb.jpg","galleries_id":188771,"server_id":32,"link":"photo_3075902.html","width":105,"caption":"Ayton Old Kirk","height":130});
															thumbnails[3075908] = clik.newPhoto({"id":3075908,"src":"basslight copy1_thumb.jpg","galleries_id":188770,"server_id":32,"link":"photo_3075908.html","width":130,"caption":"Bass Rock Lighthouse","height":87});
															thumbnails[3075973] = clik.newPhoto({"id":3075973,"src":"barnowlcopy_thumb.jpg","galleries_id":188364,"server_id":32,"link":"photo_3075973.html","width":130,"caption":"Barn Owl","height":99});
															thumbnails[3484607] = clik.newPhoto({"id":3484607,"src":"bass_thumb.jpg","galleries_id":188770,"server_id":32,"link":"photo_3484607.html","width":130,"caption":"Bass Rock","height":84});
															thumbnails[3076031] = clik.newPhoto({"id":3076031,"src":"Aqaba Cranes_thumb.jpg","galleries_id":188774,"server_id":32,"link":"photo_3076031.html","width":130,"caption":"Container Cranes","height":84});
															thumbnails[9011180] = clik.newPhoto({"id":9011180,"src":"wood_thumb.jpg","galleries_id":188363,"server_id":32,"link":"photo_9011180.html","width":130,"caption":"Woodland","height":98});
															thumbnails[3413164] = clik.newPhoto({"id":3413164,"src":"tractorbw1_thumb.jpg","galleries_id":188774,"server_id":32,"link":"photo_3413164.html","width":130,"caption":"Old Tractor","height":90});
															thumbnails[9011160] = clik.newPhoto({"id":9011160,"src":"235__tonemapped_thumb.jpg","galleries_id":188771,"server_id":32,"link":"photo_9011160.html","width":130,"caption":"Shiants","height":74});
															thumbnails[8332935] = clik.newPhoto({"id":8332935,"src":"india0144_thumb.jpg","galleries_id":188580,"server_id":32,"link":"photo_8332935.html","width":108,"caption":"Red Haired Man","height":130});
															thumbnails[3076029] = clik.newPhoto({"id":3076029,"src":"bassrock11_thumb.jpg","galleries_id":188364,"server_id":32,"link":"photo_3076029.html","width":130,"caption":"Gannets Flying at Bass Rock","height":71});
															thumbnails[8332982] = clik.newPhoto({"id":8332982,"src":"scan10_thumb.jpg","galleries_id":188580,"server_id":32,"link":"photo_8332982.html","width":130,"caption":"Cusco","height":85});
															thumbnails[3076088] = clik.newPhoto({"id":3076088,"src":"Bell Rock Lighthouse1_thumb.jpg","galleries_id":188771,"server_id":32,"link":"photo_3076088.html","width":130,"caption":"Bell Rock Lighthouse","height":74});
															thumbnails[5439546] = clik.newPhoto({"id":5439546,"src":"sikundra_doorway_1_thumb.jpg","galleries_id":188771,"server_id":32,"link":"photo_5439546.html","width":89,"caption":"Entrance to Sikundra Temple, India","height":130});
															thumbnails[3412995] = clik.newPhoto({"id":3412995,"src":"Dunswood_thumb.jpg","galleries_id":188771,"server_id":32,"link":"photo_3412995.html","width":130,"caption":"Woods","height":87});
															thumbnails[3075980] = clik.newPhoto({"id":3075980,"src":"gannet_thumb.jpg","galleries_id":188364,"server_id":32,"link":"photo_3075980.html","width":130,"caption":"Gannet Portrait","height":84});
															thumbnails[5439522] = clik.newPhoto({"id":5439522,"src":"Am_GT11_thumb.jpg","galleries_id":188580,"server_id":32,"link":"photo_5439522.html","width":130,"caption":"Golden Temple, Amritsar","height":86});
															thumbnails[5439533] = clik.newPhoto({"id":5439533,"src":"shimla_town_1_thumb.jpg","galleries_id":188580,"server_id":32,"link":"photo_5439533.html","width":130,"caption":"Simla, India","height":89});
															thumbnails[7521408] = clik.newPhoto({"id":7521408,"src":"cat1_B0467940-1EC9-D45B-1C565BFF478547BC_thumb.jpg","galleries_id":188774,"server_id":32,"link":"photo_7521408.html","width":130,"caption":"Alley Cat","height":87});
															thumbnails[3076133] = clik.newPhoto({"id":3076133,"src":"The High Place_thumb.jpg","galleries_id":188580,"server_id":32,"link":"photo_3076133.html","width":130,"caption":"Jordan highpoint","height":86});
															thumbnails[3076093] = clik.newPhoto({"id":3076093,"src":"Longstone Lighthouse_thumb.jpg","galleries_id":188770,"server_id":32,"link":"photo_3076093.html","width":90,"caption":"Longstone Lighthouse","height":130});
															thumbnails[3076135] = clik.newPhoto({"id":3076135,"src":"The Treasurey_thumb.jpg","galleries_id":188580,"server_id":32,"link":"photo_3076135.html","width":85,"caption":"The Treasury","height":130});
															thumbnails[3076094] = clik.newPhoto({"id":3076094,"src":"Robin Hoods Bay_thumb.jpg","galleries_id":188771,"server_id":32,"link":"photo_3076094.html","width":92,"caption":"Robin Hoods Bay","height":130});
															thumbnails[3076136] = clik.newPhoto({"id":3076136,"src":"Xian Gates_thumb.jpg","galleries_id":188580,"server_id":32,"link":"photo_3076136.html","width":130,"caption":"Xi'an Gates at night","height":63});
															thumbnails[3413002] = clik.newPhoto({"id":3413002,"src":"Frostfield_thumb.jpg","galleries_id":188771,"server_id":32,"link":"photo_3413002.html","width":130,"caption":"Cold and Frosty Field","height":87});
															thumbnails[8333099] = clik.newPhoto({"id":8333099,"src":"scan161_thumb.jpg","galleries_id":188580,"server_id":32,"link":"photo_8333099.html","width":83,"caption":"Machu Pichu","height":130});
															thumbnails[3076096] = clik.newPhoto({"id":3076096,"src":"Rusting Steam_thumb.jpg","galleries_id":188774,"server_id":32,"link":"photo_3076096.html","width":86,"caption":"Rusting Steam","height":130});
															thumbnails[3076097] = clik.newPhoto({"id":3076097,"src":"Pond, Duns Castle_thumb.jpg","galleries_id":188771,"server_id":32,"link":"photo_3076097.html","width":109,"caption":"Summer Tranquility","height":130});
															thumbnails[3076098] = clik.newPhoto({"id":3076098,"src":"The Snook cottage_thumb.jpg","galleries_id":188771,"server_id":32,"link":"photo_3076098.html","width":130,"caption":"The Snook Cottage","height":91});
															thumbnails[3076122] = clik.newPhoto({"id":3076122,"src":"Great Wall of China_thumb.jpg","galleries_id":188580,"server_id":32,"link":"photo_3076122.html","width":130,"caption":"The Great Wall of China","height":88});
															thumbnails[3104866] = clik.newPhoto({"id":3104866,"src":"c0ve copy_thumb.jpg","galleries_id":188770,"server_id":32,"link":"photo_3104866.html","width":130,"caption":"Fishermans cottages Cove","height":79});
															thumbnails[3104827] = clik.newPhoto({"id":3104827,"src":"beachbums_thumb.jpg","galleries_id":188774,"server_id":32,"link":"photo_3104827.html","width":130,"caption":"Beach Bums","height":91});
															thumbnails[8332971] = clik.newPhoto({"id":8332971,"src":"resize4_thumb.jpg","galleries_id":188580,"server_id":32,"link":"photo_8332971.html","width":130,"caption":"lake Titticaca ","height":81});
															thumbnails[5789712] = clik.newPhoto({"id":5789712,"src":"blackrock4_thumb.jpg","galleries_id":188363,"server_id":32,"link":"photo_5789712.html","width":130,"caption":"","height":87});
															thumbnails[3076123] = clik.newPhoto({"id":3076123,"src":"jordan018_thumb.jpg","galleries_id":188580,"server_id":32,"link":"photo_3076123.html","width":85,"caption":"The Siq","height":130});
															thumbnails[9011193] = clik.newPhoto({"id":9011193,"src":"DSC_0168_thumb.jpg","galleries_id":188580,"server_id":32,"link":"photo_9011193.html","width":130,"caption":"Everest","height":87});
															thumbnails[9011164] = clik.newPhoto({"id":9011164,"src":"DSC_0027_thumb.jpg","galleries_id":188580,"server_id":32,"link":"photo_9011164.html","width":130,"caption":"All Seeing Eyes","height":87});
															thumbnails[3075994] = clik.newPhoto({"id":3075994,"src":"gannet3 copy1_thumb.jpg","galleries_id":188364,"server_id":32,"link":"photo_3075994.html","width":130,"caption":"Gannet stretching","height":88});
															thumbnails[4952209] = clik.newPhoto({"id":4952209,"src":"fordchurch_thumb.jpg","galleries_id":188771,"server_id":32,"link":"photo_4952209.html","width":86,"caption":"Ford Church","height":130});
															thumbnails[3075947] = clik.newPhoto({"id":3075947,"src":"Rhum-Laigv1 copy_thumb.jpg","galleries_id":188770,"server_id":32,"link":"photo_3075947.html","width":130,"caption":"Looking towards Rum","height":85});
															thumbnails[8332914] = clik.newPhoto({"id":8332914,"src":"DSC_0029_thumb.jpg","galleries_id":188770,"server_id":32,"link":"photo_8332914.html","width":130,"caption":"Cullen","height":82});
															thumbnails[8332969] = clik.newPhoto({"id":8332969,"src":"paint2_thumb.jpg","galleries_id":188770,"server_id":32,"link":"photo_8332969.html","width":130,"caption":"St Abbs Church","height":78});
															thumbnails[7521200] = clik.newPhoto({"id":7521200,"src":"india0205_thumb.jpg","galleries_id":188580,"server_id":32,"link":"photo_7521200.html","width":130,"caption":"","height":59});
															thumbnails[6461958] = clik.newPhoto({"id":6461958,"src":"golden_temple__thumb.jpg","galleries_id":188774,"server_id":32,"link":"photo_6461958.html","width":130,"caption":"","height":92});
															thumbnails[7033435] = clik.newPhoto({"id":7033435,"src":"blackbuck_thumb.jpg","galleries_id":188364,"server_id":32,"link":"photo_7033435.html","width":130,"caption":"","height":90});
															thumbnails[4307960] = clik.newPhoto({"id":4307960,"src":"petra4_copy_thumb.jpg","galleries_id":188580,"server_id":32,"link":"photo_4307960.html","width":82,"caption":"Treasury Petra","height":130});
															thumbnails[4952415] = clik.newPhoto({"id":4952415,"src":"villagebay_copy_thumb.jpg","galleries_id":188580,"server_id":32,"link":"photo_4952415.html","width":130,"caption":"Village Bay","height":82});
															thumbnails[8332968] = clik.newPhoto({"id":8332968,"src":"MargNov143_thumb.jpg","galleries_id":188770,"server_id":32,"link":"photo_8332968.html","width":86,"caption":"Groyne","height":130});
															thumbnails[5439580] = clik.newPhoto({"id":5439580,"src":"taj_front_2_thumb.jpg","galleries_id":188771,"server_id":32,"link":"photo_5439580.html","width":130,"caption":"Taj Mahal, India","height":89});
															thumbnails[7521193] = clik.newPhoto({"id":7521193,"src":"beach_thumb.jpg","galleries_id":188363,"server_id":32,"link":"photo_7521193.html","width":130,"caption":"","height":85});
															thumbnails[9011167] = clik.newPhoto({"id":9011167,"src":"DSC_0049_thumb.jpg","galleries_id":188580,"server_id":32,"link":"photo_9011167.html","width":130,"caption":"Swayanbuth Monkey temple","height":87});
															thumbnails[6461986] = clik.newPhoto({"id":6461986,"src":"minaret_taj_thumb.jpg","galleries_id":188774,"server_id":32,"link":"photo_6461986.html","width":87,"caption":"","height":130});
															thumbnails[8333082] = clik.newPhoto({"id":8333082,"src":"scan46_thumb.jpg","galleries_id":188580,"server_id":32,"link":"photo_8333082.html","width":85,"caption":"Machu Pichu","height":130});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  						galleries[188363] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Landscape","link":"gallery_188363.html","maxRecords":0.0,"photoIDs":[9011180.0,5789712.0,7521193.0],"skipIndex":0,"section_code":"gallery","featured_images":"9011180,7521193,5789712","id":188363,"singleSection":false});				  						galleries[188364] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Nature","link":"gallery_188364.html","maxRecords":0.0,"photoIDs":[3075973.0,3076029.0,3075980.0,3075994.0,7033435.0],"skipIndex":0,"section_code":"gallery","featured_images":"7033435,3076029,3075994,3075980,3075973","id":188364,"singleSection":false});				  						galleries[188580] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Travel","link":"gallery_188580.html","maxRecords":0.0,"photoIDs":[9011153.0,7521239.0,8332935.0,8332982.0,5439522.0,5439533.0,3076133.0,3076135.0,3076136.0,8333099.0,3076122.0,8332971.0,3076123.0,9011193.0,9011164.0,7521200.0,4307960.0,4952415.0,9011167.0,8333082.0],"skipIndex":0,"section_code":"gallery","featured_images":"9011193,9011167,9011164,9011153,8333099,8333082,8332982,8332971,8332935,7521239","id":188580,"singleSection":false});				  						galleries[188770] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Coastal","link":"gallery_188770.html","maxRecords":0.0,"photoIDs":[3075908.0,3484607.0,3076093.0,3104866.0,3075947.0,8332914.0,8332969.0,8332968.0],"skipIndex":0,"section_code":"gallery","featured_images":"8332969,8332968,8332914,3484607,3104866,3076093,3075947,3075908","id":188770,"singleSection":false});				  						galleries[188774] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"General","link":"gallery_188774.html","maxRecords":0.0,"photoIDs":[3076031.0,3413164.0,7521408.0,3076096.0,3104827.0,6461958.0,6461986.0],"skipIndex":0,"section_code":"gallery","featured_images":"7521408,6461986,6461958,3413164,3104827,3076096,3076031","id":188774,"singleSection":false});				  						galleries[188771] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Monochrome","link":"gallery_188771.html","maxRecords":0.0,"photoIDs":[3075902.0,9011160.0,3076088.0,5439546.0,3412995.0,3076094.0,3413002.0,3076097.0,3076098.0,4952209.0,5439580.0],"skipIndex":0,"section_code":"gallery","featured_images":3075902.0,"id":188771,"singleSection":false});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[1] = '3075908,3075902,3076031,3076029,3076097';
imageSets[2] = '3075902';
imageSets[3] = '9011193,9011180,9011167,9011164,9011160,9011153,8333099,8333082,8332982,8332971,8332969,8332968,8332935,8332914,7521408,7521239,7521200,7521193,7033435,6461986,6461958,5789712,5439580,5439546,5439533,5439522,4952415,4952209,4307960,3484607,3413164,3413002,3412995,3104866,3104827,3076136,3076135,3076133,3076123,3076122,3076098,3076097,3076096,3076094,3076093,3076088,3076031,3076029,3075994,3075980';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 51:
		val = 'http://www12.clikpic.com/MargaretandGary/images';
		break;
	}
		switch (server_id) {
		case 0:
		val = 'http://www.clikpic.com/MargaretandGary/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/MargaretandGary/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/MargaretandGary/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/MargaretandGary/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/MargaretandGary/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/MargaretandGary/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/MargaretandGary/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/MargaretandGary/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/MargaretandGary/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/MargaretandGary/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/MargaretandGary/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/MargaretandGary/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/MargaretandGary/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/MargaretandGary/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/MargaretandGary/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/MargaretandGary/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/MargaretandGary/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/MargaretandGary/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/MargaretandGary/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/MargaretandGary/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/MargaretandGary/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/MargaretandGary/images';
		break;
	}
		switch (server_id) {
		case 53:
		val = 'http://images.clikpic.com/MargaretandGary/images';
		break;
	}
		switch (server_id) {
		case 52:
		val = 'http://tpc22/clikpic/MargaretandGary/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/MargaretandGary/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/MargaretandGary/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 = 'Far and Near Images: ' + 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 !== '') {
			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;
	}
}

			

