window.thumbnails = {};
															thumbnails[2699856] = clik.newPhoto({"id":2699856,"src":"UK-COVER_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":141});
															thumbnails[2699858] = clik.newPhoto({"id":2699858,"src":"US-COVER_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":141});
															thumbnails[2699861] = clik.newPhoto({"id":2699861,"src":"SINAI_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":141});
															thumbnails[2700599] = clik.newPhoto({"id":2700599,"src":"AUTHOR-PHOTO_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":200});
															thumbnails[2822407] = clik.newPhoto({"id":2822407,"src":"book and luke4_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":81});
															thumbnails[2848220] = clik.newPhoto({"id":2848220,"src":"PRISTON COCKREL - WEBSITE 23_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":194});
															thumbnails[6336593] = clik.newPhoto({"id":6336593,"src":"GOOD_LOO_HUNTING-COVER_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":130});
															thumbnails[6346763] = clik.newPhoto({"id":6346763,"src":"AUTHOR_PHOTO_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":87});
															thumbnails[6346785] = clik.newPhoto({"id":6346785,"src":"AUTHOR_PHOTO1_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":87});
															thumbnails[6356289] = clik.newPhoto({"id":6356289,"src":"RIBBLEHEAD1_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":87});
															thumbnails[6356328] = clik.newPhoto({"id":6356328,"src":"PUMPAID_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":98});
															thumbnails[6357450] = clik.newPhoto({"id":6357450,"src":"virgin_logo_2_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":135});
															thumbnails[6357538] = clik.newPhoto({"id":6357538,"src":"AUTHOR_PHOTO_2_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":181});
															thumbnails[6365558] = clik.newPhoto({"id":6365558,"src":"EPHESUS-COLE_AND_LYNDA_HARDISON_ARLINGTON_TEXAS_thumb.JPG","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":89});
															thumbnails[6365561] = clik.newPhoto({"id":6365561,"src":"LADYBOWER-ANNY_JONES_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":106});
															thumbnails[6365562] = clik.newPhoto({"id":6365562,"src":"LES_DIABLERETS-JEAN_HUGHES_thumb.JPG","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":93});
															thumbnails[6365564] = clik.newPhoto({"id":6365564,"src":"MIKE_LARGE-AUDIENCE_thumb.JPG","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":98});
															thumbnails[6365567] = clik.newPhoto({"id":6365567,"src":"PAM_BOWKER-SKIING_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":206});
															thumbnails[6365569] = clik.newPhoto({"id":6365569,"src":"PAM_BOWKER-SKIING-002_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":194});
															thumbnails[6365574] = clik.newPhoto({"id":6365574,"src":"ROMAN-SJAAK_TEUWISSEN_thumb.JPG","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":94});
															thumbnails[6365575] = clik.newPhoto({"id":6365575,"src":"SEOUL_TOWER-RATKO_JAGODIC_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":195});
															thumbnails[6365576] = clik.newPhoto({"id":6365576,"src":"DANIEL_JAULINO-LOST_CITY-002_thumb.JPG","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":76});
															thumbnails[6365578] = clik.newPhoto({"id":6365578,"src":"SHEENA_BALLARD_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":98});
															thumbnails[6365579] = clik.newPhoto({"id":6365579,"src":"TEE-PEE-Lieke_Augustijn__the_netherlands_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":98});
															thumbnails[6365581] = clik.newPhoto({"id":6365581,"src":"TWIT_T-LOO-DAVID_WILLIAMS_PHOTOGRAPHY_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":113});
															thumbnails[6365582] = clik.newPhoto({"id":6365582,"src":"TWIT-T-LOO_-_David_Williams_Photography_thumb.JPG","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":87});
															thumbnails[6372655] = clik.newPhoto({"id":6372655,"src":"LOO_FUN-001_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":195});
															thumbnails[6372656] = clik.newPhoto({"id":6372656,"src":"LOO_FUN-002_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":190});
															thumbnails[6375003] = clik.newPhoto({"id":6375003,"src":"LOO_FUN-003_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":180});
															thumbnails[6388768] = clik.newPhoto({"id":6388768,"src":"AUTHOR_PIC_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":87});
															thumbnails[6392441] = clik.newPhoto({"id":6392441,"src":"ALCATRAZ-001_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":154});
															thumbnails[6392463] = clik.newPhoto({"id":6392463,"src":"ALCATRAZ-0011_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":92});
															thumbnails[6405007] = clik.newPhoto({"id":6405007,"src":"CONTROL_CENTRE-001_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":198});
															thumbnails[6405029] = clik.newPhoto({"id":6405029,"src":"UNINSPIRING_VIEW_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":92});
															thumbnails[6426798] = clik.newPhoto({"id":6426798,"src":"loo_fun-002_1501EF77-24E8-5EC4-4FF79B86D8848566_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":180});
															thumbnails[6562301] = clik.newPhoto({"id":6562301,"src":"LUKE_ON_LAPTOP_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":87});
															thumbnails[6562312] = clik.newPhoto({"id":6562312,"src":"LUKE_ON_LAPTOP1_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":87});
															thumbnails[6562435] = clik.newPhoto({"id":6562435,"src":"LUKE_ON_LAPTOP12_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":87});
															thumbnails[6562484] = clik.newPhoto({"id":6562484,"src":"LUKE_ON_LAP_TOP_-002_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":91});
															thumbnails[8143989] = clik.newPhoto({"id":8143989,"src":"ALCATRAZ-001-COPYRIGHT_LUKE_BARCLAY_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":195});
															thumbnails[8144455] = clik.newPhoto({"id":8144455,"src":"WEBSITE_ALCATRAZ_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":185});
															thumbnails[8442509] = clik.newPhoto({"id":8442509,"src":"LOO_SECTION_DIVIDER_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":20});
															thumbnails[8476956] = clik.newPhoto({"id":8476956,"src":"SEOUL_TOWER12_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":195});
															thumbnails[8477002] = clik.newPhoto({"id":8477002,"src":"SEOUL_TOWER-002_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":195});
															thumbnails[8477014] = clik.newPhoto({"id":8477014,"src":"SEOUL_TOWER-BORDER_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":184});
															thumbnails[8477445] = clik.newPhoto({"id":8477445,"src":"SEOUL_TOWER-BORDER1_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":184});
															thumbnails[8477488] = clik.newPhoto({"id":8477488,"src":"NAMIBIA-002_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":80});
															thumbnails[8477502] = clik.newPhoto({"id":8477502,"src":"THIKSEY_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":80});
															thumbnails[8493386] = clik.newPhoto({"id":8493386,"src":"ALASKA_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":80});
															thumbnails[8493702] = clik.newPhoto({"id":8493702,"src":"TENGBOCHE-001_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":80});
															thumbnails[8493733] = clik.newPhoto({"id":8493733,"src":"CHANGI_AIRPORT-001_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":195});
															thumbnails[8495667] = clik.newPhoto({"id":8495667,"src":"AMERICAN_COVER-001_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":130});
															thumbnails[8507145] = clik.newPhoto({"id":8507145,"src":"ORIGINAL_LOO_COVER_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":130});
															thumbnails[8507192] = clik.newPhoto({"id":8507192,"src":"GOOD_LOO_HUNTING_COVER_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":130});
															thumbnails[8507474] = clik.newPhoto({"id":8507474,"src":"SEOUL_TOWER1_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":194});
															thumbnails[8507496] = clik.newPhoto({"id":8507496,"src":"SEOUL_TOWER-BORDER_B0D3261A-1EC9-DFB6-09ECFA57B7BC3AE0_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":184});
															thumbnails[8711944] = clik.newPhoto({"id":8711944,"src":"YUFUIN-JAPAN1_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":80});
															thumbnails[8716222] = clik.newPhoto({"id":8716222,"src":"NILE_SHOWER_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":195});
															thumbnails[7161049] = clik.newPhoto({"id":7161049,"src":"New_in_Good_Loo_Hunting_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":133});
															thumbnails[7161235] = clik.newPhoto({"id":7161235,"src":"sensational_views_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":133});
															thumbnails[7163132] = clik.newPhoto({"id":7163132,"src":"sensational_views_image123_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":133});
															thumbnails[7161337] = clik.newPhoto({"id":7161337,"src":"urinals_from_heaven_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":133});
															thumbnails[2814781] = clik.newPhoto({"id":2814781,"src":"VIRGIN BOOKS LOGO1_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":135});
															thumbnails[6341166] = clik.newPhoto({"id":6341166,"src":"VIRGIN_LOGO_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":133});
															thumbnails[7163304] = clik.newPhoto({"id":7163304,"src":"urinals_from_heaven_image12_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":134});
															thumbnails[2814783] = clik.newPhoto({"id":2814783,"src":"tengboche - website_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":135});
															thumbnails[7161333] = clik.newPhoto({"id":7161333,"src":"elephants_crossing_the_zambezi_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":133});
															thumbnails[2821145] = clik.newPhoto({"id":2821145,"src":"BOOK IMAGE_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":164});
															thumbnails[7162541] = clik.newPhoto({"id":7162541,"src":"elephants_crossing_the_zambezi_image_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":133});
															thumbnails[7161389] = clik.newPhoto({"id":7161389,"src":"awesome_national_parks_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":133});
															thumbnails[2817851] = clik.newPhoto({"id":2817851,"src":"LOO OF THE MONTH - NOVEMBER_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":98});
															thumbnails[7162266] = clik.newPhoto({"id":7162266,"src":"awesome_national_parks_image_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":133});
															thumbnails[2819797] = clik.newPhoto({"id":2819797,"src":"EMPIRE STATE BUILDING_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":179});
															thumbnails[7161392] = clik.newPhoto({"id":7161392,"src":"windmills_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":133});
															thumbnails[7162359] = clik.newPhoto({"id":7162359,"src":"windmills_image_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":133});
															thumbnails[7161395] = clik.newPhoto({"id":7161395,"src":"and_many_more_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":133});
															thumbnails[6341151] = clik.newPhoto({"id":6341151,"src":"LOOS_2_COVER_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":133});
															thumbnails[6341255] = clik.newPhoto({"id":6341255,"src":"LOOS_1_COVER1_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":133});
															thumbnails[2699911] = clik.newPhoto({"id":2699911,"src":"CHANGI-AIRPORT_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":141});
															thumbnails[6354006] = clik.newPhoto({"id":6354006,"src":"CHANGI_21_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":133});
															thumbnails[6350029] = clik.newPhoto({"id":6350029,"src":"EVEREST3_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":133});
															thumbnails[6351753] = clik.newPhoto({"id":6351753,"src":"SINAI2_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":133});
															thumbnails[6361752] = clik.newPhoto({"id":6361752,"src":"VIRGIN_LOGO-0031_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":133});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[1] = '8507474,8495667,8493733,8493702,8493386,8477502,8477488';
imageSets[3] = '6346763';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 51:
		val = 'http://www12.clikpic.com/lukebarclay/images';
		break;
	}
		switch (server_id) {
		case 0:
		val = 'http://www.clikpic.com/lukebarclay/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/lukebarclay/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/lukebarclay/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/lukebarclay/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/lukebarclay/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/lukebarclay/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/lukebarclay/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/lukebarclay/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/lukebarclay/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/lukebarclay/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/lukebarclay/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/lukebarclay/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/lukebarclay/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/lukebarclay/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/lukebarclay/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/lukebarclay/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/lukebarclay/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/lukebarclay/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/lukebarclay/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/lukebarclay/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/lukebarclay/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/lukebarclay/images';
		break;
	}
		switch (server_id) {
		case 53:
		val = 'http://images.clikpic.com/lukebarclay/images';
		break;
	}
		switch (server_id) {
		case 52:
		val = 'http://tpc22/clikpic/lukebarclay/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/lukebarclay/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/lukebarclay/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 += '.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 && '' != '') {
					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 = 'LOOS WITH VIEWS: ' + 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;
	}
}

			

