window.thumbnails = {};
															thumbnails[210784] = clik.newPhoto({"id":210784,"src":"G010_thumb.jpg","galleries_id":"","server_id":15,"link":"#","width":130,"caption":"Beaches of Harris","height":181});
															thumbnails[210786] = clik.newPhoto({"id":210786,"src":"G040_thumb.jpg","galleries_id":"","server_id":15,"link":"#","width":130,"caption":"Spring at Last","height":200});
															thumbnails[210993] = clik.newPhoto({"id":210993,"src":"G050_thumb.jpg","galleries_id":"","server_id":15,"link":"#","width":130,"caption":"Logo","height":50});
															thumbnails[1845869] = clik.newPhoto({"id":1845869,"src":"newfront_thumb.jpg","galleries_id":"","server_id":15,"link":"#","width":130,"caption":"","height":199});
															thumbnails[209484] = clik.newPhoto({"id":209484,"src":"G1011_thumb.jpg","galleries_id":18659,"server_id":15,"link":"photo_209484.html","width":130,"caption":"Mackerel Sky","height":81});
															thumbnails[209522] = clik.newPhoto({"id":209522,"src":"G201_thumb.jpg","galleries_id":18708,"server_id":15,"link":"photo_209522.html","width":130,"caption":"Sea of Red","height":85});
															thumbnails[209560] = clik.newPhoto({"id":209560,"src":"G301_thumb.jpg","galleries_id":18709,"server_id":15,"link":"photo_209560.html","width":130,"caption":"Tranquil Rydal","height":85});
															thumbnails[209609] = clik.newPhoto({"id":209609,"src":"G401_thumb.jpg","galleries_id":18710,"server_id":15,"link":"photo_209609.html","width":130,"caption":"Beaches of Lewis","height":85});
															thumbnails[209628] = clik.newPhoto({"id":209628,"src":"G505_thumb.jpg","galleries_id":18711,"server_id":15,"link":"photo_209628.html","width":130,"caption":"Cutting Edge","height":198});
															thumbnails[1845821] = clik.newPhoto({"id":1845821,"src":"radziwellview1_thumb.jpg","galleries_id":48080,"server_id":15,"link":"photo_1845821.html","width":130,"caption":"Princess Radziwell's View","height":95});
															thumbnails[1845890] = clik.newPhoto({"id":1845890,"src":"boys1_thumb.jpg","galleries_id":48079,"server_id":15,"link":"photo_1845890.html","width":130,"caption":"Braving the Waves","height":104});
															thumbnails[1845830] = clik.newPhoto({"id":1845830,"src":"harbour2_thumb.jpg","galleries_id":48080,"server_id":15,"link":"photo_1845830.html","width":130,"caption":"Fisherman's Beach","height":93});
															thumbnails[1845895] = clik.newPhoto({"id":1845895,"src":"whitbybay2_thumb.jpg","galleries_id":48079,"server_id":15,"link":"photo_1845895.html","width":130,"caption":"Yachts at Whitby","height":81});
															thumbnails[209488] = clik.newPhoto({"id":209488,"src":"G1021_thumb.jpg","galleries_id":18659,"server_id":15,"link":"photo_209488.html","width":130,"caption":"Brough Haven","height":83});
															thumbnails[209524] = clik.newPhoto({"id":209524,"src":"G202_thumb.jpg","galleries_id":18708,"server_id":15,"link":"photo_209524.html","width":130,"caption":"Fields of Yellow","height":199});
															thumbnails[209564] = clik.newPhoto({"id":209564,"src":"G3021_thumb.jpg","galleries_id":18709,"server_id":15,"link":"photo_209564.html","width":130,"caption":"Melbreak Reflection","height":86});
															thumbnails[209613] = clik.newPhoto({"id":209613,"src":"G403_thumb.jpg","galleries_id":18710,"server_id":15,"link":"photo_209613.html","width":130,"caption":"Callanish Stone","height":202});
															thumbnails[209625] = clik.newPhoto({"id":209625,"src":"G502_thumb.jpg","galleries_id":18711,"server_id":15,"link":"photo_209625.html","width":130,"caption":"Heralds of the Harvest","height":84});
															thumbnails[1845833] = clik.newPhoto({"id":1845833,"src":"shellfull3_thumb.jpg","galleries_id":48080,"server_id":15,"link":"photo_1845833.html","width":130,"caption":"Shell Beach looking Busy","height":79});
															thumbnails[1845898] = clik.newPhoto({"id":1845898,"src":"whitby3_thumb.jpg","galleries_id":48079,"server_id":15,"link":"photo_1845898.html","width":130,"caption":"Work & Play","height":84});
															thumbnails[1845902] = clik.newPhoto({"id":1845902,"src":"beachhuts4_thumb.jpg","galleries_id":48079,"server_id":15,"link":"photo_1845902.html","width":130,"caption":"North Bay Whitby","height":85});
															thumbnails[1845834] = clik.newPhoto({"id":1845834,"src":"shellsky4_thumb.jpg","galleries_id":48080,"server_id":15,"link":"photo_1845834.html","width":130,"caption":"Skyscape at Shell Beach","height":101});
															thumbnails[209492] = clik.newPhoto({"id":209492,"src":"G103_thumb.jpg","galleries_id":18659,"server_id":15,"link":"photo_209492.html","width":130,"caption":"Golden Light","height":83});
															thumbnails[209525] = clik.newPhoto({"id":209525,"src":"G203_thumb.jpg","galleries_id":18708,"server_id":15,"link":"photo_209525.html","width":130,"caption":"Snow Puddles","height":85});
															thumbnails[209565] = clik.newPhoto({"id":209565,"src":"G303_thumb.jpg","galleries_id":18709,"server_id":15,"link":"photo_209565.html","width":130,"caption":"Crummock Reflection","height":85});
															thumbnails[209626] = clik.newPhoto({"id":209626,"src":"G503_thumb.jpg","galleries_id":18711,"server_id":15,"link":"photo_209626.html","width":130,"caption":"Single Daffodil","height":198});
															thumbnails[210679] = clik.newPhoto({"id":210679,"src":"G402a_thumb.jpg","galleries_id":18710,"server_id":15,"link":"photo_210679.html","width":130,"caption":"Once Upon a Time","height":86});
															thumbnails[1845839] = clik.newPhoto({"id":1845839,"src":"tridentwaiting5_thumb.jpg","galleries_id":48080,"server_id":15,"link":"photo_1845839.html","width":130,"caption":"Trident waitng on Captain's Table","height":99});
															thumbnails[1845903] = clik.newPhoto({"id":1845903,"src":"dog5_thumb.jpg","galleries_id":48079,"server_id":15,"link":"photo_1845903.html","width":130,"caption":"Playing Fetch in the Water","height":85});
															thumbnails[1845905] = clik.newPhoto({"id":1845905,"src":"nlanding6_thumb.jpg","galleries_id":48079,"server_id":15,"link":"photo_1845905.html","width":130,"caption":"Fishing Boat at North Landing","height":198});
															thumbnails[1846020] = clik.newPhoto({"id":1846020,"src":"hermharbourmod6_thumb.jpg","galleries_id":48080,"server_id":15,"link":"photo_1846020.html","width":130,"caption":"Herm Harbour","height":98});
															thumbnails[209496] = clik.newPhoto({"id":209496,"src":"G104_thumb.jpg","galleries_id":18659,"server_id":15,"link":"photo_209496.html","width":130,"caption":"Middle Whitton","height":85});
															thumbnails[209526] = clik.newPhoto({"id":209526,"src":"G204_thumb.jpg","galleries_id":18708,"server_id":15,"link":"photo_209526.html","width":130,"caption":"Lonely tree on High Hunsley","height":198});
															thumbnails[209568] = clik.newPhoto({"id":209568,"src":"G304_thumb.jpg","galleries_id":18709,"server_id":15,"link":"photo_209568.html","width":130,"caption":"Wast Water","height":86});
															thumbnails[209616] = clik.newPhoto({"id":209616,"src":"G405_thumb.jpg","galleries_id":18710,"server_id":15,"link":"photo_209616.html","width":130,"caption":"Autumn comes to Loch Rannoch","height":198});
															thumbnails[209624] = clik.newPhoto({"id":209624,"src":"G501_thumb.jpg","galleries_id":18711,"server_id":15,"link":"photo_209624.html","width":130,"caption":"Simply Red","height":86});
															thumbnails[1845846] = clik.newPhoto({"id":1845846,"src":"unloadseahorse7_thumb.jpg","galleries_id":48080,"server_id":15,"link":"photo_1845846.html","width":130,"caption":"Unloading the Seahorse","height":98});
															thumbnails[1845909] = clik.newPhoto({"id":1845909,"src":"scarborofishing7_thumb.jpg","galleries_id":48079,"server_id":15,"link":"photo_1845909.html","width":130,"caption":"Business & Pleasure","height":86});
															thumbnails[209514] = clik.newPhoto({"id":209514,"src":"G105_thumb.jpg","galleries_id":18659,"server_id":15,"link":"photo_209514.html","width":130,"caption":"Evening Shift","height":84});
															thumbnails[209527] = clik.newPhoto({"id":209527,"src":"G205_thumb.jpg","galleries_id":18708,"server_id":15,"link":"photo_209527.html","width":130,"caption":"Crackling of Frost","height":87});
															thumbnails[209571] = clik.newPhoto({"id":209571,"src":"G305_thumb.jpg","galleries_id":18709,"server_id":15,"link":"photo_209571.html","width":130,"caption":"Private Picnic","height":87});
															thumbnails[209614] = clik.newPhoto({"id":209614,"src":"G404_thumb.jpg","galleries_id":18710,"server_id":15,"link":"photo_209614.html","width":130,"caption":"River Reflection","height":84});
															thumbnails[209627] = clik.newPhoto({"id":209627,"src":"G504_thumb.jpg","galleries_id":18711,"server_id":15,"link":"photo_209627.html","width":130,"caption":"Busy with Veronica","height":198});
															thumbnails[1845856] = clik.newPhoto({"id":1845856,"src":"offshellbeachmod9_thumb.jpg","galleries_id":48080,"server_id":15,"link":"photo_1845856.html","width":130,"caption":"Boats off Shell Beach","height":81});
															thumbnails[1845912] = clik.newPhoto({"id":1845912,"src":"scarboro8_thumb.jpg","galleries_id":48079,"server_id":15,"link":"photo_1845912.html","width":130,"caption":"Rough seas at Scarborough","height":83});
															thumbnails[1845916] = clik.newPhoto({"id":1845916,"src":"recovered9_thumb.jpg","galleries_id":48079,"server_id":15,"link":"photo_1845916.html","width":130,"caption":"Recovering Fishing boat at Filey","height":85});
															thumbnails[1850855] = clik.newPhoto({"id":1850855,"src":"mousonnierewave11_thumb.jpg","galleries_id":48080,"server_id":15,"link":"photo_1850855.html","width":130,"caption":"Wave at Alderney Point","height":100});
															thumbnails[209516] = clik.newPhoto({"id":209516,"src":"G106_thumb.jpg","galleries_id":18659,"server_id":15,"link":"photo_209516.html","width":130,"caption":"Sand Bar ","height":85});
															thumbnails[209529] = clik.newPhoto({"id":209529,"src":"G206_thumb.jpg","galleries_id":18708,"server_id":15,"link":"photo_209529.html","width":130,"caption":"Church in the Dale","height":84});
															thumbnails[209572] = clik.newPhoto({"id":209572,"src":"G306_thumb.jpg","galleries_id":18709,"server_id":15,"link":"photo_209572.html","width":130,"caption":"Under Haystacks","height":85});
															thumbnails[209620] = clik.newPhoto({"id":209620,"src":"G408_thumb.jpg","galleries_id":18710,"server_id":15,"link":"photo_209620.html","width":130,"caption":"Old Man of Storr","height":84});
															thumbnails[209630] = clik.newPhoto({"id":209630,"src":"G507_thumb.jpg","galleries_id":18711,"server_id":15,"link":"photo_209630.html","width":130,"caption":"Single Barley","height":196});
															thumbnails[1845862] = clik.newPhoto({"id":1845862,"src":"offbelvoir10_thumb.jpg","galleries_id":48080,"server_id":15,"link":"photo_1845862.html","width":130,"caption":"Towards Alderney","height":91});
															thumbnails[1845920] = clik.newPhoto({"id":1845920,"src":"thornwick10_thumb.jpg","galleries_id":48079,"server_id":15,"link":"photo_1845920.html","width":130,"caption":"Sunset over Thornwick Bay","height":135});
															thumbnails[209517] = clik.newPhoto({"id":209517,"src":"G107_thumb.jpg","galleries_id":18659,"server_id":15,"link":"photo_209517.html","width":130,"caption":"Bouncing Ball","height":85});
															thumbnails[209532] = clik.newPhoto({"id":209532,"src":"G208_thumb.jpg","galleries_id":18708,"server_id":15,"link":"photo_209532.html","width":130,"caption":"Fish Docks, Hull","height":195});
															thumbnails[209573] = clik.newPhoto({"id":209573,"src":"G307_thumb.jpg","galleries_id":18709,"server_id":15,"link":"photo_209573.html","width":130,"caption":"Buttermere Pines","height":85});
															thumbnails[209618] = clik.newPhoto({"id":209618,"src":"G407_thumb.jpg","galleries_id":18710,"server_id":15,"link":"photo_209618.html","width":130,"caption":"Autumn in Glen Dochart","height":195});
															thumbnails[209629] = clik.newPhoto({"id":209629,"src":"G506_thumb.jpg","galleries_id":18711,"server_id":15,"link":"photo_209629.html","width":130,"caption":"Pastel Shades","height":85});
															thumbnails[209518] = clik.newPhoto({"id":209518,"src":"G108_thumb.jpg","galleries_id":18659,"server_id":15,"link":"photo_209518.html","width":130,"caption":"Last Man Home","height":84});
															thumbnails[209530] = clik.newPhoto({"id":209530,"src":"G207_thumb.jpg","galleries_id":18708,"server_id":15,"link":"photo_209530.html","width":130,"caption":"Wolds Village","height":85});
															thumbnails[209574] = clik.newPhoto({"id":209574,"src":"G308_thumb.jpg","galleries_id":18709,"server_id":15,"link":"photo_209574.html","width":130,"caption":"River Brathay","height":86});
															thumbnails[209621] = clik.newPhoto({"id":209621,"src":"G409_thumb.jpg","galleries_id":18710,"server_id":15,"link":"photo_209621.html","width":130,"caption":"Watery Sunlight","height":83});
															thumbnails[209631] = clik.newPhoto({"id":209631,"src":"G508_thumb.jpg","galleries_id":18711,"server_id":15,"link":"photo_209631.html","width":130,"caption":"Sunset Barley","height":85});
															thumbnails[209519] = clik.newPhoto({"id":209519,"src":"G109_thumb.jpg","galleries_id":18659,"server_id":15,"link":"photo_209519.html","width":130,"caption":"High Water at Brough Haven","height":85});
															thumbnails[209536] = clik.newPhoto({"id":209536,"src":"G209_thumb.jpg","galleries_id":18708,"server_id":15,"link":"photo_209536.html","width":130,"caption":"North Bank Giant","height":198});
															thumbnails[209575] = clik.newPhoto({"id":209575,"src":"G309_thumb.jpg","galleries_id":18709,"server_id":15,"link":"photo_209575.html","width":130,"caption":"Borrowdale Sunlight","height":85});
															thumbnails[209617] = clik.newPhoto({"id":209617,"src":"G406_thumb.jpg","galleries_id":18710,"server_id":15,"link":"photo_209617.html","width":130,"caption":"Lochans on Rannoch Moor","height":199});
															thumbnails[209633] = clik.newPhoto({"id":209633,"src":"G510_thumb.jpg","galleries_id":18711,"server_id":15,"link":"photo_209633.html","width":130,"caption":"Friendly Encounter","height":85});
															thumbnails[209520] = clik.newPhoto({"id":209520,"src":"G110_thumb.jpg","galleries_id":18659,"server_id":15,"link":"photo_209520.html","width":130,"caption":"Humber Bridge at Twilight","height":87});
															thumbnails[209541] = clik.newPhoto({"id":209541,"src":"G210_thumb.jpg","galleries_id":18708,"server_id":15,"link":"photo_209541.html","width":130,"caption":"Brantingham Top","height":89});
															thumbnails[209576] = clik.newPhoto({"id":209576,"src":"G310_thumb.jpg","galleries_id":18709,"server_id":15,"link":"photo_209576.html","width":130,"caption":"Mackerel and Cats","height":85});
															thumbnails[209622] = clik.newPhoto({"id":209622,"src":"G410_thumb.jpg","galleries_id":18710,"server_id":15,"link":"photo_209622.html","width":130,"caption":"Sundown on Loch Cill Chriosd","height":84});
															thumbnails[209632] = clik.newPhoto({"id":209632,"src":"G509_thumb.jpg","galleries_id":18711,"server_id":15,"link":"photo_209632.html","width":130,"caption":"Lavender Web","height":200});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  						galleries[18659] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Humber Estuary","link":"gallery_18659.html","maxRecords":0.0,"photoIDs":[209484.0,209488.0,209492.0,209496.0,209514.0,209516.0,209517.0,209518.0,209519.0,209520.0],"skipIndex":0,"section_code":"gallery","featured_images":"209520,209519,209518,209517,209516,209514,209496,209492,209488,209484","id":18659,"singleSection":false});				  						galleries[18708] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"East Yorkshire & The Wolds","link":"gallery_18708.html","maxRecords":0.0,"photoIDs":[209522.0,209524.0,209525.0,209526.0,209527.0,209529.0,209532.0,209530.0,209536.0,209541.0],"skipIndex":0,"section_code":"gallery","featured_images":"209541,209536,209532,209530,209529,209527,209526,209525,209524,209522","id":18708,"singleSection":false});				  						galleries[48079] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Yorkshire Coast","link":"gallery_48079.html","maxRecords":0.0,"photoIDs":[1845890.0,1845895.0,1845898.0,1845902.0,1845903.0,1845905.0,1845909.0,1845912.0,1845916.0,1845920.0],"skipIndex":0,"section_code":"gallery","featured_images":"1845920,1845916,1845912,1845909,1845905,1845903,1845902,1845898,1845895,1845890","id":48079,"singleSection":false});				  						galleries[18709] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Lake District","link":"gallery_18709.html","maxRecords":0.0,"photoIDs":[209560.0,209564.0,209565.0,209568.0,209571.0,209572.0,209573.0,209574.0,209575.0,209576.0],"skipIndex":0,"section_code":"gallery","featured_images":"209576,209575,209574,209573,209572,209571,209568,209565,209564,209560","id":18709,"singleSection":false});				  						galleries[18710] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Western Isles & Scottish Highlands","link":"gallery_18710.html","maxRecords":0.0,"photoIDs":[209609.0,209613.0,210679.0,209616.0,209614.0,209620.0,209618.0,209621.0,209617.0,209622.0],"skipIndex":0,"section_code":"gallery","featured_images":"210679,209622,209618,209617,209616,209614,209613,209609","id":18710,"singleSection":false});				  						galleries[48080] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Herm Island","link":"gallery_48080.html","maxRecords":0.0,"photoIDs":[1845821.0,1845830.0,1845833.0,1845834.0,1845839.0,1846020.0,1845846.0,1845856.0,1850855.0,1845862.0],"skipIndex":0,"section_code":"gallery","featured_images":"1850855,1846020,1845862,1845856,1845846,1845839,1845834,1845833,1845830,1845821","id":48080,"singleSection":false});				  						galleries[18711] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Nature and Flowers","link":"gallery_18711.html","maxRecords":0.0,"photoIDs":[209628.0,209625.0,209626.0,209624.0,209627.0,209630.0,209629.0,209631.0,209633.0,209632.0],"skipIndex":0,"section_code":"gallery","featured_images":"209633,209632,209631,209630,209629,209628,209627,209626,209625,209624","id":18711,"singleSection":false});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[1] = '1850855,1846020,1845920,1845916,1845912,1845909,1845905,1845903,1845902,1845898,1845895,1845890,1845869,1845862,1845856,1845846,1845839,1845834,1845833,1845830,1845821,209522';
imageSets[2] = '1850855,1846020,1845920,1845916,1845912,1845909,1845905,1845903,1845902,1845898,1845895,1845890,1845862,1845856,1845846,1845839,1845834,1845833,1845830,1845821,210679,209633,209632,209631,209630,209629,209628,209627,209626,209625,209624,209622,209618,209617,209616,209614,209613,209609,209576,209575,209574,209573,209572,209571,209568,209565,209564,209560,209541,209536,209532,209530,209529,209527,209526,209525,209524,209522,209520,209519,209518,209517,209516,209514,209496,209492,209488,209484';
imageSets[3] = '1850855,1846020,1845920,1845916,1845912,1845909,1845905,1845903,1845902,1845898,1845895,1845890,1845869,1845862,1845856,1845846,1845839,1845834,1845833,1845830,1845821,210993,210786,210784,210679,209633,209632,209631,209630,209629,209628,209627,209626,209625,209624,209622,209621,209620,209618,209617,209616,209614,209613,209609,209576,209575,209574,209573,209572,209571';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/edwardo/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/edwardo/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/edwardo/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/edwardo/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/edwardo/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/edwardo/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/edwardo/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/edwardo/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/edwardo/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/edwardo/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/edwardo/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/edwardo/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/edwardo/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/edwardo/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/edwardo/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/edwardo/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/edwardo/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/edwardo/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/edwardo/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/edwardo/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/edwardo/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/edwardo/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/edwardo/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 = 'Humber 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> ' + (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 += '<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;
	}
}

			

