window.thumbnails = new Object();
												thumbnails[4755829] = new thumbnail(4755829,'322818','The Model','Model_thumb.jpg',130, 100,1,'photo_4755829.html');
												thumbnails[4261148] = new thumbnail(4261148,'322815','Michelle','Michelle05_thumb.jpg',130, 87,1,'photo_4261148.html');
												thumbnails[4261107] = new thumbnail(4261107,'322815','Michelle','Michelle01f_thumb.jpg',130, 195,1,'photo_4261107.html');
												thumbnails[4261559] = new thumbnail(4261559,'322813','Poppies','Poppies_thumb.jpg',130, 86,1,'photo_4261559.html');
												thumbnails[4288001] = new thumbnail(4288001,'322814','Poppies and Rape Field','poppy_and_rape_field_thumb.jpg',130, 98,1,'photo_4288001.html');
												thumbnails[4261554] = new thumbnail(4261554,'322814','Early morning fisherman','Fishing-at-sun-up_thumb.jpg',130, 195,1,'photo_4261554.html');
												thumbnails[4287996] = new thumbnail(4287996,'322814','Ibiza Sunrise','ibiza_sunrise_thumb.jpg',130, 98,1,'photo_4287996.html');
												thumbnails[3906358] = new thumbnail(3906358,'322815','Posh Pink Punk','punk_thumb.jpg',130, 184,1,'photo_3906358.html');
												thumbnails[3906354] = new thumbnail(3906354,'322818','Cavalier','Cavalier_thumb.jpg',130, 92,1,'photo_3906354.html');
												thumbnails[3906371] = new thumbnail(3906371,'322814','Wheaton Aston Canal','wheato-canal_thumb.jpg',130, 92,1,'photo_3906371.html');
												thumbnails[3651394] = new thumbnail(3651394,'322813','Street Cafe','Street_Cafe_thumb.jpg',130, 104,1,'photo_3651394.html');
												thumbnails[3906429] = new thumbnail(3906429,'322814','Vatican by Night','Vatican-at-Night_thumb.jpg',130, 108,1,'photo_3906429.html');
												thumbnails[3906447] = new thumbnail(3906447,'322814','Castello San Angelo','Castello-San-Angelo_thumb.jpg',130, 70,1,'photo_3906447.html');
												thumbnails[3651369] = new thumbnail(3651369,'322812','Vatican Columns','vatican_columns_thumb.jpg',130, 167,1,'photo_3651369.html');
												thumbnails[3651345] = new thumbnail(3651345,'322814','Colosseum by Night','Colosseum_by_Night_thumb.jpg',130, 104,1,'photo_3651345.html');
												thumbnails[3651362] = new thumbnail(3651362,'322813','Through the Window','through_the_window_thumb.jpg',130, 163,1,'photo_3651362.html');
												thumbnails[2988183] = new thumbnail(2988183,'322818','Lady selling goods at Dubrovnik market','Market Lady_thumb.jpg',130, 195,1,'photo_2988183.html');
												thumbnails[2988720] = new thumbnail(2988720,'322814','Fort of Dubrovnik','Fort_thumb.jpg',130, 86,1,'photo_2988720.html');
												thumbnails[3468657] = new thumbnail(3468657,'322814','Dubrovnik','Miniature Dubrovnik 03_thumb.jpg',130, 67,1,'photo_3468657.html');
												thumbnails[2988061] = new thumbnail(2988061,'322818','Fisherman working on his boat','Just going out by John_thumb.jpg',130, 86,1,'photo_2988061.html');
												thumbnails[2987929] = new thumbnail(2987929,'322818','Lady doing embroidery in the shade of a tree','Embroidery in the shade by John_thumb.jpg',130, 108,1,'photo_2987929.html');
												thumbnails[2988725] = new thumbnail(2988725,'322814','Sunset in Lopud','Lopud Sunset_thumb.jpg',130, 86,1,'photo_2988725.html');
												thumbnails[2988747] = new thumbnail(2988747,'322814','Rocks being battered by the sea','Rocks_thumb.jpg',130, 83,1,'photo_2988747.html');
												thumbnails[2988200] = new thumbnail(2988200,'322818','Lady relaxing with a crossword','Relaxing at tea time by John_thumb.jpg',130, 157,1,'photo_2988200.html');
												thumbnails[2988752] = new thumbnail(2988752,'322814','Sunset in Rhossilli bay','sunset in Rhossilli_thumb.jpg',130, 72,1,'photo_2988752.html');
												thumbnails[2988755] = new thumbnail(2988755,'322814','The Gower Peninsula','The gower_thumb.jpg',130, 86,1,'photo_2988755.html');
												thumbnails[4288139] = new thumbnail(4288139,'322814','Rhossilli Beach','Gower_1_thumb.jpg',130, 86,1,'photo_4288139.html');
												thumbnails[2988749] = new thumbnail(2988749,'322814','The Sea','seascape_thumb.jpg',130, 83,1,'photo_2988749.html');
												thumbnails[2987914] = new thumbnail(2987914,'322818','Dubs on the Beach 2008','Dub3 bw copy_thumb.jpg',130, 86,1,'photo_2987914.html');
												thumbnails[3906364] = new thumbnail(3906364,'322818','1963 VW Panel Van','Funky-Bus_thumb.jpg',130, 92,1,'photo_3906364.html');
												thumbnails[3906378] = new thumbnail(3906378,'322818','VW Beetle Reflection','Reflection1_thumb.jpg',130, 92,1,'photo_3906378.html');
												thumbnails[2988134] = new thumbnail(2988134,'322816','Kimi Raikkonen','Kimi copy_thumb.jpg',130, 67,1,'photo_2988134.html');
												thumbnails[2988217] = new thumbnail(2988217,'322816','Mark Webber on Practice Day','Webber Red Bull F1 Car_thumb.jpg',130, 68,1,'photo_2988217.html');
												thumbnails[2988743] = new thumbnail(2988743,'322817','Pink Flower','pink flower_thumb.jpg',130, 130,1,'photo_2988743.html');
												thumbnails[4287979] = new thumbnail(4287979,'322817','Cream Rose','Cream_rose_thumb.jpg',130, 98,1,'photo_4287979.html');
												thumbnails[2217363] = new thumbnail(2217363,'322818','Italian Delicatessen','italian deli_thumb.jpg',130, 86,1,'photo_2217363.html');
												thumbnails[2217460] = new thumbnail(2217460,'322818','Quiet Study','bologna_thumb.jpg',130, 98,1,'photo_2217460.html');
												thumbnails[2217479] = new thumbnail(2217479,'322818','Woman with red handbag','woman with red handbag_thumb.jpg',130, 104,1,'photo_2217479.html');
												thumbnails[2217493] = new thumbnail(2217493,'322818','Busker in Blue Glove','busker-09-04-copy_thumb.jpg',130, 92,1,'photo_2217493.html');
												thumbnails[2981885] = new thumbnail(2981885,'322812','Le Due Torre, Bologna','Le Due Torri Bologna_thumb.jpg',130, 195,1,'photo_2981885.html');
												thumbnails[2217474] = new thumbnail(2217474,'322818','Squatter at rest','squatter_thumb.jpg',130, 86,1,'photo_2217474.html');
												thumbnails[2217471] = new thumbnail(2217471,'322813','Through the Window','running boy_thumb.jpg',130, 104,1,'photo_2217471.html');
												thumbnails[3906385] = new thumbnail(3906385,'322814','Waterfall','waterfall_thumb.jpg',130, 92,1,'photo_3906385.html');
												thumbnails[2217492] = new thumbnail(2217492,'322814','Abruzzo Landscape','Abruzzo01_thumb.jpg',130, 98,1,'photo_2217492.html');
												thumbnails[3906383] = new thumbnail(3906383,'322812','Scanno Street','scanno_thumb.jpg',130, 183,1,'photo_3906383.html');
												thumbnails[4288134] = new thumbnail(4288134,'322814','Gran Sasso Mountain Range','Gran_Sasso_range_thumb.jpg',130, 86,1,'photo_4288134.html');
												thumbnails[2217455] = new thumbnail(2217455,'322818','Let sleeping pigs lie','pigs_thumb.jpg',130, 69,1,'photo_2217455.html');
												thumbnails[2217463] = new thumbnail(2217463,'322813','Robin','robin_thumb.jpg',130, 102,1,'photo_2217463.html');
												thumbnails[2217357] = new thumbnail(2217357,'322812','Cosford Museum','cosford_thumb.jpg',130, 195,1,'photo_2217357.html');
												thumbnails[2217350] = new thumbnail(2217350,'322812','Blue Door','blue door_thumb.jpg',130, 104,1,'photo_2217350.html');
												thumbnails[2217490] = new thumbnail(2217490,'322812','Selfridges Store In Birmingham','Selfridges_thumb.jpg',130, 205,1,'photo_2217490.html');
												thumbnails[3906373] = new thumbnail(3906373,'322817','Purple Rose','Purple-Rose_thumb.jpg',130, 92,1,'photo_3906373.html');
												thumbnails[2217370] = new thumbnail(2217370,'322815','Enjoying a drink','nathan2_thumb.jpg',130, 104,1,'photo_2217370.html');
												thumbnails[2217495] = new thumbnail(2217495,'322815','Nathan','nathan_thumb.jpg',130, 104,1,'photo_2217495.html');
												thumbnails[2217499] = new thumbnail(2217499,'322812','Staircase','staircase02_thumb.jpg',130, 86,1,'photo_2217499.html');
												thumbnails[4755817] = new thumbnail(4755817,'322815','Rock and Roller','Dave_thumb.jpg',130, 195,1,'photo_4755817.html');
												thumbnails[4755820] = new thumbnail(4755820,'322815','True Love','GemDave_thumb.jpg',130, 87,1,'photo_4755820.html');
												thumbnails[4755824] = new thumbnail(4755824,'322815','Disco Dave and Miss Honeybun','Sexy_thumb.jpg',130, 195,1,'photo_4755824.html');
												thumbnails[5101232] = new thumbnail(5101232,'322815','Carl','Carl01_thumb.jpg',130, 195,1,'photo_5101232.html');
												thumbnails[5101233] = new thumbnail(5101233,'322815','Carl','Carl02_thumb.jpg',130, 195,1,'photo_5101233.html');
												thumbnails[5101236] = new thumbnail(5101236,'322815','Jess','Jess01_thumb.jpg',130, 195,1,'photo_5101236.html');
												thumbnails[5101238] = new thumbnail(5101238,'322815','Jess','Jess02_thumb.jpg',130, 87,1,'photo_5101238.html');
												thumbnails[5101239] = new thumbnail(5101239,'322815','Jess','Jess03_thumb.jpg',130, 195,1,'photo_5101239.html');
												thumbnails[5101244] = new thumbnail(5101244,'322815','Katy','Katy02_thumb.jpg',130, 87,1,'photo_5101244.html');
												thumbnails[5101246] = new thumbnail(5101246,'322815','Michelle','MichelleBW_thumb.jpg',130, 191,1,'photo_5101246.html');
												thumbnails[5700118] = new thumbnail(5700118,'322815','Nanette','Nanette0009_thumb.jpg',130, 196,1,'photo_5700118.html');
												thumbnails[5700120] = new thumbnail(5700120,'322815','Nanette','Nanette0018f_thumb.jpg',130, 86,1,'photo_5700120.html');
												thumbnails[5700121] = new thumbnail(5700121,'322815','Nanette','nanette6000black_copy_thumb.jpg',130, 201,1,'photo_5700121.html');
												thumbnails[5700125] = new thumbnail(5700125,'322815','Nanette','Nanetteblack_copy_thumb.jpg',130, 197,1,'photo_5700125.html');
												thumbnails[6910325] = new thumbnail(6910325,'374910','Wedding Day','IMG_7932_thumb.jpg',130, 195,1,'photo_6910325.html');
												thumbnails[6910333] = new thumbnail(6910333,'374910','Wedding Day','IMG_8866_thumb.jpg',130, 195,1,'photo_6910333.html');
												thumbnails[6910337] = new thumbnail(6910337,'374910','Wedding Day','IMG_8909-2_thumb.jpg',130, 87,1,'photo_6910337.html');
												thumbnails[6910338] = new thumbnail(6910338,'374910','Wedding Day','IMG_8967bw_thumb.jpg',130, 195,1,'photo_6910338.html');
												thumbnails[6910341] = new thumbnail(6910341,'374910','Wedding Day','img_8976b_thumb.jpg',130, 195,1,'photo_6910341.html');
												thumbnails[2988147] = new thumbnail(2988147,'322816','Lewis Hamilton','Lewis Winning_thumb.jpg',130, 69,1,'photo_2988147.html');
												thumbnails[1856189] = new thumbnail(1856189,'322814','Farindola, Abruzzo ','Abruzzo_Italy01_thumb.jpg',130, 72,1,'photo_1856189.html');
												thumbnails[1856225] = new thumbnail(1856225,'322818','Wood Turner','Wood_Turner_thumb.jpg',130, 184,1,'photo_1856225.html');
												thumbnails[1856272] = new thumbnail(1856272,'322818','Coppersmith at work','Coppersmith_thumb.jpg',130, 157,1,'photo_1856272.html');
												thumbnails[1856211] = new thumbnail(1856211,'322817','Tomatoes','Tomatoes01_thumb.jpg',130, 86,1,'photo_1856211.html');
												thumbnails[1856217] = new thumbnail(1856217,'322813','Nice place to live?','colander house_thumb.jpg',130, 86,1,'photo_1856217.html');
												thumbnails[1856274] = new thumbnail(1856274,'322818','Man on a Bike','Man_on_Bike_thumb.jpg',130, 195,1,'photo_1856274.html');
												thumbnails[1856279] = new thumbnail(1856279,'322818','Old Rover','Old_Rover_thumb.jpg',130, 86,1,'photo_1856279.html');
												thumbnails[1856221] = new thumbnail(1856221,'322813','Hand on guitar','Guitar01_thumb.jpg',130, 184,1,'photo_1856221.html');
												thumbnails[1856213] = new thumbnail(1856213,'322817','Lemon and Lime','Lemon_Lime_thumb.jpg',130, 97,1,'photo_1856213.html');
												thumbnails[1856250] = new thumbnail(1856250,'322812','Elevated Walkway','Abruzzo_Street_thumb.jpg',130, 192,1,'photo_1856250.html');
												thumbnails[1856222] = new thumbnail(1856222,'322813','Hands across the keys.','Keyboard_thumb.jpg',130, 184,1,'photo_1856222.html');
												thumbnails[1856214] = new thumbnail(1856214,'322817','Red peppers','Peppers_thumb.jpg',130, 96,1,'photo_1856214.html');
												thumbnails[1856178] = new thumbnail(1856178,'322814','Frascati Night','Frascati_Italy01_thumb.jpg',130, 195,1,'photo_1856178.html');
												thumbnails[1856205] = new thumbnail(1856205,'322814','Reflection','Reflection_thumb.jpg',130, 96,1,'photo_1856205.html');
												thumbnails[1856265] = new thumbnail(1856265,'322812','Up the Tower!','Church_Tower_thumb.jpg',130, 95,1,'photo_1856265.html');
												thumbnails[1856209] = new thumbnail(1856209,'322814','Afternoon Light','Afternoon_Light_thumb.jpg',130, 76,1,'photo_1856209.html');

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  					galleries[374910] = new gallery(374910,'6910338,6910337','Weddings','gallery',[6910325,6910333,6910337,6910338,6910341],0, 0, '', 'gallery_374910.html',0,0);
				  					galleries[322815] = new gallery(322815,'5700125,5700121,5700120,4755824,4755817,2217495','Portraits','gallery',[4261148,4261107,3906358,2217370,2217495,4755817,4755820,4755824,5101232,5101233,5101236,5101238,5101239,5101244,5101246,5700118,5700120,5700121,5700125],0, 0, '', 'gallery_322815.html',0,0);
				  					galleries[322812] = new gallery(322812,'3906383,3651369,2217499,2217490,2217357,1856265,1856250','Architecture','gallery',[3651369,2981885,3906383,2217357,2217350,2217490,2217499,1856250,1856265],0, 0, '', 'gallery_322812.html',0,0);
				  					galleries[322813] = new gallery(322813,'3651362,1856221,1856217','Artistic','gallery',[4261559,3651394,3651362,2217471,2217463,1856217,1856221,1856222],0, 0, '', 'gallery_322813.html',0,0);
				  					galleries[322816] = new gallery(322816,'2988217,2988147,2988134','Sport','gallery',[2988134,2988217,2988147],0, 0, '', 'gallery_322816.html',0,0);
				  					galleries[322814] = new gallery(322814,'4288139,4288134,4288001,4287996,4261554,3906447,3906429,3906385,2988755,2988752,2988749,2988725,2988720,1856205,1856189','Landscape','gallery',[4288001,4261554,4287996,3906371,3906429,3906447,3651345,2988720,3468657,2988725,2988747,2988752,2988755,4288139,2988749,3906385,2217492,4288134,1856189,1856178,1856205,1856209],0, 0, '', 'gallery_322814.html',0,0);
				  					galleries[322817] = new gallery(322817,'4287979,3906373,1856211','Still Life','gallery',[2988743,4287979,3906373,1856211,1856213,1856214],0, 0, '', 'gallery_322817.html',0,0);
				  					galleries[322818] = new gallery(322818,'3906378,2988061,2987914,2217493,1856279,1856272','Street Life','gallery',[4755829,3906354,2988183,2988061,2987929,2988200,2987914,3906364,3906378,2217363,2217460,2217479,2217493,2217474,2217455,1856225,1856272,1856274,1856279],0, 0, '', 'gallery_322818.html',0,0);
/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = new Object();
imageSets[1] = '6910338,6910337,6910325,5700125,5101246,5101239,4755820,4288001,4287979,1856189';
imageSets[2] = '6910338,6910337,5700125,5700121,5700120,4755824,4755817,4288139,4288134,4288001,4287996,4287979,4261554,3906447,3906429,3906385,3906383,3906378,3906373,3651369,3651362,2988755,2988752,2988749,2988725,2988720,2988217,2988147,2988134,2988061,2987914,2217499,2217495,2217493,2217490,2217357,1856279,1856272,1856265,1856250,1856221,1856217,1856211,1856205,1856189';
imageSets[3] = '5101246,5101244,5101239,5101238,5101236,5101233,5101232,4755829,4755824,4755820,4755817,4288139,4288134,4288001,4287996,4287979,4261559,4261554,4261148,4261107,3906447,3906429,3906385,3906383,3906378,3906373,3906371,3906364,3906358,3906354,3651394,3651369,3651362,3651345,3468657,2988755,2988752,2988749,2988747,2988743,2988725,2988720,2988217,2988200,2988183,2988134,2988061,2987929,2987914';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/jandmphotos/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/jandmphotos/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/jandmphotos/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/jandmphotos/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/jandmphotos/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/jandmphotos/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/jandmphotos/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/jandmphotos/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/jandmphotos/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/jandmphotos/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/jandmphotos/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/jandmphotos/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/jandmphotos/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/jandmphotos/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/jandmphotos/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://admin2.clikpic.com/jandmphotos/images';
		break;
	}
		switch (server_id) {
		case 33:
		val = 'http://www8.clikpic.com/jandmphotos/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/jandmphotos/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/jandmphotos/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/jandmphotos/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/jandmphotos/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/jandmphotos/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 = 'J and M Photos: ' + photoCaption;
			    }
        if (op.$detail.length > 0) {
      temp = op.nextPhoto.fnGetImageDetails();
	    op.$detail.fadeGalleryDetails(temp, op.speed, function(){
	    var options = {};	    	      	      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 == undefined) {
    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="updateCartValue(document.forms.paymentForm,this.form.payment_options_id.options[this.form.payment_options_id.options.selectedIndex].value); if(divShowing(\'paymentConfirm\')){fadeOut(\'paymentConfirm\', 3)};">';
				
		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">';
	temp = temp + '	<input type="hidden" name="item_option" value="' + item_option + '">';
	temp = temp + '	<input type="hidden" name="site" value="JANDMPHOTOS">';
		temp = temp + '	<input type="hidden" name="item_number" value="'+ this.id +'">';
			temp = temp + '	<input type="hidden" name="quantity" value="1">';
								temp = temp + '	<input value="Add to cart" id="paymentAddButton" class="button" onmouseover="this.className=\'buttonHi\'\;" onmouseout="this.className=\'button\'\;" type="Button">';
			temp = 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 = temp + '</form>';
		temp = temp + '<div class="clearing">&nbsp;</div>';
	temp = temp + '<div id="confirmContainer">';
	temp = temp + '<div id="paymentConfirm">Item added to cart</div>';
	temp = temp + '</div>';
			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;
	}
}

			

