window.thumbnails = {};
															thumbnails[8856789] = clik.newPhoto({"id":8856789,"src":"Dawn_over_Landacre_Gate._thumb.jpg","galleries_id":465683,"server_id":32,"link":"photo_8856789.html","width":130,"caption":"Dawn At Landacre Gate","height":87});
															thumbnails[8856808] = clik.newPhoto({"id":8856808,"src":"Beached_At_Sunset1._Instow._Devon._October_thumb.jpg","galleries_id":465682,"server_id":32,"link":"photo_8856808.html","width":130,"caption":"Beached At Sunset.","height":87});
															thumbnails[8856820] = clik.newPhoto({"id":8856820,"src":"Dawn_Light_On_The_Blockhouse1_thumb.jpg","galleries_id":465684,"server_id":32,"link":"photo_8856820.html","width":130,"caption":"Sunrise At The Bockhouse","height":87});
															thumbnails[8856825] = clik.newPhoto({"id":8856825,"src":"Broken_Bridge_thumb.jpg","galleries_id":465682,"server_id":32,"link":"photo_8856825.html","width":130,"caption":"Broken Bridge","height":87});
															thumbnails[8856869] = clik.newPhoto({"id":8856869,"src":"Dreams_Of_Sailing1_thumb.jpg","galleries_id":465684,"server_id":32,"link":"photo_8856869.html","width":130,"caption":"Dreams Of Sailing","height":195});
															thumbnails[8856926] = clik.newPhoto({"id":8856926,"src":"Dusk_At_The_Blockhouse_thumb.jpg","galleries_id":465684,"server_id":32,"link":"photo_8856926.html","width":130,"caption":"Dusk At the Blockhouse.","height":87});
															thumbnails[8856947] = clik.newPhoto({"id":8856947,"src":"Grey_Clouds_Over_Hell_Bay_thumb.jpg","galleries_id":465684,"server_id":32,"link":"photo_8856947.html","width":130,"caption":"Grey Skies Over Great Popplestone","height":85});
															thumbnails[8856970] = clik.newPhoto({"id":8856970,"src":"IMG_0628_thumb.jpg","galleries_id":465682,"server_id":32,"link":"photo_8856970.html","width":130,"caption":"hartland Lighthouse.","height":195});
															thumbnails[8856986] = clik.newPhoto({"id":8856986,"src":"IMG_0640_thumb.jpg","galleries_id":465682,"server_id":32,"link":"photo_8856986.html","width":130,"caption":"Westward-Ho! Shipwreck","height":87});
															thumbnails[8857000] = clik.newPhoto({"id":8857000,"src":"IMG_0694_thumb.jpg","galleries_id":465682,"server_id":32,"link":"photo_8857000.html","width":130,"caption":"Old Oak Sunrise","height":87});
															thumbnails[8857011] = clik.newPhoto({"id":8857011,"src":"IMG_0703_thumb.jpg","galleries_id":465683,"server_id":32,"link":"photo_8857011.html","width":130,"caption":"The Punch Bowl","height":87});
															thumbnails[8857014] = clik.newPhoto({"id":8857014,"src":"IMG_0754_thumb.jpg","galleries_id":465683,"server_id":32,"link":"photo_8857014.html","width":130,"caption":"Luccombe View","height":87});
															thumbnails[8857017] = clik.newPhoto({"id":8857017,"src":"IMG_0795_thumb.jpg","galleries_id":465684,"server_id":32,"link":"photo_8857017.html","width":130,"caption":"Porth Nanven Sunset.","height":195});
															thumbnails[8857025] = clik.newPhoto({"id":8857025,"src":"IMG_1484_thumb.jpg","galleries_id":465682,"server_id":32,"link":"photo_8857025.html","width":130,"caption":"Bluebells At Arlington","height":87});
															thumbnails[8861697] = clik.newPhoto({"id":8861697,"src":"IMG_07961_thumb.jpg","galleries_id":465684,"server_id":32,"link":"photo_8861697.html","width":130,"caption":"Moods Of Porth Nanven","height":130});
															thumbnails[8861731] = clik.newPhoto({"id":8861731,"src":"IMG_1277_thumb.jpg","galleries_id":465993,"server_id":32,"link":"photo_8861731.html","width":130,"caption":"Backlit Fern","height":87});
															thumbnails[8861799] = clik.newPhoto({"id":8861799,"src":"IMG_1588_thumb.jpg","galleries_id":465683,"server_id":32,"link":"photo_8861799.html","width":130,"caption":"River Barle In Spring","height":87});
															thumbnails[8861862] = clik.newPhoto({"id":8861862,"src":"IMG_17211_thumb.jpg","galleries_id":465682,"server_id":32,"link":"photo_8861862.html","width":130,"caption":"Sunset Over The Bar.","height":128});
															thumbnails[8861903] = clik.newPhoto({"id":8861903,"src":"IMG_1766_thumb.jpg","galleries_id":465683,"server_id":32,"link":"photo_8861903.html","width":130,"caption":"First Snow On Winsford Hill","height":87});
															thumbnails[8861930] = clik.newPhoto({"id":8861930,"src":"IMG_1836_thumb.jpg","galleries_id":465683,"server_id":32,"link":"photo_8861930.html","width":130,"caption":"Little Shed Simonsbath","height":86});
															thumbnails[8862015] = clik.newPhoto({"id":8862015,"src":"IMG_2671_thumb.jpg","galleries_id":465993,"server_id":32,"link":"photo_8862015.html","width":130,"caption":"A Splash Of Red","height":87});
															thumbnails[8867658] = clik.newPhoto({"id":8867658,"src":"IMG_19111_thumb.jpg","galleries_id":465682,"server_id":32,"link":"photo_8867658.html","width":130,"caption":"A Busy Day On Clovelly Quay","height":87});
															thumbnails[8867678] = clik.newPhoto({"id":8867678,"src":"IMG_2002_thumb.jpg","galleries_id":465683,"server_id":32,"link":"photo_8867678.html","width":130,"caption":"Little Red Barn","height":87});
															thumbnails[8867685] = clik.newPhoto({"id":8867685,"src":"IMG_2004_thumb.jpg","galleries_id":465683,"server_id":32,"link":"photo_8867685.html","width":130,"caption":"Three Trees","height":87});
															thumbnails[8867687] = clik.newPhoto({"id":8867687,"src":"IMG_2155_thumb.jpg","galleries_id":465993,"server_id":32,"link":"photo_8867687.html","width":130,"caption":"A Family Of Five","height":87});
															thumbnails[8867694] = clik.newPhoto({"id":8867694,"src":"IMG_2688_thumb.jpg","galleries_id":465683,"server_id":32,"link":"photo_8867694.html","width":130,"caption":"Evening Light On Porlock","height":87});
															thumbnails[8867702] = clik.newPhoto({"id":8867702,"src":"IMG_2694_thumb.jpg","galleries_id":465683,"server_id":32,"link":"photo_8867702.html","width":130,"caption":"Porlock To Culbone","height":87});
															thumbnails[8867717] = clik.newPhoto({"id":8867717,"src":"IMG_2809_thumb.jpg","galleries_id":465683,"server_id":32,"link":"photo_8867717.html","width":130,"caption":"Rain Immanent","height":195});
															thumbnails[8867736] = clik.newPhoto({"id":8867736,"src":"IMG_6946_thumb.jpg","galleries_id":465683,"server_id":32,"link":"photo_8867736.html","width":130,"caption":"Sunrise Over Withypool Common","height":87});
															thumbnails[8867759] = clik.newPhoto({"id":8867759,"src":"Lonely_Poppy._Braunton._Devon.Cover_thumb.jpg","galleries_id":465993,"server_id":32,"link":"photo_8867759.html","width":130,"caption":"Lonely Poppy","height":87});
															thumbnails[8867767] = clik.newPhoto({"id":8867767,"src":"River_Barl2_Exmoor_thumb.jpg","galleries_id":465683,"server_id":32,"link":"photo_8867767.html","width":130,"caption":"River Barle","height":195});
															thumbnails[8867774] = clik.newPhoto({"id":8867774,"src":"Rugby_Club_Display._Barnstaple._Devon.November_thumb.jpg","galleries_id":465682,"server_id":32,"link":"photo_8867774.html","width":130,"caption":"Barnstaple Rugby Club Display.","height":94});
															thumbnails[8867779] = clik.newPhoto({"id":8867779,"src":"Slipway_Sunset_thumb.jpg","galleries_id":465682,"server_id":32,"link":"photo_8867779.html","width":130,"caption":"Slipway Sunset","height":87});
															thumbnails[8867786] = clik.newPhoto({"id":8867786,"src":"April_thumb.jpg","galleries_id":465993,"server_id":32,"link":"photo_8867786.html","width":130,"caption":"Snakehead Fritillary","height":87});
															thumbnails[8867795] = clik.newPhoto({"id":8867795,"src":"St_martins_from_Borough_Farm_thumb.jpg","galleries_id":465684,"server_id":32,"link":"photo_8867795.html","width":130,"caption":"St Martins From Borough Farm","height":87});
															thumbnails[8867803] = clik.newPhoto({"id":8867803,"src":"Sunrise_At_Porth_Green_thumb.jpg","galleries_id":465684,"server_id":32,"link":"photo_8867803.html","width":130,"caption":"Sunrise At Porth Green.","height":87});
															thumbnails[8867810] = clik.newPhoto({"id":8867810,"src":"Sunrise_At_The_Blockhouse_thumb.jpg","galleries_id":465684,"server_id":32,"link":"photo_8867810.html","width":130,"caption":"Dawn At The Blockhouse","height":87});
															thumbnails[8867819] = clik.newPhoto({"id":8867819,"src":"Sunset_Bales_Overlooking_the_Bar_Devon_thumb.jpg","galleries_id":465682,"server_id":32,"link":"photo_8867819.html","width":130,"caption":"Bales At Sunset","height":195});
															thumbnails[8867843] = clik.newPhoto({"id":8867843,"src":"Untitled_LundyPanorama2_thumb.jpg","galleries_id":465682,"server_id":32,"link":"photo_8867843.html","width":130,"caption":"Lundy Sunset","height":65});
															thumbnails[8867879] = clik.newPhoto({"id":8867879,"src":"Untitled_Panorama1_thumb.jpg","galleries_id":465682,"server_id":32,"link":"photo_8867879.html","width":130,"caption":"Massive View","height":54});
															thumbnails[8872815] = clik.newPhoto({"id":8872815,"src":"IMG_2724_thumb.jpg","galleries_id":465683,"server_id":32,"link":"photo_8872815.html","width":130,"caption":"Sunrise On Porlock Hill","height":130});
															thumbnails[8872828] = clik.newPhoto({"id":8872828,"src":"IMG_5439_thumb.jpg","galleries_id":465682,"server_id":32,"link":"photo_8872828.html","width":130,"caption":"Sunrise Over West Appledore","height":87});
															thumbnails[8872843] = clik.newPhoto({"id":8872843,"src":"IMG_6744_thumb.jpg","galleries_id":465682,"server_id":32,"link":"photo_8872843.html","width":130,"caption":"Mist On The River Torridge","height":130});
															thumbnails[8872853] = clik.newPhoto({"id":8872853,"src":"IMG_7048_thumb.jpg","galleries_id":465682,"server_id":32,"link":"photo_8872853.html","width":130,"caption":"Winter River Lyn","height":87});
															thumbnails[8872864] = clik.newPhoto({"id":8872864,"src":"IMG_7539_thumb.jpg","galleries_id":465682,"server_id":32,"link":"photo_8872864.html","width":130,"caption":"Dusk At Barricane Beach","height":197});
															thumbnails[8872886] = clik.newPhoto({"id":8872886,"src":"IMG_7911_thumb.jpg","galleries_id":465682,"server_id":32,"link":"photo_8872886.html","width":130,"caption":"Sunset Over Morte Point","height":130});
															thumbnails[8872899] = clik.newPhoto({"id":8872899,"src":"IMG_8540_thumb.jpg","galleries_id":465682,"server_id":32,"link":"photo_8872899.html","width":130,"caption":"Westward-Ho! Sunset","height":195});
															thumbnails[8872912] = clik.newPhoto({"id":8872912,"src":"IMG_8757_thumb.jpg","galleries_id":465682,"server_id":32,"link":"photo_8872912.html","width":130,"caption":"Sunset From Potters Hill","height":87});
															thumbnails[8872915] = clik.newPhoto({"id":8872915,"src":"vortex_thumb.jpg","galleries_id":465682,"server_id":32,"link":"photo_8872915.html","width":130,"caption":"Snow At Fremington Quay","height":87});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  						galleries[465684] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Cornwall","link":"gallery_465684.html","maxRecords":0.0,"photoIDs":[8856820.0,8856869.0,8856926.0,8856947.0,8857017.0,8861697.0,8867795.0,8867803.0,8867810.0],"skipIndex":0,"section_code":"gallery","featured_images":"8867810,8867803,8867795,8861697,8857017,8856947,8856926,8856869,8856820","id":465684,"singleSection":false});				  						galleries[465682] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Devon","link":"gallery_465682.html","maxRecords":0.0,"photoIDs":[8856808.0,8856825.0,8856970.0,8856986.0,8857000.0,8857025.0,8861862.0,8867658.0,8867774.0,8867779.0,8867819.0,8867843.0,8867879.0,8872828.0,8872843.0,8872853.0,8872864.0,8872886.0,8872899.0,8872912.0,8872915.0],"skipIndex":0,"section_code":"gallery","featured_images":"8872915,8872912,8872899,8872886,8872864,8872853,8872843,8872828,8867879,8867843","id":465682,"singleSection":false});				  						galleries[465993] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Nature","link":"gallery_465993.html","maxRecords":0.0,"photoIDs":[8861731.0,8862015.0,8867687.0,8867759.0,8867786.0],"skipIndex":0,"section_code":"gallery","featured_images":"8867786,8867759,8867687,8862015,8861731","id":465993,"singleSection":false});				  						galleries[465683] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Somerset and Exmoor.","link":"gallery_465683.html","maxRecords":0.0,"photoIDs":[8856789.0,8857011.0,8857014.0,8861799.0,8861903.0,8861930.0,8867678.0,8867685.0,8867694.0,8867702.0,8867717.0,8867736.0,8867767.0,8872815.0],"skipIndex":0,"section_code":"gallery","featured_images":"8872815,8867767,8867736,8867717,8867702,8867694,8867685,8867678,8861930,8861903","id":465683,"singleSection":false});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[1] = '8872915,8872912,8872899,8872886,8872864,8872853,8872843,8872828,8872815,8867879,8867843,8867819,8867810,8867803,8867795,8867786,8867779,8867774,8867767,8867759,8867736,8867717,8867702,8867694,8867687,8867685,8867678,8867658,8862015,8861930,8861903,8861862,8861799,8861731,8861697,8857025,8857017,8857014,8857011,8857000,8856986,8856970,8856947,8856926,8856869,8856825,8856820,8856808,8856789';
imageSets[3] = '8872915,8872912,8872899,8872886,8872864,8872853,8872843,8872828,8872815,8867879,8867843,8867819,8867810,8867803,8867795,8867786,8867779,8867774,8867767,8867759,8867736,8867717,8867702,8867694,8867687,8867685,8867678,8867658,8862015,8861930,8861903,8861862,8861799,8861731,8861697,8857025,8857017,8857014,8857011,8857000,8856986,8856970,8856947,8856926,8856869,8856825,8856820,8856808,8856789';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 51:
		val = 'http://www12.clikpic.com/andyjw/images';
		break;
	}
		switch (server_id) {
		case 0:
		val = 'http://www.clikpic.com/andyjw/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/andyjw/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/andyjw/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/andyjw/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/andyjw/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/andyjw/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/andyjw/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/andyjw/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/andyjw/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/andyjw/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/andyjw/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/andyjw/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/andyjw/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/andyjw/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/andyjw/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/andyjw/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/andyjw/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/andyjw/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/andyjw/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/andyjw/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/andyjw/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/andyjw/images';
		break;
	}
		switch (server_id) {
		case 53:
		val = 'http://images.clikpic.com/andyjw/images';
		break;
	}
		switch (server_id) {
		case 52:
		val = 'http://tpc22/clikpic/andyjw/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/andyjw/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/andyjw/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 = 'Andrew Wheatley Photography: ' + 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="updateCartValue($(this.form).next(\'#paymentForm\')[0],this.form.payment_options_id.options[this.form.payment_options_id.options.selectedIndex].value); if(divShowing(\'paymentConfirm\')){fadeOut(\'paymentConfirm\', 3)};">';
		
		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">';
			temp += '	<input type="hidden" name="item_option" value="' + item_option + '">';
			temp += '	<input type="hidden" name="site" value="ANDYJW">';
			temp += '	<input type="hidden" name="item_number" value="'+ this.id +'">';
			temp += '	<input type="hidden" name="quantity" value="1">';
						temp += '	<input value="Add to cart" id="paymentAddButton" class="button" onmouseover="this.className=\'buttonHi\'\;" onmouseout="this.className=\'button\'\;" type="Button">';
							temp += '	<input value="View cart" id="paymentViewButton" class="button" onmouseover="this.className=\'buttonHi\';" onmouseout="this.className=\'button\';" type="Button" onclick="javascript:window.location=\'cart.html\'">';
			temp += '</form>';
						temp += '<div class="clearing">&nbsp;</div>';
			temp += '<div id="confirmContainer">';
			temp += '<div id="paymentConfirm">Item added to cart</div>';
			temp += '</div>';
			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;
	}
}

			

