window.thumbnails = {};
															thumbnails[8357602] = clik.newPhoto({"id":8357602,"src":"BB58bookweb_thumb.jpg","galleries_id":"","server_id":35,"link":"#","width":130,"caption":"","height":195});
															thumbnails[2187510] = clik.newPhoto({"id":2187510,"src":"Successweb_thumb.jpg","galleries_id":"","server_id":1,"link":"#","width":130,"caption":"Editorial Example","height":92});
															thumbnails[2187513] = clik.newPhoto({"id":2187513,"src":"Columbusmagazineweb_thumb.jpg","galleries_id":"","server_id":1,"link":"#","width":130,"caption":"Editorial Example","height":86});
															thumbnails[2187520] = clik.newPhoto({"id":2187520,"src":"Columbusmagazineweb2_thumb.jpg","galleries_id":"","server_id":1,"link":"#","width":130,"caption":"Editorial Example","height":129});
															thumbnails[7127194] = clik.newPhoto({"id":7127194,"src":"foganfellweb_thumb.jpg","galleries_id":"","server_id":1,"link":"#","width":130,"caption":"Forestry, 2010","height":130});
															thumbnails[2977223] = clik.newPhoto({"id":2977223,"src":"shanghaiscene_thumb.jpg","galleries_id":"","server_id":1,"link":"#","width":130,"caption":"Editorial Example - Urban Contrast","height":85});
															thumbnails[7188048] = clik.newPhoto({"id":7188048,"src":"creeriverfogweb_thumb.jpg","galleries_id":"","server_id":1,"link":"#","width":130,"caption":"Mist, 2010","height":130});
															thumbnails[6111084] = clik.newPhoto({"id":6111084,"src":"volunteers1webi_thumb.jpg","galleries_id":342504,"server_id":1,"link":"photo_6111084.html","width":130,"caption":"","height":130});
															thumbnails[6869769] = clik.newPhoto({"id":6869769,"src":"slide-5-1971web_thumb.jpg","galleries_id":372943,"server_id":1,"link":"photo_6869769.html","width":130,"caption":"","height":88});
															thumbnails[8357805] = clik.newPhoto({"id":8357805,"src":"jerusalem651web_thumb.jpg","galleries_id":443906,"server_id":35,"link":"photo_8357805.html","width":130,"caption":"","height":83});
															thumbnails[6447094] = clik.newPhoto({"id":6447094,"src":"danielfablevisionvolunteerw_thumb.jpg","galleries_id":342504,"server_id":1,"link":"photo_6447094.html","width":130,"caption":"","height":130});
															thumbnails[6869784] = clik.newPhoto({"id":6869784,"src":"slide-a-2009web_thumb.jpg","galleries_id":372943,"server_id":1,"link":"photo_6869784.html","width":130,"caption":"","height":87});
															thumbnails[6716365] = clik.newPhoto({"id":6716365,"src":"lochriquor2web_thumb.jpg","galleries_id":342497,"server_id":1,"link":"photo_6716365.html","width":130,"caption":"Loch Riecawr, 2009","height":130});
															thumbnails[6869773] = clik.newPhoto({"id":6869773,"src":"slide-8-1971web_thumb.jpg","galleries_id":372943,"server_id":1,"link":"photo_6869773.html","width":130,"caption":"","height":89});
															thumbnails[8357604] = clik.newPhoto({"id":8357604,"src":"Bedouin-Camp-YB104bookweb_thumb.jpg","galleries_id":443906,"server_id":35,"link":"photo_8357604.html","width":130,"caption":"","height":87});
															thumbnails[6111085] = clik.newPhoto({"id":6111085,"src":"volunteer2web_thumb.jpg","galleries_id":342504,"server_id":1,"link":"photo_6111085.html","width":130,"caption":"","height":130});
															thumbnails[6869792] = clik.newPhoto({"id":6869792,"src":"slide-c-2009web_thumb.jpg","galleries_id":372943,"server_id":1,"link":"photo_6869792.html","width":130,"caption":"","height":86});
															thumbnails[6869777] = clik.newPhoto({"id":6869777,"src":"slide-21-1971web_thumb.jpg","galleries_id":372943,"server_id":1,"link":"photo_6869777.html","width":130,"caption":"","height":88});
															thumbnails[8031652] = clik.newPhoto({"id":8031652,"src":"lellandk02website_thumb.jpg","galleries_id":431223,"server_id":1,"link":"photo_8031652.html","width":130,"caption":"","height":78});
															thumbnails[8357609] = clik.newPhoto({"id":8357609,"src":"R23webnoprocessing_thumb.jpg","galleries_id":443906,"server_id":35,"link":"photo_8357609.html","width":130,"caption":"","height":84});
															thumbnails[6447248] = clik.newPhoto({"id":6447248,"src":"shaunfarevolunteerweb_thumb.jpg","galleries_id":342504,"server_id":1,"link":"photo_6447248.html","width":130,"caption":"","height":130});
															thumbnails[6869787] = clik.newPhoto({"id":6869787,"src":"slide-b-2009web_thumb.jpg","galleries_id":372943,"server_id":1,"link":"photo_6869787.html","width":130,"caption":"","height":93});
															thumbnails[6869781] = clik.newPhoto({"id":6869781,"src":"slide-25-1971web_thumb.jpg","galleries_id":372943,"server_id":1,"link":"photo_6869781.html","width":130,"caption":"","height":88});
															thumbnails[8031653] = clik.newPhoto({"id":8031653,"src":"lellandk03website_thumb.jpg","galleries_id":431223,"server_id":1,"link":"photo_8031653.html","width":130,"caption":"","height":130});
															thumbnails[8357610] = clik.newPhoto({"id":8357610,"src":"R33bookweb_thumb.jpg","galleries_id":443906,"server_id":35,"link":"photo_8357610.html","width":130,"caption":"","height":87});
															thumbnails[6869795] = clik.newPhoto({"id":6869795,"src":"slide-d-2009web_thumb.jpg","galleries_id":372943,"server_id":1,"link":"photo_6869795.html","width":130,"caption":"","height":86});
															thumbnails[8357618] = clik.newPhoto({"id":8357618,"src":"YR51webnoprocessing_thumb.jpg","galleries_id":443906,"server_id":35,"link":"photo_8357618.html","width":130,"caption":"","height":86});
															thumbnails[2666764] = clik.newPhoto({"id":2666764,"src":"boatflickr_thumb.jpg","galleries_id":342501,"server_id":1,"link":"photo_2666764.html","width":130,"caption":"Boat and Buoy","height":86});
															thumbnails[5689623] = clik.newPhoto({"id":5689623,"src":"dumfriestreesweb_thumb.jpg","galleries_id":342497,"server_id":1,"link":"photo_5689623.html","width":130,"caption":"Glow, 2010","height":130});
															thumbnails[8357619] = clik.newPhoto({"id":8357619,"src":"Y14webnoprocessing_thumb.jpg","galleries_id":443906,"server_id":35,"link":"photo_8357619.html","width":130,"caption":"","height":82});
															thumbnails[8357625] = clik.newPhoto({"id":8357625,"src":"YWd58webnoprocessing_thumb.jpg","galleries_id":443906,"server_id":35,"link":"photo_8357625.html","width":130,"caption":"","height":87});
															thumbnails[2666767] = clik.newPhoto({"id":2666767,"src":"creelpotandgrassslideflickr_thumb.jpg","galleries_id":342501,"server_id":1,"link":"photo_2666767.html","width":130,"caption":"Creel pot and dune grass under storm clouds","height":87});
															thumbnails[8357627] = clik.newPhoto({"id":8357627,"src":"BB50webnoprocessing_thumb.jpg","galleries_id":443906,"server_id":35,"link":"photo_8357627.html","width":130,"caption":"","height":87});
															thumbnails[6209156] = clik.newPhoto({"id":6209156,"src":"vickyvolunteerweb_thumb.jpg","galleries_id":342504,"server_id":1,"link":"photo_6209156.html","width":130,"caption":"","height":130});
															thumbnails[8357629] = clik.newPhoto({"id":8357629,"src":"YR16webnoprocessing_thumb.jpg","galleries_id":443906,"server_id":35,"link":"photo_8357629.html","width":130,"caption":"","height":85});
															thumbnails[4282516] = clik.newPhoto({"id":4282516,"src":"flowersinthewoodfinalweb_thumb.jpg","galleries_id":342497,"server_id":1,"link":"photo_4282516.html","width":130,"caption":"Woods, 2009","height":130});
															thumbnails[6111095] = clik.newPhoto({"id":6111095,"src":"treelineweb_thumb.jpg","galleries_id":342497,"server_id":1,"link":"photo_6111095.html","width":130,"caption":"Treeline, 2009","height":130});
															thumbnails[7127201] = clik.newPhoto({"id":7127201,"src":"woodofcreeweb_thumb.jpg","galleries_id":342497,"server_id":1,"link":"photo_7127201.html","width":130,"caption":"Woodland Composition, 2010","height":130});
															thumbnails[8357633] = clik.newPhoto({"id":8357633,"src":"YW52webnoprocessing_thumb.jpg","galleries_id":443906,"server_id":35,"link":"photo_8357633.html","width":130,"caption":"","height":84});
															thumbnails[6664135] = clik.newPhoto({"id":6664135,"src":"liamknowetopweb_thumb.jpg","galleries_id":342504,"server_id":1,"link":"photo_6664135.html","width":130,"caption":"","height":130});
															thumbnails[8357704] = clik.newPhoto({"id":8357704,"src":"YW71bookweb_thumb.jpg","galleries_id":443906,"server_id":35,"link":"photo_8357704.html","width":130,"caption":"","height":87});
															thumbnails[2641010] = clik.newPhoto({"id":2641010,"src":"southuistmistflickr_thumb.jpg","galleries_id":342501,"server_id":1,"link":"photo_2641010.html","width":130,"caption":"Evening Mist, South Uist ","height":83});
															thumbnails[8357705] = clik.newPhoto({"id":8357705,"src":"YW35bookweb_thumb.jpg","galleries_id":443906,"server_id":35,"link":"photo_8357705.html","width":130,"caption":"","height":87});
															thumbnails[8357804] = clik.newPhoto({"id":8357804,"src":"FlowersCaesareaBW110web_thumb.jpg","galleries_id":443906,"server_id":35,"link":"photo_8357804.html","width":130,"caption":"","height":86});
															thumbnails[2646837] = clik.newPhoto({"id":2646837,"src":"beachsouthuistflickr_thumb.jpg","galleries_id":342501,"server_id":1,"link":"photo_2646837.html","width":130,"caption":"Rocks and Sand, South Uist. ","height":87});
															thumbnails[8357806] = clik.newPhoto({"id":8357806,"src":"YWd51web_thumb.jpg","galleries_id":443906,"server_id":35,"link":"photo_8357806.html","width":130,"caption":"","height":87});
															thumbnails[6122319] = clik.newPhoto({"id":6122319,"src":"Callanish66web_thumb.jpg","galleries_id":342501,"server_id":1,"link":"photo_6122319.html","width":130,"caption":"Standing Stones at Callanish","height":130});
															thumbnails[6447273] = clik.newPhoto({"id":6447273,"src":"Nikkifarevolunteerweb_thumb.jpg","galleries_id":342504,"server_id":1,"link":"photo_6447273.html","width":130,"caption":"","height":130});
															thumbnails[7188788] = clik.newPhoto({"id":7188788,"src":"silverbirchinmistweb1_thumb.jpg","galleries_id":342497,"server_id":1,"link":"photo_7188788.html","width":130,"caption":"Silver Birch in Mist, 2009","height":130});
															thumbnails[8357808] = clik.newPhoto({"id":8357808,"src":"YR71web_thumb.jpg","galleries_id":443906,"server_id":35,"link":"photo_8357808.html","width":130,"caption":"","height":87});
															thumbnails[6447097] = clik.newPhoto({"id":6447097,"src":"edfablevisionvolunteerweb_thumb.jpg","galleries_id":342504,"server_id":1,"link":"photo_6447097.html","width":130,"caption":"","height":130});
															thumbnails[7170626] = clik.newPhoto({"id":7170626,"src":"trees66v2web_thumb.jpg","galleries_id":342497,"server_id":1,"link":"photo_7170626.html","width":130,"caption":"Trees, 2009","height":130});
															thumbnails[8357809] = clik.newPhoto({"id":8357809,"src":"RR24web_thumb.jpg","galleries_id":443906,"server_id":35,"link":"photo_8357809.html","width":130,"caption":"","height":83});
															thumbnails[5715489] = clik.newPhoto({"id":5715489,"src":"foggyweb_thumb.jpg","galleries_id":342497,"server_id":1,"link":"photo_5715489.html","width":130,"caption":"Fog, 2009","height":130});
															thumbnails[8357811] = clik.newPhoto({"id":8357811,"src":"R18web_thumb.jpg","galleries_id":443906,"server_id":35,"link":"photo_8357811.html","width":130,"caption":"","height":87});
															thumbnails[8357813] = clik.newPhoto({"id":8357813,"src":"YWd53web_thumb.jpg","galleries_id":443906,"server_id":35,"link":"photo_8357813.html","width":130,"caption":"","height":88});
															thumbnails[8357815] = clik.newPhoto({"id":8357815,"src":"YWd52web_thumb.jpg","galleries_id":443906,"server_id":35,"link":"photo_8357815.html","width":130,"caption":"","height":82});
															thumbnails[6209153] = clik.newPhoto({"id":6209153,"src":"debbievolunteerweb_thumb.jpg","galleries_id":342504,"server_id":1,"link":"photo_6209153.html","width":130,"caption":"","height":130});
															thumbnails[8357817] = clik.newPhoto({"id":8357817,"src":"YWd60web_thumb.jpg","galleries_id":443906,"server_id":35,"link":"photo_8357817.html","width":130,"caption":"","height":87});
															thumbnails[8357820] = clik.newPhoto({"id":8357820,"src":"YY23web_thumb.jpg","galleries_id":443906,"server_id":35,"link":"photo_8357820.html","width":130,"caption":"","height":87});
															thumbnails[6664137] = clik.newPhoto({"id":6664137,"src":"joelknowetopweb_thumb.jpg","galleries_id":342504,"server_id":1,"link":"photo_6664137.html","width":130,"caption":"","height":130});
															thumbnails[7188099] = clik.newPhoto({"id":7188099,"src":"goldentree66web_thumb.jpg","galleries_id":342497,"server_id":1,"link":"photo_7188099.html","width":130,"caption":"Russet Tree, 2009","height":130});
															thumbnails[7486906] = clik.newPhoto({"id":7486906,"src":"Gandermooweb_thumb.jpg","galleries_id":405950,"server_id":1,"link":"photo_7486906.html","width":130,"caption":"","height":87});
															thumbnails[7486909] = clik.newPhoto({"id":7486909,"src":"Irvinebaymooweb_thumb.jpg","galleries_id":405950,"server_id":1,"link":"photo_7486909.html","width":130,"caption":"","height":87});
															thumbnails[7486912] = clik.newPhoto({"id":7486912,"src":"vikmooweb_thumb.jpg","galleries_id":405950,"server_id":1,"link":"photo_7486912.html","width":130,"caption":"","height":87});
															thumbnails[7486914] = clik.newPhoto({"id":7486914,"src":"woodofcreemooweb_thumb.jpg","galleries_id":405950,"server_id":1,"link":"photo_7486914.html","width":130,"caption":"","height":92});
															thumbnails[7486932] = clik.newPhoto({"id":7486932,"src":"woodlandcrochetweb_thumb.jpg","galleries_id":405955,"server_id":1,"link":"photo_7486932.html","width":130,"caption":"Reflection, 2011","height":130});
															thumbnails[2646725] = clik.newPhoto({"id":2646725,"src":"dianafinalweb_thumb.jpg","galleries_id":405950,"server_id":1,"link":"photo_2646725.html","width":130,"caption":"","height":87});
															thumbnails[7486935] = clik.newPhoto({"id":7486935,"src":"RocksandSandlimited_thumb.jpg","galleries_id":405955,"server_id":1,"link":"photo_7486935.html","width":130,"caption":"Rocks and Sand, South Uist, 2008","height":87});
															thumbnails[2666756] = clik.newPhoto({"id":2666756,"src":"Watchtowerflickr_thumb.jpg","galleries_id":405950,"server_id":1,"link":"photo_2666756.html","width":130,"caption":"","height":87});
															thumbnails[7486901] = clik.newPhoto({"id":7486901,"src":"BenCruachanmooweb_thumb.jpg","galleries_id":405950,"server_id":1,"link":"photo_7486901.html","width":130,"caption":"","height":87});
															thumbnails[7486905] = clik.newPhoto({"id":7486905,"src":"elgolmooweb_thumb.jpg","galleries_id":405950,"server_id":1,"link":"photo_7486905.html","width":130,"caption":"","height":80});
															thumbnails[3037523] = clik.newPhoto({"id":3037523,"src":"queens_thumb.jpg","galleries_id":405950,"server_id":1,"link":"photo_3037523.html","width":130,"caption":"","height":98});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  						galleries[405955] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Limited Editions","link":"section485442_405955.html","maxRecords":0.0,"photoIDs":[7486932.0,7486935.0],"skipIndex":0,"section_code":"section485442","featured_images":7486932.0,"id":405955,"singleSection":false});				  						galleries[431223] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Recent work","link":"gallery_431223.html","maxRecords":0.0,"photoIDs":[8031652.0,8031653.0],"skipIndex":0,"section_code":"gallery","featured_images":"8031653,8031652","id":431223,"singleSection":false});				  						galleries[342497] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Landscapes - 2009 and 2010","link":"gallery_342497.html","maxRecords":0.0,"photoIDs":[6716365.0,5689623.0,4282516.0,6111095.0,7127201.0,7188788.0,7170626.0,5715489.0,7188099.0],"skipIndex":0,"section_code":"gallery","featured_images":5689623.0,"id":342497,"singleSection":false});				  						galleries[342501] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Western Isles - 2008","link":"gallery_342501.html","maxRecords":0.0,"photoIDs":[2666764.0,2666767.0,2641010.0,2646837.0,6122319.0],"skipIndex":0,"section_code":"gallery","featured_images":"6122319,2666767,2666764,2646837,2641010","id":342501,"singleSection":false});				  						galleries[372943] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Reclaimed and Revisited","link":"gallery_372943.html","maxRecords":0.0,"photoIDs":[6869769.0,6869784.0,6869773.0,6869792.0,6869777.0,6869787.0,6869781.0,6869795.0],"skipIndex":0,"section_code":"gallery","featured_images":"6869795,6869792,6869787,6869784,6869781,6869777,6869773,6869769","id":372943,"singleSection":false});				  						galleries[342504] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Volunteers","link":"gallery_342504.html","maxRecords":0.0,"photoIDs":[6111084.0,6447094.0,6111085.0,6447248.0,6209156.0,6664135.0,6447273.0,6447097.0,6209153.0,6664137.0],"skipIndex":0,"section_code":"gallery","featured_images":"6447248,6447094","id":342504,"singleSection":false});				  						galleries[405950] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Greetings Cards","link":"section485442_405950.html","maxRecords":0.0,"photoIDs":[7486906.0,7486909.0,7486912.0,7486914.0,2646725.0,2666756.0,7486901.0,7486905.0,3037523.0],"skipIndex":0,"section_code":"section485442","featured_images":7486905.0,"id":405950,"singleSection":false});				  						galleries[443906] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Holy Land","link":"gallery_443906.html","maxRecords":0.0,"photoIDs":[8357805.0,8357604.0,8357609.0,8357610.0,8357618.0,8357619.0,8357625.0,8357627.0,8357629.0,8357633.0,8357704.0,8357705.0,8357804.0,8357806.0,8357808.0,8357809.0,8357811.0,8357813.0,8357815.0,8357817.0,8357820.0],"skipIndex":0,"section_code":"gallery","featured_images":"8357619,8357604","id":443906,"singleSection":false});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[1] = '8031653,8031652,7486901,7188788,7188099,7170626,7127201,6716365,6111095,5715489,4282516,2666767,2666756,2646837,2641010';
imageSets[2] = '8357619,8357604,7486932,7486905,7188048,6447248,6447094,5689623,2187513';
imageSets[3] = '2977223,2666767,2666764,2646837,2646725,2641010,2187520,2187513,2187510';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/kevinlelland/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/kevinlelland/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/kevinlelland/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/kevinlelland/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/kevinlelland/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/kevinlelland/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/kevinlelland/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/kevinlelland/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/kevinlelland/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/kevinlelland/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/kevinlelland/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/kevinlelland/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/kevinlelland/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/kevinlelland/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/kevinlelland/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/kevinlelland/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://admin2.clikpic.com/kevinlelland/images';
		break;
	}
		switch (server_id) {
		case 33:
		val = 'http://www8.clikpic.com/kevinlelland/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/kevinlelland/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/kevinlelland/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/kevinlelland/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/kevinlelland/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/kevinlelland/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/kevinlelland/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 = 'www.lelland.com : ' + 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>';
	}
				
	temp += this.fnGetPaymentInfo();
				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>Buy now using PayPal:</p>';
				temp += '<div class="imageinfo" id="imagePrice"><strong>' + this.purchase_instruction + '</strong> &pound;' + (this.item_price).toFixed(2) + '</div>';
		var item_name  = this.purchase_instruction;
		var amount = (this.item_price).toFixed(2);
		var item_option  = 0;
	}
	else if (this.payment_groups_id !== '') {
		temp += '<p>Buy this print online:</p>';
				temp += '<form id="paymentOptions" style="margin:0px;border:0px;" name="paymentOptions">';
		 									temp += '<select class="paymentlink" name="payment_options_id" onchange="updateCartValue($(this.form).next(\'#paymentForm\')[0],this.form.payment_options_id.options[this.form.payment_options_id.options.selectedIndex].value); if(divShowing(\'paymentConfirm\')){fadeOut(\'paymentConfirm\', 3)};">';
		
		temp += getPaymentOptions(this.payment_groups_id);
		temp += '</select>';
		temp += '</form>';
				var item_option  = paymentGroups[this.payment_groups_id].options[0];
		if(paymentOptions[item_option]){
			var item_name  = paymentOptions[item_option].payment_option;
			var amount =  paymentOptions[item_option].price;
		}
			}
	else {
		
	}
	if (this.item_price !== '' || this.payment_groups_id !== '') {
											temp += '<form id="paymentForm" style="margin:0px;border:0px;" name="paymentForm">';
			temp += '	<input type="hidden" name="item_option" value="' + item_option + '">';
			temp += '	<input type="hidden" name="site" value="KEVINLELLAND">';
			temp += '	<input type="hidden" name="item_number" value="'+ this.id +'">';
			temp += '	<input type="hidden" name="quantity" value="1">';
						temp += '	<input value="Add to cart" id="paymentAddButton" class="button" onmouseover="this.className=\'buttonHi\'\;" onmouseout="this.className=\'button\'\;" type="Button">';
							temp += '	<input value="View cart" id="paymentViewButton" class="button" onmouseover="this.className=\'buttonHi\';" onmouseout="this.className=\'button\';" type="Button" onclick="javascript:window.location=\'cart.html\'">';
			temp += '</form>';
						temp += '<div class="clearing">&nbsp;</div>';
			temp += '<div id="confirmContainer">';
			temp += '<div id="paymentConfirm">Item added to cart</div>';
			temp += '</div>';
			temp += '<div class="clearing">&nbsp;</div>';
	}
	return temp;};

/***************************************************************************
* Pick a photo at random from the featured images of a gallery.            *
* Gallery_id = id of gallery to choose,                                    *
* img = reference to html image in                                         *
* which to show image                                                      *
***************************************************************************/
function showGalleryImage(gallery_id, img, updateLink) {
	
	if(img){
		if (location.hash.match('galleries_id=' + gallery_id) && (imageID = location.hash.match('.*photos_id=(.+)$'))) {
		  	imageID = imageID[1];
		} else {
		  	imageID = randomListVal(galleries[gallery_id].featured_images);
		}
		
		if (imageID != 0) {
			img.src = thumbnails[imageID].src;
			img.width = thumbnails[imageID].width;
			img.height = thumbnails[imageID].height;
			img.alt = galleries[gallery_id].title;
			if (updateLink) {
				$(img).parent().attr({					href: thumbnails[imageID].fnGalleryLink(gallery_id),					title: galleries[gallery_id].title				});
			}
		}
	}
}

/***************************************************************************
* If we have dynamic HTML, replace the galleries link with a list that     *
* doesn't include thecurrent gallery                                       *
***************************************************************************/
function showGalleries(gallery_id) {
		
	
	if (!basic) {
		temp = '';
		for (i = 0; i < galleries.length; i++) {
						
			
			if (galleries[i].id != gallery_id) {
								
				if (temp != '') {
					temp += ' | ';
				}
								temp += '<a href="' + galleries[i].section_code + '_' + galleries[i].id + '.html">' + galleries[i].title + '</a>';
							}
		}
		document.all.galleryLinks.innerHTML = 'Other galleries: ' + temp;
	}
}

			

