window.thumbnails = new Object();
												thumbnails[5775387] = new thumbnail(5775387,'327132','Me at the RSA with my award','meee_thumb.gif',130, 195,15,'photo_5775387.html');
												thumbnails[5775390] = new thumbnail(5775390,'327132','The RSA show','RSA_thumb.gif',130, 87,15,'photo_5775390.html');
												thumbnails[5775396] = new thumbnail(5775396,'327132','RSA New Contemporaries 2010','rsa2_thumb.gif',130, 87,15,'photo_5775396.html');
												thumbnails[3702116] = new thumbnail(3702116,'222265','','2peepds_thumb.gif',130, 132,15,'photo_3702116.html');
												thumbnails[3726903] = new thumbnail(3726903,'226013','Jessops take 2','jessopsREPLYTOWRONGEMAIL1_thumb.jpg',130, 184,15,'photo_3726903.html');
												thumbnails[3701852] = new thumbnail(3701852,'226175','Palmers Cocoa Butter Formula','IMG_0001_thumb.jpg',130, 184,15,'photo_3701852.html');
												thumbnails[3709315] = new thumbnail(3709315,'226175','Jessops','JessopsWRONG_thumb.jpg',130, 184,15,'photo_3709315.html');
												thumbnails[3727802] = new thumbnail(3727802,'226175','Cauldron ','Cauldron_thumb.jpg',130, 184,15,'photo_3727802.html');
												thumbnails[3701988] = new thumbnail(3701988,'226013','Jessops','jessops_thumb.jpg',130, 184,15,'photo_3701988.html');
												thumbnails[3709299] = new thumbnail(3709299,'226013','Blue Tack','bluetack1_thumb.jpg',130, 184,15,'photo_3709299.html');
												thumbnails[3727566] = new thumbnail(3727566,'226013','Aroma Home','aromahome_thumb.jpg',130, 184,15,'photo_3727566.html');
												thumbnails[3701803] = new thumbnail(3701803,'226175','Clarins','Clarins_thumb.jpg',130, 184,15,'photo_3701803.html');
												thumbnails[3726946] = new thumbnail(3726946,'226013','Australian Coasters','australiancoasters_thumb.jpg',130, 184,15,'photo_3726946.html');
												thumbnails[3728114] = new thumbnail(3728114,'226013','Stencil books','stencilbooks_thumb.jpg',130, 184,15,'photo_3728114.html');
												thumbnails[3733618] = new thumbnail(3733618,'226013','Crayola','crayola_thumb.jpg',130, 184,15,'photo_3733618.html');
												thumbnails[3701882] = new thumbnail(3701882,'226013','Citroen','Citroen_thumb.jpg',130, 184,15,'photo_3701882.html');
												thumbnails[3701380] = new thumbnail(3701380,'226013','Glasgow City Council - Refuse Collection','Binmen_thumb.jpg',130, 184,15,'photo_3701380.html');
												thumbnails[3733602] = new thumbnail(3733602,'226013','Thorntons','_thorntons2_thumb.jpg',130, 184,15,'photo_3733602.html');
												thumbnails[3701828] = new thumbnail(3701828,'226175','Staedtler','Staedler_thumb.jpg',130, 184,15,'photo_3701828.html');
												thumbnails[3640394] = new thumbnail(3640394,'226175','Cadbury\'s','CAdbury_thumb.jpg',130, 184,15,'photo_3640394.html');
												thumbnails[3640391] = new thumbnail(3640391,'226175','PZ Cussons (Carex)','Carex_thumb.jpg',130, 184,15,'photo_3640391.html');
												thumbnails[3709322] = new thumbnail(3709322,'226013','Cadbury\'s','cadburys_thumb.jpg',130, 184,15,'photo_3709322.html');
												thumbnails[3726940] = new thumbnail(3726940,'226013','Bic Pens','bicpens_thumb.jpg',130, 184,15,'photo_3726940.html');
												thumbnails[3701766] = new thumbnail(3701766,'226013','Strathclyde Partnership for Transport','SPT_thumb.jpg',130, 184,15,'photo_3701766.html');
												thumbnails[3701771] = new thumbnail(3701771,'226013','Maped','paperpaperclips_thumb.jpg',130, 180,15,'photo_3701771.html');
												thumbnails[3701774] = new thumbnail(3701774,'226013','Carex','Carex1_thumb.jpg',130, 184,15,'photo_3701774.html');
												thumbnails[3726758] = new thumbnail(3726758,'226013','Dry Shampoo','batistedryshampoo1_thumb.jpg',130, 184,15,'photo_3726758.html');
												thumbnails[3701799] = new thumbnail(3701799,'226175','Pilot','Pilot_thumb.jpg',130, 184,15,'photo_3701799.html');
												thumbnails[3701374] = new thumbnail(3701374,'226013','Beechams','Beechamsveno_thumb.jpg',130, 184,15,'photo_3701374.html');
												thumbnails[3701763] = new thumbnail(3701763,'226013','Marlboro Lights','marlboro_thumb.jpg',130, 184,15,'photo_3701763.html');
												thumbnails[3701391] = new thumbnail(3701391,'226013','The Body Shop','BodyShop_thumb.jpg',130, 184,15,'photo_3701391.html');
												thumbnails[3727950] = new thumbnail(3727950,'226013','WH Smith','whsmith1_thumb.jpg',130, 184,15,'photo_3727950.html');
												thumbnails[3702136] = new thumbnail(3702136,'226211','Silver Spoon Sugar','biggranulatededitedssf_thumb.gif',130, 87,15,'photo_3702136.html');
												thumbnails[3636575] = new thumbnail(3636575,'222265','Gus','GUS1_thumb.gif',130, 79,15,'photo_3636575.html');
												thumbnails[3636534] = new thumbnail(3636534,'222265','Gratuity Appreciated','webtest1_thumb.jpg',130, 95,15,'photo_3636534.html');
												thumbnails[3642461] = new thumbnail(3642461,'222519','','Burtons_50p_thumb.jpg',130, 70,15,'photo_3642461.html');
												thumbnails[3642468] = new thumbnail(3642468,'222519','','Glaxosmithkline_thumb.jpg',130, 85,15,'photo_3642468.html');
												thumbnails[3642506] = new thumbnail(3642506,'222519','','Kelloggs_thumb.jpg',130, 74,15,'photo_3642506.html');
												thumbnails[3701790] = new thumbnail(3701790,'226175','Strathclyde Partnership for Transport','SPT1_thumb.jpg',130, 184,15,'photo_3701790.html');
												thumbnails[3701833] = new thumbnail(3701833,'226175','Bostik','BOstik_thumb.jpg',130, 184,15,'photo_3701833.html');
												thumbnails[3701905] = new thumbnail(3701905,'222519','','danone_thumb.jpg',130, 97,15,'photo_3701905.html');
												thumbnails[3701909] = new thumbnail(3701909,'226189','Staedtler','test3_thumb.gif',130, 73,15,'photo_3701909.html');
												thumbnails[3727578] = new thumbnail(3727578,'226175','WH Smith','WHSMITH_thumb.jpg',130, 184,15,'photo_3727578.html');
												thumbnails[3728123] = new thumbnail(3728123,'226175','McDonalds','McDonalds_thumb.jpg',130, 184,15,'photo_3728123.html');
												thumbnails[3728131] = new thumbnail(3728131,'226175','Tolberone','TOlberone_thumb.jpg',130, 184,15,'photo_3728131.html');
												thumbnails[3774530] = new thumbnail(3774530,'222265','','Photo08_5_thumb.gif',130, 87,15,'photo_3774530.html');
												thumbnails[4028951] = new thumbnail(4028951,'222265','Val','valsmaller_thumb.gif',130, 97,15,'photo_4028951.html');
												thumbnails[4028966] = new thumbnail(4028966,'222265','Trifles','trifle_thumb.gif',130, 87,15,'photo_4028966.html');
												thumbnails[4028976] = new thumbnail(4028976,'222265','','sheep_thumb.gif',130, 93,15,'photo_4028976.html');
												thumbnails[4028986] = new thumbnail(4028986,'222265','','Photo13_10_thumb.gif',130, 87,15,'photo_4028986.html');
												thumbnails[4028997] = new thumbnail(4028997,'222265','','Photo18_15_thumb.gif',130, 87,15,'photo_4028997.html');
												thumbnails[4029006] = new thumbnail(4029006,'222265','','toilets_thumb.gif',130, 87,15,'photo_4029006.html');
												thumbnails[4029053] = new thumbnail(4029053,'222265','Rosie','rosie_thumb.gif',130, 61,15,'photo_4029053.html');
												thumbnails[4029113] = new thumbnail(4029113,'222265','Philip','philip_thumb.gif',130, 87,15,'photo_4029113.html');
												thumbnails[4029170] = new thumbnail(4029170,'222265','Ellie','ellielong_thumb.gif',130, 58,15,'photo_4029170.html');
												thumbnails[4029202] = new thumbnail(4029202,'226211','Seven Seas Cod Liver Oil','take2_thumb.gif',130, 83,15,'photo_4029202.html');
												thumbnails[4029430] = new thumbnail(4029430,'226211','Strathclyde Partnership for Transport Badge','subwaybadge_thumb.gif',130, 87,15,'photo_4029430.html');
												thumbnails[4029439] = new thumbnail(4029439,'226211','Staedtler pencils ','staedlerpackewgitet_thumb.gif',130, 87,15,'photo_4029439.html');
												thumbnails[4029513] = new thumbnail(4029513,'222266','Rigor Mortis Horse','rigormortisaaa_thumb.gif',130, 92,15,'photo_4029513.html');
												thumbnails[4029783] = new thumbnail(4029783,'222266','Disappointed chicken','chickebnn_thumb.gif',130, 92,15,'photo_4029783.html');
												thumbnails[4029914] = new thumbnail(4029914,'243057','Envelopes envelopes everywhere!','envelopes_thumb.gif',130, 184,15,'photo_4029914.html');
												thumbnails[4030733] = new thumbnail(4030733,'222266','Considerate Goat','considerategoat_thumb.gif',130, 89,15,'photo_4030733.html');
												thumbnails[4030735] = new thumbnail(4030735,'222266','Perturbed cow','perturbed-cow_thumb.gif',130, 92,15,'photo_4030735.html');
												thumbnails[4030737] = new thumbnail(4030737,'222266','Pensive Duck','pensveducksingle_thumb.gif',130, 92,15,'photo_4030737.html');
												thumbnails[4030741] = new thumbnail(4030741,'222265','Des','destake2_thumb.gif',130, 86,15,'photo_4030741.html');
												thumbnails[4030749] = new thumbnail(4030749,'222265','Dry Paint','DRYPAINTPOSTCARD3_thumb.gif',130, 92,15,'photo_4030749.html');
												thumbnails[4030826] = new thumbnail(4030826,'243057','','moose_thumb.gif',130, 83,15,'photo_4030826.html');
												thumbnails[4034761] = new thumbnail(4034761,'243057','All of the envelope windows from the project','smaller_thumb.gif',130, 184,15,'photo_4034761.html');
												thumbnails[4034766] = new thumbnail(4034766,'226211','Bostik Badge ','Businesscard_thumb.gif',130, 86,15,'photo_4034766.html');
												thumbnails[4035650] = new thumbnail(4035650,'226211','DKNY Umbrella','umbrellanocase_thumb.gif',130, 70,15,'photo_4035650.html');
												thumbnails[4155325] = new thumbnail(4155325,'248090','','DSC_0923_thumb.gif',130, 86,15,'photo_4155325.html');
												thumbnails[4155327] = new thumbnail(4155327,'248090','','DSC_0920_thumb.gif',130, 86,15,'photo_4155327.html');
												thumbnails[4155407] = new thumbnail(4155407,'248090','','DSC_0919a_thumb.gif',130, 86,15,'photo_4155407.html');
												thumbnails[4155409] = new thumbnail(4155409,'248090','','DSC_0914a_thumb.gif',130, 86,15,'photo_4155409.html');
												thumbnails[4155411] = new thumbnail(4155411,'248090','','DSC_0909_thumb.gif',130, 86,15,'photo_4155411.html');
												thumbnails[4155439] = new thumbnail(4155439,'243057','Installing the exhibition was a challenge...','P1040812b_thumb.gif',130, 195,15,'photo_4155439.html');
												thumbnails[4155443] = new thumbnail(4155443,'243057','The string...','P1040825_thumb.gif',130, 87,15,'photo_4155443.html');
												thumbnails[4155444] = new thumbnail(4155444,'243057','8 calories','8-calories_thumb.gif',130, 130,15,'photo_4155444.html');
												thumbnails[4155445] = new thumbnail(4155445,'243057','','fact_thumb.gif',130, 59,15,'photo_4155445.html');
												thumbnails[4155450] = new thumbnail(4155450,'243057','','tally_thumb.gif',130, 139,15,'photo_4155450.html');
												thumbnails[4155452] = new thumbnail(4155452,'243057','Postman stalking','postman-stalking2_thumb.gif',130, 80,15,'photo_4155452.html');
												thumbnails[4222926] = new thumbnail(4222926,'248090','','P1050266_thumb.gif',130, 87,15,'photo_4222926.html');
												thumbnails[4222928] = new thumbnail(4222928,'248090','','P1050267_thumb.gif',130, 87,15,'photo_4222928.html');
												thumbnails[5408235] = new thumbnail(5408235,'248090','Section from comment book','IMG_0020_thumb.gif',130, 101,15,'photo_5408235.html');
												thumbnails[5408244] = new thumbnail(5408244,'248090','Comments ','IMG_0003_thumb.gif',130, 101,15,'photo_5408244.html');
												thumbnails[5408257] = new thumbnail(5408257,'226175','Letter received from the Queen','queen_thumb.gif',130, 184,15,'photo_5408257.html');
												thumbnails[6256734] = new thumbnail(6256734,'222265','','knees_thumb.gif',130, 98,15,'photo_6256734.html');
												thumbnails[6256787] = new thumbnail(6256787,'222265','','santa-van_thumb.gif',130, 87,15,'photo_6256787.html');
												thumbnails[6256789] = new thumbnail(6256789,'222265','','elliestitch_thumb.gif',130, 98,15,'photo_6256789.html');
												thumbnails[6256813] = new thumbnail(6256813,'222265','','Dog_thumb.gif',130, 87,15,'photo_6256813.html');
												thumbnails[6256861] = new thumbnail(6256861,'222265','','camel_thumb.gif',130, 87,15,'photo_6256861.html');
												thumbnails[6256913] = new thumbnail(6256913,'222265','','BRUISEA3_thumb.gif',130, 92,15,'photo_6256913.html');
												thumbnails[6797508] = new thumbnail(6797508,'226013','DKNY','dkny_thumb.gif',130, 184,15,'photo_6797508.html');
												thumbnails[6797580] = new thumbnail(6797580,'226013','Jamie Oliver','jamieoliver_thumb.gif',130, 184,15,'photo_6797580.html');
												thumbnails[7565787] = new thumbnail(7565787,'222265','','P1020078_thumb.gif',130, 87,15,'photo_7565787.html');

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  					galleries[243057] = new gallery(243057,'4155444,4029914','All the things in between','gallery',[4029914,4030826,4034761,4155439,4155443,4155444,4155445,4155450,4155452],0, 0, '226182', 'gallery_243057.html',0,0);
				  					galleries[248090] = new gallery(248090,'4222928,4222926,4155411,4155409,4155407,4155327,4155325','Exhibition images','gallery',[4155325,4155327,4155407,4155409,4155411,4222926,4222928,5408235,5408244],0, 0, '226182', 'gallery_248090.html',0,0);
				  					galleries[226175] = new gallery(226175,'5408257,3728131,3728123,3727802,3727578,3709315,3701852,3701833,3701828,3701803','Letters Received','gallery',[3701852,3709315,3727802,3701803,3701828,3640394,3640391,3701799,3701790,3701833,3727578,3728123,3728131,5408257],0, 0, '226182', 'gallery_226175.html',0,0);
				  					galleries[226013] = new gallery(226013,'6797580,6797508,3733618,3733602,3728114,3727950,3727566,3726946,3726940,3726903','Letters sent','gallery',[3726903,3701988,3709299,3727566,3726946,3728114,3733618,3701882,3701380,3733602,3709322,3726940,3701766,3701771,3701774,3726758,3701374,3701763,3701391,3727950,6797508,6797580],0, 0, '226182', 'gallery_226013.html',0,0);
				  					galleries[226211] = new gallery(226211,'4035650,3702136','Products Received','gallery',[3702136,4029202,4029430,4029439,4034766,4035650],0, 0, '226182', 'gallery_226211.html',0,0);
				  					galleries[226189] = new gallery(226189,'3701909','Responses to products sent','gallery',[3701909],0, 0, '226182', 'gallery_226189.html',0,0);
				  					galleries[226182] = new gallery(226182,'5775396,5775390,5775387,4222928,4222926,4155444,4155411,4155409,4155407,4155327,4155325,4035650,4029914,3702136','The \'Big Thank You\' Project','gallery',[],0, 0, '', 'gallery_226182.html',0,0);
				  					galleries[327132] = new gallery(327132,'5775396,5775390,5775387','The Royal Scottish Academy New Contemporaries','gallery',[5775387,5775390,5775396],0, 0, '226182', 'gallery_327132.html',0,0);
				  					galleries[222519] = new gallery(222519,'3701905,3642506,3642468,3642461','The Vouchers','gallery',[3642461,3642468,3642506,3701905],0, 0, '226182', 'gallery_222519.html',0,0);
				  					galleries[222265] = new gallery(222265,'6256913,6256813,6256789,6256787,6256734,4030749,4030741','A selection of Photographs','gallery',[3702116,3636575,3636534,3774530,4028951,4028966,4028976,4028986,4028997,4029006,4029053,4029113,4029170,4030741,4030749,6256734,6256787,6256789,6256813,6256861,6256913,7565787],0, 0, '', 'gallery_222265.html',0,0);
				  					galleries[222266] = new gallery(222266,'4030737,4030735,4030733','Drawings','gallery',[4029513,4029783,4030733,4030735,4030737],0, 0, '', 'gallery_222266.html',0,0);
/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = new Object();
imageSets[1] = '7565787,6256913,6256813,6256789,6256787,6256734,4155411,4155409,4155407,4155327,4155325,4030749,4030741,4029113,4029053,4028997,4028986,4028976,4028966,4028951,3702136,3702116,3636575,3636534';
imageSets[2] = '6256913,6256813,6256789,6256787,6256734,5775396,5775390,5775387,4222928,4222926,4155444,4155411,4155409,4155407,4155327,4155325,4035650,4030749,4030741,4030737,4030735,4030733,4029914,3702136';
imageSets[3] = '7565787,6797580,6797508,6256913,6256861,6256813,6256789,6256787,6256734,5775396,5775390,5775387,5408257,5408244,5408235,4222928,4222926,4155452,4155450,4155445,4155444,4155443,4155439,4155411,4155409,4155407,4155327,4155325,4035650,4034766,4034761,4030826,4030749,4030741,4030737,4030735,4030733,4029914,4029783,4029513,4029439,4029430,4029202,4029170,4029113,4029053,4029006,4028997,4028986,4028976';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/HarrietLowther/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/HarrietLowther/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/HarrietLowther/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/HarrietLowther/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/HarrietLowther/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/HarrietLowther/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/HarrietLowther/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/HarrietLowther/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/HarrietLowther/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/HarrietLowther/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/HarrietLowther/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/HarrietLowther/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/HarrietLowther/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/HarrietLowther/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/HarrietLowther/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://admin2.clikpic.com/HarrietLowther/images';
		break;
	}
		switch (server_id) {
		case 33:
		val = 'http://www8.clikpic.com/HarrietLowther/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/HarrietLowther/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/HarrietLowther/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/HarrietLowther/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/HarrietLowther/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/HarrietLowther/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 = 'HarrietLowther: ' + 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;
	}
}

			

