window.thumbnails = {};
															thumbnails[1765562] = clik.newPhoto({"id":1765562,"src":"charlotte02 roy appleby_thumb.jpg","galleries_id":34159,"server_id":15,"link":"photo_1765562.html","width":130,"caption":"Charlotte","height":195});
															thumbnails[1765609] = clik.newPhoto({"id":1765609,"src":"Ennerdale Water Mark Dougal_thumb.jpg","galleries_id":34160,"server_id":15,"link":"photo_1765609.html","width":130,"caption":"Ennerdale Water","height":87});
															thumbnails[1765611] = clik.newPhoto({"id":1765611,"src":"Pen Lithrid Mark Dougal_thumb.jpg","galleries_id":34160,"server_id":15,"link":"photo_1765611.html","width":130,"caption":"Pen Lithrid","height":87});
															thumbnails[1765619] = clik.newPhoto({"id":1765619,"src":"lillies Mark Dougal_thumb.jpg","galleries_id":34161,"server_id":15,"link":"photo_1765619.html","width":130,"caption":"Lillies","height":87});
															thumbnails[1765623] = clik.newPhoto({"id":1765623,"src":"Perfect fit-angelacarr_thumb.jpg","galleries_id":34161,"server_id":15,"link":"photo_1765623.html","width":130,"caption":"Perfect Fit","height":124});
															thumbnails[1765627] = clik.newPhoto({"id":1765627,"src":"bellybutton bernard_thumb.jpg","galleries_id":68794,"server_id":15,"link":"photo_1765627.html","width":130,"caption":"Bellybutton","height":194});
															thumbnails[1765628] = clik.newPhoto({"id":1765628,"src":"bluebells Mark Dougal_thumb.jpg","galleries_id":34161,"server_id":15,"link":"photo_1765628.html","width":130,"caption":"Bluebells","height":194});
															thumbnails[1765629] = clik.newPhoto({"id":1765629,"src":"BoltonParishChurch Norman Scott_thumb.jpg","galleries_id":68795,"server_id":15,"link":"photo_1765629.html","width":130,"caption":"Bolton Parish Church","height":195});
															thumbnails[1765662] = clik.newPhoto({"id":1765662,"src":"Buoy On Promenade_thumb.jpg","galleries_id":68794,"server_id":15,"link":"photo_1765662.html","width":130,"caption":"Buoy On Promenade","height":204});
															thumbnails[1765671] = clik.newPhoto({"id":1765671,"src":"Colours of the market angela carr_thumb.jpg","galleries_id":68794,"server_id":15,"link":"photo_1765671.html","width":130,"caption":"Colours of the Market","height":173});
															thumbnails[1765674] = clik.newPhoto({"id":1765674,"src":"dive dennis crinson_thumb.jpg","galleries_id":68794,"server_id":15,"link":"photo_1765674.html","width":130,"caption":"Dive!","height":189});
															thumbnails[1765676] = clik.newPhoto({"id":1765676,"src":"fabricvic riley_thumb.jpg","galleries_id":68794,"server_id":15,"link":"photo_1765676.html","width":130,"caption":"Fabric","height":86});
															thumbnails[1765713] = clik.newPhoto({"id":1765713,"src":"flowers and bees mark dougal_thumb.jpg","galleries_id":34161,"server_id":15,"link":"photo_1765713.html","width":130,"caption":"Flowers and Bees","height":195});
															thumbnails[1765715] = clik.newPhoto({"id":1765715,"src":"flowers mark dougal_thumb.jpg","galleries_id":34161,"server_id":15,"link":"photo_1765715.html","width":130,"caption":"Flowers","height":194});
															thumbnails[1765717] = clik.newPhoto({"id":1765717,"src":"frotto bernard_thumb.jpg","galleries_id":68794,"server_id":15,"link":"photo_1765717.html","width":130,"caption":"'Frotto","height":87});
															thumbnails[1765723] = clik.newPhoto({"id":1765723,"src":"Hulme_arch_Vic_Riley_thumb.jpg","galleries_id":68795,"server_id":15,"link":"photo_1765723.html","width":130,"caption":"Hulme Arch","height":86});
															thumbnails[1765724] = clik.newPhoto({"id":1765724,"src":"lakeland colourvic riley_thumb.jpg","galleries_id":68794,"server_id":15,"link":"photo_1765724.html","width":130,"caption":"Lakeland Colour","height":93});
															thumbnails[1765727] = clik.newPhoto({"id":1765727,"src":"Lineup roy apleby_thumb.jpg","galleries_id":68794,"server_id":15,"link":"photo_1765727.html","width":130,"caption":"Lineup","height":83});
															thumbnails[1765729] = clik.newPhoto({"id":1765729,"src":"Manchester Library vic riley_thumb.jpg","galleries_id":68795,"server_id":15,"link":"photo_1765729.html","width":130,"caption":"Manchester Library","height":195});
															thumbnails[1765733] = clik.newPhoto({"id":1765733,"src":"Manchester on the move vic riley_thumb.jpg","galleries_id":68795,"server_id":15,"link":"photo_1765733.html","width":130,"caption":"Manchester on the Move","height":86});
															thumbnails[1765739] = clik.newPhoto({"id":1765739,"src":"Manchester Pride-angela carr_thumb.jpg","galleries_id":34159,"server_id":15,"link":"photo_1765739.html","width":130,"caption":"Manchester Pride","height":227});
															thumbnails[1765745] = clik.newPhoto({"id":1765745,"src":"manchester through the ages-Roy Appleby_thumb.jpg","galleries_id":68795,"server_id":15,"link":"photo_1765745.html","width":130,"caption":"Manchester Through the Ages","height":87});
															thumbnails[1765748] = clik.newPhoto({"id":1765748,"src":"Myier zoom tight vic riley_thumb.jpg","galleries_id":34159,"server_id":15,"link":"photo_1765748.html","width":130,"caption":"Myier Zoom Tight","height":97});
															thumbnails[1765751] = clik.newPhoto({"id":1765751,"src":"outburst-kevin_thumb.jpg","galleries_id":68794,"server_id":15,"link":"photo_1765751.html","width":130,"caption":"Outburst","height":195});
															thumbnails[1765757] = clik.newPhoto({"id":1765757,"src":"Pistyll Rhaeadr  angela carr_thumb.jpg","galleries_id":34160,"server_id":15,"link":"photo_1765757.html","width":130,"caption":"Pistyll Rhaeadr","height":194});
															thumbnails[1765772] = clik.newPhoto({"id":1765772,"src":"Reproduction_Vic_Riley_thumb.jpg","galleries_id":34161,"server_id":15,"link":"photo_1765772.html","width":130,"caption":"Reproduction","height":86});
															thumbnails[1765777] = clik.newPhoto({"id":1765777,"src":"Ruined cottage Mark dougal_thumb.jpg","galleries_id":68795,"server_id":15,"link":"photo_1765777.html","width":130,"caption":"Ruined Cottage","height":84});
															thumbnails[1765779] = clik.newPhoto({"id":1765779,"src":"smartyvic riley_thumb.jpg","galleries_id":68794,"server_id":15,"link":"photo_1765779.html","width":130,"caption":"Smarty","height":88});
															thumbnails[1600581] = clik.newPhoto({"id":1600581,"src":"2tyred_DennisCrinson_thumb.jpg","galleries_id":68794,"server_id":15,"link":"photo_1600581.html","width":130,"caption":"2 Tyred","height":92});
															thumbnails[1600584] = clik.newPhoto({"id":1600584,"src":"backtor_DennisCrinson_thumb.jpg","galleries_id":34160,"server_id":15,"link":"photo_1600584.html","width":130,"caption":"Back Tor","height":195});
															thumbnails[1600587] = clik.newPhoto({"id":1600587,"src":"derbyshire sunset-dennis crinson_thumb.jpg","galleries_id":34160,"server_id":15,"link":"photo_1600587.html","width":130,"caption":"Derbyshire Sunset","height":80});
															thumbnails[1600588] = clik.newPhoto({"id":1600588,"src":"doors_DennisCrinson_thumb.jpg","galleries_id":68794,"server_id":15,"link":"photo_1600588.html","width":130,"caption":"Doors","height":191});
															thumbnails[1600591] = clik.newPhoto({"id":1600591,"src":"MakingBread_DennisCrinson_thumb.jpg","galleries_id":34159,"server_id":15,"link":"photo_1600591.html","width":130,"caption":"Making Bread","height":145});
															thumbnails[1600596] = clik.newPhoto({"id":1600596,"src":"peb1_DennisCrinson_thumb.jpg","galleries_id":68794,"server_id":15,"link":"photo_1600596.html","width":130,"caption":"Pebbles","height":89});
															thumbnails[1600598] = clik.newPhoto({"id":1600598,"src":"tree_DennisCrinson_thumb.jpg","galleries_id":34160,"server_id":15,"link":"photo_1600598.html","width":130,"caption":"Tree","height":88});
															thumbnails[1600616] = clik.newPhoto({"id":1600616,"src":"iron man-denis crinson1_thumb.jpg","galleries_id":68794,"server_id":15,"link":"photo_1600616.html","width":130,"caption":"Iron Man","height":87});
															thumbnails[897419] = clik.newPhoto({"id":897419,"src":"Niagra Falls at a distance_thumb.jpg","galleries_id":34160,"server_id":15,"link":"photo_897419.html","width":130,"caption":"Niagra Falls at a distance","height":98});
															thumbnails[897427] = clik.newPhoto({"id":897427,"src":"Niagra Falls, up close and wet_thumb.jpg","galleries_id":34160,"server_id":15,"link":"photo_897427.html","width":130,"caption":"Niagra Falls, up close and wet","height":69});
															thumbnails[897435] = clik.newPhoto({"id":897435,"src":"Colden yellow_thumb.jpg","galleries_id":34161,"server_id":15,"link":"photo_897435.html","width":130,"caption":"Colden Yellow","height":91});
															thumbnails[897438] = clik.newPhoto({"id":897438,"src":"Fungi_thumb.jpg","galleries_id":34161,"server_id":15,"link":"photo_897438.html","width":130,"caption":"Fungi","height":119});
															thumbnails[897440] = clik.newPhoto({"id":897440,"src":"Iris_thumb.jpg","galleries_id":34161,"server_id":15,"link":"photo_897440.html","width":130,"caption":"Iris","height":281});
															thumbnails[897445] = clik.newPhoto({"id":897445,"src":"Love the hair do!_thumb.jpg","galleries_id":34161,"server_id":15,"link":"photo_897445.html","width":130,"caption":"Love the hair do!","height":117});
															thumbnails[897450] = clik.newPhoto({"id":897450,"src":"Old tree_thumb.jpg","galleries_id":34161,"server_id":15,"link":"photo_897450.html","width":130,"caption":"Old tree","height":173});
															thumbnails[897454] = clik.newPhoto({"id":897454,"src":"pallets wanted_thumb.jpg","galleries_id":68794,"server_id":15,"link":"photo_897454.html","width":130,"caption":"Pallets wanted","height":98});
															thumbnails[897461] = clik.newPhoto({"id":897461,"src":"pebbles2_thumb.jpg","galleries_id":68794,"server_id":15,"link":"photo_897461.html","width":130,"caption":"Pebbles 2","height":94});
															thumbnails[897462] = clik.newPhoto({"id":897462,"src":"pebbles6_thumb.jpg","galleries_id":68794,"server_id":15,"link":"photo_897462.html","width":130,"caption":"Pebbles 6","height":118});
															thumbnails[897464] = clik.newPhoto({"id":897464,"src":"Please release us_thumb.jpg","galleries_id":34161,"server_id":15,"link":"photo_897464.html","width":130,"caption":"Please release us","height":98});
															thumbnails[897466] = clik.newPhoto({"id":897466,"src":"Primula_thumb.jpg","galleries_id":34161,"server_id":15,"link":"photo_897466.html","width":130,"caption":"Primula","height":145});
															thumbnails[897467] = clik.newPhoto({"id":897467,"src":"Rainy Rose_thumb.jpg","galleries_id":34161,"server_id":15,"link":"photo_897467.html","width":130,"caption":"Rainy Rose","height":98});
															thumbnails[897468] = clik.newPhoto({"id":897468,"src":"Snowbud_thumb.jpg","galleries_id":34161,"server_id":15,"link":"photo_897468.html","width":130,"caption":"Snowbud","height":199});
															thumbnails[897474] = clik.newPhoto({"id":897474,"src":"Skyscraper shadows_thumb.jpg","galleries_id":68795,"server_id":15,"link":"photo_897474.html","width":130,"caption":"Skyscraper shadows","height":173});
															thumbnails[897476] = clik.newPhoto({"id":897476,"src":"Victoria baths1_thumb.jpg","galleries_id":68795,"server_id":15,"link":"photo_897476.html","width":130,"caption":"Victoria Baths 1","height":85});
															thumbnails[897479] = clik.newPhoto({"id":897479,"src":"Victoria baths fish_thumb.jpg","galleries_id":68795,"server_id":15,"link":"photo_897479.html","width":130,"caption":"Victoria Baths Fish","height":98});
															thumbnails[427113] = clik.newPhoto({"id":427113,"src":"duow_thumb.jpg","galleries_id":34159,"server_id":15,"link":"photo_427113.html","width":130,"caption":"Musical Duo","height":92});
															thumbnails[427116] = clik.newPhoto({"id":427116,"src":"nat2w_thumb.jpg","galleries_id":34159,"server_id":15,"link":"photo_427116.html","width":130,"caption":"Natalie","height":186});
															thumbnails[427120] = clik.newPhoto({"id":427120,"src":"oldkeithw_thumb.jpg","galleries_id":34159,"server_id":15,"link":"photo_427120.html","width":130,"caption":"Keith","height":87});
															thumbnails[427124] = clik.newPhoto({"id":427124,"src":"dry brushw_thumb.jpg","galleries_id":34160,"server_id":15,"link":"photo_427124.html","width":130,"caption":"Autumn in Didsbury 2","height":89});
															thumbnails[427098] = clik.newPhoto({"id":427098,"src":"1pub2w_thumb.jpg","galleries_id":34160,"server_id":15,"link":"photo_427098.html","width":130,"caption":"Pub in Frodsham, Cheshire","height":91});
															thumbnails[427109] = clik.newPhoto({"id":427109,"src":"2Bee1w_thumb.jpg","galleries_id":34161,"server_id":15,"link":"photo_427109.html","width":130,"caption":"An insect on a flower","height":97});
															thumbnails[427110] = clik.newPhoto({"id":427110,"src":"3Autumn1w_thumb.jpg","galleries_id":34161,"server_id":15,"link":"photo_427110.html","width":130,"caption":"Autumn in Didsbury","height":87});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  						galleries[34159] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Portraits","link":"gallery_34159.html","maxRecords":0.0,"photoIDs":[1765562.0,1765739.0,1765748.0,1600591.0,427113.0,427116.0,427120.0],"skipIndex":0,"section_code":"gallery","featured_images":"1765748,1765739,1765562,1600591,427120,427116,427113","id":34159,"singleSection":false});				  						galleries[34160] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Landscapes","link":"gallery_34160.html","maxRecords":0.0,"photoIDs":[1765609.0,1765611.0,1765757.0,1600584.0,1600587.0,1600598.0,897419.0,897427.0,427124.0,427098.0],"skipIndex":0,"section_code":"gallery","featured_images":"1600587,1600584","id":34160,"singleSection":false});				  						galleries[34161] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Nature","link":"gallery_34161.html","maxRecords":0.0,"photoIDs":[1765619.0,1765623.0,1765628.0,1765713.0,1765715.0,1765772.0,897435.0,897438.0,897440.0,897445.0,897450.0,897464.0,897466.0,897467.0,897468.0,427109.0,427110.0],"skipIndex":0,"section_code":"gallery","featured_images":"1765772,1765715,1765713,1765628,1765623,1765619,897468,897467,897466,897464","id":34161,"singleSection":false});				  						galleries[68795] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Buildings","link":"gallery_68795.html","maxRecords":0.0,"photoIDs":[1765629.0,1765723.0,1765729.0,1765733.0,1765745.0,1765777.0,897474.0,897476.0,897479.0],"skipIndex":0,"section_code":"gallery","featured_images":"1765777,1765745,1765733,1765729,1765723,1765629,897479,897476,897474","id":68795,"singleSection":false});				  						galleries[68794] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Miscellaneous","link":"gallery_68794.html","maxRecords":0.0,"photoIDs":[1765627.0,1765662.0,1765671.0,1765674.0,1765676.0,1765717.0,1765724.0,1765727.0,1765751.0,1765779.0,1600581.0,1600588.0,1600596.0,1600616.0,897454.0,897461.0,897462.0],"skipIndex":0,"section_code":"gallery","featured_images":"1600616,1600588,1600581","id":68794,"singleSection":false});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[1] = '1600616,1600588,1600587,1600584,1600581,897479,897476,897474,897468,897467,897466,897464,897462,897461,897454,897450,897445,897440,897438,897435,897427,897419,427124,427120,427116,427113,427098,427109,427110';
imageSets[2] = '1600616,1600588,1600587,1600584,1600581';
imageSets[3] = '1765779,1765777,1765772,1765757,1765751,1765748,1765745,1765739,1765733,1765729,1765727,1765724,1765723,1765717,1765715,1765713,1765676,1765674,1765671,1765662,1765629,1765628,1765627,1765623,1765619,1765611,1765609,1765562,1600616,1600598,1600596,1600591,1600588,1600587,1600584,1600581,897479,897476,897474,897468,897467,897466,897464,897462,897461,897454,897450,897445,897440,897438';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 51:
		val = 'http://www12.clikpic.com/maps1885/images';
		break;
	}
		switch (server_id) {
		case 0:
		val = 'http://www.clikpic.com/maps1885/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/maps1885/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/maps1885/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/maps1885/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/maps1885/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/maps1885/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/maps1885/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/maps1885/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/maps1885/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/maps1885/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/maps1885/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/maps1885/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/maps1885/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/maps1885/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/maps1885/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/maps1885/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/maps1885/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/maps1885/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/maps1885/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/maps1885/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/maps1885/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/maps1885/images';
		break;
	}
		switch (server_id) {
		case 53:
		val = 'http://images.clikpic.com/maps1885/images';
		break;
	}
		switch (server_id) {
		case 52:
		val = 'http://tpc22/clikpic/maps1885/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/maps1885/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/maps1885/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 = 'Manchester Amateur Photographic Society: ' + 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;
	}
}

			

