window.thumbnails = {};
															thumbnails[9004309] = clik.newPhoto({"id":9004309,"src":"ram_lino_low_thumb.jpg","galleries_id":101253,"server_id":1,"link":"photo_9004309.html","width":130,"caption":"Witshire Horn ram","height":97});
															thumbnails[7896838] = clik.newPhoto({"id":7896838,"src":"snow01_lores_thumb.jpg","galleries_id":87981,"server_id":1,"link":"photo_7896838.html","width":130,"caption":"Stoical cattle - Woodborough Hill","height":95});
															thumbnails[9004333] = clik.newPhoto({"id":9004333,"src":"cattle_snow_v2low_thumb.jpg","galleries_id":87981,"server_id":1,"link":"photo_9004333.html","width":130,"caption":"Spooked cattle- December","height":106});
															thumbnails[9004316] = clik.newPhoto({"id":9004316,"src":"cyclamen_lores_thumb.jpg","galleries_id":87296,"server_id":1,"link":"photo_9004316.html","width":108,"caption":"White cyclamen 2","height":130});
															thumbnails[6729059] = clik.newPhoto({"id":6729059,"src":"ram_sq_sun_thumb.jpg","galleries_id":87981,"server_id":1,"link":"photo_6729059.html","width":130,"caption":"Ram and ewe winters day","height":130});
															thumbnails[6729056] = clik.newPhoto({"id":6729056,"src":"ram_sq_snowstorm_thumb.jpg","galleries_id":87981,"server_id":1,"link":"photo_6729056.html","width":130,"caption":"Ram and ewe snow","height":130});
															thumbnails[6888910] = clik.newPhoto({"id":6888910,"src":"green_garden_lores_thumb.jpg","galleries_id":87981,"server_id":1,"link":"photo_6888910.html","width":130,"caption":"Track, high summer","height":101});
															thumbnails[6726967] = clik.newPhoto({"id":6726967,"src":"ram_ewe_branches_thumb.jpg","galleries_id":87981,"server_id":1,"link":"photo_6726967.html","width":96,"caption":"Ram and ewe under branches","height":130});
															thumbnails[6726963] = clik.newPhoto({"id":6726963,"src":"ram_snowstorm_thumb.jpg","galleries_id":87981,"server_id":1,"link":"photo_6726963.html","width":96,"caption":"Ram in snowstorm","height":130});
															thumbnails[6726955] = clik.newPhoto({"id":6726955,"src":"poppy_red_3_thumb.jpg","galleries_id":87296,"server_id":1,"link":"photo_6726955.html","width":130,"caption":"Poppy 3","height":130});
															thumbnails[6726951] = clik.newPhoto({"id":6726951,"src":"poppy_red_2_thumb.jpg","galleries_id":87296,"server_id":1,"link":"photo_6726951.html","width":130,"caption":"Poppy 2","height":130});
															thumbnails[6727002] = clik.newPhoto({"id":6727002,"src":"ram_light_snow_thumb.jpg","galleries_id":87981,"server_id":1,"link":"photo_6727002.html","width":96,"caption":"Ram -  light snow","height":130});
															thumbnails[6726987] = clik.newPhoto({"id":6726987,"src":"ram_ewe_night_thumb.jpg","galleries_id":87981,"server_id":1,"link":"photo_6726987.html","width":96,"caption":"Ram and ewe nocturn","height":130});
															thumbnails[6726943] = clik.newPhoto({"id":6726943,"src":"poppy_red_1_thumb.jpg","galleries_id":87296,"server_id":1,"link":"photo_6726943.html","width":130,"caption":"Poppy 1","height":130});
															thumbnails[6726981] = clik.newPhoto({"id":6726981,"src":"ram_red_sun_thumb.jpg","galleries_id":87981,"server_id":1,"link":"photo_6726981.html","width":96,"caption":"Ram with red sun","height":130});
															thumbnails[6726957] = clik.newPhoto({"id":6726957,"src":"poppy_white_thumb.jpg","galleries_id":87296,"server_id":1,"link":"photo_6726957.html","width":130,"caption":"White poppy","height":130});
															thumbnails[6726917] = clik.newPhoto({"id":6726917,"src":"foxgloves_thumb.jpg","galleries_id":87296,"server_id":1,"link":"photo_6726917.html","width":73,"caption":"Foxgloves 2","height":130});
															thumbnails[6135226] = clik.newPhoto({"id":6135226,"src":"rf_cows_thumb.jpg","galleries_id":87981,"server_id":1,"link":"photo_6135226.html","width":130,"caption":"Woodborough hill and cows","height":93});
															thumbnails[6888903] = clik.newPhoto({"id":6888903,"src":"bluebell_wood_lores_thumb.jpg","galleries_id":87981,"server_id":1,"link":"photo_6888903.html","width":130,"caption":"Bluebells, West woods","height":102});
															thumbnails[6135205] = clik.newPhoto({"id":6135205,"src":"rf_hellibore_thumb.jpg","galleries_id":87296,"server_id":1,"link":"photo_6135205.html","width":130,"caption":"9 hellebores","height":130});
															thumbnails[6135223] = clik.newPhoto({"id":6135223,"src":"rf_snowdrops_thumb.jpg","galleries_id":87296,"server_id":1,"link":"photo_6135223.html","width":130,"caption":"Snowdrops - oil","height":130});
															thumbnails[5114636] = clik.newPhoto({"id":5114636,"src":"magnolia_lores_thumb.jpg","galleries_id":87296,"server_id":1,"link":"photo_5114636.html","width":130,"caption":"Magnolia","height":130});
															thumbnails[5114621] = clik.newPhoto({"id":5114621,"src":"landscape_lores_thumb.jpg","galleries_id":87981,"server_id":1,"link":"photo_5114621.html","width":130,"caption":"Sunken track","height":107});
															thumbnails[5114666] = clik.newPhoto({"id":5114666,"src":"tuliporangetips_lores_thumb.jpg","galleries_id":87296,"server_id":1,"link":"photo_5114666.html","width":88,"caption":"Tulips and orange tips","height":130});
															thumbnails[5114603] = clik.newPhoto({"id":5114603,"src":"dogrose_lores_thumb.jpg","galleries_id":87296,"server_id":1,"link":"photo_5114603.html","width":90,"caption":"Dog roses","height":130});
															thumbnails[5114654] = clik.newPhoto({"id":5114654,"src":"tulipbutterfly_lores_thumb.jpg","galleries_id":87296,"server_id":1,"link":"photo_5114654.html","width":91,"caption":"White tulip and butterflies","height":130});
															thumbnails[5114682] = clik.newPhoto({"id":5114682,"src":"tulipspider_lores_thumb.jpg","galleries_id":87296,"server_id":1,"link":"photo_5114682.html","width":63,"caption":"Tulip and spider","height":130});
															thumbnails[5114566] = clik.newPhoto({"id":5114566,"src":"daffodils_lores_thumb.jpg","galleries_id":87296,"server_id":1,"link":"photo_5114566.html","width":77,"caption":"Daffodils","height":130});
															thumbnails[4538424] = clik.newPhoto({"id":4538424,"src":"white_cyclamen_02_thumb.jpg","galleries_id":87296,"server_id":1,"link":"photo_4538424.html","width":130,"caption":"White cyclamen","height":176});
															thumbnails[5114643] = clik.newPhoto({"id":5114643,"src":"snowdrops_lores_thumb.jpg","galleries_id":87296,"server_id":1,"link":"photo_5114643.html","width":93,"caption":"Snowdrops and daffodils","height":130});
															thumbnails[4538535] = clik.newPhoto({"id":4538535,"src":"pink_cyclamen_01_thumb.jpg","galleries_id":87296,"server_id":1,"link":"photo_4538535.html","width":130,"caption":"Pink cyclamen 2","height":178});
															thumbnails[4538396] = clik.newPhoto({"id":4538396,"src":"hogweed_thumb.jpg","galleries_id":87296,"server_id":1,"link":"photo_4538396.html","width":130,"caption":"Hogweed and Grasses","height":179});
															thumbnails[4538279] = clik.newPhoto({"id":4538279,"src":"foxglove_thumb.jpg","galleries_id":87296,"server_id":1,"link":"photo_4538279.html","width":130,"caption":"Foxgloves","height":341});
															thumbnails[4608690] = clik.newPhoto({"id":4608690,"src":"Tulips_08_009_thumb.jpg","galleries_id":87296,"server_id":1,"link":"photo_4608690.html","width":130,"caption":"Tulips","height":130});
															thumbnails[4538413] = clik.newPhoto({"id":4538413,"src":"marsh-flower-2_thumb.jpg","galleries_id":87296,"server_id":1,"link":"photo_4538413.html","width":130,"caption":"Marsh Marigolds","height":131});
															thumbnails[4608784] = clik.newPhoto({"id":4608784,"src":"Hellbores_web_024_thumb.jpg","galleries_id":87296,"server_id":1,"link":"photo_4608784.html","width":87,"caption":"Small sunflowers","height":130});
															thumbnails[4608779] = clik.newPhoto({"id":4608779,"src":"Hellbores_web_023_thumb.jpg","galleries_id":87296,"server_id":1,"link":"photo_4608779.html","width":129,"caption":"Snowdrops and celandines","height":130});
															thumbnails[4608788] = clik.newPhoto({"id":4608788,"src":"Hellbores_web_019_thumb.jpg","galleries_id":87296,"server_id":1,"link":"photo_4608788.html","width":130,"caption":"Red Hellebore","height":130});
															thumbnails[4608772] = clik.newPhoto({"id":4608772,"src":"Hellbores_web_021_thumb.jpg","galleries_id":87296,"server_id":1,"link":"photo_4608772.html","width":130,"caption":"Double Hellebore","height":130});
															thumbnails[4608767] = clik.newPhoto({"id":4608767,"src":"Hellbores_web_014_thumb.jpg","galleries_id":87296,"server_id":1,"link":"photo_4608767.html","width":130,"caption":"Pink Hellebore","height":130});
															thumbnails[4608755] = clik.newPhoto({"id":4608755,"src":"Hellbores_web_013_thumb.jpg","galleries_id":87296,"server_id":1,"link":"photo_4608755.html","width":92,"caption":"Black hellebores","height":130});
															thumbnails[4608761] = clik.newPhoto({"id":4608761,"src":"Hellbores_web_015_thumb.jpg","galleries_id":87296,"server_id":1,"link":"photo_4608761.html","width":130,"caption":"Speckled Hellebore","height":130});
															thumbnails[1230501] = clik.newPhoto({"id":1230501,"src":"rf005_thumb.jpg","galleries_id":87981,"server_id":1,"link":"photo_1230501.html","width":130,"caption":"Woodborough Hill","height":100});
															thumbnails[1230505] = clik.newPhoto({"id":1230505,"src":"rf006_thumb.jpg","galleries_id":87981,"server_id":1,"link":"photo_1230505.html","width":130,"caption":"Marlborough Downs","height":99});
															thumbnails[1230512] = clik.newPhoto({"id":1230512,"src":"holly_thumb.jpg","galleries_id":87296,"server_id":1,"link":"photo_1230512.html","width":130,"caption":"Holly","height":99});
															thumbnails[1230515] = clik.newPhoto({"id":1230515,"src":"sunflowers_thumb.jpg","galleries_id":87296,"server_id":1,"link":"photo_1230515.html","width":130,"caption":"Sunflowers","height":100});
															thumbnails[1230523] = clik.newPhoto({"id":1230523,"src":"sunset_thumb.jpg","galleries_id":87981,"server_id":1,"link":"photo_1230523.html","width":130,"caption":"Sunset","height":90});
															thumbnails[1468309] = clik.newPhoto({"id":1468309,"src":"black-swans-evening11_thumb.jpg","galleries_id":101253,"server_id":1,"link":"photo_1468309.html","width":130,"caption":"Black Swans","height":167});
															thumbnails[1468373] = clik.newPhoto({"id":1468373,"src":"first-worm_thumb.jpg","galleries_id":101253,"server_id":1,"link":"photo_1468373.html","width":130,"caption":"First worm","height":101});
															thumbnails[1468392] = clik.newPhoto({"id":1468392,"src":"dead-nettles-butterfly_thumb.jpg","galleries_id":101253,"server_id":1,"link":"photo_1468392.html","width":130,"caption":"Dead nettles and butterfly","height":183});
															thumbnails[1468399] = clik.newPhoto({"id":1468399,"src":"grasshopper_thumb.jpg","galleries_id":101253,"server_id":1,"link":"photo_1468399.html","width":130,"caption":"Grasshopper","height":104});
															thumbnails[1468400] = clik.newPhoto({"id":1468400,"src":"peacock_thumb.jpg","galleries_id":101253,"server_id":1,"link":"photo_1468400.html","width":130,"caption":"Peacock","height":41});
															thumbnails[1468403] = clik.newPhoto({"id":1468403,"src":"pecking-order-II_thumb.jpg","galleries_id":101253,"server_id":1,"link":"photo_1468403.html","width":130,"caption":"Pecking order","height":132});
															thumbnails[1468405] = clik.newPhoto({"id":1468405,"src":"sheep-siesta_thumb.jpg","galleries_id":101253,"server_id":1,"link":"photo_1468405.html","width":130,"caption":"Sheep siesta","height":114});
															thumbnails[1468406] = clik.newPhoto({"id":1468406,"src":"snow-in-the-park_thumb.jpg","galleries_id":101253,"server_id":1,"link":"photo_1468406.html","width":130,"caption":"Snow","height":164});
															thumbnails[1468409] = clik.newPhoto({"id":1468409,"src":"snow-kew-gardens_thumb.jpg","galleries_id":101253,"server_id":1,"link":"photo_1468409.html","width":130,"caption":"Snow Kew Gardens","height":102});
															thumbnails[1468412] = clik.newPhoto({"id":1468412,"src":"autumn-extravaganza_thumb.jpg","galleries_id":101253,"server_id":1,"link":"photo_1468412.html","width":130,"caption":"Autumn arrangement","height":195});
															thumbnails[1468415] = clik.newPhoto({"id":1468415,"src":"white-swans-spring_thumb.jpg","galleries_id":101253,"server_id":1,"link":"photo_1468415.html","width":130,"caption":"White swans spring","height":99});
															thumbnails[1468417] = clik.newPhoto({"id":1468417,"src":"begonia-house_thumb.jpg","galleries_id":101253,"server_id":1,"link":"photo_1468417.html","width":130,"caption":"Begonia house","height":94});
															thumbnails[1468423] = clik.newPhoto({"id":1468423,"src":"untitled_thumb.jpg","galleries_id":101253,"server_id":1,"link":"photo_1468423.html","width":130,"caption":"Snow laden tree","height":103});
															thumbnails[1468425] = clik.newPhoto({"id":1468425,"src":"witches-cat_thumb.jpg","galleries_id":101253,"server_id":1,"link":"photo_1468425.html","width":130,"caption":"Witches cat","height":98});
															thumbnails[1468431] = clik.newPhoto({"id":1468431,"src":"peony_thumb.jpg","galleries_id":87296,"server_id":1,"link":"photo_1468431.html","width":130,"caption":"Peony","height":180});
															thumbnails[1468435] = clik.newPhoto({"id":1468435,"src":"rose_thumb.jpg","galleries_id":87296,"server_id":1,"link":"photo_1468435.html","width":130,"caption":"Rose","height":128});
															thumbnails[1468441] = clik.newPhoto({"id":1468441,"src":"woodboro-hill_thumb.jpg","galleries_id":87981,"server_id":1,"link":"photo_1468441.html","width":130,"caption":"Woodborough hill","height":95});
															thumbnails[1468492] = clik.newPhoto({"id":1468492,"src":"black-hellibore1_thumb.jpg","galleries_id":87296,"server_id":1,"link":"photo_1468492.html","width":130,"caption":"Black hellebore","height":195});
															thumbnails[1468494] = clik.newPhoto({"id":1468494,"src":"snowdrops1_thumb.jpg","galleries_id":87296,"server_id":1,"link":"photo_1468494.html","width":130,"caption":"Snowdrops","height":129});
															thumbnails[1468506] = clik.newPhoto({"id":1468506,"src":"rf0011_thumb.jpg","galleries_id":87296,"server_id":1,"link":"photo_1468506.html","width":130,"caption":"Red cyclamen","height":133});
															thumbnails[1468509] = clik.newPhoto({"id":1468509,"src":"rf0021_thumb.jpg","galleries_id":87296,"server_id":1,"link":"photo_1468509.html","width":130,"caption":"Pink cyclamen","height":198});
															thumbnails[5861061] = clik.newPhoto({"id":5861061,"src":"blackbird_lores_thumb.jpg","galleries_id":87981,"server_id":1,"link":"photo_5861061.html","width":87,"caption":"Blackbirds ","height":130});
															thumbnails[5861076] = clik.newPhoto({"id":5861076,"src":"crab_apple_portrait_lores_thumb.jpg","galleries_id":87981,"server_id":1,"link":"photo_5861076.html","width":98,"caption":"Crab apple","height":130});
															thumbnails[5861080] = clik.newPhoto({"id":5861080,"src":"rooks_lores_thumb.jpg","galleries_id":87981,"server_id":1,"link":"photo_5861080.html","width":93,"caption":"rooks in snow","height":130});
															thumbnails[5861145] = clik.newPhoto({"id":5861145,"src":"crab_apple_landscape_lores_thumb.jpg","galleries_id":87981,"server_id":1,"link":"photo_5861145.html","width":130,"caption":"Garden","height":98});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  						galleries[101253] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Handmade prints","link":"gallery_101253.html","maxRecords":0.0,"photoIDs":[9004309.0,1468309.0,1468373.0,1468392.0,1468399.0,1468400.0,1468403.0,1468405.0,1468406.0,1468409.0,1468412.0,1468415.0,1468417.0,1468423.0,1468425.0],"skipIndex":0,"section_code":"gallery","featured_images":"9004309,1468425,1468423,1468417,1468415,1468412,1468409,1468406,1468405,1468403","id":101253,"singleSection":false});				  						galleries[87981] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Landscapes","link":"gallery_87981.html","maxRecords":0.0,"photoIDs":[7896838.0,9004333.0,6729059.0,6729056.0,6888910.0,6726967.0,6726963.0,6727002.0,6726987.0,6726981.0,6135226.0,6888903.0,5114621.0,1230501.0,1230505.0,1230523.0,1468441.0,5861061.0,5861076.0,5861080.0,5861145.0],"skipIndex":0,"section_code":"gallery","featured_images":"9004333,7896838,6888910,6888903,6729059,6729056,6727002,6726987,6726981,6726967","id":87981,"singleSection":false});				  						galleries[87296] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Flowers and Still Lives","link":"gallery_87296.html","maxRecords":0.0,"photoIDs":[9004316.0,6726955.0,6726951.0,6726943.0,6726957.0,6726917.0,6135205.0,6135223.0,5114636.0,5114666.0,5114603.0,5114654.0,5114682.0,5114566.0,4538424.0,5114643.0,4538535.0,4538396.0,4538279.0,4608690.0,4538413.0,4608784.0,4608779.0,4608788.0,4608772.0,4608767.0,4608755.0,4608761.0,1230512.0,1230515.0,1468431.0,1468435.0,1468492.0,1468494.0,1468506.0,1468509.0],"skipIndex":0,"section_code":"gallery","featured_images":"9004316,6726957,6726955,6726951,6726943,6726917,6135223,6135205,5114682,5114666","id":87296,"singleSection":false});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[1] = '9004333,9004316,9004309,7896838,6888910,6888903,6729059,6729056,6727002,6726987,6726981,6726967,6726963,6726957,6726955,6726951,6726943,6726917,6135226,6135223,6135205,5861145,5861080,5861076,5861061,5114682,5114666,5114654,5114643,5114636,5114621,5114603,5114566,4608788,4608784,4608779,4608772,4608767,4608761,4608755,4608690,4538535,4538424,4538413,4538396,4538279,1468509,1468506,1468494,1468492';
imageSets[3] = '9004333,9004316,9004309,7896838,6888910,6888903,6729059,6729056,6727002,6726987,6726981,6726967,6726963,6726957,6726955,6726951,6726943,6726917,6135226,6135223,6135205,5861145,5861080,5861076,5861061,5114682,5114666,5114654,5114643,5114636,5114621,5114603,5114566,4608788,4608784,4608779,4608772,4608767,4608761,4608755,4608690,4538535,4538424,4538413,4538396,4538279,1468509,1468506,1468494,1468492';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 51:
		val = 'http://www12.clikpic.com/rosemaryfarrer/images';
		break;
	}
		switch (server_id) {
		case 0:
		val = 'http://www.clikpic.com/rosemaryfarrer/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/rosemaryfarrer/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/rosemaryfarrer/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/rosemaryfarrer/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/rosemaryfarrer/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/rosemaryfarrer/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/rosemaryfarrer/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/rosemaryfarrer/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/rosemaryfarrer/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/rosemaryfarrer/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/rosemaryfarrer/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/rosemaryfarrer/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/rosemaryfarrer/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/rosemaryfarrer/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/rosemaryfarrer/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/rosemaryfarrer/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/rosemaryfarrer/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/rosemaryfarrer/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/rosemaryfarrer/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/rosemaryfarrer/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/rosemaryfarrer/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/rosemaryfarrer/images';
		break;
	}
		switch (server_id) {
		case 53:
		val = 'http://images.clikpic.com/rosemaryfarrer/images';
		break;
	}
		switch (server_id) {
		case 52:
		val = 'http://tpc22/clikpic/rosemaryfarrer/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/rosemaryfarrer/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/rosemaryfarrer/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 || photos || {})[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 = 'Rosemary Farrer: ' + 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> ' + (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.item_price !== '') {
			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({					title: galleries[gallery_id].title				}).filter(function(){return this.href;}).attr({					href: thumbnails[imageID].fnGalleryLink(gallery_id)				});
			}
		}
	}
}

/***************************************************************************
* 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;
	}
}

			

