window.thumbnails = {};
															thumbnails[2750348] = clik.newPhoto({"id":2750348,"src":"josse2_2_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"Josse Davis in the studio","height":122});
															thumbnails[8044762] = clik.newPhoto({"id":8044762,"src":"Bb78a_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"Elephants in love","height":98});
															thumbnails[8044788] = clik.newPhoto({"id":8044788,"src":"Bb79a_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"Happy little song bird","height":98});
															thumbnails[8044824] = clik.newPhoto({"id":8044824,"src":"Bb84a_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"Little birds under moon","height":98});
															thumbnails[8044845] = clik.newPhoto({"id":8044845,"src":"Bb86a_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"Elephant, Tiger & Bird jar","height":173});
															thumbnails[8044852] = clik.newPhoto({"id":8044852,"src":"Bb92b_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"Bird jar.","height":173});
															thumbnails[8044851] = clik.newPhoto({"id":8044851,"src":"Bb91d_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"Three headed Tiger jar","height":173});
															thumbnails[8044902] = clik.newPhoto({"id":8044902,"src":"Bb94a_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"Big Cock.","height":98});
															thumbnails[8044911] = clik.newPhoto({"id":8044911,"src":"Bb93c_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"Tiger and Doves jar\t","height":160});
															thumbnails[8045008] = clik.newPhoto({"id":8045008,"src":"Bb96a_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"Bunnies and Birds.","height":98});
															thumbnails[6272431] = clik.newPhoto({"id":6272431,"src":"SS1w_thumb.jpg","galleries_id":348568,"server_id":5,"link":"photo_6272431.html","width":130,"caption":"Visitors II","height":112});
															thumbnails[6729897] = clik.newPhoto({"id":6729897,"src":"space1_thumb.jpg","galleries_id":348568,"server_id":5,"link":"photo_6729897.html","width":130,"caption":"Flying saucers","height":112});
															thumbnails[6272446] = clik.newPhoto({"id":6272446,"src":"SS3w_thumb.jpg","galleries_id":348568,"server_id":5,"link":"photo_6272446.html","width":130,"caption":"Going up.","height":112});
															thumbnails[6272449] = clik.newPhoto({"id":6272449,"src":"SS15w_212_thumb.jpg","galleries_id":348568,"server_id":5,"link":"photo_6272449.html","width":130,"caption":"Visitors III","height":223});
															thumbnails[6272450] = clik.newPhoto({"id":6272450,"src":"SS23w_thumb.jpg","galleries_id":348568,"server_id":5,"link":"photo_6272450.html","width":130,"caption":"Love amongst the Flowers","height":112});
															thumbnails[6272453] = clik.newPhoto({"id":6272453,"src":"SS252w_thumb.jpg","galleries_id":348568,"server_id":5,"link":"photo_6272453.html","width":130,"caption":"On the Beach II","height":112});
															thumbnails[6729654] = clik.newPhoto({"id":6729654,"src":"1pigeon_thumb.jpg","galleries_id":366954,"server_id":5,"link":"photo_6729654.html","width":130,"caption":"London Pigeon","height":112});
															thumbnails[5087369] = clik.newPhoto({"id":5087369,"src":"fr1_thumb.jpg","galleries_id":447809,"server_id":5,"link":"photo_5087369.html","width":130,"caption":"Pot 1          ","height":100});
															thumbnails[5087495] = clik.newPhoto({"id":5087495,"src":"fr1b_thumb.jpg","galleries_id":447809,"server_id":5,"link":"photo_5087495.html","width":130,"caption":"Pot 1","height":75});
															thumbnails[5087575] = clik.newPhoto({"id":5087575,"src":"fr12_thumb.jpg","galleries_id":447809,"server_id":5,"link":"photo_5087575.html","width":130,"caption":"Pot 2","height":98});
															thumbnails[5087576] = clik.newPhoto({"id":5087576,"src":"fr10_thumb.jpg","galleries_id":447809,"server_id":5,"link":"photo_5087576.html","width":130,"caption":"Pot 2","height":98});
															thumbnails[5088116] = clik.newPhoto({"id":5088116,"src":"sp2_thumb.jpg","galleries_id":447809,"server_id":5,"link":"photo_5088116.html","width":130,"caption":"Pot 3","height":73});
															thumbnails[5088130] = clik.newPhoto({"id":5088130,"src":"sp1_thumb.jpg","galleries_id":447809,"server_id":5,"link":"photo_5088130.html","width":130,"caption":"Pot 3","height":98});
															thumbnails[5088133] = clik.newPhoto({"id":5088133,"src":"sp3_thumb.jpg","galleries_id":447809,"server_id":5,"link":"photo_5088133.html","width":130,"caption":"Pot 3","height":108});
															thumbnails[5088152] = clik.newPhoto({"id":5088152,"src":"z4_thumb.jpg","galleries_id":447809,"server_id":5,"link":"photo_5088152.html","width":130,"caption":"Pot 4","height":84});
															thumbnails[5088163] = clik.newPhoto({"id":5088163,"src":"z1_thumb.jpg","galleries_id":447809,"server_id":5,"link":"photo_5088163.html","width":130,"caption":"Pot 4","height":98});
															thumbnails[6727661] = clik.newPhoto({"id":6727661,"src":"b-on-w_thumb.jpg","galleries_id":366616,"server_id":5,"link":"photo_6727661.html","width":130,"caption":"Pagan dancers III","height":112});
															thumbnails[6727666] = clik.newPhoto({"id":6727666,"src":"TR25z_thumb.jpg","galleries_id":366616,"server_id":5,"link":"photo_6727666.html","width":130,"caption":"Hearts II","height":112});
															thumbnails[6727685] = clik.newPhoto({"id":6727685,"src":"TR7z_thumb.jpg","galleries_id":366616,"server_id":5,"link":"photo_6727685.html","width":130,"caption":"Orange Snake","height":112});
															thumbnails[6727723] = clik.newPhoto({"id":6727723,"src":"TRz_thumb.jpg","galleries_id":366616,"server_id":5,"link":"photo_6727723.html","width":130,"caption":"Sun Snake<br>\r\n<br>\r\n","height":112});
															thumbnails[6727733] = clik.newPhoto({"id":6727733,"src":"w-on-b_thumb.jpg","galleries_id":366616,"server_id":5,"link":"photo_6727733.html","width":130,"caption":"Pagan Dancers II ","height":112});
															thumbnails[6727759] = clik.newPhoto({"id":6727759,"src":"TR8z_thumb.jpg","galleries_id":366616,"server_id":5,"link":"photo_6727759.html","width":130,"caption":"Green Snake II","height":112});
															thumbnails[6727761] = clik.newPhoto({"id":6727761,"src":"RE35z_thumb.jpg","galleries_id":366616,"server_id":5,"link":"photo_6727761.html","width":130,"caption":"Hearts IV","height":112});
															thumbnails[6727766] = clik.newPhoto({"id":6727766,"src":"TR9z_thumb.jpg","galleries_id":366616,"server_id":5,"link":"photo_6727766.html","width":130,"caption":"Checker Snake","height":112});
															thumbnails[6727775] = clik.newPhoto({"id":6727775,"src":"leaf1_thumb.jpg","galleries_id":366616,"server_id":5,"link":"photo_6727775.html","width":130,"caption":"Leaf VI","height":112});
															thumbnails[6727796] = clik.newPhoto({"id":6727796,"src":"esca1_thumb.jpg","galleries_id":172409,"server_id":5,"link":"photo_6727796.html","width":130,"caption":"Escalator I","height":112});
															thumbnails[6727786] = clik.newPhoto({"id":6727786,"src":"bus1a_thumb.jpg","galleries_id":172409,"server_id":5,"link":"photo_6727786.html","width":130,"caption":"Bus stop II","height":112});
															thumbnails[6727803] = clik.newPhoto({"id":6727803,"src":"kings2a_thumb.jpg","galleries_id":172409,"server_id":5,"link":"photo_6727803.html","width":130,"caption":"Kings Arms VII","height":112});
															thumbnails[6727794] = clik.newPhoto({"id":6727794,"src":"dog-walk1_thumb.jpg","galleries_id":172409,"server_id":5,"link":"photo_6727794.html","width":130,"caption":"Dog walk in the snow","height":112});
															thumbnails[6727856] = clik.newPhoto({"id":6727856,"src":"P1030109_thumb.jpg","galleries_id":172409,"server_id":5,"link":"photo_6727856.html","width":130,"caption":"London II","height":112});
															thumbnails[6727859] = clik.newPhoto({"id":6727859,"src":"thames6_thumb.jpg","galleries_id":172409,"server_id":5,"link":"photo_6727859.html","width":130,"caption":"Thames II","height":112});
															thumbnails[6727880] = clik.newPhoto({"id":6727880,"src":"TR47_thumb.jpg","galleries_id":172409,"server_id":5,"link":"photo_6727880.html","width":130,"caption":"Kings Arms IX","height":112});
															thumbnails[6727787] = clik.newPhoto({"id":6727787,"src":"carpark_thumb.jpg","galleries_id":172409,"server_id":5,"link":"photo_6727787.html","width":130,"caption":"Multi-story car park","height":112});
															thumbnails[6727790] = clik.newPhoto({"id":6727790,"src":"demo1_thumb.jpg","galleries_id":172409,"server_id":5,"link":"photo_6727790.html","width":130,"caption":"Demo","height":112});
															thumbnails[8464182] = clik.newPhoto({"id":8464182,"src":"stacker_E65F28DD-1EC9-DFB6-096134363D9B8873_thumb.jpg","galleries_id":172409,"server_id":5,"link":"photo_8464182.html","width":130,"caption":"Shelf stacker","height":104});
															thumbnails[8464189] = clik.newPhoto({"id":8464189,"src":"DSC01407_E665596F-1EC9-DFB6-09535D28DA8279B5_thumb.JPG","galleries_id":172409,"server_id":5,"link":"photo_8464189.html","width":130,"caption":"Bird jigsaw ","height":104});
															thumbnails[6729696] = clik.newPhoto({"id":6729696,"src":"1seal_thumb.jpg","galleries_id":366954,"server_id":5,"link":"photo_6729696.html","width":130,"caption":"Seals off Norfolk","height":112});
															thumbnails[6729701] = clik.newPhoto({"id":6729701,"src":"1zeb_thumb.jpg","galleries_id":366954,"server_id":5,"link":"photo_6729701.html","width":130,"caption":"Zebra migration","height":112});
															thumbnails[6729715] = clik.newPhoto({"id":6729715,"src":"2pigs_thumb.jpg","galleries_id":366954,"server_id":5,"link":"photo_6729715.html","width":130,"caption":"Pigs","height":112});
															thumbnails[6729721] = clik.newPhoto({"id":6729721,"src":"rats1000_thumb.jpg","galleries_id":366954,"server_id":5,"link":"photo_6729721.html","width":130,"caption":"Rats","height":112});
															thumbnails[6729764] = clik.newPhoto({"id":6729764,"src":"1plague_thumb.jpg","galleries_id":366954,"server_id":5,"link":"photo_6729764.html","width":130,"caption":"The Plague ","height":112});
															thumbnails[6729799] = clik.newPhoto({"id":6729799,"src":"nets1_thumb.jpg","galleries_id":366954,"server_id":5,"link":"photo_6729799.html","width":130,"caption":"Chasing Love","height":112});
															thumbnails[6729786] = clik.newPhoto({"id":6729786,"src":"figs1_thumb.jpg","galleries_id":366954,"server_id":5,"link":"photo_6729786.html","width":130,"caption":"Frolics I","height":112});
															thumbnails[6729839] = clik.newPhoto({"id":6729839,"src":"hen1_thumb.jpg","galleries_id":366954,"server_id":5,"link":"photo_6729839.html","width":130,"caption":"Chicken","height":112});
															thumbnails[9038404] = clik.newPhoto({"id":9038404,"src":"RB128_thumb.jpg","galleries_id":172409,"server_id":5,"link":"photo_9038404.html","width":130,"caption":"Ice Cream Van","height":98});
															thumbnails[9038405] = clik.newPhoto({"id":9038405,"src":"RB130_thumb.jpg","galleries_id":172409,"server_id":5,"link":"photo_9038405.html","width":130,"caption":"Sweet Shop","height":98});
															thumbnails[9038406] = clik.newPhoto({"id":9038406,"src":"RB134_thumb.jpg","galleries_id":172409,"server_id":5,"link":"photo_9038406.html","width":130,"caption":"Piano","height":98});
															thumbnails[9038408] = clik.newPhoto({"id":9038408,"src":"RB135_thumb.jpg","galleries_id":172409,"server_id":5,"link":"photo_9038408.html","width":130,"caption":"Freezer (encounter)","height":98});
															thumbnails[9038317] = clik.newPhoto({"id":9038317,"src":"SwB173_thumb.jpg","galleries_id":476276,"server_id":5,"link":"photo_9038317.html","width":130,"caption":"Let's Rumba Darling.","height":98});
															thumbnails[9038318] = clik.newPhoto({"id":9038318,"src":"SwB179_thumb.jpg","galleries_id":476276,"server_id":5,"link":"photo_9038318.html","width":130,"caption":"Making Whoopee ","height":98});
															thumbnails[9038320] = clik.newPhoto({"id":9038320,"src":"SwB180_thumb.jpg","galleries_id":476276,"server_id":5,"link":"photo_9038320.html","width":130,"caption":"Young Love","height":98});
															thumbnails[9038388] = clik.newPhoto({"id":9038388,"src":"Bb133_thumb.jpg","galleries_id":476276,"server_id":5,"link":"photo_9038388.html","width":130,"caption":"Adam & Eve ","height":98});
															thumbnails[9038392] = clik.newPhoto({"id":9038392,"src":"Bb134c_thumb.jpg","galleries_id":476276,"server_id":5,"link":"photo_9038392.html","width":130,"caption":"Ripe fruits","height":98});
															thumbnails[9038352] = clik.newPhoto({"id":9038352,"src":"SwB171_thumb.jpg","galleries_id":476276,"server_id":5,"link":"photo_9038352.html","width":130,"caption":"Hearts bowl (with lip) 1 ","height":98});
															thumbnails[9038360] = clik.newPhoto({"id":9038360,"src":"SwM191_thumb.jpg","galleries_id":476276,"server_id":5,"link":"photo_9038360.html","width":130,"caption":"Heart Mug 5","height":98});
															thumbnails[9038365] = clik.newPhoto({"id":9038365,"src":"SwM176_thumb.jpg","galleries_id":476276,"server_id":5,"link":"photo_9038365.html","width":130,"caption":"Frolics with hearts mug","height":98});
															thumbnails[9038370] = clik.newPhoto({"id":9038370,"src":"SwV195b_thumb.jpg","galleries_id":476276,"server_id":5,"link":"photo_9038370.html","width":130,"caption":"Love all round","height":98});
															thumbnails[9038373] = clik.newPhoto({"id":9038373,"src":"SwT198c_thumb.jpg","galleries_id":476276,"server_id":5,"link":"photo_9038373.html","width":130,"caption":"Hearts Tea Pot 1","height":98});
															thumbnails[9038377] = clik.newPhoto({"id":9038377,"src":"SwT197a_thumb.jpg","galleries_id":476276,"server_id":5,"link":"photo_9038377.html","width":130,"caption":"Happy Lovers Tea Pot","height":98});
															thumbnails[9038379] = clik.newPhoto({"id":9038379,"src":"SwT196_thumb.jpg","galleries_id":476276,"server_id":5,"link":"photo_9038379.html","width":130,"caption":"Frolics with hearts Tea Pot 1","height":98});
															thumbnails[6729889] = clik.newPhoto({"id":6729889,"src":"SS41a_thumb.jpg","galleries_id":348568,"server_id":5,"link":"photo_6729889.html","width":130,"caption":"Roller coaster","height":98});
															thumbnails[6729890] = clik.newPhoto({"id":6729890,"src":"SS39a_thumb.jpg","galleries_id":348568,"server_id":5,"link":"photo_6729890.html","width":130,"caption":"Bedtime ","height":94});
															thumbnails[6729891] = clik.newPhoto({"id":6729891,"src":"SS34a1_thumb.jpg","galleries_id":348568,"server_id":5,"link":"photo_6729891.html","width":130,"caption":"Artist and model","height":97});
															thumbnails[6272456] = clik.newPhoto({"id":6272456,"src":"SS30a_thumb.jpg","galleries_id":348568,"server_id":5,"link":"photo_6272456.html","width":130,"caption":"The Conference.","height":98});
															thumbnails[6729894] = clik.newPhoto({"id":6729894,"src":"SS23a_thumb.jpg","galleries_id":348568,"server_id":5,"link":"photo_6729894.html","width":130,"caption":"Hammock I","height":95});
															thumbnails[6729895] = clik.newPhoto({"id":6729895,"src":"SS19a_thumb.jpg","galleries_id":348568,"server_id":5,"link":"photo_6729895.html","width":130,"caption":"The escalator I","height":100});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  						galleries[476276] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Latest Stoneware","link":"gallery_476276.html","maxRecords":0.0,"photoIDs":[9038317.0,9038318.0,9038320.0,9038388.0,9038392.0,9038352.0,9038360.0,9038365.0,9038370.0,9038373.0,9038377.0,9038379.0],"skipIndex":0,"section_code":"gallery","featured_images":"9038352,9038317","id":476276,"singleSection":false});				  						galleries[172409] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Figurative Raku","link":"gallery_172409.html","maxRecords":0.0,"photoIDs":[6727796.0,6727786.0,6727803.0,6727794.0,6727856.0,6727859.0,6727880.0,6727787.0,6727790.0,8464182.0,8464189.0,9038404.0,9038405.0,9038406.0,9038408.0],"skipIndex":0,"section_code":"gallery","featured_images":"8464189,8464182,6727856,6727786","id":172409,"singleSection":false});				  						galleries[366616] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Decorative Raku","link":"gallery_366616.html","maxRecords":0.0,"photoIDs":[6727661.0,6727666.0,6727685.0,6727723.0,6727733.0,6727759.0,6727761.0,6727766.0,6727775.0],"skipIndex":0,"section_code":"gallery","featured_images":"6727723,6727685","id":366616,"singleSection":false});				  						galleries[366954] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Multi-animal","link":"gallery_366954.html","maxRecords":0.0,"photoIDs":[6729654.0,6729696.0,6729701.0,6729715.0,6729721.0,6729764.0,6729799.0,6729786.0,6729839.0],"skipIndex":0,"section_code":"gallery","featured_images":6729701.0,"id":366954,"singleSection":false});				  						galleries[348568] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Aliens theme ","link":"gallery_348568.html","maxRecords":0.0,"photoIDs":[6272431.0,6729897.0,6272446.0,6272449.0,6272450.0,6272453.0,6729889.0,6729890.0,6729891.0,6272456.0,6729894.0,6729895.0],"skipIndex":0,"section_code":"gallery","featured_images":"6729897,6272453","id":348568,"singleSection":false});				  						galleries[447809] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Other Stoneware","link":"gallery_447809.html","maxRecords":0.0,"photoIDs":[5087369.0,5087495.0,5087575.0,5087576.0,5088116.0,5088130.0,5088133.0,5088152.0,5088163.0],"skipIndex":0,"section_code":"gallery","featured_images":5088133.0,"id":447809,"singleSection":false});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[1] = '2750348';
imageSets[2] = '6729897,6272453,5088133,6727685,6727723,6727786,6727856,8464182,8464189,6729701,8044762,8044788,8044845,8045008,9038317,9038352';
imageSets[3] = '6727796,6727786,6727803,6727787,6727790';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 51:
		val = 'http://www12.clikpic.com/josse1959/images';
		break;
	}
		switch (server_id) {
		case 0:
		val = 'http://www.clikpic.com/josse1959/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/josse1959/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/josse1959/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/josse1959/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/josse1959/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/josse1959/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/josse1959/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/josse1959/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/josse1959/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/josse1959/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/josse1959/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/josse1959/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/josse1959/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/josse1959/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/josse1959/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/josse1959/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/josse1959/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/josse1959/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/josse1959/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/josse1959/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/josse1959/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/josse1959/images';
		break;
	}
		switch (server_id) {
		case 53:
		val = 'http://images.clikpic.com/josse1959/images';
		break;
	}
		switch (server_id) {
		case 52:
		val = 'http://tpc22/clikpic/josse1959/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/josse1959/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/josse1959/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 = 'Josse Davis: ' + 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;
	}
}

			

