window.thumbnails = new Object();
												thumbnails[678268] = new thumbnail(678268,'9378','Mummy Short Arms','music_0011_thumb.jpg',130, 211,1,'photo_678268.html');
												thumbnails[678280] = new thumbnail(678280,'9378','Amongst The Arrows','music_004_thumb.jpg',130, 86,1,'photo_678280.html');
												thumbnails[678284] = new thumbnail(678284,'51844','1950 D.A.','music_005_thumb.jpg',130, 86,1,'photo_678284.html');
												thumbnails[678302] = new thumbnail(678302,'9378','Chime Recording Session 2006','music_011_thumb.jpg',130, 86,1,'photo_678302.html');
												thumbnails[678322] = new thumbnail(678322,'9378','1950 D.A.','music_015_thumb.jpg',130, 86,1,'photo_678322.html');
												thumbnails[678324] = new thumbnail(678324,'9378','1950 D.A.','music_016_thumb.jpg',130, 86,1,'photo_678324.html');
												thumbnails[678327] = new thumbnail(678327,'51844','Sucioperro','music_017_thumb.jpg',130, 86,1,'photo_678327.html');
												thumbnails[678331] = new thumbnail(678331,'51844','Big Burd','music_018_thumb.jpg',130, 86,1,'photo_678331.html');
												thumbnails[678340] = new thumbnail(678340,'9378','Genepool','music_020_thumb.jpg',130, 86,1,'photo_678340.html');
												thumbnails[678346] = new thumbnail(678346,'9378','The Ansion','music_022_thumb.jpg',130, 86,1,'photo_678346.html');
												thumbnails[678358] = new thumbnail(678358,'9378','The Ansion','music_023_thumb.jpg',130, 86,1,'photo_678358.html');
												thumbnails[678743] = new thumbnail(678743,'9378','Mummy Short Arms','music_026_thumb.jpg',130, 195,1,'photo_678743.html');
												thumbnails[681083] = new thumbnail(681083,'9378','This Familiar Smile','music_036_thumb.jpg',130, 195,1,'photo_681083.html');
												thumbnails[681089] = new thumbnail(681089,'9378','My Final Wish','Low Wattage_220705015_thumb.jpg',130, 195,1,'photo_681089.html');
												thumbnails[681105] = new thumbnail(681105,'9378','...And You Will Know Us By The Trail Of Dead','TOD14_thumb.jpg',130, 86,1,'photo_681105.html');
												thumbnails[681139] = new thumbnail(681139,'405638','B.Y.T','byt_thumb.jpg',130, 196,1,'photo_681139.html');
												thumbnails[681187] = new thumbnail(681187,'52105','Lactose Fermenting on a Blood Agar Plate','bacteriology plate1_thumb.jpg',130, 130,1,'photo_681187.html');
												thumbnails[681215] = new thumbnail(681215,'52105','Blackpool 2006','bpool 086_thumb.jpg',130, 130,1,'photo_681215.html');
												thumbnails[681219] = new thumbnail(681219,'405618','Defensive Position I','def_posI_thumb.jpg',130, 130,1,'photo_681219.html');
												thumbnails[681221] = new thumbnail(681221,'405618','Defensive Position II','def_posII_thumb.jpg',130, 109,1,'photo_681221.html');
												thumbnails[681233] = new thumbnail(681233,'405618','Defensive Position III','def_posIII_thumb.jpg',130, 130,1,'photo_681233.html');
												thumbnails[681234] = new thumbnail(681234,'405618','Shiny Beast','Shiny Beast_thumb.jpg',130, 97,1,'photo_681234.html');
												thumbnails[681236] = new thumbnail(681236,'52105','Slugs and Snails...','2006-06-17001_thumb.jpg',130, 94,1,'photo_681236.html');
												thumbnails[681237] = new thumbnail(681237,'51844','Chloe','Chloe026_thumb.jpg',130, 86,1,'photo_681237.html');
												thumbnails[704086] = new thumbnail(704086,'9378','Arab Strap','Arab Strap 5_thumb.jpg',130, 86,1,'photo_704086.html');
												thumbnails[704087] = new thumbnail(704087,'9378','Sucioperro','dragon_thumb.jpg',130, 85,1,'photo_704087.html');
												thumbnails[704089] = new thumbnail(704089,'9378','Tempercalm','Low Wattage_190805k_thumb.jpg',130, 245,1,'photo_704089.html');
												thumbnails[704092] = new thumbnail(704092,'405618','Fly On The Wall','fly 1_thumb.jpg',130, 86,1,'photo_704092.html');
												thumbnails[710740] = new thumbnail(710740,'9378','Genepool','genepool1_thumb.jpg',130, 87,1,'photo_710740.html');
												thumbnails[748600] = new thumbnail(748600,'51844','The Ansion','Ansion_01_thumb.jpg',130, 178,1,'photo_748600.html');
												thumbnails[755611] = new thumbnail(755611,'405638','Ailsa Craig','Ailsa_1_thumb.jpg',130, 86,1,'photo_755611.html');
												thumbnails[3184744] = new thumbnail(3184744,'405614','Untitled','Sepia_002b_thumb.jpg',130, 194,1,'photo_3184744.html');
												thumbnails[3184746] = new thumbnail(3184746,'405614','Christine','Sepia_008b_thumb.jpg',130, 88,1,'photo_3184746.html');
												thumbnails[3184755] = new thumbnail(3184755,'51844','This Familier Smile','This Familier Smile_thumb.jpg',130, 186,1,'photo_3184755.html');
												thumbnails[3199922] = new thumbnail(3199922,'51844','Amelie','Amelie_-73_thumb.jpg',130, 196,1,'photo_3199922.html');
												thumbnails[3199925] = new thumbnail(3199925,'9378','Spleen','Brian_thumb.jpg',130, 196,1,'photo_3199925.html');
												thumbnails[3199927] = new thumbnail(3199927,'405638','Day Surgery Statue, Ayr Hospital','Day Surgery Statue BW 2_thumb.jpg',130, 76,1,'photo_3199927.html');
												thumbnails[3199940] = new thumbnail(3199940,'52105','Heart','Heart_thumb.jpg',130, 130,1,'photo_3199940.html');
												thumbnails[7481829] = new thumbnail(7481829,'405614','Untitled','Samples_009_thumb.jpg',130, 86,1,'photo_7481829.html');
												thumbnails[7481856] = new thumbnail(7481856,'405614','Reservoir Dogs Theme','Samples_010_thumb.jpg',130, 87,1,'photo_7481856.html');
												thumbnails[7481860] = new thumbnail(7481860,'405614','','Samples_028_thumb.jpg',130, 86,1,'photo_7481860.html');
												thumbnails[7481870] = new thumbnail(7481870,'405614','Ashley','Samples_032_thumb.jpg',130, 86,1,'photo_7481870.html');
												thumbnails[7481874] = new thumbnail(7481874,'405614','','Samples_033_thumb.jpg',130, 196,1,'photo_7481874.html');
												thumbnails[7481875] = new thumbnail(7481875,'405614','Flower Girl','Samples_035_thumb.jpg',130, 196,1,'photo_7481875.html');
												thumbnails[7481881] = new thumbnail(7481881,'405614','Craig And Jenifer','Samples_037_thumb.jpg',130, 96,1,'photo_7481881.html');
												thumbnails[7481884] = new thumbnail(7481884,'405614','Ashley And Neil','Samples_039_thumb.jpg',130, 104,1,'photo_7481884.html');
												thumbnails[7481886] = new thumbnail(7481886,'405614','A kiss in Alloway Church','Samples_044_thumb.jpg',130, 163,1,'photo_7481886.html');
												thumbnails[7481890] = new thumbnail(7481890,'405614','Stephen and the \'team\'','Samples_053_thumb.jpg',130, 86,1,'photo_7481890.html');
												thumbnails[7481892] = new thumbnail(7481892,'405614','','Samples_056_thumb.jpg',130, 115,1,'photo_7481892.html');
												thumbnails[7482327] = new thumbnail(7482327,'405638','Ardrossan Beach','Ardrossan_Beach_thumb.jpg',130, 87,1,'photo_7482327.html');
												thumbnails[7482328] = new thumbnail(7482328,'405638','','Dalry_Wind_Farm_thumb.jpg',130, 86,1,'photo_7482328.html');
												thumbnails[7482342] = new thumbnail(7482342,'405638','Millport','DED_-141_thumb.jpg',130, 87,1,'photo_7482342.html');
												thumbnails[7482344] = new thumbnail(7482344,'405638','Girvan Boating Pond','Girvan_Boating_Pond_thumb.jpg',130, 86,1,'photo_7482344.html');
												thumbnails[7482348] = new thumbnail(7482348,'405652','Seafeild Children\'s Hospital','Seafield_001_thumb.jpg',130, 194,1,'photo_7482348.html');
												thumbnails[7482349] = new thumbnail(7482349,'405638','Portencross','Untitled_HDR2_thumb.jpg',130, 86,1,'photo_7482349.html');
												thumbnails[7482351] = new thumbnail(7482351,'9378','','Cpt_Rest_-5_thumb.jpg',130, 86,1,'photo_7482351.html');
												thumbnails[7482352] = new thumbnail(7482352,'9378','A Plastic Rose','DED_0008_thumb.jpg',130, 86,1,'photo_7482352.html');
												thumbnails[7482354] = new thumbnail(7482354,'9378','What The Blood Revealed','DED_0106_thumb.jpg',130, 196,1,'photo_7482354.html');
												thumbnails[7482355] = new thumbnail(7482355,'9378','What The Blood Revealed','DED_0115_thumb.jpg',130, 86,1,'photo_7482355.html');
												thumbnails[7482356] = new thumbnail(7482356,'9378','What The Blood Revealed','DED_0123_thumb.jpg',130, 86,1,'photo_7482356.html');
												thumbnails[7482358] = new thumbnail(7482358,'9378','','DED_0855_thumb.jpg',130, 196,1,'photo_7482358.html');
												thumbnails[7482362] = new thumbnail(7482362,'9378','Galoshins','Galoshins_005_thumb.jpg',130, 86,1,'photo_7482362.html');
												thumbnails[7482363] = new thumbnail(7482363,'9378','Galoshins','Galoshins_034_thumb.jpg',130, 86,1,'photo_7482363.html');
												thumbnails[7482365] = new thumbnail(7482365,'9378','Burning Mountain','HAC_090320-29_thumb.jpg',130, 196,1,'photo_7482365.html');
												thumbnails[7482367] = new thumbnail(7482367,'9378','Culann','HAC040709_019_thumb.jpg',130, 86,1,'photo_7482367.html');
												thumbnails[7482372] = new thumbnail(7482372,'405652','Stairwell Ayrshire Central Hospital','ACH_Stairwell_002_thumb.jpg',130, 194,1,'photo_7482372.html');
												thumbnails[7482375] = new thumbnail(7482375,'405618','Bee on the bedroom windowsill','bee_002_thumb.jpg',130, 86,1,'photo_7482375.html');
												thumbnails[7482384] = new thumbnail(7482384,'405638','Bike','Bike_thumb.jpg',130, 183,1,'photo_7482384.html');
												thumbnails[7482485] = new thumbnail(7482485,'52105','','Cut_Wood_thumb.jpg',130, 87,1,'photo_7482485.html');
												thumbnails[7482486] = new thumbnail(7482486,'405638','','DED_0002_thumb.jpg',130, 86,1,'photo_7482486.html');
												thumbnails[7482493] = new thumbnail(7482493,'405638','','DED_0012_thumb.jpg',130, 86,1,'photo_7482493.html');
												thumbnails[7482501] = new thumbnail(7482501,'52105','','DED_0015_thumb.jpg',130, 86,1,'photo_7482501.html');
												thumbnails[7482502] = new thumbnail(7482502,'405618','Dead Bee in the stones','DED_0019_thumb.jpg',130, 86,1,'photo_7482502.html');
												thumbnails[7482503] = new thumbnail(7482503,'405652','Palma Cathedral','DED_0071_thumb.jpg',130, 86,1,'photo_7482503.html');
												thumbnails[7482514] = new thumbnail(7482514,'405638','','DED_0081_thumb.jpg',130, 86,1,'photo_7482514.html');
												thumbnails[7482537] = new thumbnail(7482537,'405638','','DED_0124_thumb.jpg',130, 86,1,'photo_7482537.html');
												thumbnails[7482543] = new thumbnail(7482543,'405638','Amelie','DED_0282_thumb.jpg',130, 86,1,'photo_7482543.html');
												thumbnails[7482544] = new thumbnail(7482544,'52105','CPR Dolls','DSCF0018_thumb.jpg',130, 194,1,'photo_7482544.html');
												thumbnails[7482547] = new thumbnail(7482547,'52105','CPR Dolls','DSCF0066_thumb.jpg',130, 194,1,'photo_7482547.html');
												thumbnails[7482550] = new thumbnail(7482550,'52105','CPR Dolls','DSCF0070_thumb.jpg',130, 194,1,'photo_7482550.html');
												thumbnails[7482552] = new thumbnail(7482552,'52105','','Hands_Gretna_thumb.jpg',130, 86,1,'photo_7482552.html');
												thumbnails[7482553] = new thumbnail(7482553,'405618','Decapitated Wasp','headless_wasp_002_thumb.jpg',130, 86,1,'photo_7482553.html');
												thumbnails[7482690] = new thumbnail(7482690,'52105','Stuart the Lush Wasp','Lush_Wasp_thumb.jpg',130, 161,1,'photo_7482690.html');
												thumbnails[7482700] = new thumbnail(7482700,'405638','Open Goal','OG_002_thumb.jpg',130, 86,1,'photo_7482700.html');
												thumbnails[7482701] = new thumbnail(7482701,'405638','Open Goal','OG_005_thumb.jpg',130, 86,1,'photo_7482701.html');
												thumbnails[7482702] = new thumbnail(7482702,'405638','Open Goal','OG_008_thumb.jpg',130, 86,1,'photo_7482702.html');
												thumbnails[7482703] = new thumbnail(7482703,'405638','OPen Goal','OG012_thumb.jpg',130, 86,1,'photo_7482703.html');
												thumbnails[7482705] = new thumbnail(7482705,'405638','Open Goal','OG016_thumb.jpg',130, 86,1,'photo_7482705.html');
												thumbnails[7482706] = new thumbnail(7482706,'405652','The Two Churches','The_Two_Churches_thumb.jpg',130, 92,1,'photo_7482706.html');
												thumbnails[7482708] = new thumbnail(7482708,'405618','Trapped','VFT_001_thumb.jpg',130, 86,1,'photo_7482708.html');
												thumbnails[7482712] = new thumbnail(7482712,'405618','Trapped','Trapped_Fly_005_thumb.jpg',130, 86,1,'photo_7482712.html');
												thumbnails[7482714] = new thumbnail(7482714,'405618','Dead Wasp','wasp_-29_thumb.jpg',130, 86,1,'photo_7482714.html');
												thumbnails[7482729] = new thumbnail(7482729,'405618','What\'s Best For Them...','wbft_002_thumb.jpg',130, 185,1,'photo_7482729.html');
												thumbnails[7482738] = new thumbnail(7482738,'51844','Alan (What The Blood Revealed)','Alan_thumb.jpg',130, 196,1,'photo_7482738.html');
												thumbnails[7482741] = new thumbnail(7482741,'51844','Gav (What The Blood Revealed)','Gav_thumb.jpg',130, 196,1,'photo_7482741.html');
												thumbnails[7482744] = new thumbnail(7482744,'51844','Scott (What The Blood Revealed)','Scott_thumb.jpg',130, 196,1,'photo_7482744.html');
												thumbnails[7482747] = new thumbnail(7482747,'51844','Stuart (What The Blood Revealed)','Stuart_thumb.jpg',130, 196,1,'photo_7482747.html');
												thumbnails[7482748] = new thumbnail(7482748,'51844','Culann','Culann_021_thumb.jpg',130, 86,1,'photo_7482748.html');
												thumbnails[7482751] = new thumbnail(7482751,'51844','Stuart and Nicki','DED_037_thumb.jpg',130, 140,1,'photo_7482751.html');
												thumbnails[7482915] = new thumbnail(7482915,'51844','What The Blood Revealed','WTBR_002_thumb.jpg',130, 86,1,'photo_7482915.html');

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  					galleries[52105] = new gallery(52105,'7482690,7482552,7482550,7482547,7482544,7482501,7482485,3199940,681236,681215','Abstract','gallery',[681187,681215,681236,3199940,7482485,7482501,7482544,7482547,7482550,7482552,7482690],0, 0, '', 'gallery_52105.html',0,0);
				  					galleries[405652] = new gallery(405652,'7482706,7482503,7482372,7482348','Architecture','gallery',[7482348,7482372,7482503,7482706],0, 0, '', 'gallery_405652.html',0,0);
				  					galleries[405638] = new gallery(405638,'7482705,7482703,7482702,7482701,7482700,7482543,7482537,7482514,7482493,7482486','Landscapes','gallery',[681139,755611,3199927,7482327,7482328,7482342,7482344,7482349,7482384,7482486,7482493,7482514,7482537,7482543,7482700,7482701,7482702,7482703,7482705],0, 0, '', 'gallery_405638.html',0,0);
				  					galleries[51844] = new gallery(51844,'7482915,7482751,7482748,7482747,7482744,7482741,7482738,3199922,3184755,748600','Portrait','gallery',[678284,678327,678331,681237,748600,3184755,3199922,7482738,7482741,7482744,7482747,7482748,7482751,7482915],0, 0, '', 'gallery_51844.html',0,0);
				  					galleries[405614] = new gallery(405614,'7481892,7481890,7481886,7481884,7481881,7481875,7481874,7481870,7481860,7481856','Weddings','gallery',[3184744,3184746,7481829,7481856,7481860,7481870,7481874,7481875,7481881,7481884,7481886,7481890,7481892],0, 0, '', 'gallery_405614.html',0,0);
				  					galleries[405618] = new gallery(405618,'7482729,7482714,7482712,7482708,7482553,7482502,7482375,704092,681234,681233','Windowsill Graveyard','gallery',[681219,681221,681233,681234,704092,7482375,7482502,7482553,7482708,7482712,7482714,7482729],0, 0, '', 'gallery_405618.html',0,0);
				  					galleries[9378] = new gallery(9378,'7482367,7482365,7482363,7482362,7482358,7482356,7482355,7482354,7482352,7482351','Music','gallery',[678268,678280,678302,678322,678324,678340,678346,678358,678743,681083,681089,681105,704086,704087,704089,710740,3199925,7482351,7482352,7482354,7482355,7482356,7482358,7482362,7482363,7482365,7482367],0, 0, '', 'gallery_9378.html',0,0);
/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = new Object();
imageSets[240285] = '7482706,7482537,7482514,7482384';
imageSets[1] = '7482915,7482706,7482701,7482690,7482552,7482544,7482543,7482537,7482501,7482485,7482348,3199927';
imageSets[3] = '7482706,7482701,7482537,7482485';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/Max_Fax/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/Max_Fax/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/Max_Fax/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/Max_Fax/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/Max_Fax/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/Max_Fax/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/Max_Fax/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/Max_Fax/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/Max_Fax/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/Max_Fax/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/Max_Fax/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/Max_Fax/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/Max_Fax/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/Max_Fax/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/Max_Fax/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://admin2.clikpic.com/Max_Fax/images';
		break;
	}
		switch (server_id) {
		case 33:
		val = 'http://www8.clikpic.com/Max_Fax/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/Max_Fax/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/Max_Fax/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/Max_Fax/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/Max_Fax/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/Max_Fax/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 = 'Dave Dickie: Photography: ' + photoCaption;
			    }
        if (op.$detail.length > 0) {
      temp = op.nextPhoto.fnGetImageDetails();
	    op.$detail.fadeGalleryDetails(temp, op.speed, function(){
	    var options = {photoinfominwidth:200};	    		options.photoinfoadjacent = true;			      	      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>';
	}
					
	temp = temp + this.fnGetPaymentInfo();
				if (temp != '') {
		temp = temp + '<div class="spacer"></div>';
	}
	return temp;
};

/***************************************************************************
* Get payment info for image - add as 'method' to photo object             *
***************************************************************************/
photo.prototype.fnGetPaymentInfo = function(){
	var temp = '';
	if (this.item_price !== '') {
																		temp = temp + '<p>Buy now using PayPal:</p>';
				temp = temp + '<p class="imageinfo" id="imagePrice"><strong>' + this.purchase_instruction + '</strong> &pound;' + (this.item_price).toFixed(2) + '</p>';
		var item_name  = this.purchase_instruction;
		var amount = (this.item_price).toFixed(2);
		var item_option  = 0;
	}
	else if (this.payment_groups_id !== '') {
		temp = temp + '<p>Buy this print online:</p>';
				temp = temp + '<form id="paymentOptions" style="margin:0px;border:0px;" name="paymentOptions">';
		 									temp = temp + '<select class="paymentlink" name="payment_options_id" onchange="updateCartValue(document.forms.paymentForm,this.form.payment_options_id.options[this.form.payment_options_id.options.selectedIndex].value); if(divShowing(\'paymentConfirm\')){fadeOut(\'paymentConfirm\', 3)};">';
				
		temp = temp + getPaymentOptions(this.payment_groups_id);
		temp = temp + '</select>';
		temp = temp + '</form>';
				var item_option  = paymentGroups[this.payment_groups_id].options[0];
		if(paymentOptions[item_option]){
			var item_name  = paymentOptions[item_option].payment_option;
			var amount =  paymentOptions[item_option].price;
		}
			}
	else {
				
	}
	if (this.item_price !== '' || this.payment_groups_id !== '') {
									temp = temp + '<form id="paymentForm" style="margin:0px;border:0px;" name="paymentForm">';
	temp = temp + '	<input type="hidden" name="item_option" value="' + item_option + '">';
	temp = temp + '	<input type="hidden" name="site" value="MAX_FAX">';
		temp = temp + '	<input type="hidden" name="item_number" value="'+ this.id +'">';
			temp = temp + '	<input type="hidden" name="quantity" value="1">';
								temp = temp + '	<input value="Add to cart" id="paymentAddButton" class="button" onmouseover="this.className=\'buttonHi\'\;" onmouseout="this.className=\'button\'\;" type="Button">';
			temp = temp + '	<input value="View cart" id="paymentViewButton" class="button" onmouseover="this.className=\'buttonHi\';" onmouseout="this.className=\'button\';" type="Button" onclick="javascript:window.location=\'cart.html\'">';
	temp = temp + '</form>';
		temp = temp + '<div class="clearing">&nbsp;</div>';
	temp = temp + '<div id="confirmContainer">';
	temp = temp + '<div id="paymentConfirm">Item added to cart</div>';
	temp = temp + '</div>';
			temp = temp + '<div class="clearing">&nbsp;</div>';
	}
	return temp;};

/***************************************************************************
* Pick a photo at random from the featured images of a gallery.            *
* Gallery_id = id of gallery to choose,                                    *
* img = reference to html image in                                         *
* which to show image                                                      *
***************************************************************************/
function showGalleryImage(gallery_id, img, updateLink) {
		
	if(img){
	      if (location.hash.match('galleries_id=' + gallery_id) && (imageID = location.hash.match('.*photos_id=(.+)$'))) {
        imageID = imageID[1];
      } else {
			  imageID = randomListVal(galleries[gallery_id].featured_images);
      }
							
			if (imageID != 0) {
				img.src = thumbnails[imageID].src;
				img.width = thumbnails[imageID].width;
				img.height = thumbnails[imageID].height;
				img.alt = galleries[gallery_id].title;
        if (updateLink) {
          $(img).parent().attr({            href: thumbnails[imageID].fnGalleryLink(gallery_id),            title: galleries[gallery_id].title          });
        }
							}
										}
}

/***************************************************************************
* If we have dynamic HTML, replace the galleries link with a list that     *
* doesn't include thecurrent gallery                                       *
***************************************************************************/
function showGalleries(gallery_id) {
		
	
	if (!basic) {
		temp = '';
		for (i = 0; i < galleries.length; i++) {
						
			
			if (galleries[i].id != gallery_id) {
								
				if (temp != '') {
					temp = temp + ' | ';
				}
				temp = temp + '<a href="' + galleries[i].section_code + '_' + galleries[i].id + '.html">' + galleries[i].title + '</a>';
			}
		}
		document.all.galleryLinks.innerHTML = 'Other galleries: ' + temp;
	}
}

			

