window.thumbnails = {};
															thumbnails[9015013] = clik.newPhoto({"id":9015013,"src":"Skyward_thumb.jpg","galleries_id":208542,"server_id":15,"link":"photo_9015013.html","width":130,"caption":"Geometry 2","height":87});
															thumbnails[3853870] = clik.newPhoto({"id":3853870,"src":"Winston_watermarkedjpg_thumb.jpg","galleries_id":208543,"server_id":15,"link":"photo_3853870.html","width":130,"caption":"Winston","height":90});
															thumbnails[3853885] = clik.newPhoto({"id":3853885,"src":"Snow_Leopard_2_watermarkedjpg_thumb.jpg","galleries_id":208543,"server_id":15,"link":"photo_3853885.html","width":130,"caption":"Snow Leopard","height":109});
															thumbnails[3853886] = clik.newPhoto({"id":3853886,"src":"White_Tiger_3_watermarkedjpg_thumb.jpg","galleries_id":208543,"server_id":15,"link":"photo_3853886.html","width":130,"caption":"White Tiger","height":125});
															thumbnails[3853901] = clik.newPhoto({"id":3853901,"src":"lip_licking_lion_watermarkedjpg_thumb.jpg","galleries_id":208543,"server_id":15,"link":"photo_3853901.html","width":130,"caption":"Lion","height":87});
															thumbnails[3889781] = clik.newPhoto({"id":3889781,"src":"cheetah_watermarkedjpg_thumb.jpg","galleries_id":208543,"server_id":15,"link":"photo_3889781.html","width":130,"caption":"Cheetah","height":93});
															thumbnails[3853871] = clik.newPhoto({"id":3853871,"src":"Alice_watermarkedjpg_thumb.jpg","galleries_id":208955,"server_id":15,"link":"photo_3853871.html","width":130,"caption":"Alice","height":104});
															thumbnails[3853884] = clik.newPhoto({"id":3853884,"src":"Wolfs_Head_and_Vixen_Morris_watermarkedjpg_thumb.jpg","galleries_id":208955,"server_id":15,"link":"photo_3853884.html","width":130,"caption":"Wolfs Head & Vixen Morris","height":120});
															thumbnails[3853918] = clik.newPhoto({"id":3853918,"src":"Im_not_sure_this_is_a_good_idea_watermarkedjpg_thumb.jpg","galleries_id":208955,"server_id":15,"link":"photo_3853918.html","width":130,"caption":"I'm not so sure this is a good idea!","height":98});
															thumbnails[3813720] = clik.newPhoto({"id":3813720,"src":"another_night_another_boat_watermarkedjpg_thumb.jpg","galleries_id":208541,"server_id":15,"link":"photo_3813720.html","width":130,"caption":"another night, another boat","height":160});
															thumbnails[3813730] = clik.newPhoto({"id":3813730,"src":"Low_tide_light_trails_watermarkedjpg_thumb.jpg","galleries_id":208541,"server_id":15,"link":"photo_3813730.html","width":130,"caption":"Low tide light trails","height":87});
															thumbnails[3813740] = clik.newPhoto({"id":3813740,"src":"Raising_Kingsferry_watermarkedjpg_thumb.jpg","galleries_id":208541,"server_id":15,"link":"photo_3813740.html","width":130,"caption":"Raising Kingsferry","height":78});
															thumbnails[3798319] = clik.newPhoto({"id":3798319,"src":"Ships_that_pass_in_the_night1jpg_thumb.jpg","galleries_id":208541,"server_id":15,"link":"photo_3798319.html","width":130,"caption":"Ships that pass in the night","height":77});
															thumbnails[3798218] = clik.newPhoto({"id":3798218,"src":"electrical_symetrical1jpg_thumb.jpg","galleries_id":206460,"server_id":15,"link":"photo_3798218.html","width":130,"caption":"Electrical symmetry","height":98});
															thumbnails[3798307] = clik.newPhoto({"id":3798307,"src":"Otterham_reserve1jpg_thumb.jpg","galleries_id":208539,"server_id":15,"link":"photo_3798307.html","width":130,"caption":"Otterham Reserve","height":94});
															thumbnails[3798133] = clik.newPhoto({"id":3798133,"src":"artistic_license1jpg_thumb.jpg","galleries_id":206460,"server_id":15,"link":"photo_3798133.html","width":130,"caption":"Desolation Row","height":195});
															thumbnails[3798234] = clik.newPhoto({"id":3798234,"src":"Otterham_Quay_by_night1jpg_thumb.jpg","galleries_id":208541,"server_id":15,"link":"photo_3798234.html","width":130,"caption":"Otterham Quay by night","height":78});
															thumbnails[3416284] = clik.newPhoto({"id":3416284,"src":"macrowaterdropswatermarkjpg_thumb.jpg","galleries_id":206459,"server_id":15,"link":"photo_3416284.html","width":130,"caption":"Macro water drops","height":76});
															thumbnails[3416289] = clik.newPhoto({"id":3416289,"src":"macrowaterdropwatermarkjpg_thumb.jpg","galleries_id":206459,"server_id":15,"link":"photo_3416289.html","width":130,"caption":"Macro water drop","height":112});
															thumbnails[3416338] = clik.newPhoto({"id":3416338,"src":"waitingtobeplayedwatermarkjpg_thumb.jpg","galleries_id":206460,"server_id":15,"link":"photo_3416338.html","width":130,"caption":"Waiting to be played","height":193});
															thumbnails[3419838] = clik.newPhoto({"id":3419838,"src":"Daniellewatermarkjpg_thumb.jpg","galleries_id":208955,"server_id":15,"link":"photo_3419838.html","width":130,"caption":"Danielle","height":170});
															thumbnails[3416343] = clik.newPhoto({"id":3416343,"src":"whywatermarkedjpg_thumb.jpg","galleries_id":208539,"server_id":15,"link":"photo_3416343.html","width":130,"caption":"Why cant I shoot into the sun?","height":80});
															thumbnails[3419385] = clik.newPhoto({"id":3419385,"src":"towerbridgewatermarkjpg_thumb.jpg","galleries_id":208542,"server_id":15,"link":"photo_3419385.html","width":130,"caption":"Tower Bridge","height":94});
															thumbnails[3416235] = clik.newPhoto({"id":3416235,"src":"flyagaricwatermarkjpg_thumb.jpg","galleries_id":206459,"server_id":15,"link":"photo_3416235.html","width":130,"caption":"Fly Agaric","height":109});
															thumbnails[3419562] = clik.newPhoto({"id":3419562,"src":"benjoneswatermarkjpg_thumb.jpg","galleries_id":208955,"server_id":15,"link":"photo_3419562.html","width":130,"caption":"Ben Jones","height":132});
															thumbnails[3419712] = clik.newPhoto({"id":3419712,"src":"burnpapertigerswatermarkjpg_thumb.jpg","galleries_id":208955,"server_id":15,"link":"photo_3419712.html","width":130,"caption":"Burn Paper Tigers","height":95});
															thumbnails[3416323] = clik.newPhoto({"id":3416323,"src":"sunrisegallopwatermarkjpg_thumb.jpg","galleries_id":208540,"server_id":15,"link":"photo_3416323.html","width":130,"caption":"Sunrise gallop","height":97});
															thumbnails[3416268] = clik.newPhoto({"id":3416268,"src":"goldenwatermarkjpg_thumb.jpg","galleries_id":208540,"server_id":15,"link":"photo_3416268.html","width":130,"caption":"Golden sunrise","height":195});
															thumbnails[3416224] = clik.newPhoto({"id":3416224,"src":"earlymorningridewatermarkjpg_thumb.jpg","galleries_id":208540,"server_id":15,"link":"photo_3416224.html","width":130,"caption":"Early morning ride","height":87});
															thumbnails[3416218] = clik.newPhoto({"id":3416218,"src":"catchingthesunrisewatermarkjpg_thumb.jpg","galleries_id":208540,"server_id":15,"link":"photo_3416218.html","width":130,"caption":"Shooting the sunrise","height":99});
															thumbnails[3416228] = clik.newPhoto({"id":3416228,"src":"emergingwatermarkjpg_thumb.jpg","galleries_id":206459,"server_id":15,"link":"photo_3416228.html","width":130,"caption":"Emerging","height":117});
															thumbnails[3416333] = clik.newPhoto({"id":3416333,"src":"thistlewatermarkedjpg_thumb.jpg","galleries_id":206459,"server_id":15,"link":"photo_3416333.html","width":130,"caption":"Thistle","height":108});
															thumbnails[3416229] = clik.newPhoto({"id":3416229,"src":"Falconwatermarkjpg_thumb.jpg","galleries_id":208543,"server_id":15,"link":"photo_3416229.html","width":130,"caption":"Falcon","height":96});
															thumbnails[3419062] = clik.newPhoto({"id":3419062,"src":"badhairdaywatermarkjpg_thumb.jpg","galleries_id":208543,"server_id":15,"link":"photo_3419062.html","width":130,"caption":"Bad hair day","height":91});
															thumbnails[3419072] = clik.newPhoto({"id":3419072,"src":"peregrinewatermarkjpg_thumb.jpg","galleries_id":208543,"server_id":15,"link":"photo_3419072.html","width":130,"caption":"Peregrine Falcon","height":87});
															thumbnails[3416239] = clik.newPhoto({"id":3416239,"src":"formwatermarkjpg_thumb.jpg","galleries_id":206459,"server_id":15,"link":"photo_3416239.html","width":130,"caption":"Form","height":111});
															thumbnails[3419403] = clik.newPhoto({"id":3419403,"src":"scotneywatermarkjpg_thumb.jpg","galleries_id":208539,"server_id":15,"link":"photo_3419403.html","width":130,"caption":"Scotney Castle gardens","height":87});
															thumbnails[3418934] = clik.newPhoto({"id":3418934,"src":"faginwatermarkjpg_thumb.jpg","galleries_id":208955,"server_id":15,"link":"photo_3418934.html","width":130,"caption":"Fagin","height":177});
															thumbnails[3416214] = clik.newPhoto({"id":3416214,"src":"aylesfordvillagewatermarkjpg_thumb.jpg","galleries_id":208539,"server_id":15,"link":"photo_3416214.html","width":130,"caption":"Aylesford","height":80});
															thumbnails[3419065] = clik.newPhoto({"id":3419065,"src":"blacklabradorwatermarkjpg_thumb.jpg","galleries_id":208543,"server_id":15,"link":"photo_3419065.html","width":130,"caption":"Black Labrador","height":87});
															thumbnails[3416221] = clik.newPhoto({"id":3416221,"src":"dandelionclockwatermarkjpg_thumb.jpg","galleries_id":206459,"server_id":15,"link":"photo_3416221.html","width":130,"caption":"Dandelion clock","height":121});
															thumbnails[3416233] = clik.newPhoto({"id":3416233,"src":"fireworkswatermarkedjpg_thumb.jpg","galleries_id":206459,"server_id":15,"link":"photo_3416233.html","width":130,"caption":"Outer edge","height":93});
															thumbnails[3419069] = clik.newPhoto({"id":3419069,"src":"lapwingwatermarkjpg_thumb.jpg","galleries_id":208543,"server_id":15,"link":"photo_3419069.html","width":130,"caption":"Lapwing","height":102});
															thumbnails[3416273] = clik.newPhoto({"id":3416273,"src":"ladybirdwatermarkjpg_thumb.jpg","galleries_id":206459,"server_id":15,"link":"photo_3416273.html","width":130,"caption":"Ladybird","height":103});
															thumbnails[3416242] = clik.newPhoto({"id":3416242,"src":"geometrywatermarkjpg_thumb.jpg","galleries_id":208542,"server_id":15,"link":"photo_3416242.html","width":130,"caption":"Geometry","height":87});
															thumbnails[3416207] = clik.newPhoto({"id":3416207,"src":"allingtonmarinawatermarkedjpg_thumb.jpg","galleries_id":208541,"server_id":15,"link":"photo_3416207.html","width":130,"caption":"Allington Marina","height":107});
															thumbnails[3416308] = clik.newPhoto({"id":3416308,"src":"reculverbluewatermarkjpg_thumb.jpg","galleries_id":208540,"server_id":15,"link":"photo_3416308.html","width":130,"caption":"Reculver blue","height":87});
															thumbnails[3416313] = clik.newPhoto({"id":3416313,"src":"Reculverwatermarkjpg_thumb.jpg","galleries_id":208540,"server_id":15,"link":"photo_3416313.html","width":130,"caption":"Reculver Sunday sunrise","height":87});
															thumbnails[3416317] = clik.newPhoto({"id":3416317,"src":"reculverwhitewatermarkjpg_thumb.jpg","galleries_id":208540,"server_id":15,"link":"photo_3416317.html","width":130,"caption":"Reculver lighter sunrise","height":85});
															thumbnails[3416310] = clik.newPhoto({"id":3416310,"src":"reculversunrisewatermarkjpg_thumb.jpg","galleries_id":208540,"server_id":15,"link":"photo_3416310.html","width":130,"caption":"Reculver ruin sunrise","height":108});
															thumbnails[3416329] = clik.newPhoto({"id":3416329,"src":"sunriseruinwatermarkjpg_thumb.jpg","galleries_id":208540,"server_id":15,"link":"photo_3416329.html","width":130,"caption":"Sunrise ruin uncropped","height":108});
															thumbnails[3416277] = clik.newPhoto({"id":3416277,"src":"lestweforgetwatermarkjpg_thumb.jpg","galleries_id":206460,"server_id":15,"link":"photo_3416277.html","width":130,"caption":"Lest we forget","height":98});
															thumbnails[3416320] = clik.newPhoto({"id":3416320,"src":"reflectionswatermarkjpg_thumb.jpg","galleries_id":206460,"server_id":15,"link":"photo_3416320.html","width":130,"caption":"Reflections","height":87});
															thumbnails[3416297] = clik.newPhoto({"id":3416297,"src":"medwayriversidewatermarkjpg_thumb.jpg","galleries_id":208541,"server_id":15,"link":"photo_3416297.html","width":130,"caption":"Medway boats","height":84});
															thumbnails[3416300] = clik.newPhoto({"id":3416300,"src":"purplewatermarkjpg_thumb.jpg","galleries_id":206459,"server_id":15,"link":"photo_3416300.html","width":130,"caption":"Purple","height":101});
															thumbnails[3438547] = clik.newPhoto({"id":3438547,"src":"oilonwaterwatermarkjpg_thumb.jpg","galleries_id":206460,"server_id":15,"link":"photo_3438547.html","width":130,"caption":"Diesel on seawater.","height":185});
															thumbnails[3416336] = clik.newPhoto({"id":3416336,"src":"veryeffectivewatermarkjpg_thumb.jpg","galleries_id":206460,"server_id":15,"link":"photo_3416336.html","width":130,"caption":"Very effective","height":106});
															thumbnails[3419074] = clik.newPhoto({"id":3419074,"src":"squirrelwatermarkjpg_thumb.jpg","galleries_id":208543,"server_id":15,"link":"photo_3419074.html","width":130,"caption":"Squirrel","height":93});
															thumbnails[3419316] = clik.newPhoto({"id":3419316,"src":"londonwatermarkjpg_thumb.jpg","galleries_id":208542,"server_id":15,"link":"photo_3419316.html","width":130,"caption":"London view","height":66});
															thumbnails[3419365] = clik.newPhoto({"id":3419365,"src":"looktothefuturewatermarkjpg_thumb.jpg","galleries_id":208542,"server_id":15,"link":"photo_3419365.html","width":130,"caption":"Looking to the future","height":88});
															thumbnails[3470597] = clik.newPhoto({"id":3470597,"src":"serenitywatermarkedjpg_thumb.jpg","galleries_id":208543,"server_id":15,"link":"photo_3470597.html","width":130,"caption":"Serenity","height":195});
															thumbnails[9015008] = clik.newPhoto({"id":9015008,"src":"Robin_thumb.jpg","galleries_id":208543,"server_id":15,"link":"photo_9015008.html","width":130,"caption":"Robin taken at Shorne Country Park Jan 2012","height":116});
															thumbnails[9015012] = clik.newPhoto({"id":9015012,"src":"blueandyellow_thumb.jpg","galleries_id":208542,"server_id":15,"link":"photo_9015012.html","width":130,"caption":"Blue and Yellow","height":195});
															thumbnails[3438562] = clik.newPhoto({"id":3438562,"src":"blackswanpreeningwatermarkedjpg_thumb.jpg","galleries_id":208543,"server_id":15,"link":"photo_3438562.html","width":130,"caption":"Black Swan preening","height":197});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  						galleries[208538] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Landscapes","link":"gallery_208538.html","maxRecords":0.0,"photoIDs":[],"skipIndex":0,"section_code":"gallery","featured_images":"3416242,3416224,3416207","id":208538,"singleSection":false});				  						galleries[206459] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Macro","link":"gallery_206459.html","maxRecords":0.0,"photoIDs":[3416284.0,3416289.0,3416235.0,3416228.0,3416333.0,3416239.0,3416221.0,3416233.0,3416273.0,3416300.0],"skipIndex":0,"section_code":"gallery","featured_images":3416239.0,"id":206459,"singleSection":false});				  						galleries[206460] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Miscellaneous","link":"gallery_206460.html","maxRecords":0.0,"photoIDs":[3798218.0,3798133.0,3416338.0,3416277.0,3416320.0,3438547.0,3416336.0],"skipIndex":0,"section_code":"gallery","featured_images":3416277.0,"id":206460,"singleSection":false});				  						galleries[208539] = clik.newGallery({"parentGallery":208538,"usePopups":false,"title":"countryside","link":"gallery_208539.html","maxRecords":0.0,"photoIDs":[3798307.0,3416343.0,3419403.0,3416214.0],"skipIndex":0,"section_code":"gallery","featured_images":"3798307,3419403,3416343,3416214","id":208539,"singleSection":false});				  						galleries[208540] = clik.newGallery({"parentGallery":208538,"usePopups":false,"title":"Sunrise\/Sunset","link":"gallery_208540.html","maxRecords":0.0,"photoIDs":[3416323.0,3416268.0,3416224.0,3416218.0,3416308.0,3416313.0,3416317.0,3416310.0,3416329.0],"skipIndex":0,"section_code":"gallery","featured_images":3416224.0,"id":208540,"singleSection":false});				  						galleries[208541] = clik.newGallery({"parentGallery":208538,"usePopups":false,"title":"Waterscapes","link":"gallery_208541.html","maxRecords":0.0,"photoIDs":[3813720.0,3813730.0,3813740.0,3798319.0,3798234.0,3416207.0,3416297.0],"skipIndex":0,"section_code":"gallery","featured_images":3416207.0,"id":208541,"singleSection":false});				  						galleries[208542] = clik.newGallery({"parentGallery":208538,"usePopups":false,"title":"Urban","link":"gallery_208542.html","maxRecords":0.0,"photoIDs":[9015013.0,3419385.0,3416242.0,3419316.0,3419365.0,9015012.0],"skipIndex":0,"section_code":"gallery","featured_images":3416242.0,"id":208542,"singleSection":false});				  						galleries[208543] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Animals","link":"gallery_208543.html","maxRecords":0.0,"photoIDs":[3853870.0,3853885.0,3853886.0,3853901.0,3889781.0,3416229.0,3419062.0,3419072.0,3419065.0,3419069.0,3419074.0,3470597.0,9015008.0,3438562.0],"skipIndex":0,"section_code":"gallery","featured_images":"9015008,3889781,3853901,3853886,3853885,3853870,3470597,3438562,3419074,3419072","id":208543,"singleSection":false});				  						galleries[208955] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"People\/Portraits","link":"gallery_208955.html","maxRecords":0.0,"photoIDs":[3853871.0,3853884.0,3853918.0,3419838.0,3419562.0,3419712.0,3418934.0],"skipIndex":0,"section_code":"gallery","featured_images":3419838.0,"id":208955,"singleSection":false});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[1] = '9015012,3813740,3416242,3416239';
imageSets[2] = '3419838,3416277,3416242,3416239,3416224,3416207';
imageSets[3] = '9015013,9015012,9015008,3889781,3853918,3853901,3853886,3853885,3853884,3853871,3853870,3813740,3813730,3813720,3798319,3798307,3798234,3798218,3798133,3470597,3438562,3438547,3419838,3419712,3419562,3419403,3419385,3419365,3419316,3419074,3419072,3419069,3419065,3419062,3418934,3416343,3416338,3416336,3416333,3416329,3416323,3416320,3416317,3416313,3416310,3416308,3416300,3416297,3416289,3416284';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 51:
		val = 'http://www12.clikpic.com/garryj/images';
		break;
	}
		switch (server_id) {
		case 0:
		val = 'http://www.clikpic.com/garryj/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/garryj/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/garryj/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/garryj/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/garryj/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/garryj/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/garryj/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/garryj/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/garryj/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/garryj/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/garryj/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/garryj/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/garryj/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/garryj/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/garryj/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/garryj/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/garryj/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/garryj/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/garryj/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/garryj/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/garryj/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/garryj/images';
		break;
	}
		switch (server_id) {
		case 53:
		val = 'http://images.clikpic.com/garryj/images';
		break;
	}
		switch (server_id) {
		case 52:
		val = 'http://tpc22/clikpic/garryj/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/garryj/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/garryj/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 = 'Garry Jenkins Imaging: ' + 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.item_price !== '') {
																		temp += '<form id="paymentForm" style="margin:0px;border:0px;" name="paymentForm" target="_blank" action="https://www.paypal.com/cgi-bin/webscr" method="post">';
			temp += '<input type="hidden" name="item_name" value="'+item_name+'">';
			ref = '';
			if(this.photo_ref != ''){
				ref = this.photo_ref+' - '+this.caption;
			}
			else{
				ref = this.id+' - '+this.caption;
			}
			price = amount;								temp += '<input type="hidden" name="cmd" value="_cart">';
					temp += '<input type="hidden" name="business" value="foggy_5@hotmail.com">';
					temp += '<input type="hidden" name="currency_code" value="GBP">';
					temp += '<input type="hidden" name="add" value="1">';
													temp += '<input type="hidden" name="amount" value="'+amount+'">';
					temp += '<input type="hidden" name="item_number" value="'+ref+'">';
													temp += '<input type=\"Submit\" value=\"Add to cart\" id=\"paymentAddButton\" class=\"button\" onmouseover=\"this.className=\'buttonHi\';\" onmouseout=\"this.className=\'button\';\">';
										temp += '</form>';
										temp += '<form id="paymentCartForm" style="margin:0px;" name="paymentCartForm" target="_blank" action="https://www.paypal.com/cgi-bin/webscr" method="post">';
				temp += '<input type="hidden" name="cmd" value="_cart">';
				temp += '<input type="hidden" name="business" value="foggy_5@hotmail.com">';
				temp += '<input type="hidden" name="display" value="1">';
				temp += '<input type=\"Submit\" value=\"View cart\" id=\"paymentViewButton\" class=\"button\" onmouseover=\"this.className=\'buttonHi\';\" onmouseout=\"this.className=\'button\';\">';
				temp += '</form>';
						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;
	}
}

			

