window.thumbnails = new Object();
												thumbnails[6397396] = new thumbnail(6397396,'56310','','Sunken_Images_2abc_thumb.jpg',130, 96,18,'photo_6397396.html');
												thumbnails[1534559] = new thumbnail(1534559,'56310','David Buckle<br>\r\nUnderwater Photographer','dave1_thumb.jpg',130, 199,18,'photo_1534559.html');
												thumbnails[904904] = new thumbnail(904904,'56310','Prop and Rudder on the SS Thistlegorm','march 071_thumb.jpg',130, 93,18,'photo_904904.html');
												thumbnails[904909] = new thumbnail(904909,'56310','Water Tanker and Bollards on the port side of the SS Thistlegorm','march03075_thumb.jpg',130, 180,18,'photo_904909.html');
												thumbnails[732151] = new thumbnail(732151,'56310','Anchor chains & winches on the SS. Thistlegorm','DAVE BUCKLE_00004_thumb.jpg',130, 86,18,'photo_732151.html');
												thumbnails[732160] = new thumbnail(732160,'56310','Locomotive from the wreck of SS.Thistlegorm','DAVE BUCKLE_00010_thumb.jpg',130, 87,18,'photo_732160.html');
												thumbnails[771927] = new thumbnail(771927,'56310','Locomotive rail tender on the SS Thistlegorm','cnv000242_thumb.jpg',130, 87,18,'photo_771927.html');
												thumbnails[1198892] = new thumbnail(1198892,'56310','Diver on the stern section of the Rosalie Moller','tim1_thumb.jpg',130, 195,18,'photo_1198892.html');
												thumbnails[732174] = new thumbnail(732174,'56310','SS Ghiannis D shipwreck','DAVE BUCKLE_000021_thumb.jpg',130, 195,18,'photo_732174.html');
												thumbnails[771920] = new thumbnail(771920,'56310','Lion fish at Um Usk reef','cnv000011_thumb.jpg',130, 195,18,'photo_771920.html');
												thumbnails[732157] = new thumbnail(732157,'56310','RMS.Carnatic Shipwreck Red Sea','DAVE BUCKLE_00008_thumb.jpg',130, 87,18,'photo_732157.html');
												thumbnails[732156] = new thumbnail(732156,'56310','SS.Chrisoula K shipwreck in the Red Sea','DAVE BUCKLE_00007_thumb.jpg',130, 195,18,'photo_732156.html');
												thumbnails[771941] = new thumbnail(771941,'56310','SS Kimon M Propeller & Rudder','cnv00010_thumb.jpg',130, 87,18,'photo_771941.html');
												thumbnails[732150] = new thumbnail(732150,'56310','Paravane & Tender on the SS.Thistlegorm','DAVE BUCKLE_00003_thumb.jpg',130, 87,18,'photo_732150.html');
												thumbnails[732139] = new thumbnail(732139,'56310',' SS.Ghiannis D shipwreck.<br>\r\n','DAVE BUCKLE_00001_thumb.jpg',130, 195,18,'photo_732139.html');
												thumbnails[771949] = new thumbnail(771949,'56310','Pair of Clown fish near the Blue Hole Dahab','cnv00007_thumb.jpg',130, 87,18,'photo_771949.html');
												thumbnails[732161] = new thumbnail(732161,'56310','SS.Kingston Shipwreck Red Sea on Shag Rock','DAVE BUCKLE_00011_thumb.jpg',130, 195,18,'photo_732161.html');
												thumbnails[904910] = new thumbnail(904910,'56310','Water tanker and bollards looking for,ard on the port side of the SS Thistlegorm','march03074_thumb.jpg',130, 180,18,'photo_904910.html');
												thumbnails[904907] = new thumbnail(904907,'56310','Spare Prop on the SS Kingston','march030706_thumb.jpg',130, 93,18,'photo_904907.html');
												thumbnails[1917761] = new thumbnail(1917761,'56310','SS. KINGSTON','king1_thumb.jpg',130, 181,18,'photo_1917761.html');
												thumbnails[3642129] = new thumbnail(3642129,'56310','Bow of the Thistlegorm','img019_thumb.jpg',130, 132,18,'photo_3642129.html');
												thumbnails[771930] = new thumbnail(771930,'56310','SS Thistlegorm No4 hold remains of bombs and truck wreckage','cnv00008_thumb.jpg',130, 87,18,'photo_771930.html');
												thumbnails[771921] = new thumbnail(771921,'56310','Motocycles in the hold on the SS Thistlegorm','cnv00018_thumb.jpg',130, 87,18,'photo_771921.html');
												thumbnails[771957] = new thumbnail(771957,'56310','Puffer fish on the Lighthouse Reef Dahab','cnv00004_thumb.jpg',130, 87,18,'photo_771957.html');
												thumbnails[771922] = new thumbnail(771922,'56310','Trucks in the hold on the SS Thistlegorm','cnv00019_thumb.jpg',130, 87,18,'photo_771922.html');
												thumbnails[771928] = new thumbnail(771928,'56310','SS.Thistlegorm Fore deck & workshop ','cnv00023_thumb.jpg',130, 87,18,'photo_771928.html');
												thumbnails[905105] = new thumbnail(905105,'56310','Starboard side gangway on the SS Ghiannis D','march01_thumb.jpg',130, 180,18,'photo_905105.html');
												thumbnails[771943] = new thumbnail(771943,'56310','SS Chrisoula K rudder & propeller','cnv00012_thumb.jpg',130, 194,18,'photo_771943.html');
												thumbnails[771936] = new thumbnail(771936,'56310','Stern section of the SS Ghiannis D','cnv00015_thumb.jpg',130, 194,18,'photo_771936.html');
												thumbnails[904916] = new thumbnail(904916,'56310','4.7inch anti aircraft gun on the stern of the SS Thistlegorm','march03072_thumb.jpg',130, 93,18,'photo_904916.html');
												thumbnails[771935] = new thumbnail(771935,'56310','SS Thistlegorm midships','cnv00017_thumb.jpg',130, 87,18,'photo_771935.html');
												thumbnails[904912] = new thumbnail(904912,'56310','4.7inch anti aircraft gun on the stern section of the SS Thistlegorm','march03073_thumb.jpg',130, 93,18,'photo_904912.html');
												thumbnails[905107] = new thumbnail(905107,'56310','Gangway on the SS Ghiannis D ','march02_thumb.jpg',130, 180,18,'photo_905107.html');
												thumbnails[905115] = new thumbnail(905115,'56310','Divers on the starboard side of the SS Ghiannis D shipwreck','march06_thumb.jpg',130, 180,18,'photo_905115.html');
												thumbnails[905112] = new thumbnail(905112,'56310','Diver videoing the SS Ghiannis D','march05_thumb.jpg',130, 180,18,'photo_905112.html');
												thumbnails[905110] = new thumbnail(905110,'56310','Propellor starboard side of the SS Ghiannis D','march04_thumb.jpg',130, 180,18,'photo_905110.html');
												thumbnails[771955] = new thumbnail(771955,'56310','Pair of Lionfish at Um Usk','cnv00002_thumb.jpg',130, 87,18,'photo_771955.html');
												thumbnails[771926] = new thumbnail(771926,'56310','Water tanker on deck of the SS Thistlegorm','cnv00022_thumb.jpg',130, 87,18,'photo_771926.html');
												thumbnails[771959] = new thumbnail(771959,'56310','Clownfish at the Lighthouse Dahab','cnv00006_thumb.jpg',130, 87,18,'photo_771959.html');
												thumbnails[3583344] = new thumbnail(3583344,'56310','\"Harbour Wreck\". Egyptian gun boat sunk during the six day war between Israel and Egypt','egypt_wreck_thumb.jpg',130, 193,18,'photo_3583344.html');
												thumbnails[732154] = new thumbnail(732154,'56310','Paddys Bottlenose Dolphin','DAVE BUCKLE_00006_thumb.jpg',130, 87,18,'photo_732154.html');
												thumbnails[771946] = new thumbnail(771946,'56310','RMS Carnatic stern section','cnv00014_thumb.jpg',130, 194,18,'photo_771946.html');
												thumbnails[3642197] = new thumbnail(3642197,'56310','Diver leaving the Harbour wreck','img016_thumb.jpg',130, 133,18,'photo_3642197.html');
												thumbnails[905164] = new thumbnail(905164,'56310','Barge at Bluff Point Red Sea','march031_thumb.jpg',130, 180,18,'photo_905164.html');
												thumbnails[905161] = new thumbnail(905161,'56310','Remains of the Barge at Bluff Point in the Red Sea','march021_thumb.jpg',130, 93,18,'photo_905161.html');
												thumbnails[3642099] = new thumbnail(3642099,'56310','Blue Angel fish on the Thistlegorm','angel2_thumb.jpg',130, 134,18,'photo_3642099.html');
												thumbnails[3642153] = new thumbnail(3642153,'56310','Grouper on the sea bed','img021_thumb.jpg',130, 132,18,'photo_3642153.html');
												thumbnails[905108] = new thumbnail(905108,'56310','SS Ghiannis D','march03_thumb.jpg',130, 180,18,'photo_905108.html');
												thumbnails[7714873] = new thumbnail(7714873,'417519','','20110327_407abcde_thumb.jpg',130, 98,18,'photo_7714873.html');
												thumbnails[7714970] = new thumbnail(7714970,'417519','','20110327_193ab_thumb.jpg',130, 84,18,'photo_7714970.html');
												thumbnails[7715016] = new thumbnail(7715016,'417519','','20110327_194a_thumb.jpg',130, 87,18,'photo_7715016.html');
												thumbnails[7714870] = new thumbnail(7714870,'417519','','20110327_158ab_thumb.jpg',130, 74,18,'photo_7714870.html');
												thumbnails[7714897] = new thumbnail(7714897,'417519','','20110327_360abc_thumb.jpg',130, 100,18,'photo_7714897.html');
												thumbnails[7714993] = new thumbnail(7714993,'417519','','20110327_601ab_thumb.jpg',130, 87,18,'photo_7714993.html');
												thumbnails[7714841] = new thumbnail(7714841,'417519','','20110327_117abc_jpg_thumb.jpg',130, 88,18,'photo_7714841.html');
												thumbnails[7714924] = new thumbnail(7714924,'417519','','20110327_191ab_thumb.jpg',130, 82,18,'photo_7714924.html');
												thumbnails[7714894] = new thumbnail(7714894,'417519','','20110327_153ab_thumb.jpg',130, 87,18,'photo_7714894.html');
												thumbnails[7714899] = new thumbnail(7714899,'417519','','20110327_137ab_thumb.jpg',130, 90,18,'photo_7714899.html');
												thumbnails[7715040] = new thumbnail(7715040,'417519','','20110327_181ab_thumb.jpg',130, 86,18,'photo_7715040.html');
												thumbnails[7714888] = new thumbnail(7714888,'417519','','20110327_122ab_thumb.jpg',130, 83,18,'photo_7714888.html');
												thumbnails[7714909] = new thumbnail(7714909,'417519','','20110327_206abc_thumb.jpg',130, 87,18,'photo_7714909.html');
												thumbnails[7714877] = new thumbnail(7714877,'417519','','20110327_305ab_thumb.jpg',130, 89,18,'photo_7714877.html');
												thumbnails[7716436] = new thumbnail(7716436,'417519','','20110327_304ab_thumb.jpg',130, 87,18,'photo_7716436.html');
												thumbnails[7714919] = new thumbnail(7714919,'417519','','20110327_185ab_thumb.jpg',130, 87,18,'photo_7714919.html');
												thumbnails[7716441] = new thumbnail(7716441,'417519','','20110327_488ab_thumb.jpg',130, 114,18,'photo_7716441.html');
												thumbnails[7728433] = new thumbnail(7728433,'417519','','20110327_177ab_thumb.jpg',130, 87,18,'photo_7728433.html');
												thumbnails[7728435] = new thumbnail(7728435,'417519','','20110327_602ab_thumb.jpg',130, 87,18,'photo_7728435.html');
												thumbnails[7728437] = new thumbnail(7728437,'417519','','20110327_594ab_thumb.jpg',130, 87,18,'photo_7728437.html');
												thumbnails[7714883] = new thumbnail(7714883,'417519','','20110327_147ab_thumb.jpg',130, 114,18,'photo_7714883.html');
												thumbnails[7716437] = new thumbnail(7716437,'417519','','20110327_357abc_thumb.jpg',130, 89,18,'photo_7716437.html');
												thumbnails[7715046] = new thumbnail(7715046,'417519','','20110327_174ab_thumb.jpg',130, 87,18,'photo_7715046.html');
												thumbnails[4183357] = new thumbnail(4183357,'249158','Cage Diving with the Great White Shark','sa31_thumb.jpg',130, 87,18,'photo_4183357.html');
												thumbnails[4183327] = new thumbnail(4183327,'249158','Black Tip Reef Shark','DSC_0896a_thumb.jpg',130, 66,18,'photo_4183327.html');
												thumbnails[4182855] = new thumbnail(4182855,'249158','Oceanic Black Reef Shark and Diver','sa25a_thumb.jpg',130, 66,18,'photo_4182855.html');
												thumbnails[4184404] = new thumbnail(4184404,'249158','Shark Silhouette','DSC_0908_thumb.jpg',130, 85,18,'photo_4184404.html');
												thumbnails[4183347] = new thumbnail(4183347,'249158','Oceanic Black Tip Shark','20090929_10_thumb.jpg',130, 79,18,'photo_4183347.html');
												thumbnails[4184192] = new thumbnail(4184192,'249158','Sun Kissed Oceanic Black Tip Reef Shark','DSC_0959a_thumb.jpg',130, 73,18,'photo_4184192.html');
												thumbnails[4183419] = new thumbnail(4183419,'249158','Shark Attack','shark4_thumb.jpg',130, 63,18,'photo_4183419.html');
												thumbnails[4184073] = new thumbnail(4184073,'249158','Photographing a Great White Shark from a cage','DSC_1343abc_thumb.jpg',130, 89,18,'photo_4184073.html');
												thumbnails[4186154] = new thumbnail(4186154,'249158','Breaching Great White Shark','DSC_1100_thumb.jpg',130, 94,18,'photo_4186154.html');
												thumbnails[4185161] = new thumbnail(4185161,'249158','Sunburst on Aliwal Shoal','sa24a_thumb.jpg',130, 194,18,'photo_4185161.html');
												thumbnails[4187023] = new thumbnail(4187023,'249158','Charge of the Great White Shark','DSC_1326cb_thumb.jpg',130, 87,18,'photo_4187023.html');
												thumbnails[4186971] = new thumbnail(4186971,'249158','FULL on ATTACK','DSC_1111_thumb.jpg',130, 84,18,'photo_4186971.html');
												thumbnails[4186248] = new thumbnail(4186248,'249158','Jaws','shark6_thumb.jpg',130, 75,18,'photo_4186248.html');
												thumbnails[4184153] = new thumbnail(4184153,'249158','Approaching Great White Shark','sa2_thumb.jpg',130, 100,18,'photo_4184153.html');
												thumbnails[4189969] = new thumbnail(4189969,'249158','Coming in for the Bait','shark_20_thumb.jpg',130, 87,18,'photo_4189969.html');
												thumbnails[4273983] = new thumbnail(4273983,'249158','Look behind you','sa27a_thumb.jpg',130, 120,18,'photo_4273983.html');
												thumbnails[6406795] = new thumbnail(6406795,'249158','Black Tip Reef Shark','DSC_0926a_thumb.jpg',130, 69,18,'photo_6406795.html');
												thumbnails[6406831] = new thumbnail(6406831,'249158','Behind you','sa21_thumb.jpg',130, 90,18,'photo_6406831.html');
												thumbnails[6408020] = new thumbnail(6408020,'249158','Sun Rays','DSC_0928ab_thumb.jpg',130, 53,18,'photo_6408020.html');
												thumbnails[4273955] = new thumbnail(4273955,'249158','Awaiting the Bait','2_sharks_thumb.jpg',130, 56,18,'photo_4273955.html');
												thumbnails[6406837] = new thumbnail(6406837,'249158','Great White','DSC_1340a_thumb.jpg',130, 95,18,'photo_6406837.html');
												thumbnails[6406824] = new thumbnail(6406824,'249158','','DSC_0988a_thumb.jpg',130, 129,18,'photo_6406824.html');
												thumbnails[4273980] = new thumbnail(4273980,'249158','Raggie Tooth of Aliwal Shoals','DSC_0654a_thumb.jpg',130, 55,18,'photo_4273980.html');
												thumbnails[4966827] = new thumbnail(4966827,'249158','Great White Shark','DSC_1337abc_thumb.jpg',130, 88,18,'photo_4966827.html');
												thumbnails[4452468] = new thumbnail(4452468,'249158','Tiger Shark','20090929_11_thumb.jpg',130, 77,18,'photo_4452468.html');
												thumbnails[4452356] = new thumbnail(4452356,'249158','Black Tip Shark','DSC_0898_bc1_thumb.jpg',130, 81,18,'photo_4452356.html');
												thumbnails[4452363] = new thumbnail(4452363,'249158','Shark penertrating the sun rays','DSC_0792ab_thumb.jpg',130, 83,18,'photo_4452363.html');
												thumbnails[4452432] = new thumbnail(4452432,'249158','Shark swim past','DSC_0937ab_thumb.jpg',130, 87,18,'photo_4452432.html');
												thumbnails[4452453] = new thumbnail(4452453,'249158','Sharks circling the dive boat','sa8_thumb.jpg',130, 101,18,'photo_4452453.html');

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  					galleries[56310] = new gallery(56310,'6397396,3642197,3642153,3642129,3642099,3583344,1917761,1534559,1198892,905164','SHIPWRECKS','gallery',[6397396,1534559,904904,904909,732151,732160,771927,1198892,732174,771920,732157,732156,771941,732150,732139,771949,732161,904910,904907,1917761,3642129,771930,771921,771957,771922,771928,905105,771943,771936,904916,771935,904912,905107,905115,905112,905110,771955,771926,771959,3583344,732154,771946,3642197,905164,905161,3642099,3642153,905108],0, 0, '', 'gallery.html',0,1);
				  					galleries[249158] = new gallery(249158,'6408020,6406837,6406831,6406824,6406795,4966827,4452468,4452453,4452432,4452363','Sharks','section301635',[4183357,4183327,4182855,4184404,4183347,4184192,4183419,4184073,4186154,4185161,4187023,4186971,4186248,4184153,4189969,4273983,6406795,6406831,6408020,4273955,6406837,6406824,4273980,4966827,4452468,4452356,4452363,4452432,4452453],0, 0, '', 'section301635.html',0,1);
				  					galleries[417519] = new gallery(417519,'7728437,7728435,7728433,7716441,7716437,7716436,7715046,7715040,7715016,7714993','Barbados','section500208',[7714873,7714970,7715016,7714870,7714897,7714993,7714841,7714924,7714894,7714899,7715040,7714888,7714909,7714877,7716436,7714919,7716441,7728433,7728435,7728437,7714883,7716437,7715046],0, 0, '', 'section500208.html',0,1);
/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = new Object();
imageSets[1] = '6397396';
imageSets[3] = '7728437,7728435,7728433,7716441,7716437,7716436,7715046,7715040,7715016,7714993,7714970,7714924,7714919,7714909,7714899,7714897,7714894,7714888,7714883,7714877,7714873,7714870,7714841,6408020,6406837,6406831,6406824,6406795,6397396,4966827,4452468,4452453,4452432,4452363,4452356,4273983,4273980,4273955,4189969,4187023,4186971,4186248,4186154,4185161,4184404,4184192,4184153,4184073,4183419,4183357';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/davidhelmet/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/davidhelmet/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/davidhelmet/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/davidhelmet/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/davidhelmet/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/davidhelmet/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/davidhelmet/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/davidhelmet/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/davidhelmet/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/davidhelmet/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/davidhelmet/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/davidhelmet/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/davidhelmet/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/davidhelmet/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/davidhelmet/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://admin2.clikpic.com/davidhelmet/images';
		break;
	}
		switch (server_id) {
		case 33:
		val = 'http://www8.clikpic.com/davidhelmet/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/davidhelmet/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/davidhelmet/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/davidhelmet/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/davidhelmet/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/davidhelmet/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 = ' Sunken Images - David Buckle : ' + 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>';
	}
					
				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;
	}
}

			

