window.thumbnails = {};
															thumbnails[9088885] = clik.newPhoto({"id":9088885,"src":"wedding_clik_1_thumb.jpg","galleries_id":228012,"server_id":1,"link":"photo_9088885.html","width":260,"caption":"A sparkling wedding  shot","height":390});
															thumbnails[9096537] = clik.newPhoto({"id":9096537,"src":"Kiana_clik2_1_thumb.jpg","galleries_id":286104,"server_id":1,"link":"photo_9096537.html","width":260,"caption":"Kiana","height":246});
															thumbnails[9101204] = clik.newPhoto({"id":9101204,"src":"Adam_and_Claire_clik_1_thumb.jpg","galleries_id":228012,"server_id":1,"link":"photo_9101204.html","width":260,"caption":"Adam and Claire","height":260});
															thumbnails[9103923] = clik.newPhoto({"id":9103923,"src":"Otto_-_Judo_Star_1_thumb.jpg","galleries_id":286104,"server_id":1,"link":"photo_9103923.html","width":260,"caption":"Junior Judo star","height":327});
															thumbnails[5056224] = clik.newPhoto({"id":5056224,"src":"Pete_and_Claudine1_065lo_res1_thumb.jpg","galleries_id":286104,"server_id":1,"link":"photo_5056224.html","width":130,"caption":"A relaxed family shoot in the garden","height":87});
															thumbnails[8931768] = clik.newPhoto({"id":8931768,"src":"_MG_0337_4164_thumb.jpg","galleries_id":286104,"server_id":1,"link":"photo_8931768.html","width":130,"caption":"Bridie and Rob in the studio","height":130});
															thumbnails[8931861] = clik.newPhoto({"id":8931861,"src":"_MG_9528_disc_thumb.jpg","galleries_id":286104,"server_id":1,"link":"photo_8931861.html","width":130,"caption":"Molly ","height":182});
															thumbnails[8932630] = clik.newPhoto({"id":8932630,"src":"James-033_thumb.jpg","galleries_id":247376,"server_id":1,"link":"photo_8932630.html","width":130,"caption":"","height":91});
															thumbnails[8932701] = clik.newPhoto({"id":8932701,"src":"James-3418_thumb.jpg","galleries_id":247376,"server_id":1,"link":"photo_8932701.html","width":130,"caption":"","height":87});
															thumbnails[9088922] = clik.newPhoto({"id":9088922,"src":"wedding_vows_clik_1_thumb.jpg","galleries_id":228012,"server_id":1,"link":"photo_9088922.html","width":260,"caption":"","height":183});
															thumbnails[9088969] = clik.newPhoto({"id":9088969,"src":"Lady_Helen_Nall-1_1_thumb.jpg","galleries_id":247376,"server_id":1,"link":"photo_9088969.html","width":260,"caption":"Lady Helen Nall - author","height":390});
															thumbnails[5056392] = clik.newPhoto({"id":5056392,"src":"PeteClaudine3_056lo_res_thumb.jpg","galleries_id":480401,"server_id":1,"link":"photo_5056392.html","width":130,"caption":"","height":87});
															thumbnails[8931808] = clik.newPhoto({"id":8931808,"src":"Kiana_5685_edited_PB_thumb.jpg","galleries_id":286104,"server_id":1,"link":"photo_8931808.html","width":130,"caption":"Studio shoots can be funny!","height":81});
															thumbnails[8931966] = clik.newPhoto({"id":8931966,"src":"BG-200-11_thumb_312B78CC-1EC9-DFB6-09760A8379F038B8.jpg","galleries_id":228012,"server_id":1,"link":"photo_8931966.html","width":130,"caption":"","height":87});
															thumbnails[8933527] = clik.newPhoto({"id":8933527,"src":"Ruth_and_Michael_Hudson_262_a_mono_thumb.jpg","galleries_id":228012,"server_id":1,"link":"photo_8933527.html","width":150,"caption":"","height":100});
															thumbnails[9088896] = clik.newPhoto({"id":9088896,"src":"Tracey_and_Sabrina_clik_1_thumb.jpg","galleries_id":286104,"server_id":1,"link":"photo_9088896.html","width":260,"caption":"Tracey and Sabrina","height":173});
															thumbnails[9088899] = clik.newPhoto({"id":9088899,"src":"Sarah_clik_1_thumb.jpg","galleries_id":247376,"server_id":1,"link":"photo_9088899.html","width":260,"caption":"","height":390});
															thumbnails[9088901] = clik.newPhoto({"id":9088901,"src":"Kaylee_clik_1_thumb.jpg","galleries_id":247376,"server_id":1,"link":"photo_9088901.html","width":260,"caption":"","height":390});
															thumbnails[9088928] = clik.newPhoto({"id":9088928,"src":"wedding_joy_clik_1_thumb.jpg","galleries_id":228012,"server_id":1,"link":"photo_9088928.html","width":260,"caption":"","height":178});
															thumbnails[9089308] = clik.newPhoto({"id":9089308,"src":"Molly_and_Billy-1-2_1_thumb.jpg","galleries_id":286104,"server_id":1,"link":"photo_9089308.html","width":260,"caption":"Sister and Brother","height":260});
															thumbnails[8931857] = clik.newPhoto({"id":8931857,"src":"print-3504_fb_thumb.jpg","galleries_id":286104,"server_id":1,"link":"photo_8931857.html","width":130,"caption":"","height":87});
															thumbnails[8931887] = clik.newPhoto({"id":8931887,"src":"_MG_9602_disc_thumb.jpg","galleries_id":286104,"server_id":1,"link":"photo_8931887.html","width":130,"caption":"","height":182});
															thumbnails[9088869] = clik.newPhoto({"id":9088869,"src":"Annette_and_girls_clik_1_thumb.jpg","galleries_id":286104,"server_id":1,"link":"photo_9088869.html","width":260,"caption":"","height":260});
															thumbnails[9088931] = clik.newPhoto({"id":9088931,"src":"mono_wedding_1_thumb.jpg","galleries_id":228012,"server_id":1,"link":"photo_9088931.html","width":260,"caption":"","height":173});
															thumbnails[9096535] = clik.newPhoto({"id":9096535,"src":"Kiana_clik_1_thumb.jpg","galleries_id":286104,"server_id":1,"link":"photo_9096535.html","width":260,"caption":"Kiana","height":390});
															thumbnails[8931864] = clik.newPhoto({"id":8931864,"src":"_MG_9465_disc_thumb.jpg","galleries_id":286104,"server_id":1,"link":"photo_8931864.html","width":130,"caption":"","height":130});
															thumbnails[8933239] = clik.newPhoto({"id":8933239,"src":"_MG_0079_thumb.JPG","galleries_id":286104,"server_id":1,"link":"photo_8933239.html","width":150,"caption":"","height":100});
															thumbnails[9088877] = clik.newPhoto({"id":9088877,"src":"Elegant_lady_clik_1_thumb.jpg","galleries_id":247376,"server_id":1,"link":"photo_9088877.html","width":260,"caption":"An elegant older lady","height":350});
															thumbnails[9088884] = clik.newPhoto({"id":9088884,"src":"Leo_and_Christina_Gallo_1_thumb.jpg","galleries_id":286104,"server_id":1,"link":"photo_9088884.html","width":260,"caption":"Baby Leo and mum Christina","height":364});
															thumbnails[5056398] = clik.newPhoto({"id":5056398,"src":"Amber_lores_thumb.jpg","galleries_id":286104,"server_id":1,"link":"photo_5056398.html","width":130,"caption":"","height":165});
															thumbnails[9089314] = clik.newPhoto({"id":9089314,"src":"MollyMattie_and_Billy-1_1_thumb.jpg","galleries_id":286104,"server_id":1,"link":"photo_9089314.html","width":260,"caption":"Mollie,Mattie and Billy","height":173});
															thumbnails[9101196] = clik.newPhoto({"id":9101196,"src":"Serene_bride_clik_1_thumb.jpg","galleries_id":228012,"server_id":1,"link":"photo_9101196.html","width":260,"caption":"Serene Bride","height":173});
															thumbnails[9101482] = clik.newPhoto({"id":9101482,"src":"A_stylish_guest_1_thumb.jpg","galleries_id":228012,"server_id":1,"link":"photo_9101482.html","width":260,"caption":"A stylish guest","height":390});
															thumbnails[5056082] = clik.newPhoto({"id":5056082,"src":"PeteClaudine2_106_mono_lo_res_thumb.jpg","galleries_id":286104,"server_id":1,"link":"photo_5056082.html","width":130,"caption":"","height":87});
															thumbnails[5056400] = clik.newPhoto({"id":5056400,"src":"Freddie_lores_thumb.jpg","galleries_id":286104,"server_id":1,"link":"photo_5056400.html","width":130,"caption":"","height":195});
															thumbnails[7048663] = clik.newPhoto({"id":7048663,"src":"Dipesh_and_Bavini2_2861_clikpix_thumb.jpg","galleries_id":247376,"server_id":1,"link":"photo_7048663.html","width":130,"caption":"","height":195});
															thumbnails[4151497] = clik.newPhoto({"id":4151497,"src":"Bernie_Keith_Show_lo_res_thumb.jpg","galleries_id":247376,"server_id":1,"link":"photo_4151497.html","width":130,"caption":"BBC Radio Northampton presenter,Bernie Keith on the morning show at work in the studio","height":195});
															thumbnails[9098823] = clik.newPhoto({"id":9098823,"src":"Wedding_promise_clik_1_thumb.jpg","galleries_id":228012,"server_id":1,"link":"photo_9098823.html","width":260,"caption":"Wedding promises ","height":158});
															thumbnails[9103126] = clik.newPhoto({"id":9103126,"src":"Gabriella_Cilmi_Rock_Chick_1_thumb.jpg","galleries_id":247376,"server_id":1,"link":"photo_9103126.html","width":260,"caption":"Gabriella Cilmi Rock Chick!","height":390});
															thumbnails[9103425] = clik.newPhoto({"id":9103425,"src":"Andrea_Jung_-_Avon_Cosmetics_CEO_1_thumb.jpg","galleries_id":247376,"server_id":1,"link":"photo_9103425.html","width":260,"caption":" Avon Cosmetics CEO","height":173});
															thumbnails[7048602] = clik.newPhoto({"id":7048602,"src":"Dipesh_and_Bavini2_2747_clikpix_thumb.jpg","galleries_id":247376,"server_id":1,"link":"photo_7048602.html","width":130,"caption":"","height":195});
															thumbnails[9108062] = clik.newPhoto({"id":9108062,"src":"Suzanne_Dando_1_thumb.jpg","galleries_id":247376,"server_id":1,"link":"photo_9108062.html","width":260,"caption":"Olympic medal winner Suzanne Dando for the Lymphoma Association","height":348});
															thumbnails[9108065] = clik.newPhoto({"id":9108065,"src":"CA_Fair_70_thumb.jpg","galleries_id":247376,"server_id":1,"link":"photo_9108065.html","width":260,"caption":"The Marquess of Northampton at Castle Ashby","height":390});
															thumbnails[4170763] = clik.newPhoto({"id":4170763,"src":"Poppy_Engagement2_clikpic_thumb.jpg","galleries_id":228012,"server_id":1,"link":"photo_4170763.html","width":130,"caption":"R romantic venue for an engagement shoot","height":87});
															thumbnails[7048482] = clik.newPhoto({"id":7048482,"src":"Dipesh_and_Bavini2_2729_clikpix_thumb.jpg","galleries_id":247376,"server_id":1,"link":"photo_7048482.html","width":130,"caption":"","height":167});
															thumbnails[9088898] = clik.newPhoto({"id":9088898,"src":"Gail__clik_1_thumb.jpg","galleries_id":247376,"server_id":1,"link":"photo_9088898.html","width":260,"caption":"","height":173});
															thumbnails[9101483] = clik.newPhoto({"id":9101483,"src":"Almost_Ready..._1_thumb.jpg","galleries_id":228012,"server_id":1,"link":"photo_9101483.html","width":260,"caption":"Almost Ready...","height":247});
															thumbnails[9101485] = clik.newPhoto({"id":9101485,"src":"Button__clik_1_thumb.jpg","galleries_id":228012,"server_id":1,"link":"photo_9101485.html","width":260,"caption":"A quiet moment...","height":274});
															thumbnails[9098824] = clik.newPhoto({"id":9098824,"src":"Bridal_Party_clik_1_thumb.jpg","galleries_id":228012,"server_id":1,"link":"photo_9098824.html","width":260,"caption":"Classic Bridal Party ","height":173});
															thumbnails[9103127] = clik.newPhoto({"id":9103127,"src":"Jackie_1_thumb.jpg","galleries_id":247376,"server_id":1,"link":"photo_9103127.html","width":260,"caption":"Jackie","height":390});
															thumbnails[9103171] = clik.newPhoto({"id":9103171,"src":"Chocolate_Labs_1_thumb.jpg","galleries_id":480401,"server_id":1,"link":"photo_9103171.html","width":260,"caption":"Chocolate Labs","height":260});
															thumbnails[9103426] = clik.newPhoto({"id":9103426,"src":"Avon_Lady_-_Andrea_JungAvon_Cosmetics_CEO_1_thumb.jpg","galleries_id":247376,"server_id":1,"link":"photo_9103426.html","width":260,"caption":" Andrea Jung,Avon Cosmetics CEO","height":190});
															thumbnails[9101484] = clik.newPhoto({"id":9101484,"src":"Bridesmaids_1_thumb.jpg","galleries_id":228012,"server_id":1,"link":"photo_9101484.html","width":260,"caption":"Bridesmaids","height":184});
															thumbnails[9103130] = clik.newPhoto({"id":9103130,"src":"Jackie_and_Kaylee_1_thumb.jpg","galleries_id":247376,"server_id":1,"link":"photo_9103130.html","width":260,"caption":"Jackie and Kaylee","height":173});
															thumbnails[9103172] = clik.newPhoto({"id":9103172,"src":"Rodney_1_thumb.jpg","galleries_id":480401,"server_id":1,"link":"photo_9103172.html","width":260,"caption":"Rodney","height":332});
															thumbnails[9103437] = clik.newPhoto({"id":9103437,"src":"Fashionable_Teen_1_thumb.jpg","galleries_id":286104,"server_id":1,"link":"photo_9103437.html","width":260,"caption":"Fashionable Teen!","height":260});
															thumbnails[9098827] = clik.newPhoto({"id":9098827,"src":"Greg_and_Susi_clik_1_thumb.jpg","galleries_id":228012,"server_id":1,"link":"photo_9098827.html","width":260,"caption":"Greg and Susi ","height":299});
															thumbnails[9103131] = clik.newPhoto({"id":9103131,"src":"John_Griff_1_thumb.jpg","galleries_id":247376,"server_id":1,"link":"photo_9103131.html","width":260,"caption":"John Griff","height":390});
															thumbnails[9103173] = clik.newPhoto({"id":9103173,"src":"Lily_1_thumb.jpg","galleries_id":480401,"server_id":1,"link":"photo_9103173.html","width":260,"caption":"Lily","height":173});
															thumbnails[9103438] = clik.newPhoto({"id":9103438,"src":"Game_Boy_1_thumb.jpg","galleries_id":286104,"server_id":1,"link":"photo_9103438.html","width":260,"caption":"Game Boy","height":260});
															thumbnails[8932721] = clik.newPhoto({"id":8932721,"src":"Gail__3713_thumb.jpg","galleries_id":247376,"server_id":1,"link":"photo_8932721.html","width":150,"caption":"","height":103});
															thumbnails[9101486] = clik.newPhoto({"id":9101486,"src":"First_Dance_1_thumb.jpg","galleries_id":228012,"server_id":1,"link":"photo_9101486.html","width":260,"caption":"First Dance","height":390});
															thumbnails[9098829] = clik.newPhoto({"id":9098829,"src":"Signing_the_Register_clik_1_thumb.jpg","galleries_id":228012,"server_id":1,"link":"photo_9098829.html","width":260,"caption":"Signing the Register ","height":197});
															thumbnails[9103174] = clik.newPhoto({"id":9103174,"src":"Lily_the_Lab_1_thumb.jpg","galleries_id":480401,"server_id":1,"link":"photo_9103174.html","width":260,"caption":"Lily the Lab","height":260});
															thumbnails[9101487] = clik.newPhoto({"id":9101487,"src":"Mother_of_the_Groom..._1_thumb.jpg","galleries_id":228012,"server_id":1,"link":"photo_9101487.html","width":260,"caption":"Mother of the Groom...","height":355});
															thumbnails[9098830] = clik.newPhoto({"id":9098830,"src":"The_Kiss_clik_1_thumb.jpg","galleries_id":228012,"server_id":1,"link":"photo_9098830.html","width":260,"caption":"The Kiss ","height":173});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  							galleries[286104] = clik.newGallery({"parentGallery":"","usePopups":true,"title":"Kids and families","link":"gallery.html#galleries_id=286104","maxRecords":0.0,"photoIDs":[9096537.0,9103923.0,5056224.0,8931768.0,8931861.0,8931808.0,9088896.0,9089308.0,8931857.0,8931887.0,9088869.0,9096535.0,8931864.0,8933239.0,9088884.0,5056398.0,9089314.0,5056082.0,5056400.0,9103437.0,9103438.0],"skipIndex":true,"section_code":"gallery","featured_images":"9096537,9088896","id":286104,"singleSection":false});				  							galleries[228012] = clik.newGallery({"parentGallery":"","usePopups":true,"title":"Wedding Photography","link":"gallery.html#galleries_id=228012","maxRecords":0.0,"photoIDs":[9088885.0,9101204.0,9088922.0,8931966.0,8933527.0,9088928.0,9088931.0,9101196.0,9101482.0,9098823.0,4170763.0,9101483.0,9101485.0,9098824.0,9101484.0,9098827.0,9101486.0,9098829.0,9101487.0,9098830.0],"skipIndex":true,"section_code":"gallery","featured_images":9088928.0,"id":228012,"singleSection":false});				  							galleries[247376] = clik.newGallery({"parentGallery":"","usePopups":true,"title":"Portraiture and People","link":"gallery.html#galleries_id=247376","maxRecords":0.0,"photoIDs":[8932630.0,8932701.0,9088969.0,9088899.0,9088901.0,9088877.0,7048663.0,4151497.0,9103126.0,9103425.0,7048602.0,9108062.0,9108065.0,7048482.0,9088898.0,9103127.0,9103426.0,9103130.0,9103131.0,8932721.0],"skipIndex":true,"section_code":"gallery","featured_images":"9108065,9108062,9103426,9103425,9103131,9103130,9103127,9103126,9088969,9088901","id":247376,"singleSection":false});				  							galleries[480401] = clik.newGallery({"parentGallery":"","usePopups":true,"title":"Pets","link":"gallery.html#galleries_id=480401","maxRecords":0.0,"photoIDs":[5056392.0,9103171.0,9103172.0,9103173.0,9103174.0],"skipIndex":true,"section_code":"gallery","featured_images":"9103174,9103173,9103172,9103171,5056392","id":480401,"singleSection":false});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[1] = '9103923,9096537,8931861,5056224,9089308,9088928,9088896,8931808,5056392,8933239,9103425,9108062,9108065,9101485,9088898,4170763,9103426,9103437,9098829';
imageSets[2] = '9096537,9088928,9088896';
imageSets[3] = '9108065,9108062,9103923,9103438,9103437,9103426,9103425,9103174,9103173,9103172,9103171,9103131,9103130,9103127,9103126,9101487,9101486,9101485,9101484,9101483,9101482,9101204,9101196,9098830,9098829,9098827,9098824,9098823,9096537,9096535,9089314,9089308,9088969,9088931,9088928,9088922,9088901,9088899,9088898,9088896,9088885,9088884,9088877,9088869,8933527,8933239,8932721,8932701,8932630,8931966';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 51:
		val = 'http://www12.clikpic.com/Heantun/images';
		break;
	}
		switch (server_id) {
		case 0:
		val = 'http://www.clikpic.com/Heantun/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/Heantun/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/Heantun/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/Heantun/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/Heantun/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/Heantun/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/Heantun/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/Heantun/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/Heantun/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/Heantun/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/Heantun/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/Heantun/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/Heantun/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/Heantun/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/Heantun/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/Heantun/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/Heantun/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/Heantun/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/Heantun/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/Heantun/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/Heantun/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/Heantun/images';
		break;
	}
		switch (server_id) {
		case 53:
		val = 'http://images.clikpic.com/Heantun/images';
		break;
	}
		switch (server_id) {
		case 52:
		val = 'http://tpc22/clikpic/Heantun/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/Heantun/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/Heantun/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 = 'BOB CADDICK -\nPORTRAIT PHOTOGRAPHER\n07920 133159: ' + photoCaption;
			    }
        if (op.$detail.length > 0) {
      	temp = op.nextPhoto.fnGetImageDetails();
	    op.$detail.fadeGalleryDetails(temp, op.speed, function(){
			if (typeof(backgrounds) != 'undefined' && op.nextPhoto == backgrounds[op.nextPhoto.id]) {
				toggleAddToCartConfirm(backgrounds, op.$detail);
			} else if (typeof(photos) != 'undefined' && op.nextPhoto == photos[op.nextPhoto.id]) {
				toggleAddToCartConfirm(photos, op.$detail);
			}
			$('body').trigger('clikUpdate.popup');
	    });
    }
        $(op.$detailContainer).find('.replaceable[class*=replaceable_photo-]').each(function(){
    	var field = clik.getPrefixedClass(this.className, 'replaceable_photo-');
    	if (field in op.nextPhoto) {
    		$(this).fadeGalleryDetails(op.nextPhoto[field], op.speed);
    	}
    }).end().find('.replaceable.photoPayment').fadeGalleryDetails(op.nextPhoto.fnGetPaymentInfo(), op.speed, function(){
		if (typeof(backgrounds) != 'undefined' && op.nextPhoto == backgrounds[op.nextPhoto.id]) {
			toggleAddToCartConfirm(backgrounds, op.$detailContainer);
		} else if (typeof(photos) != 'undefined' && op.nextPhoto == photos[op.nextPhoto.id]) {
			toggleAddToCartConfirm(photos, op.$detailContainer);
		}
		$('body').trigger('clikUpdate.popup');
	});
		if (op.$photo.length > 0) {
		html = $('<img/>',{
			'class': 'mainphoto photo',
			src: photoSrc,
			id: 'mainPic',
			name: 'mainPic',
			width: op.nextPhoto.width,
			height: op.nextPhoto.height,
			alt: photoCaption,
			css: op.css || {}
		});
		if (op.href) {
			if (op.href.match(/<a/)) {
				html = $(op.href).append(html);
			} else {
				html = $('<a/>', {
					href: op.href,
					title: photoCaption
				}).append(html);
			}
		} else {
			html = $('<a/>', {
				title: photoCaption
			}).append(html);
		}
		if (op.speed == 0) {			op.$photo.html(html);			if (op.onBefore) {			  	op.onBefore.apply(op.$photo);			}			if (op.onAfter) {			  	op.onAfter.apply(op.$photo);			}		} else {			op.$photo.stop(true,true).fadeReplaceWith(html,op.speed,'',function(){  				if (op.onAfter) {				  	op.onAfter.apply(this);				}				clik.doColumnResize(false, $(this).add(op.$detail).add(op.$title));			}, op.onBefore);
		}	}
    if (op.field) {
		op.field.value = photoId;
	} else {
		op.$photo.data('image_id', photoId);
    }
        if (!op.speed) {
      	clik.doColumnResize(false, op.$photo.add(op.$detail).add(op.$title));
    }
        
    return html;
	}

/***************************************************************************
* Toggle add to cart confirmation element and set up the click event for   *
* the 'Add to cart' button.                                                *
***************************************************************************/
function toggleAddToCartConfirm(array, root){
	if (typeof(array) !== 'object' || array === null) {
	  	array = photos;
	}
	if (!$(root).length) {		root = $('body');	}	if($('#paymentConfirm', root).length > 0){
		$('#paymentConfirm', root).hide();
		$('#paymentAddButton', root)
		.unbind()
		.click(function(){
						form = $('#paymentForm', root)[0];
			option_id = 0;
			if(form.item_option.value){
				option_id = form.item_option.value;
			}
			if(addItemToBasket(form.item_number.value,array,form.site.value,parseInt(form.quantity.value, 10),option_id)){
				if($.browser.msie){$('#paymentConfirm', root).text('Item added to cart').show();}
				else{
					$('#paymentConfirm', root).text('Item added to cart').fadeIn();
					dspOrderDetails(form.site.value);
				}
			}
			else{
				$('#paymentConfirm', root).text('Item not added - check cookies are enabled in your browser.').fadeIn();
			}
		});
	}
}

/***************************************************************************
* Get payment info for image - add as 'method' to photo object             *
***************************************************************************/
clik.photo.fnGetImageDetails = function(){
	var temp = '';
	if (this.description != '') {
		temp +=  '<div id="imageDescription">' + this.description + '</div>';
	}
		if (this.photo_ref != '') {
		temp += '<div class="imageinfo" id="imageRef"><strong>Ref: </strong>' + this.photo_ref + '</div>';
	}
		if (this.takendate != '') {
		
		temp += '<div class="imageinfo" id="imageDate"><strong>Date: </strong>' + this.takendate + '</div>';
	}
	
	if (this.location != '') {
		
		temp += '<div class="imageinfo" id="imageLocation"><strong>Location: </strong>' +  this.location + '</div>';
	}
	
	if (this.photographer != '') {
		
		temp += '<div class="imageinfo" id="imagePhotographer"><strong>Photographer: </strong>' + this.photographer + '</div>';
	}
				
	temp += this.fnGetPaymentInfo();
				if (temp != '') {
		temp += '<div class="spacer"></div>';
	}
	return temp;
};

/***************************************************************************
* Get payment info for image - add as 'method' to photo object             *
***************************************************************************/
clik.photo.fnGetPaymentInfo = function(){
	var temp = '';
	if (this.item_price !== '') {
																		temp += '<p>Buy now using PayPal:</p>';
				temp += '<div class="imageinfo" id="imagePrice"><strong>' + this.purchase_instruction + '</strong> &pound;' + (this.item_price).toFixed(2) + '</div>';
		var item_name  = this.purchase_instruction;
		var amount = (this.item_price).toFixed(2);
		var item_option  = 0;
	}
		else if (this.payment_groups_id !== '') {
		temp += '<p>Buy this print online:</p>';
				temp += '<form id="paymentOptions" style="margin:0px;border:0px;" name="paymentOptions">';
											temp += '<select class="paymentlink" name="payment_options_id" onchange="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 += '<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="bob.caddick1@btinternet.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="bob.caddick1@btinternet.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;
	}
}

			

