window.thumbnails = new Object();
												thumbnails[698046] = new thumbnail(698046,'','','Sunshine and Moonbeam of Fyfe, Voiles de St Tropez 2007 100_thumb.jpg',130, 57,1,'#');
												thumbnails[697377] = new thumbnail(697377,'53439','','Hammerhead Crane_thumb.jpg',130, 163,1,'photo_697377.html');
												thumbnails[697380] = new thumbnail(697380,'53438','','Saracen 2_thumb.jpg',130, 170,1,'photo_697380.html');
												thumbnails[697382] = new thumbnail(697382,'53435','','Ericsson 100_thumb.jpg',130, 122,1,'photo_697382.html');
												thumbnails[697383] = new thumbnail(697383,'53436','','Ranger 150 15_thumb.jpg',130, 90,1,'photo_697383.html');
												thumbnails[697387] = new thumbnail(697387,'53437','','Ollie_thumb.jpg',130, 161,1,'photo_697387.html');
												thumbnails[697385] = new thumbnail(697385,'53435','','Fighting for position_thumb.jpg',130, 180,1,'photo_697385.html');
												thumbnails[697386] = new thumbnail(697386,'53437','','Brookie_thumb.jpg',130, 159,1,'photo_697386.html');
												thumbnails[697388] = new thumbnail(697388,'53436','','HMS Endurance, Trafalgar 200 Fleet Review 20053_thumb.jpg',130, 56,1,'photo_697388.html');
												thumbnails[697799] = new thumbnail(697799,'53438','','Fergus_thumb.jpg',130, 167,1,'photo_697799.html');
												thumbnails[697376] = new thumbnail(697376,'53437','','Richard Lewis_thumb.jpg',130, 161,1,'photo_697376.html');
												thumbnails[697796] = new thumbnail(697796,'53438','','Jessica_thumb.jpg',130, 147,1,'photo_697796.html');
												thumbnails[697811] = new thumbnail(697811,'53435','','Ellen Macarthur 100_thumb.jpg',130, 166,1,'photo_697811.html');
												thumbnails[698071] = new thumbnail(698071,'53436','','Thurso Lifeboat 150 15_thumb.jpg',130, 58,1,'photo_698071.html');
												thumbnails[697781] = new thumbnail(697781,'53438','','Henrietta_thumb.jpg',130, 123,1,'photo_697781.html');
												thumbnails[697837] = new thumbnail(697837,'53435','','Fastnet 2 100 15_thumb.jpg',130, 86,1,'photo_697837.html');
												thumbnails[697892] = new thumbnail(697892,'53437','','Granny Hedges_thumb.jpg',130, 171,1,'photo_697892.html');
												thumbnails[698075] = new thumbnail(698075,'53436','','HMS Trumpeter 150 15_thumb.jpg',130, 86,1,'photo_698075.html');
												thumbnails[697801] = new thumbnail(697801,'53438','','Smiley_thumb.jpg',130, 158,1,'photo_697801.html');
												thumbnails[697986] = new thumbnail(697986,'53437','','Brian Wright1_thumb.jpg',130, 158,1,'photo_697986.html');
												thumbnails[909572] = new thumbnail(909572,'53435','','Ranger and Velsheda, Antigua 100_thumb.jpg',130, 84,1,'photo_909572.html');
												thumbnails[6167456] = new thumbnail(6167456,'53429','','Tuiga_and_The_Lady_Anne_thumb.jpg',130, 86,1,'photo_6167456.html');
												thumbnails[697848] = new thumbnail(697848,'53437','','Ellen Macarthur3_thumb.jpg',130, 162,1,'photo_697848.html');
												thumbnails[945731] = new thumbnail(945731,'53435','','Bear of Britain, Chernikeef 2 150 15_thumb.jpg',130, 91,1,'photo_945731.html');
												thumbnails[697917] = new thumbnail(697917,'53437','','Carren Snagg_thumb.jpg',130, 181,1,'photo_697917.html');
												thumbnails[945742] = new thumbnail(945742,'53435','','Bear of Britain 150 15_thumb.jpg',130, 73,1,'photo_945742.html');
												thumbnails[697920] = new thumbnail(697920,'53437','','Carren Snagg detail_thumb.jpg',130, 145,1,'photo_697920.html');
												thumbnails[697354] = new thumbnail(697354,'53429','','Partridge 200_thumb.jpg',130, 98,1,'photo_697354.html');
												thumbnails[697875] = new thumbnail(697875,'53437','','Maitland and cat (detail)_thumb.jpg',130, 95,1,'photo_697875.html');
												thumbnails[945977] = new thumbnail(945977,'53435','','blue and yellow shirts 150 15 (40 x 30)_thumb.jpg',130, 95,1,'photo_945977.html');
												thumbnails[945979] = new thumbnail(945979,'53435','','Dragon 506 beating up the green 150 15 (40 x 30)_thumb.jpg',130, 179,1,'photo_945979.html');
												thumbnails[945987] = new thumbnail(945987,'53435','','Dragon 506 spinnaker 150 15 (40 x 30)_thumb.jpg',130, 178,1,'photo_945987.html');
												thumbnails[946259] = new thumbnail(946259,'53437','','Gemmell 30 x 22cm_thumb.jpg',130, 170,1,'photo_946259.html');
												thumbnails[946001] = new thumbnail(946001,'53435','','Mumm\'s at the start 150 15 (60 x 40)_thumb.jpg',130, 195,1,'photo_946001.html');
												thumbnails[946263] = new thumbnail(946263,'53437','','Gemmell  30 x 25cm_thumb.jpg',130, 155,1,'photo_946263.html');
												thumbnails[946012] = new thumbnail(946012,'53435','','On the rail 150 15 (40 x 30)_thumb.jpg',130, 95,1,'photo_946012.html');
												thumbnails[946267] = new thumbnail(946267,'53437','','Laurence\'s baby 20 x 18cm_thumb.jpg',130, 109,1,'photo_946267.html');
												thumbnails[945761] = new thumbnail(945761,'53435','','Darings and Patricia 150 15_thumb.jpg',130, 86,1,'photo_945761.html');
												thumbnails[946281] = new thumbnail(946281,'53437','','Bob 40 x 30cm_thumb.jpg',130, 163,1,'photo_946281.html');
												thumbnails[946015] = new thumbnail(946015,'53435','','Burgundy Daring racing 150 15 (50 x 35)_thumb.jpg',130, 88,1,'photo_946015.html');
												thumbnails[946283] = new thumbnail(946283,'53437','','Billy Spain 40 x 37cm_thumb.jpg',130, 155,1,'photo_946283.html');
												thumbnails[946285] = new thumbnail(946285,'53437','','Fisherman 35 x 25cm_thumb.jpg',130, 175,1,'photo_946285.html');
												thumbnails[946017] = new thumbnail(946017,'53435','','Darings at the start 150 15 (40 x 20)_thumb.jpg',130, 67,1,'photo_946017.html');
												thumbnails[946286] = new thumbnail(946286,'53437','','Gilly Nester-Smith 40 x 30cm_thumb.jpg',130, 158,1,'photo_946286.html');
												thumbnails[946019] = new thumbnail(946019,'53435','','Red Etchell Racing 150 15 (60 x 40)_thumb.jpg',130, 85,1,'photo_946019.html');
												thumbnails[946287] = new thumbnail(946287,'53437','','Jago boys 2 70 x 60cm_thumb.jpg',130, 111,1,'photo_946287.html');
												thumbnails[946021] = new thumbnail(946021,'53435','','Red, White and Blue 150 15 (50 x 40)_thumb.jpg',130, 105,1,'photo_946021.html');
												thumbnails[946289] = new thumbnail(946289,'53437','','Jago older 2 (detail)_thumb.jpg',130, 159,1,'photo_946289.html');
												thumbnails[946022] = new thumbnail(946022,'53435','','Rounding Snowdon 150 15 (50 x 35)_thumb.jpg',130, 89,1,'photo_946022.html');
												thumbnails[946024] = new thumbnail(946024,'53435','','Etchell_thumb. yellow sailors 150 15 (50 x 35).jpg',130, 86,1,'photo_946024.html');
												thumbnails[946039] = new thumbnail(946039,'53435','','Sydney Hobart start 150 15 (60 x 50)_thumb.jpg',130, 105,1,'photo_946039.html');
												thumbnails[946362] = new thumbnail(946362,'53437','','Tracy Edwards best_thumb.jpg',130, 104,1,'photo_946362.html');
												thumbnails[697356] = new thumbnail(697356,'53429','','America_thumb.jpg',130, 173,1,'photo_697356.html');
												thumbnails[946049] = new thumbnail(946049,'53435','','Eriksson 150 15 (45 x 30)_thumb.jpg',130, 86,1,'photo_946049.html');
												thumbnails[946367] = new thumbnail(946367,'53437','','Tracy Edwards (detail)1_thumb.jpg',130, 148,1,'photo_946367.html');
												thumbnails[946051] = new thumbnail(946051,'53435','','Shirley Robertson 150 15 (40 x 30)_thumb.jpg',130, 101,1,'photo_946051.html');
												thumbnails[946053] = new thumbnail(946053,'53435','','Union Jack, Cowes Week 150 15 (50 x 30)_thumb.jpg',130, 77,1,'photo_946053.html');
												thumbnails[946055] = new thumbnail(946055,'53435','','VW Tuareg Lasers 150 15 (30 x 20)_thumb.jpg',130, 99,1,'photo_946055.html');
												thumbnails[697357] = new thumbnail(697357,'53429','','The Boat Shed_thumb.jpg',130, 174,1,'photo_697357.html');
												thumbnails[946057] = new thumbnail(946057,'53435','','Quetzal 150 15 (55 x 70)_thumb.jpg',130, 166,1,'photo_946057.html');
												thumbnails[5117143] = new thumbnail(5117143,'53437','','Veryan_Sharp__thumb.jpg',130, 156,1,'photo_5117143.html');
												thumbnails[5117156] = new thumbnail(5117156,'53437','','Teddy_Walker_light_thumb.jpg',130, 163,1,'photo_5117156.html');
												thumbnails[909603] = new thumbnail(909603,'53429','','Partridge ACJ 100_thumb.jpg',130, 184,1,'photo_909603.html');
												thumbnails[909612] = new thumbnail(909612,'53429','','Moonbeam and Tuiga 100_thumb.jpg',130, 103,1,'photo_909612.html');
												thumbnails[909451] = new thumbnail(909451,'53429','','Moonbeam of Fife 200_thumb.jpg',130, 87,1,'photo_909451.html');
												thumbnails[909584] = new thumbnail(909584,'53429','','Cambria ACJ 100_thumb.jpg',130, 89,1,'photo_909584.html');
												thumbnails[909586] = new thumbnail(909586,'53429','','Cambria off Egypt Point 100_thumb.jpg',130, 85,1,'photo_909586.html');
												thumbnails[909585] = new thumbnail(909585,'53429','','Cambria off Cowes 100_thumb.jpg',130, 86,1,'photo_909585.html');
												thumbnails[909621] = new thumbnail(909621,'53429','','Chloe May 100_thumb.jpg',130, 91,1,'photo_909621.html');
												thumbnails[909623] = new thumbnail(909623,'53429','','Pesa 100_thumb.jpg',130, 86,1,'photo_909623.html');
												thumbnails[7592677] = new thumbnail(7592677,'64147','SOLD','Ahead_of_the_storm12_thumb.jpg',130, 106,1,'photo_7592677.html');
												thumbnails[7597303] = new thumbnail(7597303,'64147','','The_Lady_Anne_heading_home123_thumb.jpg',130, 171,1,'photo_7597303.html');
												thumbnails[7597290] = new thumbnail(7597290,'64147','','Heavy_weather123456_thumb.jpg',130, 174,1,'photo_7597290.html');
												thumbnails[7595674] = new thumbnail(7595674,'64147','','Lady_Anne_off_Cowes_thumb.jpg',130, 95,1,'photo_7595674.html');
												thumbnails[7595682] = new thumbnail(7595682,'64147','','Mariette_thumb.jpg',130, 86,1,'photo_7595682.html');
												thumbnails[7595685] = new thumbnail(7595685,'64147','','The_Lady_Anne_thumb.jpg',130, 87,1,'photo_7595685.html');
												thumbnails[7592621] = new thumbnail(7592621,'64147','','Brighton_beach_thumb.jpg',130, 117,1,'photo_7592621.html');
												thumbnails[910847] = new thumbnail(910847,'64144','','Falklands 25_thumb.jpg',130, 170,1,'photo_910847.html');
												thumbnails[947515] = new thumbnail(947515,'64143','','Ericsson 1002_thumb.jpg',130, 122,1,'photo_947515.html');
												thumbnails[947516] = new thumbnail(947516,'64143','','On the rail 150 15 (40 x 30)2_thumb.jpg',130, 95,1,'photo_947516.html');
												thumbnails[947518] = new thumbnail(947518,'64143','','Red, White and Blue 150 15 (50 x 40)3_thumb.jpg',130, 105,1,'photo_947518.html');
												thumbnails[947519] = new thumbnail(947519,'64143','','VW Tuareg Lasers 150 15 (30 x 20)1_thumb.jpg',130, 99,1,'photo_947519.html');
												thumbnails[947491] = new thumbnail(947491,'64144','','Everest print_thumb.jpg',130, 103,1,'photo_947491.html');
												thumbnails[950164] = new thumbnail(950164,'64143','','Tracy Edwards best1_thumb.jpg',130, 104,1,'photo_950164.html');
												thumbnails[950166] = new thumbnail(950166,'64143','','Burgundy Daring racing 150 15 (50 x 35)2_thumb.jpg',130, 88,1,'photo_950166.html');
												thumbnails[950174] = new thumbnail(950174,'64143','','Fulmar off the Squadron 150 10_thumb.jpg',130, 80,1,'photo_950174.html');
												thumbnails[950175] = new thumbnail(950175,'64143','','Hammerhead Crane1_thumb.jpg',130, 163,1,'photo_950175.html');
												thumbnails[1107043] = new thumbnail(1107043,'64143','','Alinghi racing in Valencia_thumb.jpg',130, 93,1,'photo_1107043.html');
												thumbnails[1107054] = new thumbnail(1107054,'64143','','Alinghi, Spinnaker trouble_thumb.jpg',130, 82,1,'photo_1107054.html');
												thumbnails[1107065] = new thumbnail(1107065,'64143','','Americas Cup, spinnaker run_thumb.jpg',130, 87,1,'photo_1107065.html');
												thumbnails[829970] = new thumbnail(829970,'64143','','Bear of Britain_thumb.jpg',130, 73,1,'photo_829970.html');
												thumbnails[1107069] = new thumbnail(1107069,'64143','','Racing in Antigua_thumb.jpg',130, 98,1,'photo_1107069.html');
												thumbnails[1107066] = new thumbnail(1107066,'64143','','Tuiga in Antigua_thumb.jpg',130, 73,1,'photo_1107066.html');
												thumbnails[1107076] = new thumbnail(1107076,'64143','','HMS Illustrious_thumb.jpg',130, 86,1,'photo_1107076.html');
												thumbnails[829969] = new thumbnail(829969,'64143','','Rickshaw_thumb.jpg',130, 173,1,'photo_829969.html');
												thumbnails[950248] = new thumbnail(950248,'64143','','Cockerel_thumb.jpg',130, 181,1,'photo_950248.html');
												thumbnails[950253] = new thumbnail(950253,'64143','','pheasant 150_thumb.jpg',130, 101,1,'photo_950253.html');
												thumbnails[950260] = new thumbnail(950260,'64143','','starlings 150_thumb.jpg',130, 104,1,'photo_950260.html');
												thumbnails[951886] = new thumbnail(951886,'64143','','pheasant square_thumb.jpg',130, 131,1,'photo_951886.html');
												thumbnails[950264] = new thumbnail(950264,'64143','','pheasants fighting_thumb.jpg',130, 94,1,'photo_950264.html');
												thumbnails[830137] = new thumbnail(830137,'64163','','Ro_thumb.jpg',130, 156,1,'photo_830137.html');

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  					galleries[64143] = new gallery(64143,'947516','ORIGINALS','section92977',[947515,947516,947518,947519,950164,950166,950174,950175,1107043,1107054,1107065,829970,1107069,1107066,1107076,829969,950248,950253,950260,951886,950264],0, 0, '', 'section92977_64143.html',0,0);
				  					galleries[64144] = new gallery(64144,'910847','PRINTS','section92977',[910847,947491],0, 0, '', 'section92977_64144.html',0,0);
				  					galleries[53429] = new gallery(53429,'697354','CLASSIC YACHTS','gallery',[6167456,697354,697356,697357,909603,909612,909451,909584,909586,909585,909621,909623],0, 0, '', 'gallery_53429.html',0,0);
				  					galleries[64163] = new gallery(64163,'830137','Rowena','section92998',[830137],0, 0, '', 'section92998.html',0,1);
				  					galleries[53435] = new gallery(53435,'697382','MODERN BOATS','gallery',[697382,697385,697811,697837,909572,945731,945742,945977,945979,945987,946001,946012,945761,946015,946017,946019,946021,946022,946024,946039,946049,946051,946053,946055,946057],0, 0, '', 'gallery_53435.html',0,0);
				  					galleries[53436] = new gallery(53436,'697388','SHIPS','gallery',[697383,697388,698071,698075],0, 0, '', 'gallery_53436.html',0,0);
				  					galleries[53437] = new gallery(53437,'697376','PORTRAITS','gallery',[697387,697386,697376,697892,697986,697848,697917,697920,697875,946259,946263,946267,946281,946283,946285,946286,946287,946289,946362,946367,5117143,5117156],0, 0, '', 'gallery_53437.html',0,0);
				  					galleries[53438] = new gallery(53438,'697380','PETS','gallery',[697380,697799,697796,697781,697801],0, 0, '', 'gallery_53438.html',0,0);
				  					galleries[53439] = new gallery(53439,'697377','OTHER','gallery',[697377],0, 0, '', 'gallery_53439.html',0,0);
				  					galleries[64147] = new gallery(64147,'7597303,7597290,7595685,7595682,7595674,7592677,7592621','Kendall\'s Fine Art - Easter Exhibition','section92982',[7592677,7597303,7597290,7595674,7595682,7595685,7592621],0, 0, '', 'section92982.html',0,1);
/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = new Object();
imageSets[1] = '7595682';
imageSets[2] = '947516,910847,830137,697388,697382,697380,697377,697376,697354';
imageSets[3] = '7595682';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/rowenawright/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/rowenawright/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/rowenawright/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/rowenawright/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/rowenawright/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/rowenawright/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/rowenawright/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/rowenawright/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/rowenawright/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/rowenawright/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/rowenawright/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/rowenawright/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/rowenawright/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/rowenawright/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/rowenawright/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://admin2.clikpic.com/rowenawright/images';
		break;
	}
		switch (server_id) {
		case 33:
		val = 'http://www8.clikpic.com/rowenawright/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/rowenawright/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/rowenawright/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/rowenawright/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/rowenawright/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/rowenawright/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 && backgrounds[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:'',
                    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 (!basic) {
    if (op.updateHash && clik.getIDInUrl(location.href,'photo') != op.nextPhoto.id) {
		clik.changeHash('photos_id=' + op.nextPhoto.id, true);
    }
				
    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));		  $('body').trigger('clikUpdate');		}, op.onBefore);
      }    }
    	if (op.field) {
		op.field.value = photoId;
	} else {
		op.$photo.data('image_id', photoId);
    }
	    if (op.$title.length > 0) {
  		op.$title.fadeGalleryDetails(photoCaption, op.speed);
    }
        if (op.updateDocumentTitle) {
						  document.title = 'rowena wright : ' + photoCaption;
			    }
        if (op.$detail.length > 0) {
      temp = op.nextPhoto.fnGetImageDetails();
	    op.$detail.fadeGalleryDetails(temp, op.speed, function(){
	    var options = {photoinfominwidth:200};	    		options.photoinfoadjacent = true;			      	      resizePhotoInfo(options);
        if (typeof(backgrounds) != 'undefined' && op.nextPhoto == backgrounds[op.nextPhoto.id]) {
  	      toggleAddToCartConfirm(backgrounds);
  	    } else if (typeof(photos) != 'undefined' && op.nextPhoto == photos[op.nextPhoto.id]) {
  	      toggleAddToCartConfirm(photos);
  	    }
	    });
    }
        if (!op.speed) {      clik.doColumnResize(false, op.$photo.add(op.$detail).add(op.$title));      $('body').trigger('clikUpdate');    }        
    return html;			}
	else {
				
		window.location = 'photo_' + nextPhoto.id + '.html';
	}
		
}

/***************************************************************************
* Toggle add to cart confirmation element and set up the click event for   *
* the 'Add to cart' button.                                                *
***************************************************************************/
function toggleAddToCartConfirm(array){
  if (typeof(array) !== 'object') {
    array = photos;
  }
	if($('#paymentConfirm').length > 0){
		$('#paymentConfirm').hide();
		$('#paymentAddButton')
		.unbind()
		.click(function(){
						form = document.getElementById('paymentForm');
			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').text('Item added to cart').show();}
				else{
					$('#paymentConfirm').text('Item added to cart').fadeIn();
					dspOrderDetails(form.site.value);
				}
			}
			else{
				$('#paymentConfirm').text('Item not added - check cookies are enabled in your browser.').fadeIn();
			}
		});
	}
}
/***************************************************************************
* Get payment info for image - add as 'method' to photo object             *
***************************************************************************/
photo.prototype.fnGetImageDetails = function(){
	var temp = '';
	if (this.description != '') {
		temp = temp +  '<p id="imageDescription">' + this.description + '</p>';
	}
		if (this.photo_ref != '') {
		temp = temp + '<p class="imageinfo" id="imageRef"><strong>Ref: </strong>' + this.photo_ref + '</p>';
	}
		if (this.takendate != '') {
				
		temp = temp + '<p class="imageinfo" id="imageDate"><strong>Date: </strong>' + this.takendate + '</p>';
	}
	
	if (this.location != '') {
				
		temp = temp + '<p class="imageinfo" id="imageLocation"><strong>Location: </strong>' +  this.location + '</p>';
	}
	
	if (this.photographer != '') {
				
		temp = temp + '<p class="imageinfo" id="imagePhotographer"><strong>Photographer: </strong>' + this.photographer + '</p>';
	}
					
	temp = temp + this.fnGetPaymentInfo();
				if (temp != '') {
		temp = temp + '<div class="spacer"></div>';
	}
	return temp;
};

/***************************************************************************
* Get payment info for image - add as 'method' to photo object             *
***************************************************************************/
photo.prototype.fnGetPaymentInfo = function(){
	var temp = '';
	if (this.item_price !== '') {
																		temp = temp + '<p>Buy now using PayPal:</p>';
				temp = temp + '<p class="imageinfo" id="imagePrice"><strong>' + this.purchase_instruction + '</strong> &pound;' + (this.item_price).toFixed(2) + '</p>';
		var item_name  = this.purchase_instruction;
		var amount = (this.item_price).toFixed(2);
		var item_option  = 0;
	}
	else if (this.payment_groups_id !== '') {
		temp = temp + '<p>Buy this print online:</p>';
				temp = temp + '<form id="paymentOptions" style="margin:0px;border:0px;" name="paymentOptions">';
											temp = temp + '<select class="paymentlink" name="payment_options_id" onchange="updateItemValues(document.forms.paymentForm,this.form.payment_options_id.options[this.form.payment_options_id.options.selectedIndex].value);">';
				
		temp = temp + getPaymentOptions(this.payment_groups_id);
		temp = temp + '</select>';
		temp = 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 = temp + '<form id="paymentForm" style="margin:0px;border:0px;" name="paymentForm" target="_blank" action="https://www.paypal.com/cgi-bin/webscr" method="post">';
	temp = 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 = temp + '<input type="hidden" name="cmd" value="_cart">';
	temp = temp + '<input type="hidden" name="business" value="rowena_wright@yahoo.co.uk">';
	temp = temp + '<input type="hidden" name="currency_code" value="GBP">';
	temp = temp + '<input type="hidden" name="add" value="1">';
					temp = temp + '<input type="hidden" name="amount" value="'+amount+'">';
	temp = temp + '<input type="hidden" name="item_number" value="'+ref+'">';
					temp = temp + '<input type=\"Submit\" value=\"Add to cart\" id=\"paymentAddButton\" class=\"button\" onmouseover=\"this.className=\'buttonHi\';\" onmouseout=\"this.className=\'button\';\">';
									temp = temp + '</form>';
								temp = temp + '<form id="paymentCartForm" style="margin:0px;" name="paymentCartForm" target="_blank" action="https://www.paypal.com/cgi-bin/webscr" method="post">';
	temp = temp + '<input type="hidden" name="cmd" value="_cart">';
	temp = temp + '<input type="hidden" name="business" value="rowena_wright@yahoo.co.uk">';
	temp = temp + '<input type="hidden" name="display" value="1">';
	temp = temp + '<input type=\"Submit\" value=\"View cart\" id=\"paymentViewButton\" class=\"button\" onmouseover=\"this.className=\'buttonHi\';\" onmouseout=\"this.className=\'button\';\">';
	temp = temp + '</form>';
							temp = 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({            href: thumbnails[imageID].fnGalleryLink(gallery_id),            title: galleries[gallery_id].title          });
        }
							}
										}
}

/***************************************************************************
* 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 + ' | ';
				}
				temp = temp + '<a href="' + galleries[i].section_code + '_' + galleries[i].id + '.html">' + galleries[i].title + '</a>';
			}
		}
		document.all.galleryLinks.innerHTML = 'Other galleries: ' + temp;
	}
}

		

