window.thumbnails = new Object();
												thumbnails[5939624] = new thumbnail(5939624,'335149','','6478_thumb.jpg',130, 98,5,'photo_5939624.html');
												thumbnails[5939625] = new thumbnail(5939625,'335149','','6520_thumb.jpg',130, 98,5,'photo_5939625.html');
												thumbnails[5939626] = new thumbnail(5939626,'335149','','6539_thumb.jpg',130, 98,5,'photo_5939626.html');
												thumbnails[5939627] = new thumbnail(5939627,'335149','','6559_thumb.jpg',130, 98,5,'photo_5939627.html');
												thumbnails[5939628] = new thumbnail(5939628,'335148','','0009_thumb.jpg',130, 87,5,'photo_5939628.html');
												thumbnails[5939629] = new thumbnail(5939629,'335148','','1617_thumb.jpg',130, 87,5,'photo_5939629.html');
												thumbnails[5939630] = new thumbnail(5939630,'335148','','9902_thumb.jpg',130, 87,5,'photo_5939630.html');
												thumbnails[5939631] = new thumbnail(5939631,'335148','','7222_thumb.jpg',130, 87,5,'photo_5939631.html');
												thumbnails[5939632] = new thumbnail(5939632,'335150','','0389_thumb.jpg',130, 87,5,'photo_5939632.html');
												thumbnails[5939633] = new thumbnail(5939633,'335150','','0395_thumb.jpg',130, 87,5,'photo_5939633.html');
												thumbnails[5939634] = new thumbnail(5939634,'335150','','0420_thumb.jpg',130, 87,5,'photo_5939634.html');
												thumbnails[5939635] = new thumbnail(5939635,'335150','','0430_thumb.jpg',130, 87,5,'photo_5939635.html');
												thumbnails[5957303] = new thumbnail(5957303,'335148','','btp0006_thumb.jpg',130, 87,5,'photo_5957303.html');
												thumbnails[5957308] = new thumbnail(5957308,'335148','Encounter','btp1512_thumb.jpg',130, 87,5,'photo_5957308.html');
												thumbnails[5957309] = new thumbnail(5957309,'335148','','btp2206_thumb.jpg',130, 87,5,'photo_5957309.html');
												thumbnails[5957311] = new thumbnail(5957311,'335148','','btp2484_thumb.jpg',130, 87,5,'photo_5957311.html');
												thumbnails[5957312] = new thumbnail(5957312,'335148','','btp7164_thumb.jpg',130, 87,5,'photo_5957312.html');
												thumbnails[5957314] = new thumbnail(5957314,'335148','','btp9819_thumb.jpg',130, 87,5,'photo_5957314.html');
												thumbnails[5957315] = new thumbnail(5957315,'335149','','btp6439_thumb.jpg',130, 87,5,'photo_5957315.html');
												thumbnails[5957317] = new thumbnail(5957317,'335149','','btp6448_thumb.jpg',130, 87,5,'photo_5957317.html');
												thumbnails[5957318] = new thumbnail(5957318,'335149','','btp6475_thumb.jpg',130, 87,5,'photo_5957318.html');
												thumbnails[5957320] = new thumbnail(5957320,'335149','','btp6513_thumb.jpg',130, 87,5,'photo_5957320.html');
												thumbnails[5957368] = new thumbnail(5957368,'335148','','btp0687_thumb.jpg',130, 87,5,'photo_5957368.html');
												thumbnails[5957369] = new thumbnail(5957369,'335150','','btp0433_thumb.jpg',130, 87,5,'photo_5957369.html');
												thumbnails[5957370] = new thumbnail(5957370,'335150','','btp0443_thumb.jpg',130, 87,5,'photo_5957370.html');
												thumbnails[5957372] = new thumbnail(5957372,'335150','','btp0490_thumb.jpg',130, 87,5,'photo_5957372.html');
												thumbnails[5957373] = new thumbnail(5957373,'335150','','btp0506_thumb.jpg',130, 87,5,'photo_5957373.html');
												thumbnails[5994241] = new thumbnail(5994241,'337654','','btsunset8130_thumb.jpg',130, 87,5,'photo_5994241.html');
												thumbnails[5994246] = new thumbnail(5994246,'337654','','btsunset8160_thumb.jpg',130, 87,5,'photo_5994246.html');
												thumbnails[5994249] = new thumbnail(5994249,'337654','','btsunset8162_thumb.jpg',130, 87,5,'photo_5994249.html');
												thumbnails[5994253] = new thumbnail(5994253,'337654','','btsunset9663_thumb.jpg',130, 87,5,'photo_5994253.html');
												thumbnails[5994257] = new thumbnail(5994257,'337654','','btsunset9266_thumb.jpg',130, 87,5,'photo_5994257.html');
												thumbnails[5994260] = new thumbnail(5994260,'337654','','btsunset0052_thumb.jpg',130, 87,5,'photo_5994260.html');
												thumbnails[5994264] = new thumbnail(5994264,'337654','','btsunset0047_thumb.jpg',130, 87,5,'photo_5994264.html');
												thumbnails[5994267] = new thumbnail(5994267,'337654','','btsunset0492_thumb.jpg',130, 87,5,'photo_5994267.html');
												thumbnails[5994270] = new thumbnail(5994270,'337654','','btsunset0809_thumb.jpg',130, 84,5,'photo_5994270.html');
												thumbnails[5994274] = new thumbnail(5994274,'337654','','btsunset3913_thumb.jpg',130, 87,5,'photo_5994274.html');
												thumbnails[5998168] = new thumbnail(5998168,'337941','','01btbirds0525_thumb.jpg',130, 87,5,'photo_5998168.html');
												thumbnails[5998180] = new thumbnail(5998180,'337941','','02btbirds3454_thumb.jpg',130, 87,5,'photo_5998180.html');
												thumbnails[5998184] = new thumbnail(5998184,'337941','','03btbirds3229_thumb.jpg',130, 87,5,'photo_5998184.html');
												thumbnails[5998193] = new thumbnail(5998193,'337941','','04btbirds0501_thumb.jpg',130, 87,5,'photo_5998193.html');
												thumbnails[5998197] = new thumbnail(5998197,'337941','','05btbirds4637_thumb.jpg',130, 87,5,'photo_5998197.html');
												thumbnails[5998211] = new thumbnail(5998211,'337941','','06btbirds0096_thumb.jpg',130, 87,5,'photo_5998211.html');
												thumbnails[5998218] = new thumbnail(5998218,'337941','','07btbirds0487_thumb.jpg',130, 87,5,'photo_5998218.html');
												thumbnails[5998226] = new thumbnail(5998226,'337941','','08btbirds3036_thumb.jpg',130, 87,5,'photo_5998226.html');
												thumbnails[5998229] = new thumbnail(5998229,'337941','','09btbirds0488_thumb.jpg',130, 87,5,'photo_5998229.html');
												thumbnails[5998231] = new thumbnail(5998231,'337941','','10btbirds7447_thumb.jpg',130, 87,5,'photo_5998231.html');
												thumbnails[5998239] = new thumbnail(5998239,'337941','','11btbirds3241_thumb.jpg',130, 87,5,'photo_5998239.html');
												thumbnails[5998242] = new thumbnail(5998242,'337941','','12btbirds8543_thumb.jpg',130, 87,5,'photo_5998242.html');
												thumbnails[7485307] = new thumbnail(7485307,'405850','Crowds watch as the boat reaches the water','btp3985_thumb.jpg',130, 87,5,'photo_7485307.html');
												thumbnails[7485312] = new thumbnail(7485312,'405850','The spectacular launch','btp3990_thumb.jpg',130, 87,5,'photo_7485312.html');
												thumbnails[7485385] = new thumbnail(7485385,'405850','Air sea rescue display','btp4017_thumb.jpg',130, 87,5,'photo_7485385.html');
												thumbnails[7485415] = new thumbnail(7485415,'405850','On the water','btp4119_thumb.jpg',130, 87,5,'photo_7485415.html');
												thumbnails[7485417] = new thumbnail(7485417,'405850','The crew','btp4124_thumb.jpg',130, 87,5,'photo_7485417.html');
												thumbnails[7485418] = new thumbnail(7485418,'405850','Rescue','btp4128_thumb.jpg',130, 87,5,'photo_7485418.html');
												thumbnails[7506745] = new thumbnail(7506745,'406995','On your Marks......','btp7859_thumb.jpg',130, 87,5,'photo_7506745.html');
												thumbnails[7506748] = new thumbnail(7506748,'406995','They\'re Off','btp7864_thumb.jpg',130, 87,5,'photo_7506748.html');
												thumbnails[7506750] = new thumbnail(7506750,'406995','','btp7920_thumb.jpg',130, 87,5,'photo_7506750.html');
												thumbnails[7506751] = new thumbnail(7506751,'406995','','btp7972_thumb.jpg',130, 87,5,'photo_7506751.html');
												thumbnails[7506754] = new thumbnail(7506754,'406995','','btp8011_thumb.jpg',130, 87,5,'photo_7506754.html');
												thumbnails[7506756] = new thumbnail(7506756,'406995','','btp8089_thumb.jpg',130, 87,5,'photo_7506756.html');
												thumbnails[7506760] = new thumbnail(7506760,'406995','','btp1543_thumb.jpg',130, 87,5,'photo_7506760.html');
												thumbnails[7506762] = new thumbnail(7506762,'406995','','btp1610_thumb.jpg',130, 87,5,'photo_7506762.html');
												thumbnails[7506765] = new thumbnail(7506765,'406995','','btp1613_thumb.jpg',130, 87,5,'photo_7506765.html');
												thumbnails[7506768] = new thumbnail(7506768,'406995','','btp1625_thumb.jpg',130, 87,5,'photo_7506768.html');
												thumbnails[7506770] = new thumbnail(7506770,'406995','','btp1807_thumb.jpg',130, 87,5,'photo_7506770.html');
												thumbnails[7506773] = new thumbnail(7506773,'406995','','btp1819_thumb.jpg',130, 87,5,'photo_7506773.html');
												thumbnails[5989689] = new thumbnail(5989689,'337447','','btwolves4865_thumb.jpg',130, 98,5,'photo_5989689.html');
												thumbnails[5998478] = new thumbnail(5998478,'335293','Blue-tailed Damselfly','btdamsels0001_thumb.jpg',130, 87,5,'photo_5998478.html');
												thumbnails[6318962] = new thumbnail(6318962,'350500','Signing the register','bobdeb5107_thumb.jpg',130, 87,5,'photo_6318962.html');
												thumbnails[7486601] = new thumbnail(7486601,'337447','','btp5742_thumb.jpg',130, 87,5,'photo_7486601.html');
												thumbnails[5998489] = new thumbnail(5998489,'335293','Four-spotted Chaser','btdragons2472_thumb.jpg',130, 87,5,'photo_5998489.html');
												thumbnails[6318957] = new thumbnail(6318957,'350500','In the wedding car','bobdeb5335a_thumb.jpg',130, 87,5,'photo_6318957.html');
												thumbnails[7486603] = new thumbnail(7486603,'337447','','btp5775_thumb.jpg',130, 87,5,'photo_7486603.html');
												thumbnails[5943174] = new thumbnail(5943174,'335293','','0095_thumb.jpg',130, 87,5,'photo_5943174.html');
												thumbnails[5989668] = new thumbnail(5989668,'337447','','btwolves4790_thumb.jpg',130, 98,5,'photo_5989668.html');
												thumbnails[6318964] = new thumbnail(6318964,'350500','The happy couple','bobdeb5422a_thumb.jpg',130, 87,5,'photo_6318964.html');
												thumbnails[7486635] = new thumbnail(7486635,'337447','','btp5809_thumb.jpg',130, 87,5,'photo_7486635.html');
												thumbnails[5943179] = new thumbnail(5943179,'335293','','0112_thumb.jpg',130, 87,5,'photo_5943179.html');
												thumbnails[5989691] = new thumbnail(5989691,'337447','','btwolves4873_thumb.jpg',130, 98,5,'photo_5989691.html');
												thumbnails[6318975] = new thumbnail(6318975,'350500','','charlotte0907_thumb.jpg',130, 87,5,'photo_6318975.html');
												thumbnails[7486637] = new thumbnail(7486637,'337447','','btp5822_thumb.jpg',130, 87,5,'photo_7486637.html');
												thumbnails[5943181] = new thumbnail(5943181,'335293','','0140_thumb.jpg',130, 87,5,'photo_5943181.html');
												thumbnails[5989690] = new thumbnail(5989690,'337447','','btwolves4867_thumb.jpg',130, 98,5,'photo_5989690.html');
												thumbnails[6318977] = new thumbnail(6318977,'350500','','charlotte0987_thumb.jpg',130, 87,5,'photo_6318977.html');
												thumbnails[7486639] = new thumbnail(7486639,'337447','Lee Briers holds the cup aloft','btp5825_thumb.jpg',130, 87,5,'photo_7486639.html');
												thumbnails[5943184] = new thumbnail(5943184,'335293','','0242_thumb.jpg',130, 87,5,'photo_5943184.html');
												thumbnails[6318978] = new thumbnail(6318978,'350500','','charlotte0991_thumb.jpg',130, 87,5,'photo_6318978.html');
												thumbnails[7486640] = new thumbnail(7486640,'337447','','btp5834_thumb.jpg',130, 87,5,'photo_7486640.html');
												thumbnails[5943192] = new thumbnail(5943192,'335293','','0263_thumb.jpg',130, 87,5,'photo_5943192.html');
												thumbnails[7486643] = new thumbnail(7486643,'337447','Reflections','btp5839_thumb.jpg',130, 87,5,'photo_7486643.html');
												thumbnails[5943183] = new thumbnail(5943183,'335293','','0199_thumb.jpg',130, 87,5,'photo_5943183.html');
												thumbnails[7486645] = new thumbnail(7486645,'337447','How good it looks in primrose and blue','btp5842_thumb.jpg',130, 87,5,'photo_7486645.html');
												thumbnails[5943199] = new thumbnail(5943199,'335293','','3118_thumb.jpg',130, 87,5,'photo_5943199.html');
												thumbnails[7486649] = new thumbnail(7486649,'337447','','btp4519_thumb.jpg',130, 87,5,'photo_7486649.html');
												thumbnails[5943195] = new thumbnail(5943195,'335293','','3100_thumb.jpg',130, 87,5,'photo_5943195.html');
												thumbnails[7486651] = new thumbnail(7486651,'337447','','btp4541_thumb.jpg',130, 87,5,'photo_7486651.html');
												thumbnails[5943187] = new thumbnail(5943187,'335293','','0259_thumb.jpg',130, 130,5,'photo_5943187.html');
												thumbnails[7486654] = new thumbnail(7486654,'337447','','btp5948_thumb.jpg',130, 87,5,'photo_7486654.html');
												thumbnails[7486656] = new thumbnail(7486656,'337447','Adrian Morley leading the celebrations at the Town Hall','btp6014_thumb.jpg',130, 87,5,'photo_7486656.html');

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  					galleries[335148] = new gallery(335148,'5957368,5957314,5957312,5957311,5957309,5957308,5957303,5939631,5939630,5939629','Iconic Encounter','gallery',[5939628,5939629,5939630,5939631,5957303,5957308,5957309,5957311,5957312,5957314,5957368],0, 1, '', 'gallery_335148.html',0,0);
				  					galleries[337654] = new gallery(337654,'5994274,5994270,5994267,5994264,5994260,5994257,5994253,5994249,5994246,5994241','Anglesey Sunsets','gallery',[5994241,5994246,5994249,5994253,5994257,5994260,5994264,5994267,5994270,5994274],0, 1, '', 'gallery_337654.html',0,0);
				  					galleries[335149] = new gallery(335149,'5957320,5957318,5957317,5957315,5939627,5939626,5939625,5939624','Misty Morning','gallery',[5939624,5939625,5939626,5939627,5957315,5957317,5957318,5957320],0, 1, '', 'gallery_335149.html',0,0);
				  					galleries[337941] = new gallery(337941,'5998242,5998239,5998231,5998229,5998226,5998218,5998211,5998197,5998193,5998184','Birds','gallery',[5998168,5998180,5998184,5998193,5998197,5998211,5998218,5998226,5998229,5998231,5998239,5998242],0, 1, '', 'gallery_337941.html',0,0);
				  					galleries[335293] = new gallery(335293,'5998489,5998478,5943199,5943195,5943192,5943187,5943184,5943183,5943181,5943179','Damsels and Dragons','gallery',[5998478,5998489,5943174,5943179,5943181,5943184,5943192,5943183,5943199,5943195,5943187],0, 1, '', 'gallery_335293.html',0,0);
				  					galleries[335150] = new gallery(335150,'5957373,5957372,5957370,5957369,5939635,5939634,5939633,5939632','Another Place','gallery',[5939632,5939633,5939634,5939635,5957369,5957370,5957372,5957373],0, 1, '', 'gallery_335150.html',0,0);
				  					galleries[337447] = new gallery(337447,'7486656,7486654,7486651,7486649,7486645,7486643,7486640,7486639,7486637,7486635','Warringtonians','gallery',[5989689,7486601,7486603,5989668,7486635,5989691,7486637,5989690,7486639,7486640,7486643,7486645,7486649,7486651,7486654,7486656],0, 1, '', 'gallery_337447.html',0,0);
				  					galleries[350500] = new gallery(350500,'6318978,6318977,6318975,6318964,6318962,6318957','People and Events','gallery',[6318962,6318957,6318964,6318975,6318977,6318978],0, 1, '', 'gallery_350500.html',0,0);
				  					galleries[405850] = new gallery(405850,'7485418,7485417,7485415,7485385,7485312,7485307','Lifeboat Day','gallery',[7485307,7485312,7485385,7485415,7485417,7485418],0, 1, '', 'gallery_405850.html',0,0);
				  					galleries[406995] = new gallery(406995,'7506773,7506770,7506768,7506765,7506762,7506760,7506756,7506754,7506751,7506750','A Dash and a Splash','gallery',[7506745,7506748,7506750,7506751,7506754,7506756,7506760,7506762,7506765,7506768,7506770,7506773],0, 1, '', 'gallery_406995.html',0,0);
/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = new Object();
imageSets[1] = '7506773,7506770,7506768,7506765,7506762,7506760,7506756,7506754,7506751,7506750,7506748,7506745,7486656,7486654,7486651,7486649,7486645,7486643,7486640,7486639,7486637,7486635,7486603,7486601,7485418,7485417,7485415,7485385,7485312,7485307,6318978,6318977,6318975,6318964,6318962,6318957,5998489,5998478,5998242,5998239,5998231,5998229,5998226,5998218,5998211,5998197,5998193,5998184,5998180,5998168';
imageSets[3] = '7506773,7506770,7506768,7506765,7506762,7506760,7506756,7506754,7506751,7506750,7506748,7506745,7486656,7486654,7486651,7486649,7486645,7486643,7486640,7486639,7486637,7486635,7486603,7486601,7485418,7485417,7485415,7485385,7485312,7485307,6318978,6318977,6318975,6318964,6318962,6318957,5998489,5998478,5998242,5998239,5998231,5998229,5998226,5998218,5998211,5998197,5998193,5998184,5998180,5998168';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/brian2e/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/brian2e/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/brian2e/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/brian2e/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/brian2e/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/brian2e/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/brian2e/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/brian2e/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/brian2e/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/brian2e/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/brian2e/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/brian2e/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/brian2e/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/brian2e/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/brian2e/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://admin2.clikpic.com/brian2e/images';
		break;
	}
		switch (server_id) {
		case 33:
		val = 'http://www8.clikpic.com/brian2e/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/brian2e/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/brian2e/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/brian2e/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/brian2e/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/brian2e/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 = 'Brian Tuohey Photography: ' + 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 = 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>';
	}
					
				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>Order this print:</p>';
				temp = temp + '<p class="imageinfo" id="imagePrice"><strong>' + this.purchase_instruction + '</strong> ' + (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 + '<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;
	}
}

			

