window.thumbnails = {};
															thumbnails[949892] = clik.newPhoto({"id":949892,"src":"Mr and Mrs Duck_thumb.jpg","galleries_id":365170,"server_id":18,"link":"photo_949892.html","width":130,"caption":"Mr and Mrs !","height":98});
															thumbnails[950000] = clik.newPhoto({"id":950000,"src":"sunset furzton lake_thumb.jpg","galleries_id":365170,"server_id":18,"link":"photo_950000.html","width":130,"caption":"","height":98});
															thumbnails[950001] = clik.newPhoto({"id":950001,"src":"sunset willen lake_thumb.jpg","galleries_id":365170,"server_id":18,"link":"photo_950001.html","width":130,"caption":"","height":98});
															thumbnails[950002] = clik.newPhoto({"id":950002,"src":"firework1_thumb.JPG","galleries_id":69061,"server_id":18,"link":"photo_950002.html","width":130,"caption":"Firework 2006","height":112});
															thumbnails[1133782] = clik.newPhoto({"id":1133782,"src":"church2 storm clouds resize_thumb.jpg","galleries_id":365170,"server_id":18,"link":"photo_1133782.html","width":130,"caption":"Storm clouds Brewing","height":94});
															thumbnails[1156689] = clik.newPhoto({"id":1156689,"src":"heron_thumb.jpg","galleries_id":69033,"server_id":18,"link":"photo_1156689.html","width":130,"caption":"","height":186});
															thumbnails[1227632] = clik.newPhoto({"id":1227632,"src":"Macro Flower 2_thumb.jpg","galleries_id":69033,"server_id":18,"link":"photo_1227632.html","width":130,"caption":"","height":92});
															thumbnails[1384327] = clik.newPhoto({"id":1384327,"src":"6435  F1_thumb.jpg","galleries_id":101768,"server_id":18,"link":"photo_1384327.html","width":130,"caption":"Renault F1 Donnington Sept 2007","height":59});
															thumbnails[1475464] = clik.newPhoto({"id":1475464,"src":"IMG_7610 web_thumb.jpg","galleries_id":365170,"server_id":18,"link":"photo_1475464.html","width":130,"caption":"Glen Etive","height":89});
															thumbnails[1477869] = clik.newPhoto({"id":1477869,"src":"2007 09 28 008_thumb.jpg","galleries_id":365170,"server_id":18,"link":"photo_1477869.html","width":130,"caption":"Grangemouth","height":89});
															thumbnails[1477870] = clik.newPhoto({"id":1477870,"src":"2007 09 28 018_thumb.jpg","galleries_id":365170,"server_id":18,"link":"photo_1477870.html","width":130,"caption":"Grangemouth","height":82});
															thumbnails[1483963] = clik.newPhoto({"id":1483963,"src":"normal_IMG_6922_thumb.jpg","galleries_id":365170,"server_id":18,"link":"photo_1483963.html","width":130,"caption":"","height":87});
															thumbnails[1501438] = clik.newPhoto({"id":1501438,"src":"2007 10 19 357_thumb.jpg","galleries_id":365170,"server_id":18,"link":"photo_1501438.html","width":130,"caption":"Autumn Colour","height":89});
															thumbnails[4866268] = clik.newPhoto({"id":4866268,"src":"snetterton-110709-1006_thumb.jpg","galleries_id":101768,"server_id":18,"link":"photo_4866268.html","width":130,"caption":"","height":87});
															thumbnails[4866270] = clik.newPhoto({"id":4866270,"src":"snetterton-110709-1169_thumb.jpg","galleries_id":101768,"server_id":18,"link":"photo_4866270.html","width":130,"caption":"","height":87});
															thumbnails[4866278] = clik.newPhoto({"id":4866278,"src":"snetterton-110709-652_thumb.jpg","galleries_id":101768,"server_id":18,"link":"photo_4866278.html","width":130,"caption":"","height":87});
															thumbnails[6685681] = clik.newPhoto({"id":6685681,"src":"GabyNigel-070309-1-1_thumb.jpg","galleries_id":365174,"server_id":18,"link":"photo_6685681.html","width":130,"caption":"","height":78});
															thumbnails[6685683] = clik.newPhoto({"id":6685683,"src":"GabyNigel-070309-2-2_thumb.jpg","galleries_id":365174,"server_id":18,"link":"photo_6685683.html","width":130,"caption":"","height":195});
															thumbnails[6685686] = clik.newPhoto({"id":6685686,"src":"GabyNigel-070309-16-3_thumb.jpg","galleries_id":365174,"server_id":18,"link":"photo_6685686.html","width":130,"caption":"","height":87});
															thumbnails[6685687] = clik.newPhoto({"id":6685687,"src":"GabyNigel-070309-24-4_thumb.jpg","galleries_id":365174,"server_id":18,"link":"photo_6685687.html","width":130,"caption":"","height":163});
															thumbnails[6685688] = clik.newPhoto({"id":6685688,"src":"GabyNigel-070309-26-5_thumb.jpg","galleries_id":365174,"server_id":18,"link":"photo_6685688.html","width":130,"caption":"","height":163});
															thumbnails[6685689] = clik.newPhoto({"id":6685689,"src":"GabyNigel-070309-203-9_thumb.jpg","galleries_id":365174,"server_id":18,"link":"photo_6685689.html","width":130,"caption":"","height":163});
															thumbnails[6685690] = clik.newPhoto({"id":6685690,"src":"vk-wedding-050909-69-15_thumb.jpg","galleries_id":365174,"server_id":18,"link":"photo_6685690.html","width":130,"caption":"","height":189});
															thumbnails[6685692] = clik.newPhoto({"id":6685692,"src":"vk-wedding-050909-168-16_thumb.jpg","galleries_id":365174,"server_id":18,"link":"photo_6685692.html","width":130,"caption":"","height":195});
															thumbnails[6685694] = clik.newPhoto({"id":6685694,"src":"vk-wedding-050909-178-17_thumb.jpg","galleries_id":365174,"server_id":18,"link":"photo_6685694.html","width":130,"caption":"","height":57});
															thumbnails[6685695] = clik.newPhoto({"id":6685695,"src":"vk-wedding-050909-357-Edit-19_thumb.jpg","galleries_id":365174,"server_id":18,"link":"photo_6685695.html","width":130,"caption":"","height":86});
															thumbnails[6685696] = clik.newPhoto({"id":6685696,"src":"vk-wedding-050909-362-18_thumb.jpg","galleries_id":365174,"server_id":18,"link":"photo_6685696.html","width":130,"caption":"","height":195});
															thumbnails[6685698] = clik.newPhoto({"id":6685698,"src":"wedding-lesley-andy-260909-259-14_thumb.jpg","galleries_id":365174,"server_id":18,"link":"photo_6685698.html","width":130,"caption":"","height":114});
															thumbnails[6685699] = clik.newPhoto({"id":6685699,"src":"wedding-lesley-andy-260909-111-13_thumb.jpg","galleries_id":365174,"server_id":18,"link":"photo_6685699.html","width":130,"caption":"","height":93});
															thumbnails[6685788] = clik.newPhoto({"id":6685788,"src":"2009-01-27-dani-024-1_thumb.jpg","galleries_id":365175,"server_id":18,"link":"photo_6685788.html","width":130,"caption":"","height":87});
															thumbnails[6685789] = clik.newPhoto({"id":6685789,"src":"annette170810-5-1_thumb.jpg","galleries_id":365175,"server_id":18,"link":"photo_6685789.html","width":130,"caption":"","height":186});
															thumbnails[6685790] = clik.newPhoto({"id":6685790,"src":"annette170810-5-Edit-2_thumb.jpg","galleries_id":365175,"server_id":18,"link":"photo_6685790.html","width":130,"caption":"","height":186});
															thumbnails[6685791] = clik.newPhoto({"id":6685791,"src":"baby-photos-030710-71-Edit-Edit-1_thumb.jpg","galleries_id":365175,"server_id":18,"link":"photo_6685791.html","width":130,"caption":"","height":106});
															thumbnails[6685792] = clik.newPhoto({"id":6685792,"src":"Cat-170309-18-1_thumb.jpg","galleries_id":365175,"server_id":18,"link":"photo_6685792.html","width":130,"caption":"","height":87});
															thumbnails[6685793] = clik.newPhoto({"id":6685793,"src":"honey-aylisha-210409-28-Edit-1_thumb.jpg","galleries_id":365175,"server_id":18,"link":"photo_6685793.html","width":130,"caption":"","height":101});
															thumbnails[6685794] = clik.newPhoto({"id":6685794,"src":"lucy-and-dani-46-Edit-1_thumb.jpg","galleries_id":365175,"server_id":18,"link":"photo_6685794.html","width":130,"caption":"","height":167});
															thumbnails[6685820] = clik.newPhoto({"id":6685820,"src":"monica300310-25-Edit-1_thumb.jpg","galleries_id":365175,"server_id":18,"link":"photo_6685820.html","width":130,"caption":"","height":130});
															thumbnails[6685821] = clik.newPhoto({"id":6685821,"src":"racheal171109-39-1_thumb.jpg","galleries_id":365175,"server_id":18,"link":"photo_6685821.html","width":130,"caption":"","height":87});
															thumbnails[6685822] = clik.newPhoto({"id":6685822,"src":"racheal171109-42-1_thumb.jpg","galleries_id":365175,"server_id":18,"link":"photo_6685822.html","width":130,"caption":"","height":87});
															thumbnails[6685823] = clik.newPhoto({"id":6685823,"src":"BTCC080810-276-1_thumb.jpg","galleries_id":101768,"server_id":18,"link":"photo_6685823.html","width":130,"caption":"","height":87});
															thumbnails[6685824] = clik.newPhoto({"id":6685824,"src":"BTCC080810-501-1_thumb.jpg","galleries_id":101768,"server_id":18,"link":"photo_6685824.html","width":130,"caption":"","height":87});
															thumbnails[6685825] = clik.newPhoto({"id":6685825,"src":"drag230510-140-1_thumb.jpg","galleries_id":101768,"server_id":18,"link":"photo_6685825.html","width":130,"caption":"","height":87});
															thumbnails[6685826] = clik.newPhoto({"id":6685826,"src":"snetterton-110709-642-Edita-1_thumb.jpg","galleries_id":101768,"server_id":18,"link":"photo_6685826.html","width":130,"caption":"","height":87});
															thumbnails[6685827] = clik.newPhoto({"id":6685827,"src":"trials-111009-29-1_thumb.jpg","galleries_id":101768,"server_id":18,"link":"photo_6685827.html","width":130,"caption":"","height":87});
															thumbnails[6685828] = clik.newPhoto({"id":6685828,"src":"deer-190909-5-1_thumb.jpg","galleries_id":69033,"server_id":18,"link":"photo_6685828.html","width":130,"caption":"","height":87});
															thumbnails[6685829] = clik.newPhoto({"id":6685829,"src":"deer-190909-66-Edit1-1_thumb.jpg","galleries_id":69033,"server_id":18,"link":"photo_6685829.html","width":130,"caption":"","height":92});
															thumbnails[6685830] = clik.newPhoto({"id":6685830,"src":"donnanook121209-511-Editb-1_thumb.jpg","galleries_id":69033,"server_id":18,"link":"photo_6685830.html","width":130,"caption":"","height":103});
															thumbnails[6685831] = clik.newPhoto({"id":6685831,"src":"grebe-030509-902-Edit-1_thumb.jpg","galleries_id":69033,"server_id":18,"link":"photo_6685831.html","width":130,"caption":"","height":87});
															thumbnails[6685832] = clik.newPhoto({"id":6685832,"src":"robin030110-1-Edit-1_thumb.jpg","galleries_id":69033,"server_id":18,"link":"photo_6685832.html","width":130,"caption":"","height":87});
															thumbnails[6685833] = clik.newPhoto({"id":6685833,"src":"work041109-9-Edit1-1_thumb.jpg","galleries_id":365177,"server_id":18,"link":"photo_6685833.html","width":130,"caption":"","height":92});
															thumbnails[6685850] = clik.newPhoto({"id":6685850,"src":"snowwoburn231209-78-Edit-1_thumb.jpg","galleries_id":69032,"server_id":18,"link":"photo_6685850.html","width":130,"caption":"","height":87});
															thumbnails[6726002] = clik.newPhoto({"id":6726002,"src":"wedding-lc_thumb.jpg","galleries_id":365174,"server_id":18,"link":"photo_6726002.html","width":130,"caption":"","height":87});
															thumbnails[6726005] = clik.newPhoto({"id":6726005,"src":"wedding-lc-1_thumb.jpg","galleries_id":365174,"server_id":18,"link":"photo_6726005.html","width":130,"caption":"","height":195});
															thumbnails[6726008] = clik.newPhoto({"id":6726008,"src":"wedding-lc-2_thumb.jpg","galleries_id":365174,"server_id":18,"link":"photo_6726008.html","width":130,"caption":"","height":195});
															thumbnails[6726010] = clik.newPhoto({"id":6726010,"src":"wedding-lc-3_thumb.jpg","galleries_id":365174,"server_id":18,"link":"photo_6726010.html","width":130,"caption":"","height":93});
															thumbnails[6726012] = clik.newPhoto({"id":6726012,"src":"wedding-lc-4_thumb.jpg","galleries_id":365174,"server_id":18,"link":"photo_6726012.html","width":130,"caption":"","height":195});
															thumbnails[6764991] = clik.newPhoto({"id":6764991,"src":"renaultf1-1_thumb.jpg","galleries_id":101768,"server_id":18,"link":"photo_6764991.html","width":130,"caption":"","height":87});
															thumbnails[8310147] = clik.newPhoto({"id":8310147,"src":"Roesels-Bush-Cricket-1_thumb.jpg","galleries_id":69033,"server_id":38,"link":"photo_8310147.html","width":130,"caption":"Roesel's Bush Cricket","height":87});
															thumbnails[1501388] = clik.newPhoto({"id":1501388,"src":"2007 10 19 006_thumb.jpg","galleries_id":365170,"server_id":18,"link":"photo_1501388.html","width":130,"caption":"Sunrise","height":89});
															thumbnails[2737346] = clik.newPhoto({"id":2737346,"src":"08 09 06 jetski 094 copy_thumb.jpg","galleries_id":101768,"server_id":18,"link":"photo_2737346.html","width":130,"caption":"Jetski Championships","height":87});
															thumbnails[1477273] = clik.newPhoto({"id":1477273,"src":"2007 09 29 030_thumb.jpg","galleries_id":365170,"server_id":18,"link":"photo_1477273.html","width":130,"caption":"Falls of Dochart","height":97});
															thumbnails[2737347] = clik.newPhoto({"id":2737347,"src":"08 09 06 jetski 300 copy_thumb.jpg","galleries_id":101768,"server_id":18,"link":"photo_2737347.html","width":130,"caption":"Jetski Championships","height":87});
															thumbnails[1501390] = clik.newPhoto({"id":1501390,"src":"2007 10 19 012_thumb.jpg","galleries_id":365170,"server_id":18,"link":"photo_1501390.html","width":130,"caption":"Washed up Trolley","height":89});
															thumbnails[2232635] = clik.newPhoto({"id":2232635,"src":"May 27 2008 white tree nymph 107_thumb.jpg","galleries_id":69033,"server_id":18,"link":"photo_2232635.html","width":130,"caption":"Butterfly","height":100});
															thumbnails[3090079] = clik.newPhoto({"id":3090079,"src":"bigcats4_thumb.jpg","galleries_id":69033,"server_id":18,"link":"photo_3090079.html","width":130,"caption":"Lion","height":104});
															thumbnails[1505072] = clik.newPhoto({"id":1505072,"src":"2007 10 20 054a_thumb.jpg","galleries_id":69061,"server_id":18,"link":"photo_1505072.html","width":130,"caption":"","height":195});
															thumbnails[2232660] = clik.newPhoto({"id":2232660,"src":"May 24 2008 zebra 061_thumb.jpg","galleries_id":69033,"server_id":18,"link":"photo_2232660.html","width":130,"caption":"Zebra","height":93});
															thumbnails[1501406] = clik.newPhoto({"id":1501406,"src":"2007 10 19 369_thumb.jpg","galleries_id":365170,"server_id":18,"link":"photo_1501406.html","width":130,"caption":"Shades of Green","height":89});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  						galleries[365175] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Portraiture","link":"gallery_365175.html","maxRecords":0.0,"photoIDs":[6685788.0,6685789.0,6685790.0,6685791.0,6685792.0,6685793.0,6685794.0,6685820.0,6685821.0,6685822.0],"skipIndex":0,"section_code":"gallery","featured_images":"6685822,6685821,6685820,6685794,6685793,6685792,6685791,6685790,6685789,6685788","id":365175,"singleSection":false});				  						galleries[365174] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Weddings","link":"gallery_365174.html","maxRecords":0.0,"photoIDs":[6685681.0,6685683.0,6685686.0,6685687.0,6685688.0,6685689.0,6685690.0,6685692.0,6685694.0,6685695.0,6685696.0,6685698.0,6685699.0,6726002.0,6726005.0,6726008.0,6726010.0,6726012.0],"skipIndex":0,"section_code":"gallery","featured_images":"6726012,6726010,6726008,6726005,6726002,6685699,6685698,6685696,6685695,6685694","id":365174,"singleSection":false});				  						galleries[101768] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Sport","link":"gallery_101768.html","maxRecords":0.0,"photoIDs":[1384327.0,4866268.0,4866270.0,4866278.0,6685823.0,6685824.0,6685825.0,6685826.0,6685827.0,6764991.0,2737346.0,2737347.0],"skipIndex":0,"section_code":"gallery","featured_images":"6764991,6685827,6685826,6685825,6685824,6685823,4866278,4866270,4866268,2737347","id":101768,"singleSection":false});				  						galleries[365177] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Commission work","link":"gallery_365177.html","maxRecords":0.0,"photoIDs":[6685833.0],"skipIndex":0,"section_code":"gallery","featured_images":6685833.0,"id":365177,"singleSection":false});				  						galleries[69033] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Animals, Birds and Insects","link":"gallery_69033.html","maxRecords":0.0,"photoIDs":[1156689.0,1227632.0,6685828.0,6685829.0,6685830.0,6685831.0,6685832.0,8310147.0,2232635.0,3090079.0,2232660.0],"skipIndex":0,"section_code":"gallery","featured_images":"8310147,6685832,6685831,6685830,6685829,6685828,3090079,2232660,2232635,1227632","id":69033,"singleSection":false});				  						galleries[69032] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Land & Sea scapes","link":"gallery_69032.html","maxRecords":0.0,"photoIDs":[6685850.0],"skipIndex":0,"section_code":"gallery","featured_images":6685850.0,"id":69032,"singleSection":false});				  						galleries[87875] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Macro","link":"gallery_87875.html","maxRecords":0.0,"photoIDs":[],"skipIndex":0,"section_code":"gallery","featured_images":"","id":87875,"singleSection":false});				  						galleries[69044] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Architecture","link":"gallery_69044.html","maxRecords":0.0,"photoIDs":[],"skipIndex":0,"section_code":"gallery","featured_images":"","id":69044,"singleSection":false});				  						galleries[69061] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Miscellaneous","link":"gallery_69061.html","maxRecords":0.0,"photoIDs":[950002.0,1505072.0],"skipIndex":0,"section_code":"gallery","featured_images":"1505072,950002","id":69061,"singleSection":false});				  						galleries[365170] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"The Early Years","link":"gallery_365170.html","maxRecords":0.0,"photoIDs":[949892.0,950000.0,950001.0,1133782.0,1475464.0,1477869.0,1477870.0,1483963.0,1501438.0,1501388.0,1477273.0,1501390.0,1501406.0],"skipIndex":0,"section_code":"gallery","featured_images":"1501438,1501406,1501390,1501388,1483963,1477870,1477869,1477273,1475464,1133782","id":365170,"singleSection":false});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[1] = '6764991,6685829';
imageSets[3] = '8310147,6764991,6726012,6726010,6726008,6726005,6726002,6685850,6685833,6685832,6685831,6685830,6685829,6685828,6685827,6685826,6685825,6685824,6685823,6685822,6685821,6685820,6685794,6685793,6685792,6685791,6685790,6685789,6685788,6685699,6685698,6685696,6685695,6685694,6685692,6685690,6685689,6685688,6685687,6685686,6685683,6685681,4866278,4866270,4866268,3090079,2737347,2737346,2232660,2232635';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/ljgphotos/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/ljgphotos/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/ljgphotos/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/ljgphotos/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/ljgphotos/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/ljgphotos/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/ljgphotos/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/ljgphotos/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/ljgphotos/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/ljgphotos/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/ljgphotos/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/ljgphotos/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/ljgphotos/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/ljgphotos/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/ljgphotos/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/ljgphotos/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://admin2.clikpic.com/ljgphotos/images';
		break;
	}
		switch (server_id) {
		case 33:
		val = 'http://www8.clikpic.com/ljgphotos/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/ljgphotos/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/ljgphotos/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/ljgphotos/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/ljgphotos/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/ljgphotos/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/ljgphotos/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:'',$detailContainer:'',
                    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 (op.updateHash && clik.getIDInUrl(location.href,'photo') != op.nextPhoto.id) {
		clik.changeHash('photos_id=' + op.nextPhoto.id, true);
	}
		
	    if (op.$title.length > 0) {
  		op.$title.fadeGalleryDetails(photoCaption, op.speed);
    }
        if (op.updateDocumentTitle) {
						  document.title = 'LJG Photography: ' + photoCaption;
			    }
        if (op.$detail.length > 0) {
      	temp = op.nextPhoto.fnGetImageDetails();
	    op.$detail.fadeGalleryDetails(temp, op.speed, function(){
			if (typeof(backgrounds) != 'undefined' && op.nextPhoto == backgrounds[op.nextPhoto.id]) {
				toggleAddToCartConfirm(backgrounds, op.$detail);
			} else if (typeof(photos) != 'undefined' && op.nextPhoto == photos[op.nextPhoto.id]) {
				toggleAddToCartConfirm(photos, op.$detail);
			}
			$('body').trigger('clikUpdate.popup');
	    });
    }
        $(op.$detailContainer).find('.replaceable[class*=replaceable_photo-]').each(function(){
    	var field = clik.getPrefixedClass(this.className, 'replaceable_photo-');
    	if (field in op.nextPhoto) {
    		$(this).fadeGalleryDetails(op.nextPhoto[field], op.speed);
    	}
    }).end().find('.replaceable.photoPayment').fadeGalleryDetails(op.nextPhoto.fnGetPaymentInfo(), op.speed, function(){
		if (typeof(backgrounds) != 'undefined' && op.nextPhoto == backgrounds[op.nextPhoto.id]) {
			toggleAddToCartConfirm(backgrounds, op.$detailContainer);
		} else if (typeof(photos) != 'undefined' && op.nextPhoto == photos[op.nextPhoto.id]) {
			toggleAddToCartConfirm(photos, op.$detailContainer);
		}
		$('body').trigger('clikUpdate.popup');
	});
		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.speed) {
      	clik.doColumnResize(false, op.$photo.add(op.$detail).add(op.$title));
    }
        
    return html;
	}

/***************************************************************************
* Toggle add to cart confirmation element and set up the click event for   *
* the 'Add to cart' button.                                                *
***************************************************************************/
function toggleAddToCartConfirm(array, root){
	if (typeof(array) !== 'object' || array === null) {
	  	array = photos;
	}
	if (!$(root).length) {		root = $('body');	}	if($('#paymentConfirm', root).length > 0){
		$('#paymentConfirm', root).hide();
		$('#paymentAddButton', root)
		.unbind()
		.click(function(){
						form = $('#paymentForm', root)[0];
			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', root).text('Item added to cart').show();}
				else{
					$('#paymentConfirm', root).text('Item added to cart').fadeIn();
					dspOrderDetails(form.site.value);
				}
			}
			else{
				$('#paymentConfirm', root).text('Item not added - check cookies are enabled in your browser.').fadeIn();
			}
		});
	}
}

/***************************************************************************
* Get payment info for image - add as 'method' to photo object             *
***************************************************************************/
clik.photo.fnGetImageDetails = function(){
	var temp = '';
	if (this.description != '') {
		temp +=  '<div id="imageDescription">' + this.description + '</div>';
	}
		if (this.photo_ref != '') {
		temp += '<div class="imageinfo" id="imageRef"><strong>Ref: </strong>' + this.photo_ref + '</div>';
	}
		if (this.takendate != '') {
		
		temp += '<div class="imageinfo" id="imageDate"><strong>Date: </strong>' + this.takendate + '</div>';
	}
	
	if (this.location != '') {
		
		temp += '<div class="imageinfo" id="imageLocation"><strong>Location: </strong>' +  this.location + '</div>';
	}
	
	if (this.photographer != '') {
		
		temp += '<div class="imageinfo" id="imagePhotographer"><strong>Photographer: </strong>' + this.photographer + '</div>';
	}
				
				if (temp != '') {
		temp += '<div class="spacer"></div>';
	}
	return temp;
};

/***************************************************************************
* Get payment info for image - add as 'method' to photo object             *
***************************************************************************/
clik.photo.fnGetPaymentInfo = function(){
	var temp = '';
	if (this.item_price !== '') {
				temp += '<p>Order this print:</p>';
				temp += '<div class="imageinfo" id="imagePrice"><strong>' + this.purchase_instruction + '</strong> &pound;' + (this.item_price).toFixed(2) + '</div>';
		var item_name  = this.purchase_instruction;
		var amount = (this.item_price).toFixed(2);
		var item_option  = 0;
	}
	else if (this.payment_groups_id !== '') {
		temp += '<p>Buy this print online:</p>';
				temp += '<form id="paymentOptions" style="margin:0px;border:0px;" name="paymentOptions">';
											temp += '<select class="paymentlink" name="payment_options_id" onchange="updateItemValues($(this.form).next(\'#paymentForm\')[0],this.form.payment_options_id.options[this.form.payment_options_id.options.selectedIndex].value);">';
		
		temp += getPaymentOptions(this.payment_groups_id);
		temp += '</select>';
		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 += '<form id="paymentForm" style="margin:0px;border:0px;" name="paymentForm" target="_blank" action="https://www.paypal.com/cgi-bin/webscr" method="post">';
			temp += '<input type="hidden" name="item_name" value="'+item_name+'">';
			ref = '';
			if(this.photo_ref != ''){
				ref = this.photo_ref+' - '+this.caption;
			}
			else{
				ref = this.id+' - '+this.caption;
			}
			price = amount;								temp += '<input type="hidden" name="cmd" value="_cart">';
					temp += '<input type="hidden" name="business" value="">';
					temp += '<input type="hidden" name="currency_code" value="GBP">';
					temp += '<input type="hidden" name="add" value="1">';
													temp += '<input type="hidden" name="amount" value="'+amount+'">';
					temp += '<input type="hidden" name="item_number" value="'+ref+'">';
													temp += '<input type=\"Submit\" value=\"Add to cart\" id=\"paymentAddButton\" class=\"button\" onmouseover=\"this.className=\'buttonHi\';\" onmouseout=\"this.className=\'button\';\">';
										temp += '</form>';
										temp += '<form id="paymentCartForm" style="margin:0px;" name="paymentCartForm" target="_blank" action="https://www.paypal.com/cgi-bin/webscr" method="post">';
				temp += '<input type="hidden" name="cmd" value="_cart">';
				temp += '<input type="hidden" name="business" value="">';
				temp += '<input type="hidden" name="display" value="1">';
				temp += '<input type=\"Submit\" value=\"View cart\" id=\"paymentViewButton\" class=\"button\" onmouseover=\"this.className=\'buttonHi\';\" onmouseout=\"this.className=\'button\';\">';
				temp += '</form>';
						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 += '<a href="' + galleries[i].section_code + '_' + galleries[i].id + '.html">' + galleries[i].title + '</a>';
							}
		}
		document.all.galleryLinks.innerHTML = 'Other galleries: ' + temp;
	}
}

			

