window.thumbnails = {};
															thumbnails[1824873] = clik.newPhoto({"id":1824873,"src":"Phormium_Stripes13_thumb.jpg","galleries_id":122374,"server_id":18,"link":"photo_1824873.html","width":130,"caption":"Phormium StripesAward winning image","height":87});
															thumbnails[1825095] = clik.newPhoto({"id":1825095,"src":"Winter_Walk_thumb.jpg","galleries_id":122657,"server_id":18,"link":"photo_1825095.html","width":130,"caption":"Winter Walk","height":195});
															thumbnails[2835842] = clik.newPhoto({"id":2835842,"src":"Exmoor_Ice_thumb.jpg","galleries_id":176723,"server_id":18,"link":"photo_2835842.html","width":130,"caption":"Exmoor Ice","height":195});
															thumbnails[3995968] = clik.newPhoto({"id":3995968,"src":"Mackeral_thumb.jpg","galleries_id":176721,"server_id":18,"link":"photo_3995968.html","width":130,"caption":"Mackerel","height":390});
															thumbnails[1825087] = clik.newPhoto({"id":1825087,"src":"Low_Tide_thumb.jpg","galleries_id":122657,"server_id":18,"link":"photo_1825087.html","width":130,"caption":"Low Tide","height":195});
															thumbnails[2015497] = clik.newPhoto({"id":2015497,"src":"Flaxen_Colours_2_thumb.jpg","galleries_id":122374,"server_id":18,"link":"photo_2015497.html","width":130,"caption":"Flaxen Colours 2","height":87});
															thumbnails[2835824] = clik.newPhoto({"id":2835824,"src":"Snakelock_Anemone_thumb.jpg","galleries_id":176721,"server_id":18,"link":"photo_2835824.html","width":130,"caption":"Snakelock Anemone","height":390});
															thumbnails[2835844] = clik.newPhoto({"id":2835844,"src":"Rust_Abstract_thumb.jpg","galleries_id":176723,"server_id":18,"link":"photo_2835844.html","width":130,"caption":"Rust Abstract","height":195});
															thumbnails[3989357] = clik.newPhoto({"id":3989357,"src":"Turbulent_Seas_thumb.jpg","galleries_id":241326,"server_id":18,"link":"photo_3989357.html","width":130,"caption":"Turbulent seas","height":195});
															thumbnails[1825123] = clik.newPhoto({"id":1825123,"src":"Sunset_over_Lundy_thumb.jpg","galleries_id":122657,"server_id":18,"link":"photo_1825123.html","width":130,"caption":"Sunset over Lundy","height":198});
															thumbnails[2015502] = clik.newPhoto({"id":2015502,"src":"Flaxen_Purple_thumb.jpg","galleries_id":122374,"server_id":18,"link":"photo_2015502.html","width":130,"caption":"Flaxen Purple","height":87});
															thumbnails[2835841] = clik.newPhoto({"id":2835841,"src":"Beadlet_Anemone_2_thumb.jpg","galleries_id":176721,"server_id":18,"link":"photo_2835841.html","width":130,"caption":"Beadlet Anemone","height":390});
															thumbnails[3989380] = clik.newPhoto({"id":3989380,"src":"Quartz_Veins_thumb.jpg","galleries_id":241326,"server_id":18,"link":"photo_3989380.html","width":130,"caption":"Quartz Veins","height":195});
															thumbnails[3551077] = clik.newPhoto({"id":3551077,"src":"Cordyline_Stripes_2_thumb.jpg","galleries_id":122374,"server_id":18,"link":"photo_3551077.html","width":130,"caption":"Cordyline Stripes 2","height":87});
															thumbnails[3550946] = clik.newPhoto({"id":3550946,"src":"Cordyline_Blue_thumb.jpg","galleries_id":122374,"server_id":18,"link":"photo_3550946.html","width":130,"caption":"Cordyline Blue","height":87});
															thumbnails[1825137] = clik.newPhoto({"id":1825137,"src":"Winter_Sunset_thumb.jpg","galleries_id":122657,"server_id":18,"link":"photo_1825137.html","width":130,"caption":"Winter Sunset","height":195});
															thumbnails[1825150] = clik.newPhoto({"id":1825150,"src":"Estuary_Low_Tide_4_thumb.jpg","galleries_id":122657,"server_id":18,"link":"photo_1825150.html","width":130,"caption":"Estuary Low Tide 4","height":195});
															thumbnails[1825377] = clik.newPhoto({"id":1825377,"src":"Sunlit_Cabbage_thumb.jpg","galleries_id":122374,"server_id":18,"link":"photo_1825377.html","width":130,"caption":"Sunlit Cabbage","height":87});
															thumbnails[7264793] = clik.newPhoto({"id":7264793,"src":"Shoreline_thumb.jpg","galleries_id":135089,"server_id":18,"link":"photo_7264793.html","width":130,"caption":"Shoreline","height":195});
															thumbnails[1825153] = clik.newPhoto({"id":1825153,"src":"Estuary_Reflections_2_thumb.jpg","galleries_id":122657,"server_id":18,"link":"photo_1825153.html","width":130,"caption":"Estuary Reflections 2","height":196});
															thumbnails[1825416] = clik.newPhoto({"id":1825416,"src":"Clematis_thumb.jpg","galleries_id":122374,"server_id":18,"link":"photo_1825416.html","width":130,"caption":"Clematis","height":390});
															thumbnails[3989347] = clik.newPhoto({"id":3989347,"src":"Following_the_Sun_thumb.jpg","galleries_id":241326,"server_id":18,"link":"photo_3989347.html","width":130,"caption":"Following the Sun","height":87});
															thumbnails[7264932] = clik.newPhoto({"id":7264932,"src":"Waiting_in_Line_thumb.jpg","galleries_id":135089,"server_id":18,"link":"photo_7264932.html","width":130,"caption":"Waiting in Line","height":195});
															thumbnails[7303951] = clik.newPhoto({"id":7303951,"src":"Fast_Track_thumb.jpg","galleries_id":176723,"server_id":18,"link":"photo_7303951.html","width":130,"caption":"Fast Track","height":196});
															thumbnails[5153216] = clik.newPhoto({"id":5153216,"src":"Afterglow_thumb.jpg","galleries_id":122657,"server_id":18,"link":"photo_5153216.html","width":130,"caption":"Afterglow","height":196});
															thumbnails[7264916] = clik.newPhoto({"id":7264916,"src":"Touching_the_Surface_thumb.jpg","galleries_id":135089,"server_id":18,"link":"photo_7264916.html","width":130,"caption":"Touching the Surface","height":195});
															thumbnails[3989342] = clik.newPhoto({"id":3989342,"src":"Cosmic_Storm_thumb.jpg","galleries_id":241326,"server_id":18,"link":"photo_3989342.html","width":130,"caption":"Cosmic Storm","height":195});
															thumbnails[1825307] = clik.newPhoto({"id":1825307,"src":"Boat_Abstract_3_thumb.jpg","galleries_id":135089,"server_id":18,"link":"photo_1825307.html","width":130,"caption":"Boat Abstract 3","height":195});
															thumbnails[2015507] = clik.newPhoto({"id":2015507,"src":"Lilly_Lake_thumb.jpg","galleries_id":122374,"server_id":18,"link":"photo_2015507.html","width":130,"caption":"Lily Lake","height":390});
															thumbnails[5153224] = clik.newPhoto({"id":5153224,"src":"Sunset_Moods_thumb.jpg","galleries_id":122657,"server_id":18,"link":"photo_5153224.html","width":130,"caption":"Sunset Moods","height":195});
															thumbnails[7264790] = clik.newPhoto({"id":7264790,"src":"Frozen_Forest_thumb.jpg","galleries_id":176723,"server_id":18,"link":"photo_7264790.html","width":130,"caption":"Frozen Forest","height":195});
															thumbnails[3995839] = clik.newPhoto({"id":3995839,"src":"Amonite_thumb.jpg","galleries_id":241326,"server_id":18,"link":"photo_3995839.html","width":130,"caption":"Ammonite","height":195});
															thumbnails[5153234] = clik.newPhoto({"id":5153234,"src":"Storm_Fire_thumb.jpg","galleries_id":122657,"server_id":18,"link":"photo_5153234.html","width":130,"caption":"Storm Fire","height":195});
															thumbnails[1825379] = clik.newPhoto({"id":1825379,"src":"Cherry_Bark_thumb.jpg","galleries_id":122374,"server_id":18,"link":"photo_1825379.html","width":130,"caption":"Cherry Bark","height":390});
															thumbnails[1825376] = clik.newPhoto({"id":1825376,"src":"Succulent_Rossette_3_thumb.jpg","galleries_id":122374,"server_id":18,"link":"photo_1825376.html","width":130,"caption":"Succulent Rosette 3","height":195});
															thumbnails[2015513] = clik.newPhoto({"id":2015513,"src":"Rippled_Sand_and_Water_1_thumb.jpg","galleries_id":122677,"server_id":18,"link":"photo_2015513.html","width":130,"caption":"Rippled Sand and Water 1","height":87});
															thumbnails[2835706] = clik.newPhoto({"id":2835706,"src":"Westward_View_2_thumb.jpg","galleries_id":122657,"server_id":18,"link":"photo_2835706.html","width":130,"caption":"Westward View 2","height":86});
															thumbnails[3989370] = clik.newPhoto({"id":3989370,"src":"In_the_Beginning_thumb.jpg","galleries_id":241326,"server_id":18,"link":"photo_3989370.html","width":130,"caption":"In the Beginning","height":87});
															thumbnails[2835821] = clik.newPhoto({"id":2835821,"src":"Limpet_Chevron_thumb.jpg","galleries_id":176721,"server_id":18,"link":"photo_2835821.html","width":130,"caption":"Limpet Chevron","height":87});
															thumbnails[2835900] = clik.newPhoto({"id":2835900,"src":"Hellebore_thumb.jpg","galleries_id":122374,"server_id":18,"link":"photo_2835900.html","width":130,"caption":"Hellebore","height":195});
															thumbnails[3995867] = clik.newPhoto({"id":3995867,"src":"Forgotten_History_thumb.jpg","galleries_id":135089,"server_id":18,"link":"photo_3995867.html","width":130,"caption":"Forgotten History","height":195});
															thumbnails[2017691] = clik.newPhoto({"id":2017691,"src":"Estuary_Furrows_2_thumb.jpg","galleries_id":122677,"server_id":18,"link":"photo_2017691.html","width":130,"caption":"Estuary Furrows","height":87});
															thumbnails[3999760] = clik.newPhoto({"id":3999760,"src":"Silver_Birch_Bark_thumb.jpg","galleries_id":122374,"server_id":18,"link":"photo_3999760.html","width":130,"caption":"Paper Birch Bark Betula papyrifera","height":195});
															thumbnails[7264908] = clik.newPhoto({"id":7264908,"src":"Colourful_Life_thumb.jpg","galleries_id":135089,"server_id":18,"link":"photo_7264908.html","width":130,"caption":"Colourful Life","height":86});
															thumbnails[1825305] = clik.newPhoto({"id":1825305,"src":"Hull_History_1_thumb.jpg","galleries_id":135089,"server_id":18,"link":"photo_1825305.html","width":130,"caption":"Hull History 1","height":87});
															thumbnails[2017688] = clik.newPhoto({"id":2017688,"src":"Rippling_Pebble_Pool_thumb.jpg","galleries_id":122677,"server_id":18,"link":"photo_2017688.html","width":130,"caption":"Rippling Pebble Pool","height":87});
															thumbnails[2835860] = clik.newPhoto({"id":2835860,"src":"Cactus_Starburst_2_thumb.jpg","galleries_id":122374,"server_id":18,"link":"photo_2835860.html","width":130,"caption":"Cactus Starburst 2","height":87});
															thumbnails[3999744] = clik.newPhoto({"id":3999744,"src":"Sea_Jewels_thumb.jpg","galleries_id":122677,"server_id":18,"link":"photo_3999744.html","width":130,"caption":"Sea Jewels","height":195});
															thumbnails[3999750] = clik.newPhoto({"id":3999750,"src":"Rippling_Mussels_thumb.jpg","galleries_id":122677,"server_id":18,"link":"photo_3999750.html","width":130,"caption":"Rippling Mussels","height":195});
															thumbnails[1825306] = clik.newPhoto({"id":1825306,"src":"Keel_and_Barnacles_thumb.jpg","galleries_id":135089,"server_id":18,"link":"photo_1825306.html","width":130,"caption":"Keel and Barnacles","height":195});
															thumbnails[7281994] = clik.newPhoto({"id":7281994,"src":"Sunset_Sands_thumb.jpg","galleries_id":122677,"server_id":18,"link":"photo_7281994.html","width":130,"caption":"Sunset Sands","height":195});
															thumbnails[1825269] = clik.newPhoto({"id":1825269,"src":"Pebble_Abstract_2_thumb.jpg","galleries_id":122677,"server_id":18,"link":"photo_1825269.html","width":130,"caption":"Pebble Abstract 2","height":195});
															thumbnails[1825267] = clik.newPhoto({"id":1825267,"src":"Pebble_and_Sand_Abstract3_thumb.jpg","galleries_id":122677,"server_id":18,"link":"photo_1825267.html","width":130,"caption":"Pebble and Sand Abstract","height":195});
															thumbnails[1825264] = clik.newPhoto({"id":1825264,"src":"Bird_Print_thumb.jpg","galleries_id":122677,"server_id":18,"link":"photo_1825264.html","width":130,"caption":"Bird Print","height":195});
															thumbnails[2835726] = clik.newPhoto({"id":2835726,"src":"Rippling_Light_thumb.jpg","galleries_id":122677,"server_id":18,"link":"photo_2835726.html","width":130,"caption":"Rippling Light","height":195});
															thumbnails[1825280] = clik.newPhoto({"id":1825280,"src":"Pebble_Abstract_with_Bubbles_thumb.jpg","galleries_id":122677,"server_id":18,"link":"photo_1825280.html","width":130,"caption":"Pebble Abstract with Bubbles","height":195});
															thumbnails[3999786] = clik.newPhoto({"id":3999786,"src":"Sea_Lace_thumb.jpg","galleries_id":122677,"server_id":18,"link":"photo_3999786.html","width":130,"caption":"Sea Lace","height":195});
															thumbnails[2015559] = clik.newPhoto({"id":2015559,"src":"Sand_Trees_thumb.jpg","galleries_id":122677,"server_id":18,"link":"photo_2015559.html","width":130,"caption":"Sand Trees","height":195});
															thumbnails[2015499] = clik.newPhoto({"id":2015499,"src":"Blue_Pebble_2_thumb.jpg","galleries_id":122677,"server_id":18,"link":"photo_2015499.html","width":130,"caption":"Blue Pebble 2","height":195});
															thumbnails[2835735] = clik.newPhoto({"id":2835735,"src":"Sand_Patterns_thumb.jpg","galleries_id":122677,"server_id":18,"link":"photo_2835735.html","width":130,"caption":"Sand Patterns","height":195});
															thumbnails[7334504] = clik.newPhoto({"id":7334504,"src":"Rainbow_Silk_thumb.jpg","galleries_id":122677,"server_id":18,"link":"photo_7334504.html","width":130,"caption":"Rainbow Silk","height":195});
															thumbnails[2015560] = clik.newPhoto({"id":2015560,"src":"Sand_Zebra_thumb.jpg","galleries_id":122677,"server_id":18,"link":"photo_2015560.html","width":130,"caption":"Sand Zebra","height":87});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  						galleries[122677] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Pebbles, Sand and Sea","link":"gallery_122677.html","maxRecords":0.0,"photoIDs":[2015513.0,2017691.0,2017688.0,3999744.0,3999750.0,7281994.0,1825269.0,1825267.0,1825264.0,2835726.0,1825280.0,3999786.0,2015559.0,2015499.0,2835735.0,7334504.0,2015560.0],"skipIndex":0,"section_code":"gallery","featured_images":"7334504,7281994,3999786,3999750,3999744,2835726,2015559,2015499,1825280,1825269,1825267,1825264","id":122677,"singleSection":false});				  						galleries[122657] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Seascapes","link":"gallery_122657.html","maxRecords":0.0,"photoIDs":[1825095.0,1825087.0,1825123.0,1825137.0,1825150.0,1825153.0,5153216.0,5153224.0,5153234.0,2835706.0],"skipIndex":0,"section_code":"gallery","featured_images":"2835706,1825153,1825150,1825137,1825123,1825095,1825087","id":122657,"singleSection":false});				  						galleries[122374] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Plants","link":"gallery_122374.html","maxRecords":0.0,"photoIDs":[1824873.0,2015497.0,2015502.0,3551077.0,3550946.0,1825377.0,1825416.0,2015507.0,1825379.0,1825376.0,2835900.0,3999760.0,2835860.0],"skipIndex":0,"section_code":"gallery","featured_images":"3999760,3550946,2015502,2015497,1825376,1824873","id":122374,"singleSection":false});				  						galleries[176721] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Sea Life","link":"gallery_176721.html","maxRecords":0.0,"photoIDs":[3995968.0,2835824.0,2835841.0,2835821.0],"skipIndex":0,"section_code":"gallery","featured_images":2835821.0,"id":176721,"singleSection":false});				  						galleries[135089] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Boats","link":"gallery_135089.html","maxRecords":0.0,"photoIDs":[7264793.0,7264932.0,7264916.0,1825307.0,3995867.0,7264908.0,1825305.0,1825306.0],"skipIndex":0,"section_code":"gallery","featured_images":"7264932,7264916,7264908,7264793,1825307,1825306,1825305","id":135089,"singleSection":false});				  						galleries[241326] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Geology","link":"gallery_241326.html","maxRecords":0.0,"photoIDs":[3989357.0,3989380.0,3989347.0,3989342.0,3995839.0,3989370.0],"skipIndex":0,"section_code":"gallery","featured_images":"3995839,3989380,3989370,3989347,3989342","id":241326,"singleSection":false});				  						galleries[176723] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"And More...","link":"gallery_176723.html","maxRecords":0.0,"photoIDs":[2835842.0,2835844.0,7303951.0,7264790.0],"skipIndex":0,"section_code":"gallery","featured_images":"7303951,7264790","id":176723,"singleSection":false});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[1] = '1824873,2015497,2015502,3551077,3550946,7264793,7264916,3989342,7264790,3995839,2015513,2835821,2017691,7264908,1825305,2017688,3999744,3999750,1825306,7281994,1825269,1825267,1825264,2835726,1825280,3999786,2015559,2015560';
imageSets[2] = '1825095,1824873,2015497,1825087,3989380,2015502,1825123,3550946,1825150,1825137,7264793,7303951,7264932,3989347,1825153,7264916,3989342,7264790,1825307,3995839,3989370,2835706,1825376,2835821,3999760,7264908,1825305,3999744,3999750,1825306,7281994,1825269,1825267,1825264,2835726,1825280,3999786,2015559,2015499,7334504';
imageSets[3] = '7334504,7303951,7281994,7264932,7264916,7264908,7264793,7264790,5153234,5153224,5153216,3999786,3999760,3999750,3999744,3995968,3995867,3995839,3989380,3989370,3989357,3989347,3989342,3551077,3550946,2835900,2835860,2835844,2835842,2835841,2835824,2835821,2835735,2835726,2835706,2017691,2017688,2015560,2015559,2015513,2015507,2015502,2015499,2015497,1825416,1825379,1825377,1825376,1825307,1825306';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 51:
		val = 'http://www12.clikpic.com/sarahgallifent/images';
		break;
	}
		switch (server_id) {
		case 0:
		val = 'http://www.clikpic.com/sarahgallifent/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/sarahgallifent/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/sarahgallifent/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/sarahgallifent/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/sarahgallifent/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/sarahgallifent/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/sarahgallifent/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/sarahgallifent/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/sarahgallifent/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/sarahgallifent/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/sarahgallifent/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/sarahgallifent/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/sarahgallifent/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/sarahgallifent/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/sarahgallifent/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/sarahgallifent/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/sarahgallifent/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/sarahgallifent/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/sarahgallifent/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/sarahgallifent/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/sarahgallifent/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/sarahgallifent/images';
		break;
	}
		switch (server_id) {
		case 53:
		val = 'http://images.clikpic.com/sarahgallifent/images';
		break;
	}
		switch (server_id) {
		case 52:
		val = 'http://tpc22/clikpic/sarahgallifent/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/sarahgallifent/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/sarahgallifent/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 = 'Sarah Gallifent 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.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;
	}
}

			

