window.thumbnails = new Object();
												thumbnails[362189] = new thumbnail(362189,'','Carron Valley dam','Carrondam_thumb.jpg',130, 87,18,'#');
												thumbnails[362225] = new thumbnail(362225,'','Bride Indoors','social1_thumb.jpg',130, 195,18,'#');
												thumbnails[362226] = new thumbnail(362226,'','Bride and Groom in car','social2_thumb.jpg',130, 87,18,'#');
												thumbnails[410242] = new thumbnail(410242,'','Central pier and Blackpool tower','webmonofinal_thumb.jpg',130, 52,18,'#');
												thumbnails[411891] = new thumbnail(411891,'','Wedding Group','webwed_thumb.jpg',130, 87,18,'#');
												thumbnails[535644] = new thumbnail(535644,'','Kyle of Toungue','NS2H5386-copy2_thumb.jpg',130, 60,18,'#');
												thumbnails[580981] = new thumbnail(580981,'','Ben Lomond','Ben Lomond-Cockburn-007_thumb.JPG',130, 54,18,'#');
												thumbnails[950605] = new thumbnail(950605,'','Commando memorial at Spean Bridge','NS2H5775_thumb.jpg',130, 87,18,'#');
												thumbnails[1614066] = new thumbnail(1614066,'','','NS2H0005_thumb.JPG',87, 130,18,'#');
												thumbnails[1665662] = new thumbnail(1665662,'','','MW9G1773_thumb.JPG',114, 130,18,'#');
												thumbnails[1665665] = new thumbnail(1665665,'','','NS2H1741_thumb.JPG',130, 87,18,'#');
												thumbnails[1841368] = new thumbnail(1841368,'','','NS2H0909final_thumb.JPG',130, 87,18,'#');
												thumbnails[1841369] = new thumbnail(1841369,'','','NS2H1950_thumb.jpg',130, 87,18,'#');
												thumbnails[1841370] = new thumbnail(1841370,'','','NS2H2735edit_thumb.JPG',130, 87,18,'#');
												thumbnails[1841373] = new thumbnail(1841373,'','','NS2H2785_thumb.jpg',87, 130,18,'#');
												thumbnails[2221508] = new thumbnail(2221508,'','','cp17_thumb.JPG',130, 87,18,'#');
												thumbnails[2221509] = new thumbnail(2221509,'','','cp18_thumb.JPG',87, 130,18,'#');
												thumbnails[2358130] = new thumbnail(2358130,'','','MW9G2284A_thumb.JPG',87, 130,18,'#');
												thumbnails[362140] = new thumbnail(362140,'109830','Egg Astra At Knockhill','BTCCAstra_thumb.jpg',130, 87,18,'photo_362140.html');
												thumbnails[362141] = new thumbnail(362141,'109830','Lotus Elise Challenge','Lotus_thumb.jpg',130, 87,18,'photo_362141.html');
												thumbnails[362182] = new thumbnail(362182,'29703','Aviemore sled dog rally','Dogsled_thumb.jpg',130, 87,18,'photo_362182.html');
												thumbnails[362184] = new thumbnail(362184,'29704','Police car and abandoned building','policecar_thumb.jpg',130, 195,18,'photo_362184.html');
												thumbnails[362199] = new thumbnail(362199,'29704','Fuel still flowing during the fuel protests','TankerBlur_thumb.jpg',130, 87,18,'photo_362199.html');
												thumbnails[362216] = new thumbnail(362216,'29704','Pylon and power station','Pylon_thumb.jpg',130, 195,18,'photo_362216.html');
												thumbnails[362284] = new thumbnail(362284,'29704','Polini MiniMoto detail','Polinipr_thumb.jpg',130, 87,18,'photo_362284.html');
												thumbnails[411902] = new thumbnail(411902,'29703','Mark Dixon of WLCC strikes another boundary.','WLCC_thumb.jpg',130, 87,18,'photo_411902.html');
												thumbnails[583532] = new thumbnail(583532,'29704','Swamp Soccer Championships','Swampsoccer_thumb.jpg',130, 87,18,'photo_583532.html');
												thumbnails[703932] = new thumbnail(703932,'109830','Paul Young','00007_thumb.jpg',130, 87,18,'photo_703932.html');
												thumbnails[703955] = new thumbnail(703955,'29703','Scottish Slalom Championships','Slalom-Champs-johncockburn-_thumb.jpg',130, 87,18,'photo_703955.html');
												thumbnails[950603] = new thumbnail(950603,'109831','Edinburgh v llanelli, Murrayfield Stadium','Edinburgh v Llanelli-10_thumb.jpg',130, 87,18,'photo_950603.html');
												thumbnails[950604] = new thumbnail(950604,'29704','M9 Chaos after lorry hits underside of bridge','M9 Accident - cockburn - 003_thumb.jpg',130, 87,18,'photo_950604.html');
												thumbnails[950607] = new thumbnail(950607,'109831','Edinburgh v Newport Gwent Dragons, Murrayfield','NS2H8010_thumb.jpg',130, 87,18,'photo_950607.html');
												thumbnails[950608] = new thumbnail(950608,'29703','British drug free power lifting championship, Grangemouth','Power lifting - cockburn - 007_thumb.jpg',130, 87,18,'photo_950608.html');
												thumbnails[950610] = new thumbnail(950610,'29704','The rise in the number of wind turbines on Orkney','Single wind turbine - 001_thumb.jpg',87, 130,18,'photo_950610.html');
												thumbnails[950625] = new thumbnail(950625,'29704','First Scottish swamp soccer championship','Swamp Soccer - john cockburn - 044_thumb.jpg',87, 130,18,'photo_950625.html');
												thumbnails[961302] = new thumbnail(961302,'109837','Phil Oakey, Human League','philoakey_thumb.jpg',102, 130,18,'photo_961302.html');
												thumbnails[961304] = new thumbnail(961304,'109837','Kevin Clark, Our Lunar Activities','kevinclark_thumb.jpg',87, 130,18,'photo_961304.html');
												thumbnails[1156275] = new thumbnail(1156275,'109830','Johnathan Rae, BSB knockhill','MW9G0118_thumb.jpg',130, 87,18,'photo_1156275.html');
												thumbnails[1156281] = new thumbnail(1156281,'109830','Chris Walker, BSB Knockhill','MW9G0125_thumb.jpg',130, 87,18,'photo_1156281.html');
												thumbnails[1385945] = new thumbnail(1385945,'109830','Seat Cupra Challenge, Knockhill','MW9G0098_thumb.JPG',130, 87,18,'photo_1385945.html');
												thumbnails[1385946] = new thumbnail(1385946,'109830','BTCC Knockhill 2007<br>\r\n<br>\r\n','MW9G0199_thumb.JPG',130, 65,18,'photo_1385946.html');
												thumbnails[1385948] = new thumbnail(1385948,'121903','','NS2H0015_thumb.JPG',105, 130,18,'photo_1385948.html');
												thumbnails[1385949] = new thumbnail(1385949,'109830','Porsche Carrera cup','NS2H0084p_thumb.JPG',130, 45,18,'photo_1385949.html');
												thumbnails[1396647] = new thumbnail(1396647,'97089','Sunday Herald','NS2H0256_thumb.JPG',130, 113,18,'photo_1396647.html');
												thumbnails[1396651] = new thumbnail(1396651,'97089','The Scotsman','NS2H0258_thumb.JPG',130, 108,18,'photo_1396651.html');
												thumbnails[1396684] = new thumbnail(1396684,'97089','Sunday Post','NS2H0259_thumb.JPG',130, 56,18,'photo_1396684.html');
												thumbnails[1396692] = new thumbnail(1396692,'97089','Linlithgow Journal and Gazette','NS2H0260_thumb.JPG',29, 130,18,'photo_1396692.html');
												thumbnails[1614396] = new thumbnail(1614396,'109837','Greg - Mach 5','MW9G9880_thumb.JPG',87, 130,18,'photo_1614396.html');
												thumbnails[1614400] = new thumbnail(1614400,'109837','Carnival Collective','NS2H9094_thumb.jpg',87, 130,18,'photo_1614400.html');
												thumbnails[1614575] = new thumbnail(1614575,'121903','','NS2H1043_thumb.JPG',123, 130,18,'photo_1614575.html');
												thumbnails[1620134] = new thumbnail(1620134,'109831','','MW9G1325_thumb.JPG',130, 87,18,'photo_1620134.html');
												thumbnails[1620135] = new thumbnail(1620135,'109831','','NS2H0943_thumb.JPG',87, 130,18,'photo_1620135.html');
												thumbnails[1620136] = new thumbnail(1620136,'109831','','NS2H1239_thumb.JPG',87, 130,18,'photo_1620136.html');
												thumbnails[1620137] = new thumbnail(1620137,'109831','','NS2H1261_thumb.JPG',87, 130,18,'photo_1620137.html');
												thumbnails[1665711] = new thumbnail(1665711,'121903','','NS2H2279_thumb.JPG',130, 87,18,'photo_1665711.html');
												thumbnails[1665731] = new thumbnail(1665731,'109831','Edinburgh v Scarlets','NS2H2380_thumb.JPG',94, 130,18,'photo_1665731.html');
												thumbnails[1665733] = new thumbnail(1665733,'109831','Edinburgh v Scarlets ','NS2H2468_thumb.JPG',130, 107,18,'photo_1665733.html');
												thumbnails[1708449] = new thumbnail(1708449,'97089','News of the World','MW9G2914_thumb.JPG',130, 87,18,'photo_1708449.html');
												thumbnails[1815111] = new thumbnail(1815111,'121903','','MW9G0013_thumb.JPG',102, 130,18,'photo_1815111.html');
												thumbnails[1815112] = new thumbnail(1815112,'121903','','MW9G0388_thumb.JPG',130, 98,18,'photo_1815112.html');
												thumbnails[1815113] = new thumbnail(1815113,'121903','','MW9G0874_thumb.JPG',113, 130,18,'photo_1815113.html');
												thumbnails[1815114] = new thumbnail(1815114,'121903','','NS2H0574_thumb.JPG',96, 130,18,'photo_1815114.html');
												thumbnails[1815115] = new thumbnail(1815115,'121903','','NS2H0695_thumb.JPG',98, 130,18,'photo_1815115.html');
												thumbnails[1815116] = new thumbnail(1815116,'121903','','NS2H2890_thumb.JPG',130, 96,18,'photo_1815116.html');
												thumbnails[2220850] = new thumbnail(2220850,'121903','','cp01_thumb.JPG',130, 86,18,'photo_2220850.html');
												thumbnails[2220851] = new thumbnail(2220851,'121903','','cp02_thumb.JPG',130, 122,18,'photo_2220851.html');
												thumbnails[2220852] = new thumbnail(2220852,'121903','','cp03_thumb.JPG',130, 100,18,'photo_2220852.html');
												thumbnails[2220853] = new thumbnail(2220853,'121903','','cp04_thumb.JPG',110, 130,18,'photo_2220853.html');
												thumbnails[2220854] = new thumbnail(2220854,'121903','','cp05_thumb.JPG',130, 103,18,'photo_2220854.html');
												thumbnails[2220855] = new thumbnail(2220855,'121903','','cp06_thumb.JPG',119, 130,18,'photo_2220855.html');
												thumbnails[2220886] = new thumbnail(2220886,'109831','','cp12_thumb.JPG',130, 92,18,'photo_2220886.html');
												thumbnails[2220887] = new thumbnail(2220887,'109831','','cp13_thumb.JPG',102, 130,18,'photo_2220887.html');
												thumbnails[2220888] = new thumbnail(2220888,'109831','','cp14_thumb.JPG',117, 130,18,'photo_2220888.html');
												thumbnails[2220889] = new thumbnail(2220889,'109831','','cp15_thumb.JPG',130, 83,18,'photo_2220889.html');
												thumbnails[2220891] = new thumbnail(2220891,'109831','','cp16_thumb.JPG',130, 82,18,'photo_2220891.html');
												thumbnails[2358163] = new thumbnail(2358163,'29703','','Flip1a_thumb.JPG',130, 87,18,'photo_2358163.html');
												thumbnails[2358167] = new thumbnail(2358167,'29703','','Flip2a_thumb.JPG',130, 87,18,'photo_2358167.html');
												thumbnails[2358168] = new thumbnail(2358168,'29703','','MW9G1399_thumb.JPG',130, 125,18,'photo_2358168.html');
												thumbnails[2358169] = new thumbnail(2358169,'29703','','MW9G1988_thumb.JPG',102, 130,18,'photo_2358169.html');
												thumbnails[2416861] = new thumbnail(2416861,'97089','The People','NS2H3075_thumb.JPG',130, 119,18,'photo_2416861.html');
												thumbnails[2607714] = new thumbnail(2607714,'97089','','_MG_0272_thumb.JPG',103, 130,18,'photo_2607714.html');
												thumbnails[2607716] = new thumbnail(2607716,'97089','','_MG_0273_thumb.JPG',130, 76,18,'photo_2607716.html');
												thumbnails[2633174] = new thumbnail(2633174,'109830','','BTCCuniversalJC04_thumb.JPG',130, 83,18,'photo_2633174.html');
												thumbnails[2633175] = new thumbnail(2633175,'109830','','BTCCuniversalJC07_thumb.JPG',130, 114,18,'photo_2633175.html');
												thumbnails[2633177] = new thumbnail(2633177,'109830','','BTCCuniversalJC09_thumb.JPG',130, 94,18,'photo_2633177.html');
												thumbnails[2633179] = new thumbnail(2633179,'109830','','MW9G2883_thumb.JPG',130, 94,18,'photo_2633179.html');
												thumbnails[2633180] = new thumbnail(2633180,'109830','','NS2H3768_thumb.JPG',130, 72,18,'photo_2633180.html');
												thumbnails[2633181] = new thumbnail(2633181,'109830','','NS2H3813_thumb.JPG',130, 71,18,'photo_2633181.html');
												thumbnails[3043363] = new thumbnail(3043363,'121903','','17_thumb.JPG',130, 96,18,'photo_3043363.html');
												thumbnails[3236692] = new thumbnail(3236692,'97089','','Picture 1A_thumb.JPG',130, 113,18,'photo_3236692.html');
												thumbnails[4051551] = new thumbnail(4051551,'29703','Aviemore Sled Dog Rally','aviemoredogsuniversalJC02_thumb.JPG',85, 130,18,'photo_4051551.html');
												thumbnails[4051602] = new thumbnail(4051602,'109831','Emirates Airline Edinburgh Sevens','Emirates1_thumb.jpg',130, 112,18,'photo_4051602.html');
												thumbnails[4051605] = new thumbnail(4051605,'29703','Lochstock, Townhill','lochstockl06_thumb.JPG',93, 130,18,'photo_4051605.html');
												thumbnails[4051608] = new thumbnail(4051608,'121903','','motherwellcupuniversalJC12_thumb.JPG',120, 130,18,'photo_4051608.html');
												thumbnails[3155095] = new thumbnail(3155095,'150543','Fall colors in the woods.','Muiravonside01_thumb.JPG',130, 87,18,'photo_3155095.html');
												thumbnails[3155108] = new thumbnail(3155108,'150543','Fall colors in the woods.','Muiravonside02_thumb.JPG',130, 87,18,'photo_3155108.html');
												thumbnails[3155336] = new thumbnail(3155336,'150545','Rock distorted under rippled water','Distorted Rock_thumb.JPG',130, 87,18,'photo_3155336.html');
												thumbnails[3155344] = new thumbnail(3155344,'193361','Narrow streets in Stromness','Narrow street_thumb.JPG',87, 130,18,'photo_3155344.html');

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  					galleries[193361] = new gallery(193361,'3155344','Town & City','section192670',[3155344],0, 0, '', 'section192670_193361.html',0,0);
				  					galleries[29703] = new gallery(29703,'4051605,4051551,2358169,2358168,2358167,2358163,950608,703955,411902,362182','General Sport','gallery',[362182,411902,703955,950608,2358163,2358167,2358168,2358169,4051551,4051605],0, 0, '', 'gallery_29703.html',0,0);
				  					galleries[150543] = new gallery(150543,'3155108,3155095','Landscape','section192670',[3155095,3155108],0, 0, '', 'section192670_150543.html',0,0);
				  					galleries[109830] = new gallery(109830,'2633181,2633180,2633179,2633177,2633175,2633174,1385949,1385946,1385945,1156281','Motor Sport','gallery',[362140,362141,703932,1156275,1156281,1385945,1385946,1385949,2633174,2633175,2633177,2633179,2633180,2633181],0, 0, '', 'gallery_109830.html',0,0);
				  					galleries[121903] = new gallery(121903,'4051608,3043363,2220855,2220854,2220853,2220852,2220851,2220850,1815116,1815115','Football','gallery',[1385948,1614575,1665711,1815111,1815112,1815113,1815114,1815115,1815116,2220850,2220851,2220852,2220853,2220854,2220855,3043363,4051608],0, 0, '', 'gallery_121903.html',0,0);
				  					galleries[109831] = new gallery(109831,'950603','Rugby','gallery',[950603,950607,1620134,1620135,1620136,1620137,1665731,1665733,2220886,2220887,2220888,2220889,2220891,4051602],0, 0, '', 'gallery_109831.html',0,0);
				  					galleries[150545] = new gallery(150545,'3155336','Abstract','section192670',[3155336],0, 0, '', 'section192670_150545.html',0,0);
				  					galleries[29704] = new gallery(29704,'950625,950610,950604,583532,362284,362216,362199,362184','Press and PR','gallery',[362184,362199,362216,362284,583532,950604,950610,950625],0, 0, '', 'gallery_29704.html',0,0);
				  					galleries[109837] = new gallery(109837,'1614400,1614396,961304,961302','Music','gallery',[961302,961304,1614396,1614400],0, 0, '', 'gallery_109837.html',0,0);
				  					galleries[97089] = new gallery(97089,'3236692,2607716,2607714,2416861,1708449,1396692,1396684,1396651,1396647','Tear Sheets','gallery',[1396647,1396651,1396684,1396692,1708449,2416861,2607714,2607716,3236692],0, 0, '', 'gallery_97089.html',0,0);
/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = new Object();
imageSets[1] = '3043363,2633177,2358167,2220886,2220850,1815112,1665733,1385945,950607';
imageSets[2] = '950603,411891,410242';
imageSets[3] = '4051608,4051605,4051602,4051551,3236692,3155344,3155336,3155108,3155095,3043363,2633181,2633180,2633179,2633177,2633175,2633174,2607716,2607714,2416861,2358169,2358168,2358167,2358163,2358130,2221509,2221508,2220891,2220889,2220888,2220887,2220886,2220855,2220854,2220853,2220852,2220851,2220850,1841373,1841370,1841369,1841368,1815116,1815115,1815114,1815113,1815112,1815111,1708449,1665733,1665731';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/johncockburn/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/johncockburn/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/johncockburn/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/johncockburn/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/johncockburn/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/johncockburn/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/johncockburn/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/johncockburn/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/johncockburn/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/johncockburn/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/johncockburn/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/johncockburn/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/johncockburn/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/johncockburn/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/johncockburn/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://admin2.clikpic.com/johncockburn/images';
		break;
	}
		switch (server_id) {
		case 33:
		val = 'http://www8.clikpic.com/johncockburn/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/johncockburn/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/johncockburn/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/johncockburn/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/johncockburn/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/johncockburn/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 = 'John Cockburn 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>John Cockburn </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> &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="john.cockburn@blueyonder.co.uk">';
	temp = temp + '<input type="hidden" name="currency_code" value="GBP">';
	temp = temp + '<input type="hidden" name="add" value="1">';
					temp = temp + '<input type="hidden" name="amount" value="'+amount+'">';
	temp = temp + '<input type="hidden" name="item_number" value="'+ref+'">';
					temp = temp + '<input type=\"Submit\" value=\"Add to cart\" id=\"paymentAddButton\" class=\"button\" onmouseover=\"this.className=\'buttonHi\';\" onmouseout=\"this.className=\'button\';\">';
									temp = temp + '</form>';
								temp = temp + '<form id="paymentCartForm" style="margin:0px;" name="paymentCartForm" target="_blank" action="https://www.paypal.com/cgi-bin/webscr" method="post">';
	temp = temp + '<input type="hidden" name="cmd" value="_cart">';
	temp = temp + '<input type="hidden" name="business" value="john.cockburn@blueyonder.co.uk">';
	temp = temp + '<input type="hidden" name="display" value="1">';
	temp = temp + '<input type=\"Submit\" value=\"View cart\" id=\"paymentViewButton\" class=\"button\" onmouseover=\"this.className=\'buttonHi\';\" onmouseout=\"this.className=\'button\';\">';
	temp = temp + '</form>';
							temp = temp + '<div class="clearing">&nbsp;</div>';
	}
	return temp;};

/***************************************************************************
* Pick a photo at random from the featured images of a gallery.            *
* Gallery_id = id of gallery to choose,                                    *
* img = reference to html image in                                         *
* which to show image                                                      *
***************************************************************************/
function showGalleryImage(gallery_id, img, updateLink) {
		
	if(img){
	      if (location.hash.match('galleries_id=' + gallery_id) && (imageID = location.hash.match('.*photos_id=(.+)$'))) {
        imageID = imageID[1];
      } else {
			  imageID = randomListVal(galleries[gallery_id].featured_images);
      }
							
			if (imageID != 0) {
				img.src = thumbnails[imageID].src;
				img.width = thumbnails[imageID].width;
				img.height = thumbnails[imageID].height;
				img.alt = galleries[gallery_id].title;
        if (updateLink) {
          $(img).parent().attr({            href: thumbnails[imageID].fnGalleryLink(gallery_id),            title: galleries[gallery_id].title          });
        }
							}
										}
}

/***************************************************************************
* If we have dynamic HTML, replace the galleries link with a list that     *
* doesn't include thecurrent gallery                                       *
***************************************************************************/
function showGalleries(gallery_id) {
		
	
	if (!basic) {
		temp = '';
		for (i = 0; i < galleries.length; i++) {
						
			
			if (galleries[i].id != gallery_id) {
								
				if (temp != '') {
					temp = temp + ' | ';
				}
				temp = temp + '<a href="' + galleries[i].section_code + '_' + galleries[i].id + '.html">' + galleries[i].title + '</a>';
			}
		}
		document.all.galleryLinks.innerHTML = 'Other galleries: ' + temp;
	}
}

			

