window.thumbnails = new Object();
												thumbnails[4804685] = new thumbnail(4804685,'274827','Fun fun fun','b090919-52a5255tiny_thumb.jpg',130, 81,15,'							photo_4804685.html');
												thumbnails[4966895] = new thumbnail(4966895,'94861','A real Bugatti - Tour Britannia 2009','090907-52a4392tiny_thumb.jpg',130, 87,15,'							photo_4966895.html');
												thumbnails[4966896] = new thumbnail(4966896,'94861','Classic Bentley driven hard - Tour Britannia 2009','090907-52a4520tiny_thumb.jpg',130, 104,15,'							photo_4966896.html');
												thumbnails[4966897] = new thumbnail(4966897,'94861','Ford Escort twin cam sliding - Tour Britannia 2009','090907-52a4529tiny_thumb.jpg',130, 87,15,'							photo_4966897.html');
												thumbnails[1356289] = new thumbnail(1356289,'94861','Trimuph TR5 on the 2007 Motul Tour Britannia at Weston Park','at0756Thumb_thumb.jpg',130, 87,15,'							photo_1356289.html');
												thumbnails[1356292] = new thumbnail(1356292,'94861','Bristol at Weston Park on 2007 Motul Tour Britannia','at0765BristolThumb_thumb.jpg',130, 80,15,'							photo_1356292.html');
												thumbnails[1356307] = new thumbnail(1356307,'94861','Fraser Nash at speed on Motul Tour Britannia 2007','at0796FNthumb_thumb.jpg',130, 87,15,'							photo_1356307.html');
												thumbnails[1356311] = new thumbnail(1356311,'94861','Frazer Nash at speed on Motul Tour Britannia 2007','at0795FNthumb_thumb.jpg',130, 96,15,'							photo_1356311.html');
												thumbnails[1355413] = new thumbnail(1355413,'94861','Tour Britannia 1','at0420TACPthumb_thumb.jpg',130, 87,15,'							photo_1355413.html');
												thumbnails[1355452] = new thumbnail(1355452,'94861','Tour Britannia 2007 - The Long Walk','at0492TACPthmub_thumb.jpg',130, 96,15,'							photo_1355452.html');
												thumbnails[1355458] = new thumbnail(1355458,'94861','Tour Britannia 2007 Jaguar XK120','at0496TACPthumb_thumb.jpg',130, 84,15,'							photo_1355458.html');
												thumbnails[1355465] = new thumbnail(1355465,'94861','Porsche at the start of The Long Walk in Windsor on the Tour Britannia 2007','at0536TACPthumb_thumb.jpg',130, 87,15,'							photo_1355465.html');
												thumbnails[4804677] = new thumbnail(4804677,'47755','Out of the pureness of white she came.','a090915-52a5029_thumb.jpg',130, 173,15,'							photo_4804677.html');
												thumbnails[4818866] = new thumbnail(4818866,'47755','The retro Anita Debauch ','091020-3a1225tiny_thumb.jpg',130, 163,15,'							photo_4818866.html');
												thumbnails[353901] = new thumbnail(353901,'29024','Residential apartment geometry','s6406FlatsSmall_thumb.jpg',130, 92,15,'							photo_353901.html');
												thumbnails[4879740] = new thumbnail(4879740,'61278','Freshly joined hands','060506-300b5793tiny_thumb.jpg',130, 195,15,'							photo_4879740.html');
												thumbnails[5063303] = new thumbnail(5063303,'29021','The beautiful village of Cheddar....','091101-4a5200art2tiny_thumb.jpg',130, 195,15,'							photo_5063303.html');
												thumbnails[5063317] = new thumbnail(5063317,'47755','The beautiful Helen','091103-4a5241tiny_thumb.jpg',130, 195,15,'							photo_5063317.html');
												thumbnails[5016000] = new thumbnail(5016000,'47755','Jasmin Jade - Faux Country Music Star','090915-52a4902e_thumb.jpg',130, 195,15,'							photo_5016000.html');
												thumbnails[2556600] = new thumbnail(2556600,'47755','Extreme wedding','5a3385web_thumb.jpg',130, 185,15,'							photo_2556600.html');
												thumbnails[635278] = new thumbnail(635278,'28791','Old lifeboat station','a9048LifeBoatStnSmall_thumb.jpg',130, 86,15,'							photo_635278.html');
												thumbnails[635283] = new thumbnail(635283,'28791','Old pier at dusk','a9124OldPierSmall_thumb.jpg',130, 87,15,'							photo_635283.html');
												thumbnails[624360] = new thumbnail(624360,'29021','Lone tree','a5744LoneTreeSmall_thumb.jpg',130, 87,15,'							photo_624360.html');
												thumbnails[648284] = new thumbnail(648284,'48473','British Fire Engine','a5633FireEngineSmall_thumb.jpg',130, 87,15,'							photo_648284.html');
												thumbnails[624387] = new thumbnail(624387,'29022','Three reflected boats','a4025ThreeBoatsReflectedSmall_thumb.jpg',130, 87,15,'							photo_624387.html');
												thumbnails[624378] = new thumbnail(624378,'29024','Window in red','a3764BlackRedWindowSmall_thumb.jpg',130, 87,15,'							photo_624378.html');
												thumbnails[421222] = new thumbnail(421222,'29022','Old jetty','a3709JettyBoat_thumb.jpg',130, 87,15,'							photo_421222.html');
												thumbnails[624363] = new thumbnail(624363,'29024','Colourful homes','a3489QuaysideHomesSmall_thumb.jpg',130, 87,15,'							photo_624363.html');
												thumbnails[353916] = new thumbnail(353916,'28791','Sunset at Weston super Mare','s6678SunsetWsMcropSmall_thumb.jpg',130, 39,15,'							photo_353916.html');
												thumbnails[353797] = new thumbnail(353797,'29023','South Africian BMX Racer','a1476BMXracerSmall_thumb.jpg',130, 87,15,'							photo_353797.html');
												thumbnails[353804] = new thumbnail(353804,'29023','South Africian BMX racer','a1254SouthAfricanSmall_thumb.jpg',130, 87,15,'							photo_353804.html');
												thumbnails[349710] = new thumbnail(349710,'28791','Deck chairs on an English Seafront','a6571BeachChairsThumbnail_thumb.jpg',130, 77,15,'							photo_349710.html');
												thumbnails[629951] = new thumbnail(629951,'48473','Ship hatch detail','aa3146ShipHatchSmall_thumb.jpg',130, 87,15,'							photo_629951.html');
												thumbnails[4879742] = new thumbnail(4879742,'61278','Showered in confetti','060506-300b5806tiny_thumb.jpg',130, 195,15,'							photo_4879742.html');
												thumbnails[353917] = new thumbnail(353917,'29024','Red and green doors','a2857DoorsSmall_thumb.jpg',130, 87,15,'							photo_353917.html');
												thumbnails[353700] = new thumbnail(353700,'29020','Mosque of St Sofhia in Istanbul, Turkey.','a2472MosqueOfSofhiaSmall_thumb.jpg',130, 86,15,'							photo_353700.html');
												thumbnails[353711] = new thumbnail(353711,'29020','A misty day on the Bosphorus.','a2392MistyDayOnTheBosphorusSmall_thumb.jpg',130, 87,15,'							photo_353711.html');
												thumbnails[606099] = new thumbnail(606099,'28791','Steepholme behine a line of beach posts, at Weston super Mare','04-10-13WsM19beachPostsSmall_thumb.jpg',130, 54,15,'							photo_606099.html');
												thumbnails[353825] = new thumbnail(353825,'29023','Paragliding in the Italian Mountains','a0278ParaglidingSmall_thumb.jpg',130, 86,15,'							photo_353825.html');
												thumbnails[5063340] = new thumbnail(5063340,'29021','Storm clouds gather over Cheddar','091103-4a5192tiny_thumb.jpg',130, 87,15,'							photo_5063340.html');
												thumbnails[4819217] = new thumbnail(4819217,'47755','Naddy got married','c090525-52a0520_thumb.jpg',130, 195,15,'							photo_4819217.html');
												thumbnails[1889172] = new thumbnail(1889172,'47755','Dan from Ravage Raven','5a0724bWeb_thumb.jpg',130, 207,15,'							photo_1889172.html');
												thumbnails[635269] = new thumbnail(635269,'29024','Old sea front apartments','a9054OldApartmentSmall_thumb.jpg',130, 195,15,'							photo_635269.html');
												thumbnails[624350] = new thumbnail(624350,'29021','Rainbow','a8953RainbowSmall_thumb.jpg',130, 181,15,'							photo_624350.html');
												thumbnails[635292] = new thumbnail(635292,'47755','Wanderlust the Androgynous goth','a7559Wsmall_thumb.jpg',130, 195,15,'							photo_635292.html');
												thumbnails[648181] = new thumbnail(648181,'47755','Michelle','a6968MichellebwSmall_thumb.jpg',130, 195,15,'							photo_648181.html');
												thumbnails[648250] = new thumbnail(648250,'29026','Woodland toadstool','a6844ToadstoolSmall_thumb.jpg',130, 195,15,'							photo_648250.html');
												thumbnails[624367] = new thumbnail(624367,'29022','Still waters ','a3793StillHarbourSmall_thumb.jpg',130, 195,15,'							photo_624367.html');
												thumbnails[629958] = new thumbnail(629958,'29021','Old Liverpool','aa3227OldLiverpoolSmall_thumb.jpg',130, 195,15,'							photo_629958.html');
												thumbnails[349679] = new thumbnail(349679,'29024','Bright Red door ','a0936RedDoor_thumb.jpg',130, 195,15,'							photo_349679.html');
												thumbnails[606121] = new thumbnail(606121,'48473','Hanging Lobster pots ','a0378LobsterPotSmall_thumb.jpg',130, 195,15,'							photo_606121.html');
												thumbnails[349715] = new thumbnail(349715,'29026','Donkey Face','a0450DonkeyFaceSmall_thumb.jpg',130, 195,15,'							photo_349715.html');
												thumbnails[349702] = new thumbnail(349702,'29021','Gloucestershire','a0360LongBarrow_thumb.jpg',130, 195,15,'							photo_349702.html');
												thumbnails[4879749] = new thumbnail(4879749,'61278','The Wedding Car','060596-a15768tiny_thumb.jpg',130, 195,15,'							photo_4879749.html');
												thumbnails[349726] = new thumbnail(349726,'29026','Solo Sheep','a13868CroppedSheepSmall_thumb.jpg',130, 182,15,'							photo_349726.html');
												thumbnails[349721] = new thumbnail(349721,'29024','Riverside apartments','a13753AppartmentsSmall_thumb.jpg',130, 195,15,'							photo_349721.html');
												thumbnails[353927] = new thumbnail(353927,'29024','Terraced','aP0354TerraceSmall_thumb.jpg',130, 173,15,'							photo_353927.html');
												thumbnails[5016009] = new thumbnail(5016009,'29026','Effy the cat tries tree climbing','091025-d60a7816tiny_thumb.jpg',130, 87,15,'							photo_5016009.html');
												thumbnails[6785576] = new thumbnail(6785576,'47755','Gemini Rayne - Studio Set 2','100628-52b1481flkr_thumb.jpg',130, 130,15,'							photo_6785576.html');
												thumbnails[6785578] = new thumbnail(6785578,'47755','Gemini Rayne - Studio set 3','100628-52b1273-8_thumb.jpg',130, 130,15,'							photo_6785578.html');
												thumbnails[4804678] = new thumbnail(4804678,'47755','Biker Jasmin','a090915-52a4953_thumb.jpg',130, 195,15,'							photo_4804678.html');
												thumbnails[4879751] = new thumbnail(4879751,'61278','In love.','090801-52a3778tiny_thumb.jpg',130, 195,15,'							photo_4879751.html');
												thumbnails[5701716] = new thumbnail(5701716,'61278','Martin and Hannah\'s period wedding','cvccCrop5a5756-8_thumb.jpg',130, 104,15,'							photo_5701716.html');
												thumbnails[4879757] = new thumbnail(4879757,'61278','The dress','090801-52a3839tiny_thumb.jpg',130, 195,15,'							photo_4879757.html');
												thumbnails[6785452] = new thumbnail(6785452,'47755','Gemini Rayne - Studio set 1','a100628-52b1692flkr_thumb.jpg',130, 130,15,'							photo_6785452.html');
												thumbnails[6785583] = new thumbnail(6785583,'47755','Sophie - Casual','a100801-52b3632web_thumb.jpg',130, 130,15,'							photo_6785583.html');
												thumbnails[6785587] = new thumbnail(6785587,'47755','Sophie - over the shoulder','100801-7a3709flkr_thumb.jpg',130, 130,15,'							photo_6785587.html');
												thumbnails[1889183] = new thumbnail(1889183,'47755','Ravage Raven','5a0767Web_thumb.jpg',130, 125,15,'							photo_1889183.html');
												thumbnails[4879877] = new thumbnail(4879877,'61278','Speech time','060506-300a5896tiny_thumb.jpg',130, 87,15,'							photo_4879877.html');
												thumbnails[4879881] = new thumbnail(4879881,'61278','The little ones matter too.','090801-52a3848tiny_thumb.jpg',130, 87,15,'							photo_4879881.html');
												thumbnails[2556587] = new thumbnail(2556587,'47755','Dead doll in a Barn','5a4895web_thumb.jpg',130, 106,15,'							photo_2556587.html');
												thumbnails[5016003] = new thumbnail(5016003,'47755','Teen biker eyes','a090915-52a4988_thumb.jpg',130, 87,15,'							photo_5016003.html');
												thumbnails[4879890] = new thumbnail(4879890,'61278','The kiss','a090912-4a4369tiny_thumb.jpg',130, 87,15,'							photo_4879890.html');
												thumbnails[2556606] = new thumbnail(2556606,'47755','Wasted','5a3591Web_thumb.jpg',130, 90,15,'							photo_2556606.html');
												thumbnails[1889164] = new thumbnail(1889164,'47755','Ravage Raven','5a0705web2_thumb.jpg',130, 95,15,'							photo_1889164.html');
												thumbnails[648203] = new thumbnail(648203,'47755','Michelle - Albert Dock, Liverpool.','a7070Msmall_thumb.jpg',130, 87,15,'							photo_648203.html');
												thumbnails[635411] = new thumbnail(635411,'47755','Helen','a8248HLsmall_thumb.jpg',130, 87,15,'							photo_635411.html');
												thumbnails[635294] = new thumbnail(635294,'47755','Helen','a8197HLsmall_thumb.jpg',130, 87,15,'							photo_635294.html');

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  					galleries[61278] = new gallery(61278,'5701716,4879890,4879881,4879877,4879757,4879751,4879749,4879742,4879740','Weddings and ...','gallery',[4879740,4879742,4879749,4879751,5701716,4879757,4879877,4879881,4879890],0, 0, '', '																																																																																																							gallery_61278.html',0,0);
				  					galleries[47755] = new gallery(47755,'6785587,6785583,6785578,6785576,6785452,5063317,5016003,5016000,4819217,4818866','Models and characters','gallery',[4804677,4818866,5063317,5016000,2556600,4819217,1889172,635292,648181,6785576,6785578,4804678,6785452,6785583,6785587,1889183,2556587,5016003,2556606,1889164,648203,635411,635294],0, 0, '', '																																																																																																							gallery_47755.html',0,0);
				  					galleries[274827] = new gallery(274827,'4804685','MotorSport','gallery',[4804685],0, 0, '', '																																																																																																							gallery_274827.html',0,0);
				  					galleries[94861] = new gallery(94861,'1356307','Tour Britannia','gallery',[4966895,4966896,4966897,1356289,1356292,1356307,1356311,1355413,1355452,1355458,1355465],0, 0, '', '																																																																																																							gallery_94861.html',0,0);
				  					galleries[29024] = new gallery(29024,'349679','Architecture','gallery',[353901,624378,624363,353917,635269,349679,349721,353927],0, 0, '', '																																																																																																							gallery_29024.html',0,0);
				  					galleries[29021] = new gallery(29021,'5063340,5063303,629958,624360,624350,349702','England','gallery',[5063303,624360,5063340,624350,629958,349702],0, 0, '', '																																																																																																							gallery_29021.html',0,0);
				  					galleries[29022] = new gallery(29022,'624387,624367,421222','Scotland','gallery',[624387,421222,624367],0, 0, '', '																																																																																																							gallery_29022.html',0,0);
				  					galleries[29023] = new gallery(29023,'353825,353804,353797','Sports','gallery',[353797,353804,353825],0, 0, '', '																																																																																																							gallery_29023.html',0,0);
				  					galleries[48473] = new gallery(48473,'648284,629951,606121','Still life and detail','gallery',[648284,629951,606121],0, 0, '', '																																																																																																							gallery_48473.html',0,0);
				  					galleries[28791] = new gallery(28791,'635283,635278,606099,353916,349710','The English Seaside','gallery',[635278,635283,353916,349710,606099],0, 0, '', '																																																																																																							gallery_28791.html',0,0);
				  					galleries[29020] = new gallery(29020,'353711,353700','Travels','gallery',[353700,353711],0, 0, '', '																																																																																																							gallery_29020.html',0,0);
				  					galleries[29026] = new gallery(29026,'5016009,648250,349726,349715','Nature','gallery',[648250,349715,349726,5016009],0, 0, '', '																																																																																																							gallery_29026.html',0,0);
/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = new Object();
imageSets[1] = '6785587,6785583,6785578,6785576,6785452,5701716,5063340,5063317,5063303,5016009,5016003,5016000,4966897,4966896,4966895,4879890,4879881,4879877,4879757,4879751,4879749,4879742,4879740,4819217,4818866,4804685,4804678,4804677,2556606,2556600,2556587,1889183,1889172,1889164,1356311,1356307,1356292,1356289,1355465,1355458,1355452,1355413,648284,648250,648203,648181,635411,635294,635292,635283';
imageSets[2] = '4804685,1356307,349679';
imageSets[3] = '6785587,6785583,6785578,6785576,6785452,5701716,5063340,5063317,5063303,5016009,5016003,5016000,4966897,4966896,4966895,4879890,4879881,4879877,4879757,4879751,4879749,4879742,4879740,4819217,4818866,4804685,4804678,4804677,2556606,2556600,2556587,1889183,1889172,1889164,1356311,1356307,1356292,1356289,1355465,1355458,1355452,1355413,648284,648250,648203,648181,635411,635294,635292,635283';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/tacrafts/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/tacrafts/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/tacrafts/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/tacrafts/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/tacrafts/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/tacrafts/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/tacrafts/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/tacrafts/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/tacrafts/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/tacrafts/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/tacrafts/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/tacrafts/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/tacrafts/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/tacrafts/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/tacrafts/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://admin2.clikpic.com/tacrafts/images';
		break;
	}
		switch (server_id) {
		case 33:
		val = 'http://www8.clikpic.com/tacrafts/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/tacrafts/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/tacrafts/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/tacrafts/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/tacrafts/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/tacrafts/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));		}, 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 = 'TA Craft 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));    }        
    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="twlarge@hotmail.com">';
	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="twlarge@hotmail.com">';
	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;
	}
}

			

