window.thumbnails = {};
															thumbnails[1573618] = clik.newPhoto({"id":1573618,"src":"KDGP Logo - 200_thumb.jpg","galleries_id":"","server_id":18,"link":"#","width":130,"caption":"","height":124});
															thumbnails[8631923] = clik.newPhoto({"id":8631923,"src":"Bikers_Final_Threesome_thumb.jpg","galleries_id":94155,"server_id":35,"link":"photo_8631923.html","width":130,"caption":"Bikers Final Threesome","height":98});
															thumbnails[8631931] = clik.newPhoto({"id":8631931,"src":"Galactic_Express_thumb.jpg","galleries_id":94155,"server_id":35,"link":"photo_8631931.html","width":130,"caption":"Galactic Express","height":98});
															thumbnails[8631935] = clik.newPhoto({"id":8631935,"src":"Holy_Cross_thumb.jpg","galleries_id":94155,"server_id":35,"link":"photo_8631935.html","width":130,"caption":"Holy Cross","height":98});
															thumbnails[8631941] = clik.newPhoto({"id":8631941,"src":"Six_Yaks_thumb.jpg","galleries_id":95403,"server_id":35,"link":"photo_8631941.html","width":130,"caption":"Six Yaks","height":195});
															thumbnails[8632004] = clik.newPhoto({"id":8632004,"src":"Rusty_Parrotfish_thumb.jpg","galleries_id":94155,"server_id":35,"link":"photo_8632004.html","width":130,"caption":"Rusty Parrotfish","height":82});
															thumbnails[8632069] = clik.newPhoto({"id":8632069,"src":"Eating_Out_Morrocan_Style_thumb.jpg","galleries_id":94155,"server_id":35,"link":"photo_8632069.html","width":130,"caption":"Eating Out Morrocan Style","height":76});
															thumbnails[8452664] = clik.newPhoto({"id":8452664,"src":"Tower_of_Steel_FP_thumb.jpg","galleries_id":94155,"server_id":37,"link":"photo_8452664.html","width":130,"caption":"Tower of Steel - Leeds Armouries","height":87});
															thumbnails[8452693] = clik.newPhoto({"id":8452693,"src":"Estuary_FP_thumb.jpg","galleries_id":94155,"server_id":37,"link":"photo_8452693.html","width":130,"caption":"Estuary","height":87});
															thumbnails[1342351] = clik.newPhoto({"id":1342351,"src":"Air_Band_thumb.jpg","galleries_id":94155,"server_id":18,"link":"photo_1342351.html","width":130,"caption":"Air Band","height":81});
															thumbnails[1342532] = clik.newPhoto({"id":1342532,"src":"Kenworth_Chrome_thumb.jpg","galleries_id":94155,"server_id":18,"link":"photo_1342532.html","width":130,"caption":"Kenworth Chrome","height":95});
															thumbnails[1342725] = clik.newPhoto({"id":1342725,"src":"Pink_Rose_thumb.jpg","galleries_id":94155,"server_id":18,"link":"photo_1342725.html","width":130,"caption":"Pink Rose","height":87});
															thumbnails[1343078] = clik.newPhoto({"id":1343078,"src":"Entering_the_ Castle_thumb.jpg","galleries_id":94155,"server_id":18,"link":"photo_1343078.html","width":130,"caption":"Entering the Castle","height":107});
															thumbnails[1343228] = clik.newPhoto({"id":1343228,"src":"storm_pegwell_thumb.jpg","galleries_id":94155,"server_id":18,"link":"photo_1343228.html","width":130,"caption":"Storm Pegwell","height":88});
															thumbnails[1343234] = clik.newPhoto({"id":1343234,"src":"The_Hut_Rye_Harbour_thumb.jpg","galleries_id":94155,"server_id":18,"link":"photo_1343234.html","width":130,"caption":"The Hut Rye Harbour","height":87});
															thumbnails[1343239] = clik.newPhoto({"id":1343239,"src":"Through_the_wire_thumb.jpg","galleries_id":94155,"server_id":18,"link":"photo_1343239.html","width":130,"caption":"Through the Wire","height":87});
															thumbnails[1343243] = clik.newPhoto({"id":1343243,"src":"Thirsty_Work_thumb.jpg","galleries_id":94155,"server_id":18,"link":"photo_1343243.html","width":130,"caption":"Thirsty Work","height":111});
															thumbnails[1357011] = clik.newPhoto({"id":1357011,"src":"Cottages_at_ Little_ Langdale_thumb.jpg","galleries_id":94155,"server_id":18,"link":"photo_1357011.html","width":130,"caption":"Cottages at Little Langdale","height":99});
															thumbnails[1357015] = clik.newPhoto({"id":1357015,"src":"Lets_Have_a Lick_thumb.jpg","galleries_id":95403,"server_id":18,"link":"photo_1357015.html","width":130,"caption":"Lets Have a Lick","height":195});
															thumbnails[1357017] = clik.newPhoto({"id":1357017,"src":"Night_Shift_thumb.jpg","galleries_id":94155,"server_id":18,"link":"photo_1357017.html","width":130,"caption":"Night Shift","height":86});
															thumbnails[1357020] = clik.newPhoto({"id":1357020,"src":"Sagger's_strikes_thumb.jpg","galleries_id":94155,"server_id":18,"link":"photo_1357020.html","width":130,"caption":"Sagger's strikes","height":80});
															thumbnails[1363458] = clik.newPhoto({"id":1363458,"src":"1812_Overture_thumb.jpg","galleries_id":94155,"server_id":18,"link":"photo_1363458.html","width":130,"caption":"1812 Overture","height":88});
															thumbnails[1363465] = clik.newPhoto({"id":1363465,"src":"Shoe_Shine_Girls_thumb.jpg","galleries_id":94155,"server_id":18,"link":"photo_1363465.html","width":130,"caption":"Shoe Shine Girls","height":83});
															thumbnails[1384205] = clik.newPhoto({"id":1384205,"src":"No_Title_1_thumb.jpg","galleries_id":94155,"server_id":18,"link":"photo_1384205.html","width":130,"caption":"No Title","height":61});
															thumbnails[1384210] = clik.newPhoto({"id":1384210,"src":"No_Title_2_thumb.jpg","galleries_id":94155,"server_id":18,"link":"photo_1384210.html","width":130,"caption":"No Title","height":76});
															thumbnails[1632363] = clik.newPhoto({"id":1632363,"src":"Minding_the_mules_Kashgar_market_thumb.jpg","galleries_id":94155,"server_id":18,"link":"photo_1632363.html","width":130,"caption":"Minding the mules","height":87});
															thumbnails[1632365] = clik.newPhoto({"id":1632365,"src":"Take_off_at_Bempton_cliffs_thumb.jpg","galleries_id":94155,"server_id":18,"link":"photo_1632365.html","width":130,"caption":"Take off","height":85});
															thumbnails[4446138] = clik.newPhoto({"id":4446138,"src":"Bee_orchid_thumb.jpg","galleries_id":95403,"server_id":18,"link":"photo_4446138.html","width":130,"caption":"Bee Orchid","height":195});
															thumbnails[4446141] = clik.newPhoto({"id":4446141,"src":"Chicory_thumb.jpg","galleries_id":95403,"server_id":18,"link":"photo_4446141.html","width":130,"caption":"Chicory","height":195});
															thumbnails[4446142] = clik.newPhoto({"id":4446142,"src":"Honey_Fungus_thumb.jpg","galleries_id":95403,"server_id":18,"link":"photo_4446142.html","width":130,"caption":"Honey Fungus","height":195});
															thumbnails[4446146] = clik.newPhoto({"id":4446146,"src":"late_spider_orchid1_thumb.jpg","galleries_id":95403,"server_id":18,"link":"photo_4446146.html","width":130,"caption":"Late Spider Orchid","height":195});
															thumbnails[4446147] = clik.newPhoto({"id":4446147,"src":"Painted_Lady_thumb.jpg","galleries_id":94155,"server_id":18,"link":"photo_4446147.html","width":130,"caption":"Painted Lady","height":86});
															thumbnails[4446150] = clik.newPhoto({"id":4446150,"src":"Spider_eating_dragonfly_thumb.jpg","galleries_id":94155,"server_id":18,"link":"photo_4446150.html","width":130,"caption":"Spider eating dragonfly","height":100});
															thumbnails[4541210] = clik.newPhoto({"id":4541210,"src":"Dales_Fence_FP_thumb.jpg","galleries_id":94155,"server_id":18,"link":"photo_4541210.html","width":130,"caption":"Dales Fence","height":87});
															thumbnails[8452702] = clik.newPhoto({"id":8452702,"src":"Steve_FP_thumb.jpg","galleries_id":95403,"server_id":37,"link":"photo_8452702.html","width":130,"caption":"Steve","height":186});
															thumbnails[8457049] = clik.newPhoto({"id":8457049,"src":"Adieu2_thumb.jpg","galleries_id":95403,"server_id":38,"link":"photo_8457049.html","width":130,"caption":"Adieu2","height":167});
															thumbnails[8457061] = clik.newPhoto({"id":8457061,"src":"Adieu_Homeward_Bound_thumb.jpg","galleries_id":95403,"server_id":38,"link":"photo_8457061.html","width":130,"caption":"Adieu Homeward Bound","height":172});
															thumbnails[8457066] = clik.newPhoto({"id":8457066,"src":"Grey_Partridge1_thumb.jpg","galleries_id":94155,"server_id":38,"link":"photo_8457066.html","width":130,"caption":"Grey Partridge","height":85});
															thumbnails[8457070] = clik.newPhoto({"id":8457070,"src":"Valve_and_steam1_thumb.jpg","galleries_id":95403,"server_id":38,"link":"photo_8457070.html","width":130,"caption":"Valve and Steam","height":185});
															thumbnails[1342732] = clik.newPhoto({"id":1342732,"src":"2007_image_thumb.jpg","galleries_id":94339,"server_id":18,"link":"photo_1342732.html","width":130,"caption":"ORIGINAL IMAGE - 2007","height":87});
															thumbnails[8457000] = clik.newPhoto({"id":8457000,"src":"by_Paula_Ware_1_thumb.jpg","galleries_id":94339,"server_id":38,"link":"photo_8457000.html","width":130,"caption":"by Paula Ware","height":87});
															thumbnails[1384195] = clik.newPhoto({"id":1384195,"src":"by_Glyn_Bareham_thumb.jpg","galleries_id":94339,"server_id":18,"link":"photo_1384195.html","width":130,"caption":"by Glyn Bareham","height":87});
															thumbnails[1434926] = clik.newPhoto({"id":1434926,"src":"by_Mick Gilburt_thumb.jpg","galleries_id":94339,"server_id":18,"link":"photo_1434926.html","width":130,"caption":"by Mick Gilburt","height":87});
															thumbnails[1363471] = clik.newPhoto({"id":1363471,"src":"2007_image_B&W_thumb.jpg","galleries_id":94339,"server_id":18,"link":"photo_1363471.html","width":130,"caption":"by Frank Page","height":87});
															thumbnails[1443159] = clik.newPhoto({"id":1443159,"src":"by_Neville Marsh_thumb.jpg","galleries_id":94339,"server_id":18,"link":"photo_1443159.html","width":130,"caption":"by Neville Marsh","height":87});
															thumbnails[1620502] = clik.newPhoto({"id":1620502,"src":"by George Gibbs_thumb.jpg","galleries_id":94339,"server_id":18,"link":"photo_1620502.html","width":130,"caption":"by George Gibbs","height":87});
															thumbnails[1480886] = clik.newPhoto({"id":1480886,"src":"by_John_Bowsher_thumb.jpg","galleries_id":94339,"server_id":18,"link":"photo_1480886.html","width":130,"caption":"by John Bowsher","height":99});
															thumbnails[1480991] = clik.newPhoto({"id":1480991,"src":"by_John_Newell_thumb.jpg","galleries_id":94339,"server_id":18,"link":"photo_1480991.html","width":130,"caption":"by John Newell","height":173});
															thumbnails[8455467] = clik.newPhoto({"id":8455467,"src":"ORIGINAL_IMAGE_-_2008_thumb.jpg","galleries_id":94339,"server_id":38,"link":"photo_8455467.html","width":130,"caption":"ORIGINAL IMAGE - 2008","height":87});
															thumbnails[8455476] = clik.newPhoto({"id":8455476,"src":"Bexhill_01_thumb.jpg","galleries_id":94339,"server_id":38,"link":"photo_8455476.html","width":130,"caption":"Bexhill-01","height":87});
															thumbnails[8455480] = clik.newPhoto({"id":8455480,"src":"Bexhill_02_thumb.jpg","galleries_id":94339,"server_id":38,"link":"photo_8455480.html","width":130,"caption":"Bexhill-02","height":86});
															thumbnails[8455492] = clik.newPhoto({"id":8455492,"src":"Bexhill_03_thumb.jpg","galleries_id":94339,"server_id":38,"link":"photo_8455492.html","width":130,"caption":"Bexhill-03","height":98});
															thumbnails[8455494] = clik.newPhoto({"id":8455494,"src":"Bexhill_04_thumb.jpg","galleries_id":94339,"server_id":38,"link":"photo_8455494.html","width":130,"caption":"Bexhill-04","height":98});
															thumbnails[8455503] = clik.newPhoto({"id":8455503,"src":"Bexhill_05_thumb.jpg","galleries_id":94339,"server_id":38,"link":"photo_8455503.html","width":130,"caption":"Bexhill-05","height":87});
															thumbnails[8455515] = clik.newPhoto({"id":8455515,"src":"Bexhill_06_thumb.jpg","galleries_id":94339,"server_id":38,"link":"photo_8455515.html","width":130,"caption":"Bexhill-06","height":87});
															thumbnails[8455523] = clik.newPhoto({"id":8455523,"src":"Bexhill_07_thumb.jpg","galleries_id":94339,"server_id":38,"link":"photo_8455523.html","width":130,"caption":"Bexhill-07","height":98});
															thumbnails[8457007] = clik.newPhoto({"id":8457007,"src":"Bexhill_8_thumb.jpg","galleries_id":94339,"server_id":38,"link":"photo_8457007.html","width":130,"caption":"Bexhill-8","height":130});
															thumbnails[8455922] = clik.newPhoto({"id":8455922,"src":"ORIGINAL_IMAGE_-_2009_thumb.jpg","galleries_id":94339,"server_id":38,"link":"photo_8455922.html","width":130,"caption":"ORIGINAL IMAGE - 2009","height":87});
															thumbnails[8455532] = clik.newPhoto({"id":8455532,"src":"Beachhuts_01_thumb.jpg","galleries_id":94339,"server_id":38,"link":"photo_8455532.html","width":130,"caption":"Beachhuts-1","height":87});
															thumbnails[8455538] = clik.newPhoto({"id":8455538,"src":"Beachhuts_02_thumb.jpg","galleries_id":94339,"server_id":38,"link":"photo_8455538.html","width":130,"caption":"Beachhuts-2","height":86});
															thumbnails[8455540] = clik.newPhoto({"id":8455540,"src":"Beachhuts_03_thumb.jpg","galleries_id":94339,"server_id":38,"link":"photo_8455540.html","width":130,"caption":"Beachhuts-3","height":87});
															thumbnails[8457034] = clik.newPhoto({"id":8457034,"src":"Beachhuts_08_thumb.jpg","galleries_id":94339,"server_id":38,"link":"photo_8457034.html","width":130,"caption":"Beachhuts-4","height":43});
															thumbnails[8455610] = clik.newPhoto({"id":8455610,"src":"Beachhuts_05_thumb.jpg","galleries_id":94339,"server_id":38,"link":"photo_8455610.html","width":130,"caption":"Beachhuts-5","height":43});
															thumbnails[8455646] = clik.newPhoto({"id":8455646,"src":"Beachhuts_06_thumb.jpg","galleries_id":94339,"server_id":38,"link":"photo_8455646.html","width":130,"caption":"Beachhuts-6","height":87});
															thumbnails[8455652] = clik.newPhoto({"id":8455652,"src":"Beachhuts_07_thumb.jpg","galleries_id":94339,"server_id":38,"link":"photo_8455652.html","width":130,"caption":"Beachhuts-7","height":87});
															thumbnails[8455583] = clik.newPhoto({"id":8455583,"src":"Beachhuts_04_thumb.jpg","galleries_id":94339,"server_id":38,"link":"photo_8455583.html","width":130,"caption":"Beachhuts-8","height":130});
															thumbnails[8457806] = clik.newPhoto({"id":8457806,"src":"ORIGINAL_IMAGE_-_2010_thumb.JPG","galleries_id":94339,"server_id":38,"link":"photo_8457806.html","width":130,"caption":"ORIGINAL IMAGE - 2010","height":87});
															thumbnails[8456245] = clik.newPhoto({"id":8456245,"src":"Jewelled_Flowers_thumb.jpg","galleries_id":94339,"server_id":38,"link":"photo_8456245.html","width":130,"caption":"by Frank Page LRPS","height":104});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  						galleries[94339] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Image Variations by Members","link":"section127459.html","maxRecords":0.0,"photoIDs":[1342732.0,8457000.0,1384195.0,1434926.0,1363471.0,1443159.0,1620502.0,1480886.0,1480991.0,8455467.0,8455476.0,8455480.0,8455492.0,8455494.0,8455503.0,8455515.0,8455523.0,8457007.0,8455922.0,8455532.0,8455538.0,8455540.0,8457034.0,8455610.0,8455646.0,8455652.0,8455583.0,8457806.0,8456245.0],"skipIndex":0,"section_code":"section127459","featured_images":"8456245,8455652,8455646,8455538,8455532,8455523,8455494,8455492,1443159,1384195,1363471,1342732","id":94339,"singleSection":true});				  						galleries[94155] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"MEMBERS WORK - 1","link":"gallery_94155.html","maxRecords":0.0,"photoIDs":[8631923.0,8631931.0,8631935.0,8632004.0,8632069.0,8452664.0,8452693.0,1342351.0,1342532.0,1342725.0,1343078.0,1343228.0,1343234.0,1343239.0,1343243.0,1357011.0,1357017.0,1357020.0,1363458.0,1363465.0,1384205.0,1384210.0,1632363.0,1632365.0,4446147.0,4446150.0,4541210.0,8457066.0],"skipIndex":0,"section_code":"gallery","featured_images":"8452693,8452664,1342351","id":94155,"singleSection":false});				  						galleries[95403] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"MEMBERS WORK - 2","link":"gallery_95403.html","maxRecords":0.0,"photoIDs":[8631941.0,1357015.0,4446138.0,4446141.0,4446142.0,4446146.0,8452702.0,8457049.0,8457061.0,8457070.0],"skipIndex":0,"section_code":"gallery","featured_images":"8457070,8457061,8457049","id":95403,"singleSection":false});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[1] = '8457049,8452693,8452664,1632365,1632363,1384210,1384205,1363465,1363458,1357020,1357017,1357015,1357011,1343243,1343239,1343228,1343078,1342725,1342532,1342351,8455492,8455523,8455646,8456245';
imageSets[2] = '8457070,8457061,8457049,8452693,8452664,1342351,1342732,1384195,1363471,1443159,8455492,8455494,8455523,8455532,8455538,8455646,8455652,8456245';
imageSets[3] = '8632069,8632004,8631941,8631935,8631931,8631923,8457806,8457070,8457066,8457061,8457049,8457034,8457007,8457000,8456245,8455922,8455652,8455646,8455610,8455583,8455540,8455538,8455532,8455523,8455515,8455503,8455494,8455492,8455480,8455476,8455467,8452702,8452693,8452664,4541210,4446150,4446147,4446146,4446142,4446141,4446138,1632365,1632363,1620502,1573618,1480991,1480886,1443159,1434926,1384210';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 51:
		val = 'www12.clikpic.com/Frankkdpg/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/Frankkdpg/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/Frankkdpg/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/Frankkdpg/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/Frankkdpg/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/Frankkdpg/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/Frankkdpg/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/Frankkdpg/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/Frankkdpg/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/Frankkdpg/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/Frankkdpg/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/Frankkdpg/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/Frankkdpg/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/Frankkdpg/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/Frankkdpg/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/Frankkdpg/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/Frankkdpg/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/Frankkdpg/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/Frankkdpg/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/Frankkdpg/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/Frankkdpg/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/Frankkdpg/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/Frankkdpg/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/Frankkdpg/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 = 'Kent Digital Photographers Group: ' + 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.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="updateItemValues($(this.form).next(\'#paymentForm\')[0],this.form.payment_options_id.options[this.form.payment_options_id.options.selectedIndex].value);">';
		
		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 += '<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;
	}
}

			

