window.thumbnails = new Object();
												thumbnails[5101455] = new thumbnail(5101455,'63839','','Image_1_thumb.jpg',130, 130,1,'							photo_5101455.html');
												thumbnails[5101459] = new thumbnail(5101459,'63839','','Image_2_thumb.jpg',130, 130,1,'							photo_5101459.html');
												thumbnails[5101462] = new thumbnail(5101462,'63839','','Image_4_thumb.jpg',130, 130,1,'							photo_5101462.html');
												thumbnails[5101464] = new thumbnail(5101464,'63839','','Image_5_thumb.jpg',130, 130,1,'							photo_5101464.html');
												thumbnails[5101466] = new thumbnail(5101466,'63839','','Image_6_thumb.jpg',130, 130,1,'							photo_5101466.html');
												thumbnails[5101472] = new thumbnail(5101472,'63839','','Image_12_thumb.jpg',130, 130,1,'							photo_5101472.html');
												thumbnails[5101474] = new thumbnail(5101474,'63839','','Image_13_thumb.jpg',130, 130,1,'							photo_5101474.html');
												thumbnails[5101483] = new thumbnail(5101483,'63839','','Image_16_thumb.jpg',130, 130,1,'							photo_5101483.html');
												thumbnails[5101485] = new thumbnail(5101485,'63839','','Image_17_thumb.jpg',130, 130,1,'							photo_5101485.html');
												thumbnails[5101491] = new thumbnail(5101491,'63839','','Image_20_thumb.jpg',130, 130,1,'							photo_5101491.html');
												thumbnails[5101494] = new thumbnail(5101494,'63839','','Image_21_thumb.jpg',130, 130,1,'							photo_5101494.html');
												thumbnails[5101497] = new thumbnail(5101497,'63839','','Image_23_thumb.jpg',130, 130,1,'							photo_5101497.html');
												thumbnails[5101498] = new thumbnail(5101498,'63839','','Image_24_thumb.jpg',130, 130,1,'							photo_5101498.html');
												thumbnails[5101500] = new thumbnail(5101500,'63839','','Image_25_thumb.jpg',130, 130,1,'							photo_5101500.html');
												thumbnails[5101503] = new thumbnail(5101503,'63839','','Image_27_thumb.jpg',130, 130,1,'							photo_5101503.html');
												thumbnails[5101505] = new thumbnail(5101505,'63839','','Image_29_thumb.jpg',130, 130,1,'							photo_5101505.html');
												thumbnails[5101509] = new thumbnail(5101509,'63839','','Image_32_thumb.jpg',130, 130,1,'							photo_5101509.html');
												thumbnails[5101510] = new thumbnail(5101510,'63839','','Image_33_thumb.jpg',130, 130,1,'							photo_5101510.html');
												thumbnails[5101512] = new thumbnail(5101512,'63839','','Image_34_thumb.jpg',130, 130,1,'							photo_5101512.html');
												thumbnails[5101515] = new thumbnail(5101515,'63839','','Image_35_thumb.jpg',130, 130,1,'							photo_5101515.html');
												thumbnails[5101518] = new thumbnail(5101518,'63839','','Image_36_thumb.jpg',130, 130,1,'							photo_5101518.html');
												thumbnails[5101522] = new thumbnail(5101522,'63839','','Image_37_thumb.jpg',130, 130,1,'							photo_5101522.html');
												thumbnails[5101525] = new thumbnail(5101525,'63839','','Image_38_thumb.jpg',130, 130,1,'							photo_5101525.html');
												thumbnails[5101541] = new thumbnail(5101541,'63839','','Image_39_thumb.jpg',130, 130,1,'							photo_5101541.html');
												thumbnails[5101560] = new thumbnail(5101560,'63839','','Image_40_thumb.jpg',130, 130,1,'							photo_5101560.html');
												thumbnails[5101562] = new thumbnail(5101562,'63839','','Image_41_thumb.jpg',130, 130,1,'							photo_5101562.html');
												thumbnails[5101563] = new thumbnail(5101563,'63839','','Image_42_thumb.jpg',130, 130,1,'							photo_5101563.html');
												thumbnails[5101565] = new thumbnail(5101565,'63839','','Image_43_thumb.jpg',130, 130,1,'							photo_5101565.html');
												thumbnails[5101566] = new thumbnail(5101566,'63839','','Image_44_thumb.jpg',130, 130,1,'							photo_5101566.html');
												thumbnails[5101567] = new thumbnail(5101567,'63839','','Image_45_thumb.jpg',130, 130,1,'							photo_5101567.html');
												thumbnails[5101569] = new thumbnail(5101569,'63839','','Image_46_thumb.jpg',130, 130,1,'							photo_5101569.html');
												thumbnails[5101570] = new thumbnail(5101570,'63839','','Image_47_thumb.jpg',130, 130,1,'							photo_5101570.html');
												thumbnails[5101573] = new thumbnail(5101573,'63839','','Image_48_thumb.jpg',130, 130,1,'							photo_5101573.html');
												thumbnails[5101575] = new thumbnail(5101575,'63839','','Image_49_thumb.jpg',130, 130,1,'							photo_5101575.html');
												thumbnails[5101577] = new thumbnail(5101577,'63839','','Image_50_thumb.jpg',130, 130,1,'							photo_5101577.html');
												thumbnails[5101579] = new thumbnail(5101579,'63839','','Image_51_thumb.jpg',130, 130,1,'							photo_5101579.html');
												thumbnails[5101581] = new thumbnail(5101581,'63839','','Image_52_thumb.jpg',130, 130,1,'							photo_5101581.html');
												thumbnails[5101584] = new thumbnail(5101584,'63839','','Image_54_thumb.jpg',130, 130,1,'							photo_5101584.html');
												thumbnails[5101587] = new thumbnail(5101587,'63839','','Image_55_thumb.jpg',130, 130,1,'							photo_5101587.html');
												thumbnails[5101590] = new thumbnail(5101590,'63839','','Image_57_thumb.jpg',130, 130,1,'							photo_5101590.html');
												thumbnails[4911473] = new thumbnail(4911473,'63839','','Image5_thumb.jpg',130, 130,1,'							photo_4911473.html');
												thumbnails[4911476] = new thumbnail(4911476,'63839','','Image7_thumb.jpg',130, 130,1,'							photo_4911476.html');
												thumbnails[4911469] = new thumbnail(4911469,'63839','','Image2_thumb.jpg',130, 130,1,'							photo_4911469.html');
												thumbnails[4911478] = new thumbnail(4911478,'63839','','Image8_thumb.jpg',130, 130,1,'							photo_4911478.html');
												thumbnails[4911480] = new thumbnail(4911480,'63839','','Image9_thumb.jpg',130, 130,1,'							photo_4911480.html');
												thumbnails[4911488] = new thumbnail(4911488,'63839','','Image12_thumb.jpg',130, 130,1,'							photo_4911488.html');
												thumbnails[4911490] = new thumbnail(4911490,'63839','','Image14_thumb.jpg',130, 130,1,'							photo_4911490.html');
												thumbnails[4911493] = new thumbnail(4911493,'63839','','Image17_thumb.jpg',130, 130,1,'							photo_4911493.html');
												thumbnails[4911492] = new thumbnail(4911492,'63839','','Image16_thumb.jpg',130, 130,1,'							photo_4911492.html');
												thumbnails[4911491] = new thumbnail(4911491,'63839','','Image15_thumb.jpg',130, 130,1,'							photo_4911491.html');
												thumbnails[4911494] = new thumbnail(4911494,'63839','','Image18_thumb.jpg',130, 130,1,'							photo_4911494.html');
												thumbnails[4911496] = new thumbnail(4911496,'63839','','Image20_thumb.jpg',130, 130,1,'							photo_4911496.html');
												thumbnails[4911499] = new thumbnail(4911499,'63839','','Image22_thumb.jpg',130, 130,1,'							photo_4911499.html');
												thumbnails[4911497] = new thumbnail(4911497,'63839','','Image21_thumb.jpg',130, 130,1,'							photo_4911497.html');
												thumbnails[4911500] = new thumbnail(4911500,'63839','','Image23_thumb.jpg',130, 130,1,'							photo_4911500.html');
												thumbnails[4911501] = new thumbnail(4911501,'63839','','Image24_thumb.jpg',130, 130,1,'							photo_4911501.html');
												thumbnails[4911504] = new thumbnail(4911504,'63839','','Image25_thumb.jpg',130, 130,1,'							photo_4911504.html');
												thumbnails[4911512] = new thumbnail(4911512,'63839','','Image29_thumb.jpg',130, 130,1,'							photo_4911512.html');
												thumbnails[4911509] = new thumbnail(4911509,'63839','','Image27_thumb.jpg',130, 130,1,'							photo_4911509.html');
												thumbnails[4911522] = new thumbnail(4911522,'63839','','Image30_thumb.jpg',130, 130,1,'							photo_4911522.html');
												thumbnails[4911511] = new thumbnail(4911511,'63839','','Image28_thumb.jpg',130, 130,1,'							photo_4911511.html');
												thumbnails[4911489] = new thumbnail(4911489,'63839','','Image13_thumb.jpg',130, 130,1,'							photo_4911489.html');
												thumbnails[843869] = new thumbnail(843869,'306410','','Wedding-3_thumb.jpg',130, 130,1,'							photo_843869.html');
												thumbnails[843872] = new thumbnail(843872,'306410','','Wedding-6_thumb.jpg',130, 130,1,'							photo_843872.html');
												thumbnails[843875] = new thumbnail(843875,'306410','','Wedding-8_thumb.jpg',130, 130,1,'							photo_843875.html');
												thumbnails[843868] = new thumbnail(843868,'306410','','Wedding-2_thumb.jpg',130, 130,1,'							photo_843868.html');
												thumbnails[843876] = new thumbnail(843876,'306410','','Wedding-9_thumb.jpg',130, 130,1,'							photo_843876.html');
												thumbnails[843866] = new thumbnail(843866,'306410','','Wedding-1_thumb.jpg',130, 130,1,'							photo_843866.html');
												thumbnails[843877] = new thumbnail(843877,'306410','','Wedding-10_thumb.jpg',130, 130,1,'							photo_843877.html');
												thumbnails[843885] = new thumbnail(843885,'306410','','Wedding-16_thumb.jpg',130, 130,1,'							photo_843885.html');
												thumbnails[843880] = new thumbnail(843880,'306410','','Wedding-12_thumb.jpg',130, 130,1,'							photo_843880.html');
												thumbnails[843870] = new thumbnail(843870,'306410','','Wedding-4_thumb.jpg',130, 130,1,'							photo_843870.html');
												thumbnails[4911471] = new thumbnail(4911471,'306410','','Image3_thumb.jpg',130, 130,1,'							photo_4911471.html');
												thumbnails[4911475] = new thumbnail(4911475,'306410','','Image6_thumb.jpg',130, 130,1,'							photo_4911475.html');
												thumbnails[4910241] = new thumbnail(4910241,'306410','','Image1_thumb.jpg',130, 130,1,'							photo_4910241.html');
												thumbnails[843871] = new thumbnail(843871,'306410','','Wedding-5_thumb.jpg',130, 130,1,'							photo_843871.html');
												thumbnails[843873] = new thumbnail(843873,'306410','','Wedding-7_thumb.jpg',130, 130,1,'							photo_843873.html');
												thumbnails[4911472] = new thumbnail(4911472,'306410','','Image4_thumb.jpg',130, 130,1,'							photo_4911472.html');
												thumbnails[836932] = new thumbnail(836932,'63840','Happy girl','Happy_girl_thumb.jpg',130, 130,1,'							photo_836932.html');
												thumbnails[836947] = new thumbnail(836947,'63840','','Baby_Katie_thumb.jpg',130, 130,1,'							photo_836947.html');
												thumbnails[840514] = new thumbnail(840514,'63840','The Ice Queen','Ice_Queen_thumb.jpg',130, 130,1,'							photo_840514.html');
												thumbnails[840519] = new thumbnail(840519,'63840','Childhood Innocence','Innocence_of_childhood_thumb.jpg',130, 130,1,'							photo_840519.html');
												thumbnails[840538] = new thumbnail(840538,'63840','Party Girl','Party_girl_thumb.jpg',130, 130,1,'							photo_840538.html');
												thumbnails[840560] = new thumbnail(840560,'63840','Best friends','Friends2_thumb.jpg',130, 130,1,'							photo_840560.html');
												thumbnails[840565] = new thumbnail(840565,'63840','Two friends','two_Friends_thumb.jpg',130, 130,1,'							photo_840565.html');
												thumbnails[843858] = new thumbnail(843858,'63840','','Portrait-1_thumb.jpg',130, 130,1,'							photo_843858.html');
												thumbnails[843859] = new thumbnail(843859,'63840','','Portrait-2_thumb.jpg',130, 130,1,'							photo_843859.html');
												thumbnails[843860] = new thumbnail(843860,'63840','','Portrait-3_thumb.jpg',130, 130,1,'							photo_843860.html');
												thumbnails[843861] = new thumbnail(843861,'63840','','Portrait-4_thumb.jpg',130, 130,1,'							photo_843861.html');
												thumbnails[843862] = new thumbnail(843862,'63840','','Portrait-5_thumb.jpg',130, 130,1,'							photo_843862.html');
												thumbnails[843863] = new thumbnail(843863,'63840','','Portrait-6_thumb.jpg',130, 130,1,'							photo_843863.html');
												thumbnails[843864] = new thumbnail(843864,'63840','','Portrait-8_thumb.jpg',130, 130,1,'							photo_843864.html');
												thumbnails[843865] = new thumbnail(843865,'63840','','Portrait-7_thumb.jpg',130, 130,1,'							photo_843865.html');
												thumbnails[849701] = new thumbnail(849701,'63840','Daffodil Girl','Daffodil-girl_thumb.jpg',130, 130,1,'							photo_849701.html');
												thumbnails[850239] = new thumbnail(850239,'63840','Happy girl again','Happy_girl-1_thumb.jpg',130, 130,1,'							photo_850239.html');
												thumbnails[850241] = new thumbnail(850241,'63840','My daughter and friend','Two-friends-again_thumb.jpg',130, 130,1,'							photo_850241.html');
												thumbnails[836949] = new thumbnail(836949,'63841','Medieval banquet Salisbury July 06','Medieval_night_thumb.jpg',130, 130,1,'							photo_836949.html');
												thumbnails[843886] = new thumbnail(843886,'63841','','Event-1_thumb.jpg',130, 130,1,'							photo_843886.html');
												thumbnails[843887] = new thumbnail(843887,'63841','','Event-2_thumb.jpg',130, 130,1,'							photo_843887.html');
												thumbnails[843888] = new thumbnail(843888,'63841','','Event-3_thumb.jpg',130, 130,1,'							photo_843888.html');
												thumbnails[843889] = new thumbnail(843889,'63841','','Event-4_thumb.jpg',130, 130,1,'							photo_843889.html');
												thumbnails[843890] = new thumbnail(843890,'63841','','Event-5_thumb.jpg',130, 130,1,'							photo_843890.html');
												thumbnails[843891] = new thumbnail(843891,'63841','','Event-6_thumb.jpg',130, 130,1,'							photo_843891.html');
												thumbnails[843892] = new thumbnail(843892,'63841','','Event-7_thumb.jpg',130, 130,1,'							photo_843892.html');
												thumbnails[843893] = new thumbnail(843893,'63841','','Event-8_thumb.jpg',130, 130,1,'							photo_843893.html');
												thumbnails[843894] = new thumbnail(843894,'63841','','Event-9_thumb.jpg',130, 130,1,'							photo_843894.html');
												thumbnails[1557065] = new thumbnail(1557065,'63841','Police Ball Oct 07','Group 1_thumb.jpg',130, 130,1,'							photo_1557065.html');
												thumbnails[1557116] = new thumbnail(1557116,'63841','Police Ball Oct 07','Girls group_thumb.jpg',130, 130,1,'							photo_1557116.html');
												thumbnails[1557232] = new thumbnail(1557232,'63841','Military Mess Function June 07','Army Mess function_thumb.jpg',130, 130,1,'							photo_1557232.html');
												thumbnails[836928] = new thumbnail(836928,'63842','Copper Beech Tree','Copper_Beech_thumb.jpg',130, 130,1,'							photo_836928.html');
												thumbnails[836952] = new thumbnail(836952,'63842','Durdle Door Dorset','Durdle_Door_Dorset_thumb.jpg',130, 130,1,'							photo_836952.html');
												thumbnails[836954] = new thumbnail(836954,'63842','Early morning mist','Early_morning_Woodford_Vall_thumb.jpg',130, 130,1,'							photo_836954.html');
												thumbnails[840543] = new thumbnail(840543,'63842','Harbour reflections','Harbour_reflections_thumb.jpg',130, 130,1,'							photo_840543.html');
												thumbnails[840555] = new thumbnail(840555,'63842','Lake District Sunrise','Lake_District_sunrise_thumb.jpg',130, 130,1,'							photo_840555.html');
												thumbnails[840558] = new thumbnail(840558,'63842','Waterfall Stourhead Gardens','Stourhead_Waterfall_thumb.jpg',130, 130,1,'							photo_840558.html');
												thumbnails[847793] = new thumbnail(847793,'63842','A Ploughed Field','Field-of-corn_thumb.jpg',130, 130,1,'							photo_847793.html');
												thumbnails[850234] = new thumbnail(850234,'63842','The Cloisters at Lacock Abbey','Lacock-Abbey_thumb.jpg',130, 130,1,'							photo_850234.html');
												thumbnails[836955] = new thumbnail(836955,'63843','Fan Palm','Fan_Palm_thumb.jpg',130, 130,1,'							photo_836955.html');
												thumbnails[836956] = new thumbnail(836956,'63843','','Flower_closeup_thumb.jpg',130, 130,1,'							photo_836956.html');
												thumbnails[836959] = new thumbnail(836959,'63843','Yellow Flower','Flower_closeup_1_thumb.jpg',130, 130,1,'							photo_836959.html');
												thumbnails[836961] = new thumbnail(836961,'63843','','Poppy_thumb.jpg',130, 130,1,'							photo_836961.html');
												thumbnails[840559] = new thumbnail(840559,'63843','King Charles Spaniel','King_Charles_Spaniel_thumb.jpg',130, 130,1,'							photo_840559.html');

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  	  					galleries[63839] = new gallery(63839,'5101590,5101587,5101584,5101581,5101579,5101577,5101575,5101573,5101570,5101569','Weddings 1','gallery',[5101455,5101459,5101462,5101464,5101466,5101472,5101474,5101483,5101485,5101491,5101494,5101497,5101498,5101500,5101503,5101505,5101509,5101510,5101512,5101515,5101518,5101522,5101525,5101541,5101560,5101562,5101563,5101565,5101566,5101567,5101569,5101570,5101573,5101575,5101577,5101579,5101581,5101584,5101587,5101590,4911473,4911476,4911469,4911478,4911480,4911488,4911490,4911493,4911492,4911491,4911494,4911496,4911499,4911497,4911500,4911501,4911504,4911512,4911509,4911522,4911511,4911489],0, 0, '', '																																																																																																							gallery_63839.html',0,0);
				  	  					galleries[306410] = new gallery(306410,'843885,843880,843877,843876,843875,843873,843872,843871,843870,843869,843868,843866','Weddings 2','gallery',[843869,843872,843875,843868,843876,843866,843877,843885,843880,843870,4911471,4911475,4910241,843871,843873,4911472],0, 0, '', '																																																																																																							gallery_306410.html',0,0);
				  	  					galleries[63840] = new gallery(63840,'850241,850239,849701,843865,843864,843863,843862,843860,843859,843858,840565,840560,840538,840519,840514,836932','Portraits','gallery',[836932,836947,840514,840519,840538,840560,840565,843858,843859,843860,843861,843862,843863,843864,843865,849701,850239,850241],0, 0, '', '																																																																																																							gallery_63840.html',0,0);
				  	  					galleries[63841] = new gallery(63841,'843894,843893,843892,843891,843890,843889,843888,843887,843886,836949','Events','gallery',[836949,843886,843887,843888,843889,843890,843891,843892,843893,843894,1557065,1557116,1557232],0, 0, '', '																																																																																																							gallery_63841.html',0,0);
				  	  					galleries[63842] = new gallery(63842,'850234,847793,840558,840555,840543,836952,836928','Landscapes','gallery',[836928,836952,836954,840543,840555,840558,847793,850234],0, 0, '', '																																																																																																							gallery_63842.html',0,0);
				  	  					galleries[63843] = new gallery(63843,'836961,836959,836956,836955','Misc','gallery',[836955,836956,836959,836961,840559],0, 0, '', '																																																																																																							gallery_63843.html',0,0);
/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = new Object();
imageSets[1] = '850241,850239,850234,849701,847793,843894,843893,843892,843891,843890,843889,843888,843887,843886,843885,843880,843877,843876,843875,843873,843872,843871,843870,843869,843868,843866,843865,843864,843863,843862,843860,843859,843858,840565,840560,840558,840555,840543,840538,840519,840514,836959,836956,836955,836952,836932,836928';
imageSets[2] = '850241,850239,850234,849701,847793,843894,843893,843892,843891,843890,843889,843888,843887,843886,843885,843880,843877,843876,843875,843873,843872,843871,843870,843869,843868,843866,843865,843864,843863,843862,843860,843859,843858,840565,840560,840558,840555,840543,840538,840519,840514,836961,836959,836956,836955,836952,836949,836932,836928';
imageSets[3] = '5101590,5101587,5101584,5101581,5101579,5101577,5101575,5101573,5101570,5101569,5101567,5101566,5101565,5101563,5101562,5101560,5101541,5101525,5101522,5101518,5101515,5101512,5101510,5101509,5101505,5101503,5101500,5101498,5101497,5101494,5101491,5101485,5101483,5101474,5101472,5101466,5101464,5101462,5101459,5101455,4911522,4911512,4911511,4911509,4911504,4911501,4911500,4911499,4911497,4911496';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/Defencephot/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/Defencephot/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/Defencephot/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/Defencephot/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://www.clikchurch.com/Defencephot/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/Defencephot/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/Defencephot/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/Defencephot/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/Defencephot/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/Defencephot/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/Defencephot/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/Defencephot/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/Defencephot/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://admin2.clikpic.com/Defencephot/images';
		break;
	}
		switch (server_id) {
		case 33:
		val = 'http://www8.clikpic.com/Defencephot/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/Defencephot/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/Defencephot/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/Defencephot/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/Defencephot/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));		}, 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 = 'GDR Photography: ' + photoCaption;
			    }
        if (op.$detail.length > 0) {
      temp = op.nextPhoto.fnGetImageDetails();
	    op.$detail.fadeGalleryDetails(temp, op.speed, function(){
	    var options = {};	    	      	      resizePhotoInfo(options);
        if (typeof(backgrounds) != 'undefined' && op.nextPhoto == backgrounds[op.nextPhoto.id]) {
  	      toggleAddToCartConfirm(backgrounds);
  	    } else if (typeof(photos) != 'undefined' && op.nextPhoto == photos[op.nextPhoto.id]) {
  	      toggleAddToCartConfirm(photos);
  	    }
	    });
    }
        if (!op.speed) {      clik.doColumnResize(false, op.$photo.add(op.$detail).add(op.$title));    }        
    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;
	}
}

		

