window.thumbnails = {};
															thumbnails[257550] = clik.newPhoto({"id":257550,"src":"harbourboats_thumb.jpg","galleries_id":23056,"server_id":1,"link":"photo_257550.html","width":130,"caption":"harbour reflections","height":101});
															thumbnails[257618] = clik.newPhoto({"id":257618,"src":"garruchafishermanweb_thumb.jpg","galleries_id":23077,"server_id":1,"link":"photo_257618.html","width":130,"caption":"Garrucha fisherman","height":94});
															thumbnails[257705] = clik.newPhoto({"id":257705,"src":"madrid_thumb.jpg","galleries_id":23078,"server_id":1,"link":"photo_257705.html","width":130,"caption":"Plaza mayor Madrid, evening sun","height":176});
															thumbnails[257707] = clik.newPhoto({"id":257707,"src":"Crockford1_thumb.jpg","galleries_id":23077,"server_id":1,"link":"photo_257707.html","width":130,"caption":"Dai Crockford ","height":111});
															thumbnails[257711] = clik.newPhoto({"id":257711,"src":"Landingthecatch_thumb.jpg","galleries_id":23056,"server_id":1,"link":"photo_257711.html","width":130,"caption":"Landing the catch.","height":93});
															thumbnails[257713] = clik.newPhoto({"id":257713,"src":"mikeonhisboat1_thumb.jpg","galleries_id":23056,"server_id":1,"link":"photo_257713.html","width":130,"caption":"Mike on his boat","height":121});
															thumbnails[257715] = clik.newPhoto({"id":257715,"src":"marketstall1_thumb.jpg","galleries_id":23077,"server_id":1,"link":"photo_257715.html","width":130,"caption":"Tenby summer market","height":114});
															thumbnails[257718] = clik.newPhoto({"id":257718,"src":"monkstone_thumb.jpg","galleries_id":23076,"server_id":1,"link":"photo_257718.html","width":130,"caption":"Reflections, Monkstone beach","height":93});
															thumbnails[258173] = clik.newPhoto({"id":258173,"src":"julie_thumb.jpg","galleries_id":23077,"server_id":1,"link":"photo_258173.html","width":130,"caption":"Julie","height":184});
															thumbnails[258434] = clik.newPhoto({"id":258434,"src":"orangesail_thumb.jpg","galleries_id":23056,"server_id":1,"link":"photo_258434.html","width":130,"caption":"the orange sail","height":182});
															thumbnails[258441] = clik.newPhoto({"id":258441,"src":"redboat_thumb.jpg","galleries_id":23056,"server_id":1,"link":"photo_258441.html","width":130,"caption":"the red boat","height":182});
															thumbnails[258474] = clik.newPhoto({"id":258474,"src":"lampsscastlehill_thumb.jpg","galleries_id":23056,"server_id":1,"link":"photo_258474.html","width":130,"caption":"Autumn dawn over Tenby harbour","height":97});
															thumbnails[261086] = clik.newPhoto({"id":261086,"src":"Sam_thumb.jpg","galleries_id":23077,"server_id":1,"link":"photo_261086.html","width":130,"caption":"Sam ","height":102});
															thumbnails[261984] = clik.newPhoto({"id":261984,"src":"StCatherinescave_thumb.jpg","galleries_id":23056,"server_id":1,"link":"photo_261984.html","width":130,"caption":"St Catherine's Cave","height":169});
															thumbnails[262010] = clik.newPhoto({"id":262010,"src":"newlifeboathouse_thumb.jpg","galleries_id":23078,"server_id":1,"link":"photo_262010.html","width":130,"caption":"Old for new","height":169});
															thumbnails[278141] = clik.newPhoto({"id":278141,"src":"preparingsailII_thumb.jpg","galleries_id":23076,"server_id":1,"link":"photo_278141.html","width":130,"caption":"Preparing to sail II","height":43});
															thumbnails[282736] = clik.newPhoto({"id":282736,"src":"southbeach_thumb.jpg","galleries_id":23056,"server_id":1,"link":"photo_282736.html","width":130,"caption":"South Beach","height":92});
															thumbnails[874359] = clik.newPhoto({"id":874359,"src":"DSCN0010b_thumb.jpg","galleries_id":23056,"server_id":1,"link":"photo_874359.html","width":130,"caption":"3 boats","height":179});
															thumbnails[1503500] = clik.newPhoto({"id":1503500,"src":"dawnovercastlehill_thumb.jpg","galleries_id":23056,"server_id":1,"link":"photo_1503500.html","width":130,"caption":"Early light over Castle Hill","height":184});
															thumbnails[1504388] = clik.newPhoto({"id":1504388,"src":"lastonhouse_thumb.jpg","galleries_id":23056,"server_id":1,"link":"photo_1504388.html","width":130,"caption":"Laston House \/ Tenby harbour ","height":190});
															thumbnails[1504399] = clik.newPhoto({"id":1504399,"src":"Lexdenterrace_thumb.jpg","galleries_id":23078,"server_id":1,"link":"photo_1504399.html","width":130,"caption":"Lexden Terrace","height":92});
															thumbnails[1531830] = clik.newPhoto({"id":1531830,"src":"harbourshadow_thumb.jpg","galleries_id":23056,"server_id":1,"link":"photo_1531830.html","width":130,"caption":"Harbour Shadows","height":184});
															thumbnails[1567143] = clik.newPhoto({"id":1567143,"src":"paris_thumb.jpg","galleries_id":23076,"server_id":1,"link":"photo_1567143.html","width":130,"caption":"Autumn La Seine, Paris","height":96});
															thumbnails[1862749] = clik.newPhoto({"id":1862749,"src":"DSCN0007b_thumb.jpg","galleries_id":23076,"server_id":1,"link":"photo_1862749.html","width":130,"caption":"Dawn waves","height":102});
															thumbnails[1893330] = clik.newPhoto({"id":1893330,"src":"tidalreflection2_thumb.jpg","galleries_id":23056,"server_id":1,"link":"photo_1893330.html","width":130,"caption":"Tidal reflections","height":184});
															thumbnails[2235734] = clik.newPhoto({"id":2235734,"src":"DSCN1275clik_thumb.jpg","galleries_id":23078,"server_id":1,"link":"photo_2235734.html","width":130,"caption":"Honfleur.","height":176});
															thumbnails[2899671] = clik.newPhoto({"id":2899671,"src":"DSCN0006web_thumb.jpg","galleries_id":23056,"server_id":1,"link":"photo_2899671.html","width":130,"caption":"Laston House and Tenby pier","height":160});
															thumbnails[3169538] = clik.newPhoto({"id":3169538,"src":"Denzil_thumb.jpg","galleries_id":23077,"server_id":1,"link":"photo_3169538.html","width":130,"caption":"Denzil","height":163});
															thumbnails[3807333] = clik.newPhoto({"id":3807333,"src":"tankers1_thumb.jpg","galleries_id":294356,"server_id":1,"link":"photo_3807333.html","width":130,"caption":"Tankers 1","height":104});
															thumbnails[3807449] = clik.newPhoto({"id":3807449,"src":"harbour_reflectionsweb12_thumb.jpg","galleries_id":23056,"server_id":1,"link":"photo_3807449.html","width":130,"caption":"Harbour Reflections","height":156});
															thumbnails[3807466] = clik.newPhoto({"id":3807466,"src":"tankers2_thumb.jpg","galleries_id":294356,"server_id":1,"link":"photo_3807466.html","width":130,"caption":"Tankers 2","height":104});
															thumbnails[5045737] = clik.newPhoto({"id":5045737,"src":"DSCN0005a_thumb.jpg","galleries_id":294356,"server_id":1,"link":"photo_5045737.html","width":130,"caption":"Sunset over Dale","height":43});
															thumbnails[5188523] = clik.newPhoto({"id":5188523,"src":"DSCN0004web_thumb.jpg","galleries_id":294356,"server_id":1,"link":"photo_5188523.html","width":130,"caption":"Chevron, Pembroke","height":103});
															thumbnails[5189257] = clik.newPhoto({"id":5189257,"src":"DSCN0001web2_thumb.jpg","galleries_id":23056,"server_id":1,"link":"photo_5189257.html","width":130,"caption":"Tenby","height":103});
															thumbnails[5189274] = clik.newPhoto({"id":5189274,"src":"DSCN0005web_thumb.jpg","galleries_id":294356,"server_id":1,"link":"photo_5189274.html","width":130,"caption":"Bro Designer on Chevron Jetty","height":87});
															thumbnails[5189282] = clik.newPhoto({"id":5189282,"src":"DSCN0007web_thumb.jpg","galleries_id":23076,"server_id":1,"link":"photo_5189282.html","width":130,"caption":"Cliffs towards Monkstone","height":100});
															thumbnails[7139758] = clik.newPhoto({"id":7139758,"src":"DSCN0009web_thumb.jpg","galleries_id":294356,"server_id":1,"link":"photo_7139758.html","width":130,"caption":"Fresh breeze","height":103});
															thumbnails[7822109] = clik.newPhoto({"id":7822109,"src":"DSCN0016AWEB_thumb.jpg","galleries_id":23079,"server_id":1,"link":"photo_7822109.html","width":130,"caption":"Towards Giltar Point","height":186});
															thumbnails[7822111] = clik.newPhoto({"id":7822111,"src":"DSCN0022AWEB_thumb.jpg","galleries_id":294356,"server_id":1,"link":"photo_7822111.html","width":130,"caption":"Going sailing","height":90});
															thumbnails[7822116] = clik.newPhoto({"id":7822116,"src":"DSCN0018A_thumb.jpg","galleries_id":23076,"server_id":1,"link":"photo_7822116.html","width":130,"caption":"Sunset over Newport","height":130});
															thumbnails[7822138] = clik.newPhoto({"id":7822138,"src":"DSCN0025AWEB_thumb.jpg","galleries_id":23078,"server_id":1,"link":"photo_7822138.html","width":130,"caption":"Castle Beach Tenby","height":88});
															thumbnails[8384231] = clik.newPhoto({"id":8384231,"src":"tenbyboatsclik_thumb.jpg","galleries_id":23079,"server_id":1,"link":"photo_8384231.html","width":130,"caption":"Tenby Boats","height":175});
															thumbnails[8384238] = clik.newPhoto({"id":8384238,"src":"clearingskyclik_thumb.jpg","galleries_id":23079,"server_id":1,"link":"photo_8384238.html","width":130,"caption":"Clearing Sky","height":93});
															thumbnails[8384249] = clik.newPhoto({"id":8384249,"src":"tenbyharbourclik_thumb.jpg","galleries_id":23079,"server_id":1,"link":"photo_8384249.html","width":130,"caption":"Tenby Harbour","height":157});
															thumbnails[8384363] = clik.newPhoto({"id":8384363,"src":"dogonthebeachclik_thumb.jpg","galleries_id":23079,"server_id":1,"link":"photo_8384363.html","width":130,"caption":"Dog on the Beach","height":101});
															thumbnails[8541986] = clik.newPhoto({"id":8541986,"src":"brightlighthightide_thumb.jpg","galleries_id":23079,"server_id":1,"link":"photo_8541986.html","width":130,"caption":"Tenby walkway","height":108});
															thumbnails[8541988] = clik.newPhoto({"id":8541988,"src":"sparklingsunlightonafulltide_thumb.jpg","galleries_id":23079,"server_id":1,"link":"photo_8541988.html","width":130,"caption":"Tenby Harbour","height":87});
															thumbnails[8542091] = clik.newPhoto({"id":8542091,"src":"isthatmanpaintingus_thumb.jpg","galleries_id":23079,"server_id":1,"link":"photo_8542091.html","width":130,"caption":"\"Is that man painting us?\"","height":101});
															thumbnails[257625] = clik.newPhoto({"id":257625,"src":"JohnnyBull_thumb.jpg","galleries_id":23077,"server_id":1,"link":"photo_257625.html","width":130,"caption":"Johnny Bull","height":176});
															thumbnails[257714] = clik.newPhoto({"id":257714,"src":"Goscar_thumb.jpg","galleries_id":23056,"server_id":1,"link":"photo_257714.html","width":130,"caption":"Goscar rock, Tenby north beach","height":96});
															thumbnails[257689] = clik.newPhoto({"id":257689,"src":"spire2_thumb.jpg","galleries_id":23056,"server_id":1,"link":"photo_257689.html","width":130,"caption":"St Mary’s Church spire","height":158});
															thumbnails[257694] = clik.newPhoto({"id":257694,"src":"Boatsintenbyharbour_thumb.jpg","galleries_id":23056,"server_id":1,"link":"photo_257694.html","width":130,"caption":"Boats in Tenby Harbour","height":130});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  						galleries[23079] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"new work","link":"gallery_23079.html","maxRecords":0.0,"photoIDs":[7822109.0,8384231.0,8384238.0,8384249.0,8384363.0,8541986.0,8541988.0,8542091.0],"skipIndex":0,"section_code":"gallery","featured_images":"8542091,8541988,8541986,8384363,8384249,8384238,8384231,7822109","id":23079,"singleSection":false});				  						galleries[23056] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Tenby","link":"gallery_23056.html","maxRecords":0.0,"photoIDs":[257550.0,257711.0,257713.0,258434.0,258441.0,258474.0,261984.0,282736.0,874359.0,1503500.0,1504388.0,1531830.0,1893330.0,2899671.0,3807449.0,5189257.0,257714.0,257689.0,257694.0],"skipIndex":0,"section_code":"gallery","featured_images":"3807449,2899671,1893330,1504388,1503500,258434,257550","id":23056,"singleSection":false});				  						galleries[23077] = clik.newGallery({"parentGallery":"","usePopups":false,"title":" portraits","link":"gallery_23077.html","maxRecords":0.0,"photoIDs":[257618.0,257707.0,257715.0,258173.0,261086.0,3169538.0,257625.0],"skipIndex":0,"section_code":"gallery","featured_images":"261086,258173,257707,257625,257618","id":23077,"singleSection":false});				  						galleries[23076] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"landscapes","link":"gallery_23076.html","maxRecords":0.0,"photoIDs":[257718.0,278141.0,1567143.0,1862749.0,5189282.0,7822116.0],"skipIndex":0,"section_code":"gallery","featured_images":"1567143,278141","id":23076,"singleSection":false});				  						galleries[23078] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"buildings","link":"gallery_23078.html","maxRecords":0.0,"photoIDs":[257705.0,262010.0,1504399.0,2235734.0,7822138.0],"skipIndex":0,"section_code":"gallery","featured_images":"2235734,1504399,257705","id":23078,"singleSection":false});				  						galleries[294356] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"marine","link":"gallery_294356.html","maxRecords":0.0,"photoIDs":[3807333.0,3807466.0,5045737.0,5188523.0,5189274.0,7139758.0,7822111.0],"skipIndex":0,"section_code":"gallery","featured_images":"3807466,3807333","id":294356,"singleSection":false});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[1] = '3807466,3807449,3807333,3169538,2899671,2235734,1893330,1862749,1567143,1531830,1504399,1504388,1503500,874359,282736,278141,262010,261984,261086,258474,258441,258434,258173,257718,257715,257713,257711,257707,257705,257618,257550,257714,257625,257689,257694';
imageSets[2] = '3807466,3807449,3807333,2899671,2235734,1893330,1567143,1504399,1504388,1503500,278141,261086,258434,258173,257707,257705,257618,257550,257625';
imageSets[3] = '8542091,8541988,8541986,8384363,8384249,8384238,8384231,7822138,7822116,7822111,7822109,7139758,5189282,5189274,5189257,5188523,5045737,3807466,3807449,3807333,3169538,2899671,2235734,1893330,1862749,1567143,1531830,1504399,1504388,1503500,874359,282736,278141,262010,261984,261086,258474,258441,258434,258173,257718,257715,257714,257713,257711,257707,257705,257694,257689,257625';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 51:
		val = 'http://www12.clikpic.com/djpmorgan/images';
		break;
	}
		switch (server_id) {
		case 0:
		val = 'http://www.clikpic.com/djpmorgan/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/djpmorgan/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/djpmorgan/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/djpmorgan/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/djpmorgan/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/djpmorgan/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/djpmorgan/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/djpmorgan/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/djpmorgan/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/djpmorgan/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/djpmorgan/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/djpmorgan/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/djpmorgan/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/djpmorgan/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/djpmorgan/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/djpmorgan/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/djpmorgan/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/djpmorgan/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/djpmorgan/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/djpmorgan/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/djpmorgan/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/djpmorgan/images';
		break;
	}
		switch (server_id) {
		case 53:
		val = 'http://images.clikpic.com/djpmorgan/images';
		break;
	}
		switch (server_id) {
		case 52:
		val = 'http://tpc22/clikpic/djpmorgan/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/djpmorgan/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/djpmorgan/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 = 'David J P Morgan            Artist: ' + photoCaption;
			    }
        if (op.$detail.length > 0) {
      	temp = op.nextPhoto.fnGetImageDetails();
	    op.$detail.fadeGalleryDetails(temp, op.speed, function(){
			if (typeof(backgrounds) != 'undefined' && op.nextPhoto == backgrounds[op.nextPhoto.id]) {
				toggleAddToCartConfirm(backgrounds, op.$detail);
			} else if (typeof(photos) != 'undefined' && op.nextPhoto == photos[op.nextPhoto.id]) {
				toggleAddToCartConfirm(photos, op.$detail);
			}
			$('body').trigger('clikUpdate.popup');
	    });
    }
        $(op.$detailContainer).find('.replaceable[class*=replaceable_photo-]').each(function(){
    	var field = clik.getPrefixedClass(this.className, 'replaceable_photo-');
    	if (field in op.nextPhoto) {
    		$(this).fadeGalleryDetails(op.nextPhoto[field], op.speed);
    	}
    }).end().find('.replaceable.photoPayment').fadeGalleryDetails(op.nextPhoto.fnGetPaymentInfo(), op.speed, function(){
		if (typeof(backgrounds) != 'undefined' && op.nextPhoto == backgrounds[op.nextPhoto.id]) {
			toggleAddToCartConfirm(backgrounds, op.$detailContainer);
		} else if (typeof(photos) != 'undefined' && op.nextPhoto == photos[op.nextPhoto.id]) {
			toggleAddToCartConfirm(photos, op.$detailContainer);
		}
		$('body').trigger('clikUpdate.popup');
	});
		if (op.$photo.length > 0) {
		html = $('<img/>',{
			'class': 'mainphoto photo',
			src: photoSrc,
			id: 'mainPic',
			name: 'mainPic',
			width: op.nextPhoto.width,
			height: op.nextPhoto.height,
			alt: photoCaption,
			css: op.css || {}
		});
		if (op.href) {
			if (op.href.match(/<a/)) {
				html = $(op.href).append(html);
			} else {
				html = $('<a/>', {
					href: op.href,
					title: photoCaption
				}).append(html);
			}
		} else {
			html = $('<a/>', {
				title: photoCaption
			}).append(html);
		}
		if (op.speed == 0) {			op.$photo.html(html);			if (op.onBefore) {			  	op.onBefore.apply(op.$photo);			}			if (op.onAfter) {			  	op.onAfter.apply(op.$photo);			}		} else {			op.$photo.stop(true,true).fadeReplaceWith(html,op.speed,'',function(){  				if (op.onAfter) {				  	op.onAfter.apply(this);				}				clik.doColumnResize(false, $(this).add(op.$detail).add(op.$title));			}, op.onBefore);
		}	}
    if (op.field) {
		op.field.value = photoId;
	} else {
		op.$photo.data('image_id', photoId);
    }
        if (!op.speed) {
      	clik.doColumnResize(false, op.$photo.add(op.$detail).add(op.$title));
    }
        
    return html;
	}

/***************************************************************************
* Toggle add to cart confirmation element and set up the click event for   *
* the 'Add to cart' button.                                                *
***************************************************************************/
function toggleAddToCartConfirm(array, root){
	if (typeof(array) !== 'object' || array === null) {
	  	array = photos;
	}
	if (!$(root).length) {		root = $('body');	}	if($('#paymentConfirm', root).length > 0){
		$('#paymentConfirm', root).hide();
		$('#paymentAddButton', root)
		.unbind()
		.click(function(){
						form = $('#paymentForm', root)[0];
			option_id = 0;
			if(form.item_option.value){
				option_id = form.item_option.value;
			}
			if(addItemToBasket(form.item_number.value,array,form.site.value,parseInt(form.quantity.value, 10),option_id)){
				if($.browser.msie){$('#paymentConfirm', root).text('Item added to cart').show();}
				else{
					$('#paymentConfirm', root).text('Item added to cart').fadeIn();
					dspOrderDetails(form.site.value);
				}
			}
			else{
				$('#paymentConfirm', root).text('Item not added - check cookies are enabled in your browser.').fadeIn();
			}
		});
	}
}

/***************************************************************************
* Get payment info for image - add as 'method' to photo object             *
***************************************************************************/
clik.photo.fnGetImageDetails = function(){
	var temp = '';
	if (this.description != '') {
		temp +=  '<div id="imageDescription">' + this.description + '</div>';
	}
		if (this.photo_ref != '') {
		temp += '<div class="imageinfo" id="imageRef"><strong>Ref: </strong>' + this.photo_ref + '</div>';
	}
		if (this.takendate != '') {
		
		temp += '<div class="imageinfo" id="imageDate"><strong>Date: </strong>' + this.takendate + '</div>';
	}
	
	if (this.location != '') {
		
		temp += '<div class="imageinfo" id="imageLocation"><strong>Location: </strong>' +  this.location + '</div>';
	}
	
	if (this.photographer != '') {
		
		temp += '<div class="imageinfo" id="imagePhotographer"><strong>Photographer: </strong>' + this.photographer + '</div>';
	}
				
	temp += this.fnGetPaymentInfo();
				if (temp != '') {
		temp += '<div class="spacer"></div>';
	}
	return temp;
};

/***************************************************************************
* Get payment info for image - add as 'method' to photo object             *
***************************************************************************/
clik.photo.fnGetPaymentInfo = function(){
	var temp = '';
	if (this.item_price !== '') {
																		temp += '<p>Buy now using PayPal:</p>';
				temp += '<div class="imageinfo" id="imagePrice"><strong>' + this.purchase_instruction + '</strong> &pound;' + (this.item_price).toFixed(2) + '</div>';
		var item_name  = this.purchase_instruction;
		var amount = (this.item_price).toFixed(2);
		var item_option  = 0;
	}
		else if (this.payment_groups_id !== '') {
		temp += '<p>Buy this print online:</p>';
				temp += '<form id="paymentOptions" style="margin:0px;border:0px;" name="paymentOptions">';
											temp += '<select class="paymentlink" name="payment_options_id" onchange="updateItemValues($(this.form).next(\'#paymentForm\')[0],this.form.payment_options_id.options[this.form.payment_options_id.options.selectedIndex].value);">';
		
		temp += getPaymentOptions(this.payment_groups_id);
		temp += '</select>';
		temp += '</form>';
				var item_option  = paymentGroups[this.payment_groups_id].options[0];
		if(paymentOptions[item_option]){
			var item_name  = paymentOptions[item_option].payment_option;
			var amount =  paymentOptions[item_option].price;
		}
			}
		else {
		
	}
	if (this.item_price !== '' || this.payment_groups_id !== '') {
																		temp += '<form id="paymentForm" style="margin:0px;border:0px;" name="paymentForm" target="_blank" action="https://www.paypal.com/cgi-bin/webscr" method="post">';
			temp += '<input type="hidden" name="item_name" value="'+item_name+'">';
			ref = '';
			if(this.photo_ref != ''){
				ref = this.photo_ref+' - '+this.caption;
			}
			else{
				ref = this.id+' - '+this.caption;
			}
			price = amount;								temp += '<input type="hidden" name="cmd" value="_cart">';
					temp += '<input type="hidden" name="business" value="david@highseasgallery.com">';
					temp += '<input type="hidden" name="currency_code" value="GBP">';
					temp += '<input type="hidden" name="add" value="1">';
													temp += '<input type="hidden" name="amount" value="'+amount+'">';
					temp += '<input type="hidden" name="item_number" value="'+ref+'">';
													temp += '<input type=\"Submit\" value=\"Add to cart\" id=\"paymentAddButton\" class=\"button\" onmouseover=\"this.className=\'buttonHi\';\" onmouseout=\"this.className=\'button\';\">';
										temp += '</form>';
										temp += '<form id="paymentCartForm" style="margin:0px;" name="paymentCartForm" target="_blank" action="https://www.paypal.com/cgi-bin/webscr" method="post">';
				temp += '<input type="hidden" name="cmd" value="_cart">';
				temp += '<input type="hidden" name="business" value="david@highseasgallery.com">';
				temp += '<input type="hidden" name="display" value="1">';
				temp += '<input type=\"Submit\" value=\"View cart\" id=\"paymentViewButton\" class=\"button\" onmouseover=\"this.className=\'buttonHi\';\" onmouseout=\"this.className=\'button\';\">';
				temp += '</form>';
						temp += '<div class="clearing">&nbsp;</div>';
	}
	return temp;};

/***************************************************************************
* Pick a photo at random from the featured images of a gallery.            *
* Gallery_id = id of gallery to choose,                                    *
* img = reference to html image in                                         *
* which to show image                                                      *
***************************************************************************/
function showGalleryImage(gallery_id, img, updateLink) {
	
	if(img){
		if (location.hash.match('galleries_id=' + gallery_id) && (imageID = location.hash.match('.*photos_id=(.+)$'))) {
		  	imageID = imageID[1];
		} else {
		  	imageID = randomListVal(galleries[gallery_id].featured_images);
		}
		
		if (imageID != 0) {
			img.src = thumbnails[imageID].src;
			img.width = thumbnails[imageID].width;
			img.height = thumbnails[imageID].height;
			img.alt = galleries[gallery_id].title;
			if (updateLink) {
				$(img).parent().attr({					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;
	}
}

			

