window.thumbnails = new Object();
												thumbnails[99030] = new thumbnail(99030,'9392','Llangrannog shoreline','llangrannogshoreline_thumb.jpg',130, 173,15,'photo_99030.html');
												thumbnails[99032] = new thumbnail(99032,'9249','The beach at Mwnt','Mwnt_beach_thumb.jpg',130, 98,15,'photo_99032.html');
												thumbnails[99033] = new thumbnail(99033,'9393','Sammy the seal','Sammy_the_seal_thumb.jpg',130, 98,15,'photo_99033.html');
												thumbnails[99034] = new thumbnail(99034,'9249','Newquay harbour','Newquay_thumb.jpg',130, 98,15,'photo_99034.html');
												thumbnails[99035] = new thumbnail(99035,'9393','Please keep off the fence','Robin_thumb.jpg',130, 98,15,'photo_99035.html');
												thumbnails[99038] = new thumbnail(99038,'9249','Red telephone box','Telephone_box_thumb.jpg',130, 173,15,'photo_99038.html');
												thumbnails[99040] = new thumbnail(99040,'9249','Poppit ','Poppit_thumb.jpg',130, 98,15,'photo_99040.html');
												thumbnails[99041] = new thumbnail(99041,'9249','Carreg Beca','Carreg_beca_mono_thumb.jpg',130, 98,15,'photo_99041.html');
												thumbnails[99042] = new thumbnail(99042,'9393','Seals at Cwmtudu','Seals_thumb.jpg',130, 98,15,'photo_99042.html');
												thumbnails[99043] = new thumbnail(99043,'9249','Newport sands.','Newport_sands_thumb.jpg',130, 98,15,'photo_99043.html');
												thumbnails[99045] = new thumbnail(99045,'9392','Walking the dog','Walking_the_dog_thumb.jpg',130, 98,15,'photo_99045.html');
												thumbnails[99046] = new thumbnail(99046,'9393','October swans','october-swans_thumb.jpg',130, 173,15,'photo_99046.html');
												thumbnails[99047] = new thumbnail(99047,'9393','fire coral','Fire_coral_thumb.jpg',130, 130,15,'photo_99047.html');
												thumbnails[99048] = new thumbnail(99048,'9249','Autumn in Emlyn','Autumn_in_Emlyn_thumb.jpg',130, 173,15,'photo_99048.html');
												thumbnails[99049] = new thumbnail(99049,'9249','poppit sands','poppitsands_thumb.jpg',130, 98,15,'photo_99049.html');
												thumbnails[99050] = new thumbnail(99050,'9249','carreg beca rock formations','carreg-beca-rock-formations_thumb.jpg',130, 98,15,'photo_99050.html');
												thumbnails[99052] = new thumbnail(99052,'9392','Pink waterfall','Waterfall_thumb.jpg',130, 173,15,'photo_99052.html');
												thumbnails[99053] = new thumbnail(99053,'9392','Tresaith waterfall','Tresaith_waterfall_thumb.jpg',130, 98,15,'photo_99053.html');
												thumbnails[99056] = new thumbnail(99056,'9249','Llangrannog','llangrannogmono 2_thumb.jpg',130, 98,15,'photo_99056.html');
												thumbnails[99057] = new thumbnail(99057,'9249','Tresaith village','Tresaith_village_thumb.jpg',130, 98,15,'photo_99057.html');
												thumbnails[99058] = new thumbnail(99058,'9249','Pentre Ifan','Pentre_ifan1_thumb.jpg',130, 98,15,'photo_99058.html');
												thumbnails[99059] = new thumbnail(99059,'9392','View from Ceibwr','Ceibwr_thumb.jpg',130, 98,15,'photo_99059.html');
												thumbnails[3525117] = new thumbnail(3525117,'9249','low tide llangrannog','low-tide-llangrannog_thumb.jpg',130, 173,15,'photo_3525117.html');
												thumbnails[3525174] = new thumbnail(3525174,'9249','Penbryn moody skies','penbryn-mood_thumb.jpg',130, 98,15,'photo_3525174.html');
												thumbnails[3525198] = new thumbnail(3525198,'9249','Castell Emlyn','castell-emlyn_thumb.jpg',130, 98,15,'photo_3525198.html');
												thumbnails[3525316] = new thumbnail(3525316,'9249','Tenby','tenby_thumb.jpg',130, 173,15,'photo_3525316.html');
												thumbnails[3525515] = new thumbnail(3525515,'9249','View to Dinas','view-to-dinas_thumb.jpg',130, 98,15,'photo_3525515.html');
												thumbnails[3525518] = new thumbnail(3525518,'9392','Penbryn cave','penbryn-cave-mono_thumb.jpg',130, 98,15,'photo_3525518.html');
												thumbnails[3525520] = new thumbnail(3525520,'9392','October grass','october-grass_thumb.jpg',130, 173,15,'photo_3525520.html');
												thumbnails[3525521] = new thumbnail(3525521,'9249','Lochtyn autumn','lochtynautumn_thumb.jpg',130, 173,15,'photo_3525521.html');
												thumbnails[3525524] = new thumbnail(3525524,'9249','Cwmtudu','cwmtudu_1_thumb.jpg',130, 98,15,'photo_3525524.html');
												thumbnails[3525538] = new thumbnail(3525538,'9392','Carreg beca silhouette','carreg-beca-silhouette_thumb.jpg',130, 98,15,'photo_3525538.html');
												thumbnails[7775774] = new thumbnail(7775774,'9249','september tide','septembertide_thumb.jpg',130, 98,15,'photo_7775774.html');
												thumbnails[7775895] = new thumbnail(7775895,'9249','Llangrannog wave','llangrannogwave1_thumb.jpg',130, 98,15,'photo_7775895.html');
												thumbnails[7777091] = new thumbnail(7777091,'420212','White swan lake, Canada','whiteswanlake_thumb.jpg',130, 98,15,'photo_7777091.html');
												thumbnails[7777096] = new thumbnail(7777096,'420212','Southern Utah,U.S.A','utah_thumb.jpg',130, 98,15,'photo_7777096.html');
												thumbnails[7777105] = new thumbnail(7777105,'9249','tresaith coastline','tresaithcoastline_thumb.jpg',130, 173,15,'photo_7777105.html');
												thumbnails[7777111] = new thumbnail(7777111,'9393','trees','trees_thumb.jpg',130, 98,15,'photo_7777111.html');
												thumbnails[7777117] = new thumbnail(7777117,'420212','sunset in Gozo','sunsetingozo_thumb.jpg',130, 98,15,'photo_7777117.html');
												thumbnails[7777139] = new thumbnail(7777139,'9392','Surfbreak','surfbreak1_thumb.jpg',130, 173,15,'photo_7777139.html');
												thumbnails[7777142] = new thumbnail(7777142,'420212','Sunset at Grand Canyon','sunsetatthecanyon_thumb.jpg',130, 173,15,'photo_7777142.html');
												thumbnails[7777143] = new thumbnail(7777143,'9392','Summer storm','summerstorm_thumb.jpg',130, 173,15,'photo_7777143.html');
												thumbnails[7777146] = new thumbnail(7777146,'9249','Storm clouds at Tresaith','stormcloudsattresaith_thumb.jpg',130, 98,15,'photo_7777146.html');
												thumbnails[7777150] = new thumbnail(7777150,'9392','Sky on fire','skyonfire_thumb.jpg',130, 173,15,'photo_7777150.html');
												thumbnails[7777154] = new thumbnail(7777154,'9392','Rocky shores','rockyshores_thumb.jpg',130, 173,15,'photo_7777154.html');
												thumbnails[7777158] = new thumbnail(7777158,'9249','Rainbow waterfall Tresaith','rainbowwaterfalltresaith_thumb.jpg',130, 173,15,'photo_7777158.html');
												thumbnails[7777162] = new thumbnail(7777162,'9249','Rainbow on the hill, Tregroes','rainbowonthehill_thumb.jpg',130, 173,15,'photo_7777162.html');
												thumbnails[7777165] = new thumbnail(7777165,'9249','Poppit afternoon','poppitafternoon_thumb.jpg',130, 173,15,'photo_7777165.html');
												thumbnails[7777261] = new thumbnail(7777261,'9392','Pink sunset','pinksunset_thumb.jpg',130, 173,15,'photo_7777261.html');
												thumbnails[7777272] = new thumbnail(7777272,'9392','Oceanbreak','oceanbreak_thumb.jpg',130, 98,15,'photo_7777272.html');
												thumbnails[7777277] = new thumbnail(7777277,'420212','Monmument valley, U.S.A','monumentvalley_thumb.jpg',130, 98,15,'photo_7777277.html');
												thumbnails[7777286] = new thumbnail(7777286,'420212','Lucky beach, S.W.Australia','luckybeach_thumb.jpg',130, 173,15,'photo_7777286.html');
												thumbnails[7777294] = new thumbnail(7777294,'420212','Kyrenia, Northern Cyprus','kyrenia_thumb.jpg',130, 98,15,'photo_7777294.html');
												thumbnails[7777303] = new thumbnail(7777303,'9249','Low tide Tresaith','lowtidetresaith_thumb.jpg',130, 173,15,'photo_7777303.html');
												thumbnails[7777304] = new thumbnail(7777304,'9393','Gulls','gulls_thumb.jpg',130, 98,15,'photo_7777304.html');
												thumbnails[7777309] = new thumbnail(7777309,'9249','Frozen waterfall Tresaith','frozenwaterfalltresaith_thumb.jpg',130, 173,15,'photo_7777309.html');
												thumbnails[7777316] = new thumbnail(7777316,'420212','Flagstaff fields, Arizona','flagstafffields_thumb.jpg',130, 98,15,'photo_7777316.html');
												thumbnails[7777320] = new thumbnail(7777320,'420212','Dusk at the jetty, Malcesime, Italy','duskatthejetty_thumb.jpg',130, 98,15,'photo_7777320.html');
												thumbnails[7777323] = new thumbnail(7777323,'420212','Cruising in Gozo','cruisingingozo_thumb.jpg',130, 173,15,'photo_7777323.html');
												thumbnails[7777339] = new thumbnail(7777339,'9249','Colours of the waterfall,Tresaith','coloursofthewaterfall_thumb.jpg',130, 98,15,'photo_7777339.html');
												thumbnails[7777341] = new thumbnail(7777341,'9249','Cenarth','cenarth_thumb.jpg',130, 98,15,'photo_7777341.html');
												thumbnails[7777345] = new thumbnail(7777345,'420212','Bryce canyon in the snow,Utah,U.S.A','brycecanyoninthesnow_thumb.jpg',130, 98,15,'photo_7777345.html');
												thumbnails[7777349] = new thumbnail(7777349,'420212','behind the rocks,Bunbury, Western Australia','behindtherocks_thumb.jpg',130, 98,15,'photo_7777349.html');
												thumbnails[7777354] = new thumbnail(7777354,'9249','A Welsh winter, Tregroes','awelshwinter_thumb.jpg',130, 98,15,'photo_7777354.html');
												thumbnails[7777355] = new thumbnail(7777355,'9393','Autumn leaves','autumnleaves_thumb.jpg',130, 173,15,'photo_7777355.html');
												thumbnails[7928835] = new thumbnail(7928835,'427296','Llangrannog wave panorama','llangrannogwavepanorama_thumb.jpg',130, 54,15,'photo_7928835.html');
												thumbnails[7928839] = new thumbnail(7928839,'9392','Fiery sunset','fierysunset_thumb.jpg',130, 98,15,'photo_7928839.html');
												thumbnails[7928840] = new thumbnail(7928840,'427296','January afternoon Llangrannog','januaryafternoonllangrannog_thumb.jpg',130, 54,15,'photo_7928840.html');
												thumbnails[7928843] = new thumbnail(7928843,'9392','Second beach Llangrannog','secondbeach_thumb.jpg',130, 98,15,'photo_7928843.html');
												thumbnails[7928845] = new thumbnail(7928845,'427296','Second beach tides','secondbeachtides_thumb.jpg',130, 54,15,'photo_7928845.html');
												thumbnails[7928847] = new thumbnail(7928847,'9393','Sheep in snow','sheep_thumb.jpg',130, 98,15,'photo_7928847.html');
												thumbnails[7928854] = new thumbnail(7928854,'9393','Sheep on headland','sheeponheadland_thumb.jpg',130, 98,15,'photo_7928854.html');
												thumbnails[7928857] = new thumbnail(7928857,'9249','Summer in Llangrannog','summerinllangrannog_thumb.jpg',130, 173,15,'photo_7928857.html');
												thumbnails[7928947] = new thumbnail(7928947,'9393','','Starfish_thumb.jpg',130, 130,15,'photo_7928947.html');
												thumbnails[7929014] = new thumbnail(7929014,'9249','Woodland waterfall Cwmtudu','Woodland_waterfall_thumb.jpg',130, 173,15,'photo_7929014.html');
												thumbnails[7929051] = new thumbnail(7929051,'9392','Moonlit seas','Stormy_seas_thumb.jpg',130, 98,15,'photo_7929051.html');
												thumbnails[7929056] = new thumbnail(7929056,'9392','Tresaith beach','Tresaith_beach_thumb.jpg',130, 98,15,'photo_7929056.html');
												thumbnails[7929091] = new thumbnail(7929091,'9249','Cliffs at Mwnt','mwntcliffsportrait_thumb.jpg',130, 173,15,'photo_7929091.html');
												thumbnails[7929104] = new thumbnail(7929104,'427296','Boxing day afternoon Llangrannog','boxingdayafternoonllangrannog_thumb.jpg',130, 54,15,'photo_7929104.html');
												thumbnails[7929111] = new thumbnail(7929111,'427296','Carreg beca sunset','carregbecasunset_thumb.jpg',130, 54,15,'photo_7929111.html');
												thumbnails[98974] = new thumbnail(98974,'9249','Llangrannog October light','llangrannogoctoberlight_thumb.jpg',130, 98,15,'photo_98974.html');
												thumbnails[98916] = new thumbnail(98916,'9249','Llangrannog silhouette','Llangrannog_silhouette_thumb.jpg',130, 98,15,'photo_98916.html');
												thumbnails[98975] = new thumbnail(98975,'9249','The church at Mwnt','Mwnt_thumb.jpg',130, 98,15,'photo_98975.html');
												thumbnails[98977] = new thumbnail(98977,'9249','Cwmtudu coastal walk','Cwmtudu_thumb.jpg',130, 173,15,'photo_98977.html');
												thumbnails[98982] = new thumbnail(98982,'9249','Cwm yr Eglwys silhouette','Cwm_yr_eglwys_silhouette_thumb.jpg',130, 98,15,'photo_98982.html');
												thumbnails[98984] = new thumbnail(98984,'9392','Storm at Llangrannog','Llangrannog_storm_thumb.jpg',130, 173,15,'photo_98984.html');
												thumbnails[98989] = new thumbnail(98989,'9392','Tresaith sunset','Tresaith_sunset_thumb.jpg',130, 98,15,'photo_98989.html');
												thumbnails[98992] = new thumbnail(98992,'9392','Sunlit seas','Sunlit_seas_thumb.jpg',130, 98,15,'photo_98992.html');
												thumbnails[98993] = new thumbnail(98993,'9392','Fishing at sunset','Sunset_fishing_thumb.jpg',130, 173,15,'photo_98993.html');
												thumbnails[99000] = new thumbnail(99000,'9393','sea anenome','Sea_anenome_thumb.jpg',130, 130,15,'photo_99000.html');
												thumbnails[99002] = new thumbnail(99002,'9393','bluebells','Bluebells_thumb.jpg',130, 98,15,'photo_99002.html');
												thumbnails[99024] = new thumbnail(99024,'9395','playgroup portrait example','playgroup_1_thumb.jpg',130, 172,15,'photo_99024.html');
												thumbnails[99004] = new thumbnail(99004,'9393','cowslip','Cowslip_thumb.jpg',130, 130,15,'photo_99004.html');
												thumbnails[99026] = new thumbnail(99026,'9395','playgroup portrait example','playgroup_2_thumb.jpg',130, 195,15,'photo_99026.html');
												thumbnails[99006] = new thumbnail(99006,'9393','poppies','Poppies_thumb.jpg',130, 130,15,'photo_99006.html');
												thumbnails[99008] = new thumbnail(99008,'9393','dandelion','Dandelion_thumb.jpg',130, 130,15,'photo_99008.html');
												thumbnails[99013] = new thumbnail(99013,'9394','restoration 1 original','restoration_1_original_thumb.jpg',130, 215,15,'photo_99013.html');
												thumbnails[99015] = new thumbnail(99015,'9394','restoration 1 restored','restoration_1_restored_thumb.jpg',130, 215,15,'photo_99015.html');
												thumbnails[99017] = new thumbnail(99017,'9394','montage example 1','montage _1_thumb.jpg',130, 92,15,'photo_99017.html');
												thumbnails[99020] = new thumbnail(99020,'9394','montage example 2','montage_2_thumb.jpg',130, 92,15,'photo_99020.html');

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  					galleries[427296] = new gallery(427296,'7929111,7929104,7928845,7928840,7928835','Panoramics','gallery',[7928835,7928840,7928845,7929104,7929111],0, 0, '', 'gallery_427296.html',0,0);
				  					galleries[9249] = new gallery(9249,'7929091,7929014,7777354,7777341,7777339,7777309,7777303,7777165,7777162,7777158,7777146,7777105,7775895,98974','Welsh Landscapes','gallery',[99032,99034,99038,99040,99041,99043,99048,99049,99050,99056,99057,99058,3525117,3525174,3525198,3525316,3525515,3525521,3525524,7775774,7775895,7777105,7777146,7777158,7777162,7777165,7777303,7777309,7777339,7777341,7777354,7928857,7929014,7929091,98974,98916,98975,98977,98982],0, 0, '', 'gallery_9249.html',0,0);
				  					galleries[9392] = new gallery(9392,'7929056,7929051,7928843,7928839,7777272,7777261,7777154,7777150,7777143,7777139','Seascapes and Sunsets','gallery',[99030,99045,99052,99053,99059,3525518,3525520,3525538,7777139,7777143,7777150,7777154,7777261,7777272,7928839,7928843,7929051,7929056,98984,98989,98992,98993],0, 0, '', 'gallery_9392.html',0,0);
				  					galleries[9393] = new gallery(9393,'7928947,7928854,7928847,7777355,7777304,7777111,99002','Nature','gallery',[99033,99035,99042,99046,99047,7777111,7777304,7777355,7928847,7928854,7928947,99000,99002,99004,99006,99008],0, 0, '', 'gallery_9393.html',0,0);
				  					galleries[420212] = new gallery(420212,'7777349,7777345,7777323,7777320,7777316,7777294,7777286,7777277,7777142,7777117,7777096,7777091','Another time another place','gallery',[7777091,7777096,7777117,7777142,7777277,7777286,7777294,7777316,7777320,7777323,7777345,7777349],0, 0, '', 'gallery_420212.html',0,0);
				  					galleries[9394] = new gallery(9394,'99020,99017,99015,99013','Montage and restoration','gallery',[99013,99015,99017,99020],0, 0, '', 'gallery_9394.html',0,0);
				  					galleries[9395] = new gallery(9395,'99026,99024','Playgroup Portraits','gallery',[99024,99026],0, 0, '', 'gallery_9395.html',0,0);
/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = new Object();
imageSets[1] = '7929111,7929104,7929091,7929056,7929051,7929014,7928947,7928854,7928847,7928845,7928843,7928840,7928839,7928835,7777355,7777354,7777349,7777345,7777341,7777339,7777323,7777320,7777316,7777309,7777304,7777303,7777294,7777286,7777277,7777272,7777261,7777165,7777162,7777158,7777154,7777150,7777146,7777143,7777142,7777139,7777117,7777111,7777105,7777096,7777091,7775895,7775774,3525521,3525515,3525316,3525117,99050,99048,99046,99040,99032,99030,99008,99006,99002,98992,98984,98982,98975,98974,98916';
imageSets[2] = '7929111,7929104,7929091,7929056,7929051,7929014,7928947,7928854,7928847,7928845,7928843,7928840,7928839,7928835,7777355,7777354,7777349,7777345,7777341,7777339,7777323,7777320,7777316,7777309,7777304,7777303,7777294,7777286,7777277,7777272,7777261,7777165,7777162,7777158,7777154,7777150,7777146,7777143,7777142,7777139,7777117,7777111,7777105,7777096,7777091,7775895,99002,98974';
imageSets[3] = '7929111,7929104,7929091,7929056,7929051,7929014,7928947,7928857,7928854,7928847,7928845,7928843,7928840,7928839,7928835,7777355,7777354,7777349,7777345,7777341,7777339,7777323,7777320,7777316,7777309,7777304,7777303,7777294,7777286,7777277,7777272,7777261,7777165,7777162,7777158,7777154,7777150,7777146,7777143,7777142,7777139,7777117,7777111,7777105,7777096,7777091,7775895,7775774,3525538,3525524';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/GillWillmott/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/GillWillmott/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/GillWillmott/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/GillWillmott/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/GillWillmott/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/GillWillmott/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/GillWillmott/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/GillWillmott/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/GillWillmott/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/GillWillmott/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/GillWillmott/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/GillWillmott/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/GillWillmott/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/GillWillmott/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/GillWillmott/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://admin2.clikpic.com/GillWillmott/images';
		break;
	}
		switch (server_id) {
		case 33:
		val = 'http://www8.clikpic.com/GillWillmott/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/GillWillmott/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/GillWillmott/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/GillWillmott/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/GillWillmott/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/GillWillmott/images';
		break;
	}
		return val;
}

/***************************************************************************
* img = reference to image object in which to show image                   *
***************************************************************************/
function showHomeImage(img) {

	imageID = randomListVal('');
		if (!basic) {
	img.src = photos[imageID].src;
	img.width = photos[imageID].width;
	img.height = photos[imageID].height;
  img.parentNode.title = img.alt = photos[imageID].caption;
	}
	else {
		newImage = new Image(photos[imageID].width,photos[imageID].height);
		newImage.src = photos[imageID].src;
		document.images[img.name] = newImage;
				
	}
			}

function getHomeImageLink(imageID) {
  	var href='', photo = backgrounds && backgrounds[imageID];
	if(photo){
		if (photo && photo.galleries_id != '') {
  			href = photo.fnGalleryLink();
  		}
  		  		else {
  				href += 'gallery.html';
  	  		}
	}
    return href;
}
/***************************************************************************
* Show a random image on home page from featured images                    *
***************************************************************************/
function showHomeImageInline(el, image_sets_id, href) {
	
  var css = {}, imageID,
	    imageSetsId = 1;
	if(image_sets_id){
		imageSetsId = image_sets_id;
	}
	imageID = randomListVal(imageSets[imageSetsId]);
		if (href == null && 'gallery' != '') {
					href = getHomeImageLink(imageID);
	}
    
  updateImage({nextPhoto: backgrounds[imageID], img:el.find('img')[0],
                $photo:el, $title:$('#homeimageTitleContainer'), $detail:$('#homeimageDetailsContainer'),                speed:0, href:href, css:css, onAfter: function(){                  this.closest('.contentsection').doManualAlign({				    inner: 'img',				    crop: 'a'				  });                }              });
}

/***************************************************************************
* Set 'img' to be a new image given its photo() object                     *
***************************************************************************/
function updateImage (options) {
  var defaults = {nextPhoto:'',field:'',img:'',$photo:'',$title:'',$detail:'',
                    updateDocumentTitle:false,speed:0,href:false,css:false,updateHash:false,onAfter:null,onBefore:null},
      op = $.extend({},defaults,options),
      html = '', temp = '',
      photoId = op.nextPhoto.id,
      photoCaption = op.nextPhoto.caption,
      photoSrc = op.nextPhoto.src;
		
		if (!basic) {
    if (op.updateHash && clik.getIDInUrl(location.href,'photo') != op.nextPhoto.id) {
		clik.changeHash('photos_id=' + op.nextPhoto.id, true);
    }
				
    if (op.$photo.length > 0) {
      html = $('<img/>',{
        'class': 'mainphoto photo',
        src: photoSrc,
        id: 'mainPic',
        name: 'mainPic',
        width: op.nextPhoto.width,
        height: op.nextPhoto.height,
        alt: photoCaption,
        css: op.css || {}
      });
      if (op.href) {
      	if (op.href.match(/<a/)) {
      	  html = $(op.href).append(html);
      	} else {
		  html = $('<a/>', {
			href: op.href,
			title: photoCaption
		  }).append(html);
	    }
      } else {
      	html = $('<a/>', {
			title: photoCaption
		  }).append(html);
      }
      if (op.speed == 0) {        op.$photo.html(html);        if (op.onBefore) {          op.onBefore.apply(op.$photo);        }        if (op.onAfter) {          op.onAfter.apply(op.$photo);        }      } else {        op.$photo.stop(true,true).fadeReplaceWith(html,op.speed,'',function(){            if (op.onAfter) {		    op.onAfter.apply(this);          }		  clik.doColumnResize(false, $(this).add(op.$detail).add(op.$title));		  $('body').trigger('clikUpdate');		}, op.onBefore);
      }    }
    	if (op.field) {
		op.field.value = photoId;
	} else {
		op.$photo.data('image_id', photoId);
    }
	    if (op.$title.length > 0) {
  		op.$title.fadeGalleryDetails(photoCaption, op.speed);
    }
        if (op.updateDocumentTitle) {
						  document.title = 'Gill Willmott Photography : ' + photoCaption;
			    }
        if (op.$detail.length > 0) {
      temp = op.nextPhoto.fnGetImageDetails();
	    op.$detail.fadeGalleryDetails(temp, op.speed, function(){
	    var options = {photoinfominwidth:200};	    		options.photoinfoadjacent = true;			      	      resizePhotoInfo(options);
        if (typeof(backgrounds) != 'undefined' && op.nextPhoto == backgrounds[op.nextPhoto.id]) {
  	      toggleAddToCartConfirm(backgrounds);
  	    } else if (typeof(photos) != 'undefined' && op.nextPhoto == photos[op.nextPhoto.id]) {
  	      toggleAddToCartConfirm(photos);
  	    }
	    });
    }
        if (!op.speed) {      clik.doColumnResize(false, op.$photo.add(op.$detail).add(op.$title));      $('body').trigger('clikUpdate');    }        
    return html;			}
	else {
				
		window.location = 'photo_' + nextPhoto.id + '.html';
	}
		
}

/***************************************************************************
* Toggle add to cart confirmation element and set up the click event for   *
* the 'Add to cart' button.                                                *
***************************************************************************/
function toggleAddToCartConfirm(array){
  if (typeof(array) !== 'object' || array == undefined) {
    array = photos;
  }
	if($('#paymentConfirm').length > 0){
		$('#paymentConfirm').hide();
		$('#paymentAddButton')
		.unbind()
		.click(function(){
						form = document.getElementById('paymentForm');
			option_id = 0;
			if(form.item_option.value){
				option_id = form.item_option.value;
			}
			if(addItemToBasket(form.item_number.value,array,form.site.value,parseInt(form.quantity.value, 10),option_id)){
				if($.browser.msie){$('#paymentConfirm').text('Item added to cart').show();}
				else{
					$('#paymentConfirm').text('Item added to cart').fadeIn();
					dspOrderDetails(form.site.value);
				}
			}
			else{
				$('#paymentConfirm').text('Item not added - check cookies are enabled in your browser.').fadeIn();
			}
		});
	}
}
/***************************************************************************
* Get payment info for image - add as 'method' to photo object             *
***************************************************************************/
photo.prototype.fnGetImageDetails = function(){
	var temp = '';
	if (this.description != '') {
		temp = temp +  '<p id="imageDescription">' + this.description + '</p>';
	}
		if (this.photo_ref != '') {
		temp = temp + '<p class="imageinfo" id="imageRef"><strong>Ref: </strong>' + this.photo_ref + '</p>';
	}
		if (this.takendate != '') {
				
		temp = temp + '<p class="imageinfo" id="imageDate"><strong>Date: </strong>' + this.takendate + '</p>';
	}
	
	if (this.location != '') {
				
		temp = temp + '<p class="imageinfo" id="imageLocation"><strong>Location: </strong>' +  this.location + '</p>';
	}
	
	if (this.photographer != '') {
				
		temp = temp + '<p class="imageinfo" id="imagePhotographer"><strong>Photographer: </strong>' + this.photographer + '</p>';
	}
					
				if (temp != '') {
		temp = temp + '<div class="spacer"></div>';
	}
	return temp;
};

/***************************************************************************
* Get payment info for image - add as 'method' to photo object             *
***************************************************************************/
photo.prototype.fnGetPaymentInfo = function(){
	var temp = '';
	if (this.item_price !== '') {
				temp = temp + '<p>Order this print:</p>';
				temp = temp + '<p class="imageinfo" id="imagePrice"><strong>' + this.purchase_instruction + '</strong> ' + (this.item_price).toFixed(2) + '</p>';
		var item_name  = this.purchase_instruction;
		var amount = (this.item_price).toFixed(2);
		var item_option  = 0;
	}
	else if (this.payment_groups_id !== '') {
		temp = temp + '<p>Buy this print online:</p>';
				temp = temp + '<form id="paymentOptions" style="margin:0px;border:0px;" name="paymentOptions">';
											temp = temp + '<select class="paymentlink" name="payment_options_id" onchange="updateItemValues(document.forms.paymentForm,this.form.payment_options_id.options[this.form.payment_options_id.options.selectedIndex].value);">';
				
		temp = temp + getPaymentOptions(this.payment_groups_id);
		temp = temp + '</select>';
		temp = temp + '</form>';
				var item_option  = paymentGroups[this.payment_groups_id].options[0];
		if(paymentOptions[item_option]){
			var item_name  = paymentOptions[item_option].payment_option;
			var amount =  paymentOptions[item_option].price;
		}
			}
	else {
				
	}
	if (this.item_price !== '' || this.payment_groups_id !== '') {
			temp = temp + '<div class="clearing">&nbsp;</div>';
	}
	return temp;};

/***************************************************************************
* Pick a photo at random from the featured images of a gallery.            *
* Gallery_id = id of gallery to choose,                                    *
* img = reference to html image in                                         *
* which to show image                                                      *
***************************************************************************/
function showGalleryImage(gallery_id, img, updateLink) {
		
	if(img){
	      if (location.hash.match('galleries_id=' + gallery_id) && (imageID = location.hash.match('.*photos_id=(.+)$'))) {
        imageID = imageID[1];
      } else {
			  imageID = randomListVal(galleries[gallery_id].featured_images);
      }
							
			if (imageID != 0) {
				img.src = thumbnails[imageID].src;
				img.width = thumbnails[imageID].width;
				img.height = thumbnails[imageID].height;
				img.alt = galleries[gallery_id].title;
        if (updateLink) {
          $(img).parent().attr({            href: thumbnails[imageID].fnGalleryLink(gallery_id),            title: galleries[gallery_id].title          });
        }
							}
										}
}

/***************************************************************************
* If we have dynamic HTML, replace the galleries link with a list that     *
* doesn't include thecurrent gallery                                       *
***************************************************************************/
function showGalleries(gallery_id) {
		
	
	if (!basic) {
		temp = '';
		for (i = 0; i < galleries.length; i++) {
						
			
			if (galleries[i].id != gallery_id) {
								
				if (temp != '') {
					temp = temp + ' | ';
				}
				temp = temp + '<a href="' + galleries[i].section_code + '_' + galleries[i].id + '.html">' + galleries[i].title + '</a>';
			}
		}
		document.all.galleryLinks.innerHTML = 'Other galleries: ' + temp;
	}
}

			

