window.thumbnails = new Object();
												thumbnails[6563081] = new thumbnail(6563081,'','','Chalet-Panel-1_thumb.jpg',98, 130,5,'#');
												thumbnails[4929946] = new thumbnail(4929946,'280472','','Dorn_Pedastel_bowl_Churches_thumb.jpg',130, 149,5,'photo_4929946.html');
												thumbnails[5090203] = new thumbnail(5090203,'280431','','gtc_thumb.jpg',130, 104,5,'photo_5090203.html');
												thumbnails[5170440] = new thumbnail(5170440,'280472','','Florian_tall_vase_Washington_Embassy640_thumb.jpg',101, 130,5,'photo_5170440.html');
												thumbnails[5178522] = new thumbnail(5178522,'280472','','Dartmouth_bowl_Country_House640_thumb.jpg',130, 108,5,'photo_5178522.html');
												thumbnails[5180370] = new thumbnail(5180370,'280468','','Antelope640_thumb.jpg',130, 122,5,'photo_5180370.html');
												thumbnails[5180372] = new thumbnail(5180372,'280468','','WEB_Tall_Florian_vase_King_cheetah_pair_thumb.jpg',95, 130,5,'photo_5180372.html');
												thumbnails[5180375] = new thumbnail(5180375,'280468','','Dorn_Pedastle_Bowl_Elephants640_thumb.jpg',116, 130,5,'photo_5180375.html');
												thumbnails[5180378] = new thumbnail(5180378,'280468','','Flask_Partridge640_thumb.jpg',94, 130,5,'photo_5180378.html');
												thumbnails[5180380] = new thumbnail(5180380,'280468','','Flask_Pheasants640_thumb.jpg',89, 130,5,'photo_5180380.html');
												thumbnails[5180381] = new thumbnail(5180381,'280468','','Fortuna_ftd_woodcock640_thumb.jpg',130, 104,5,'photo_5180381.html');
												thumbnails[5180384] = new thumbnail(5180384,'280468','','PEBBLE_BOWL_POLAR_BEAR_1640_thumb.jpg',130, 89,5,'photo_5180384.html');
												thumbnails[5180386] = new thumbnail(5180386,'280468','','STAG_VASE_2-1640_thumb.jpg',92, 130,5,'photo_5180386.html');
												thumbnails[5180389] = new thumbnail(5180389,'280468','','WEB_Siena_Platter_Afican_Mixture_thumb.jpg',130, 112,5,'photo_5180389.html');
												thumbnails[5180408] = new thumbnail(5180408,'280471','','Atlantis_Ships_decanter_Coat_of_Arms640_thumb.jpg',84, 130,5,'photo_5180408.html');
												thumbnails[5180410] = new thumbnail(5180410,'280471','','Ella_Spirit_Decanter_Luke_Arms640_thumb.jpg',64, 130,5,'photo_5180410.html');
												thumbnails[5180413] = new thumbnail(5180413,'280471','','Newcastle_Goblet_crest640_thumb.jpg',61, 130,5,'photo_5180413.html');
												thumbnails[5180416] = new thumbnail(5180416,'280471','','Rachael_Jugs_Coat_of_Arms___Initials640_thumb.jpg',126, 130,5,'photo_5180416.html');
												thumbnails[5180419] = new thumbnail(5180419,'280471','','Walton_goblet_Coat_of_Arms640_thumb.jpg',80, 130,5,'photo_5180419.html');
												thumbnails[5180440] = new thumbnail(5180440,'280478','','Asquith_CL640_thumb.jpg',77, 130,5,'photo_5180440.html');
												thumbnails[5180443] = new thumbnail(5180443,'280478','','Disk_Polo_trophy6401_thumb.jpg',130, 122,5,'photo_5180443.html');
												thumbnails[5180444] = new thumbnail(5180444,'280478','','Dorn_Pedastel_Bowl_Company_Logo640_thumb.jpg',130, 122,5,'photo_5180444.html');
												thumbnails[5180445] = new thumbnail(5180445,'301767','','JJ_Square_decanter_Biplane640_thumb.jpg',73, 130,5,'photo_5180445.html');
												thumbnails[5180446] = new thumbnail(5180446,'280478','','Martini_jug_CHR640_thumb.jpg',87, 130,5,'photo_5180446.html');
												thumbnails[5180447] = new thumbnail(5180447,'280478','','Royal_scott_Bowl_Initials_and_Vine640_thumb.jpg',130, 123,5,'photo_5180447.html');
												thumbnails[5180456] = new thumbnail(5180456,'280479','','Bohemia_Vase_Orchids640_thumb.jpg',109, 130,5,'photo_5180456.html');
												thumbnails[5180458] = new thumbnail(5180458,'280479','','LSA_vase_Magnolia_1640_thumb.jpg',58, 130,5,'photo_5180458.html');
												thumbnails[5180459] = new thumbnail(5180459,'280479','','Vase_dogwood640_thumb.jpg',82, 130,5,'photo_5180459.html');
												thumbnails[5180485] = new thumbnail(5180485,'301766','','Window_pane_Salmon640_thumb.jpg',93, 130,5,'photo_5180485.html');
												thumbnails[5190875] = new thumbnail(5190875,'280431','','Flagship_Store_Ground_Floor2_thumb.jpg',130, 87,5,'photo_5190875.html');
												thumbnails[5317287] = new thumbnail(5317287,'280468','','Dartington_Large_Flora_vase_Bears_fishing_WEB12_thumb.jpg',121, 130,5,'photo_5317287.html');
												thumbnails[5327254] = new thumbnail(5327254,'280468','','William_Yeoward_bowl_Salmon_WEB12_thumb.jpg',130, 98,5,'photo_5327254.html');
												thumbnails[5327596] = new thumbnail(5327596,'280468','','Dorn_Bowl_Sable_and_Oryx_WEB1_thumb.jpg',115, 130,5,'photo_5327596.html');
												thumbnails[5328733] = new thumbnail(5328733,'280479','','WEB_Lara_Storm_candle_Lily_of_the_Valley_thumb.jpg',87, 130,5,'photo_5328733.html');
												thumbnails[5328734] = new thumbnail(5328734,'280472','','Cullett_Castle_WEB1_thumb.jpg',112, 130,5,'photo_5328734.html');
												thumbnails[5328751] = new thumbnail(5328751,'280472','','Oslo_Bowl_Georgetown_House_WEB_thumb.jpg',130, 95,5,'photo_5328751.html');
												thumbnails[5328768] = new thumbnail(5328768,'280479','','Small_Freya_Bowl_Hibiscus_WEB_thumb.jpg',130, 124,5,'photo_5328768.html');
												thumbnails[5328811] = new thumbnail(5328811,'280471','','Fortuna_Footed_Crest_WEB_thumb.jpg',130, 101,5,'photo_5328811.html');
												thumbnails[5328813] = new thumbnail(5328813,'280472','','Fortuna_footed_Salisbury_Cathedral_WEB_thumb.jpg',130, 100,5,'photo_5328813.html');
												thumbnails[5328819] = new thumbnail(5328819,'280472','','Fortuna_Straight_Castle_WEB_thumb.jpg',130, 100,5,'photo_5328819.html');
												thumbnails[5328823] = new thumbnail(5328823,'280468','','Giant_Lara_Storm_Candle_Peacock_WEB_thumb.jpg',77, 130,5,'photo_5328823.html');
												thumbnails[5328824] = new thumbnail(5328824,'280472','','Fortuna_ftd_Eton_WEB_thumb.jpg',130, 104,5,'photo_5328824.html');
												thumbnails[5328875] = new thumbnail(5328875,'280478','','William_Yeoward_Bowl_RH_WEB_thumb.jpg',130, 98,5,'photo_5328875.html');
												thumbnails[5328879] = new thumbnail(5328879,'280479','','Dartington_Flora_small_vase_roses_WEB1_thumb.jpg',114, 130,5,'photo_5328879.html');
												thumbnails[5328885] = new thumbnail(5328885,'280479','','WEB_Dorn_platter_bowl_Honeysuckle_thumb.jpg',130, 109,5,'photo_5328885.html');
												thumbnails[5328901] = new thumbnail(5328901,'280478','','WEB_Dorn_Platter_lettering_thumb.jpg',130, 116,5,'photo_5328901.html');
												thumbnails[5328904] = new thumbnail(5328904,'280471','','WEB_Fortuna_Footed_Crest_2_thumb.jpg',130, 98,5,'photo_5328904.html');
												thumbnails[5328913] = new thumbnail(5328913,'280478','','WEB_Optical_Crystal_Book_award_thumb.jpg',106, 130,5,'photo_5328913.html');
												thumbnails[5328915] = new thumbnail(5328915,'280478','','WEB_Optical_Crystal_Plaque_Inscription_thumb.jpg',130, 108,5,'photo_5328915.html');
												thumbnails[5328926] = new thumbnail(5328926,'280471','','WEB_Spirit_decanter_crest_thumb.jpg',60, 130,5,'photo_5328926.html');
												thumbnails[5328934] = new thumbnail(5328934,'301766','','WEB_Porsche_Retirement_thumb.jpg',89, 130,5,'photo_5328934.html');
												thumbnails[5328978] = new thumbnail(5328978,'280478','','WEB_NOV_9_098_thumb.jpg',113, 130,5,'photo_5328978.html');
												thumbnails[5332214] = new thumbnail(5332214,'280472','','WEB_house_platter_thumb.jpg',130, 116,5,'photo_5332214.html');
												thumbnails[5332218] = new thumbnail(5332218,'280479','','WEB_Curly_platter_Grapes_thumb.jpg',130, 114,5,'photo_5332218.html');
												thumbnails[5332224] = new thumbnail(5332224,'280479','','WEB_Siena_Bowl_Shells_thumb.jpg',130, 100,5,'photo_5332224.html');
												thumbnails[5332225] = new thumbnail(5332225,'280472','','WEB_platter_life_interests_thumb.jpg',130, 117,5,'photo_5332225.html');
												thumbnails[5332229] = new thumbnail(5332229,'280472','','WEB_spirit_decanter_Corpus_Christi_thumb.jpg',65, 130,5,'photo_5332229.html');
												thumbnails[5332241] = new thumbnail(5332241,'280472','','WEB_spirit_decanter_Corpus_Christi_2_thumb.jpg',65, 130,5,'photo_5332241.html');
												thumbnails[5332388] = new thumbnail(5332388,'280478','','WEB_optical_crystal_block_with_signatures_and_shield_thumb.jpg',130, 95,5,'photo_5332388.html');
												thumbnails[5332397] = new thumbnail(5332397,'301767','','WEB_paperweight_with_Aston_thumb.jpg',130, 122,5,'photo_5332397.html');
												thumbnails[5332401] = new thumbnail(5332401,'280472','','WEB_Square_panel_with_church_thumb.jpg',130, 90,5,'photo_5332401.html');
												thumbnails[5332405] = new thumbnail(5332405,'301767','','WEB_tophy_with_racing_scene_thumb.jpg',130, 109,5,'photo_5332405.html');
												thumbnails[5332410] = new thumbnail(5332410,'280478','','WEB_optical_crystal_award_thumb.jpg',122, 130,5,'photo_5332410.html');
												thumbnails[5332492] = new thumbnail(5332492,'280478','','WEB_Optical_crystal_trophy_award_thumb.jpg',94, 130,5,'photo_5332492.html');
												thumbnails[5332497] = new thumbnail(5332497,'301767','','WEB_platter_the_Rocket_thumb.jpg',130, 102,5,'photo_5332497.html');
												thumbnails[5332727] = new thumbnail(5332727,'280471','','WEB_Chalice_with_Royal_Coat_of_arms_thumb.jpg',55, 130,5,'photo_5332727.html');
												thumbnails[5332728] = new thumbnail(5332728,'280471','','WEB_Royal_Scott_Society_flutes_thumb.jpg',115, 130,5,'photo_5332728.html');
												thumbnails[5359573] = new thumbnail(5359573,'301766','','WEB_Chapel_window_detail_thumb.jpg',121, 130,5,'photo_5359573.html');
												thumbnails[5359574] = new thumbnail(5359574,'301766','','WEB_HTB_panel_thumb.jpg',130, 97,5,'photo_5359574.html');
												thumbnails[5359575] = new thumbnail(5359575,'301766','','WEB_HTB_doors_thumb.jpg',98, 130,5,'photo_5359575.html');
												thumbnails[5359576] = new thumbnail(5359576,'301766','','WEB_livery_panel_thumb.jpg',89, 130,5,'photo_5359576.html');
												thumbnails[5359579] = new thumbnail(5359579,'301766','','WEB_Wychwood_School_panel_thumb.jpg',37, 130,5,'photo_5359579.html');
												thumbnails[5359581] = new thumbnail(5359581,'301766','','WEB_woodcock_window_thumb.jpg',130, 89,5,'photo_5359581.html');
												thumbnails[5359584] = new thumbnail(5359584,'301766','','WEB_Venice__panel_thumb.jpg',130, 44,5,'photo_5359584.html');
												thumbnails[5359588] = new thumbnail(5359588,'301766','','WEB_boardroom_portrait_thumb.jpg',104, 130,5,'photo_5359588.html');
												thumbnails[5359696] = new thumbnail(5359696,'301766','','WEB_Jesus_College_arms_panel_thumb.jpg',130, 125,5,'photo_5359696.html');
												thumbnails[5359699] = new thumbnail(5359699,'301766','','WEB_anniversary_panel_thumb.jpg',103, 130,5,'photo_5359699.html');
												thumbnails[5359701] = new thumbnail(5359701,'301766','','WEB_Door_panel_Cypriot_mosaic_design_thumb.jpg',130, 109,5,'photo_5359701.html');
												thumbnails[5359702] = new thumbnail(5359702,'301766','','WEB_Panel_lady_thumb.jpg',45, 130,5,'photo_5359702.html');
												thumbnails[5359704] = new thumbnail(5359704,'301766','','WEB_long-tailed_tits_panel_thumb.jpg',130, 124,5,'photo_5359704.html');
												thumbnails[5359708] = new thumbnail(5359708,'301766','','Chalet-Panel-11_thumb.jpg',98, 130,5,'photo_5359708.html');
												thumbnails[5359731] = new thumbnail(5359731,'301766','','WEB_Church_left_door_thumb.jpg',45, 130,5,'photo_5359731.html');
												thumbnails[5359734] = new thumbnail(5359734,'301766','','WEB_Church_right_door_thumb.jpg',41, 130,5,'photo_5359734.html');
												thumbnails[5359907] = new thumbnail(5359907,'301766','','WEB_New_Hang_Fook_camp_door_detail_thumb.jpg',98, 130,5,'photo_5359907.html');
												thumbnails[5359910] = new thumbnail(5359910,'301766','','WEB_New_Hang_Fook_Camp_inner_door_detail_thumb.jpg',75, 130,5,'photo_5359910.html');
												thumbnails[5359944] = new thumbnail(5359944,'301766','','WEB_New_Hang_Fook_Camp_inner_door_detail_2_thumb.jpg',130, 126,5,'photo_5359944.html');
												thumbnails[5359946] = new thumbnail(5359946,'301766','','WEB_New_Hang_Fook_Camp_inner_door_detail_3_thumb.jpg',129, 130,5,'photo_5359946.html');
												thumbnails[5359957] = new thumbnail(5359957,'301766','','WEB_New_Hang_Fook_Camp_inner_doors_thumb.jpg',130, 89,5,'photo_5359957.html');
												thumbnails[5359963] = new thumbnail(5359963,'301766','','WEB_New_Hang_Fook_camp_outer_doors_thumb.jpg',130, 91,5,'photo_5359963.html');
												thumbnails[5360309] = new thumbnail(5360309,'280479','','WEB_vase_with_dogrose_thumb.jpg',80, 130,5,'photo_5360309.html');
												thumbnails[5360335] = new thumbnail(5360335,'280479','','WEB_foxgloves_3_thumb.jpg',49, 130,5,'photo_5360335.html');
												thumbnails[5360346] = new thumbnail(5360346,'301767','','WEB_Elke_thumb.jpg',77, 130,5,'photo_5360346.html');
												thumbnails[5360357] = new thumbnail(5360357,'301767','','WEB_Dragon_vase_2_thumb.jpg',95, 130,5,'photo_5360357.html');
												thumbnails[5360373] = new thumbnail(5360373,'280479','','WEB_dog_rose_vase_2_thumb.jpg',51, 130,5,'photo_5360373.html');
												thumbnails[5360467] = new thumbnail(5360467,'301767','','WEB_flat_vase_with_dancer_thumb.jpg',108, 130,5,'photo_5360467.html');
												thumbnails[5365488] = new thumbnail(5365488,'280468','','WEB_Tumbler_pheasant_thumb.jpg',103, 130,5,'photo_5365488.html');
												thumbnails[5170435] = new thumbnail(5170435,'280472','','Oslo_Bowl_House5_thumb.jpg',130, 89,5,'photo_5170435.html');
												thumbnails[5178417] = new thumbnail(5178417,'280472','','Fortuna_Straight_Chalet640_thumb.jpg',130, 95,5,'photo_5178417.html');
												thumbnails[5180369] = new thumbnail(5180369,'280468','','Cullett_Zebra_drinking640_thumb.jpg',130, 75,5,'photo_5180369.html');
												thumbnails[5180388] = new thumbnail(5180388,'280468','','Swarovski_Cheetah640_thumb.jpg',130, 63,5,'photo_5180388.html');

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  					galleries[280468] = new gallery(280468,'5180381','Wildlife','gallery',[5180370,5180372,5180375,5180378,5180380,5180381,5180384,5180386,5180389,5317287,5327254,5327596,5328823,5365488,5180369,5180388],0, 0, '', 'gallery_280468.html',0,0);
				  					galleries[280472] = new gallery(280472,'4929946','Architecture','gallery',[4929946,5170440,5178522,5328734,5328751,5328813,5328819,5328824,5332214,5332225,5332229,5332241,5332401,5170435,5178417],0, 0, '', 'gallery_280472.html',0,0);
				  					galleries[280478] = new gallery(280478,'5180444','Logos and Lettering','gallery',[5180440,5180443,5180444,5180446,5180447,5328875,5328901,5328913,5328915,5328978,5332388,5332410,5332492],0, 0, '', 'gallery_280478.html',0,0);
				  					galleries[280479] = new gallery(280479,'5180456','Floral','gallery',[5180456,5180458,5180459,5328733,5328768,5328879,5328885,5332218,5332224,5360309,5360335,5360373],0, 0, '', 'gallery_280479.html',0,0);
				  					galleries[280471] = new gallery(280471,'5180416','Heraldry','gallery',[5180408,5180410,5180413,5180416,5180419,5328811,5328904,5328926,5332727,5332728],0, 0, '', 'gallery_280471.html',0,0);
				  					galleries[301766] = new gallery(301766,'5359963','Larger-scale ','gallery',[5180485,5328934,5359573,5359574,5359575,5359576,5359579,5359581,5359584,5359588,5359696,5359699,5359701,5359702,5359704,5359708,5359731,5359734,5359907,5359910,5359944,5359946,5359957,5359963],0, 0, '', 'gallery_301766.html',0,0);
				  					galleries[301767] = new gallery(301767,'5360467','Other','gallery',[5180445,5332397,5332405,5332497,5360346,5360357,5360467],0, 0, '', 'gallery_301767.html',0,0);
				  					galleries[280431] = new gallery(280431,'5090203','On Display','gallery',[5090203,5190875],0, 0, '', 'gallery_280431.html',0,0);
/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = new Object();
imageSets[1] = '5180381';
imageSets[2] = '5360467,5359963,5180456,5180444,5180416,5180381,5090203,4929946';
imageSets[3] = '6563081,5365488,5360467,5360373,5360357,5360346,5360335,5360309,5359963,5359957,5359946,5359944,5359910,5359907,5359734,5359731,5359708,5359704,5359702,5359701,5359699,5359696,5359588,5359584,5359581,5359579,5359576,5359575,5359574,5359573,5332728,5332727,5332497,5332492,5332410,5332405,5332401,5332397,5332388,5332241,5332229,5332225,5332224,5332218,5332214,5328978,5328934,5328926,5328915,5328913';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/philiplawsonjohnston/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/philiplawsonjohnston/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/philiplawsonjohnston/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/philiplawsonjohnston/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/philiplawsonjohnston/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/philiplawsonjohnston/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/philiplawsonjohnston/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/philiplawsonjohnston/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/philiplawsonjohnston/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/philiplawsonjohnston/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/philiplawsonjohnston/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/philiplawsonjohnston/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/philiplawsonjohnston/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/philiplawsonjohnston/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/philiplawsonjohnston/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://admin2.clikpic.com/philiplawsonjohnston/images';
		break;
	}
		switch (server_id) {
		case 33:
		val = 'http://www8.clikpic.com/philiplawsonjohnston/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/philiplawsonjohnston/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/philiplawsonjohnston/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/philiplawsonjohnston/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/philiplawsonjohnston/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/philiplawsonjohnston/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 = 'Philip Lawson Johnston: ' + 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;
	}
}

			

