window.thumbnails = {};
															thumbnails[1949303] = clik.newPhoto({"id":1949303,"src":"winter fields 1_thumb.JPG","galleries_id":130446,"server_id":15,"link":"photo_1949303.html","width":130,"caption":"Winter Fields 1, SOLD","height":89});
															thumbnails[1949304] = clik.newPhoto({"id":1949304,"src":"winter fields 2_thumb.JPG","galleries_id":130446,"server_id":15,"link":"photo_1949304.html","width":130,"caption":"Winter Fields 2, SOLD","height":90});
															thumbnails[1949305] = clik.newPhoto({"id":1949305,"src":"winter fields 3_thumb.JPG","galleries_id":130446,"server_id":15,"link":"photo_1949305.html","width":130,"caption":"Winter Fields 3, SOLD","height":91});
															thumbnails[1949306] = clik.newPhoto({"id":1949306,"src":"winter fields 4_thumb.JPG","galleries_id":130446,"server_id":15,"link":"photo_1949306.html","width":130,"caption":"Winter Fields 4, SOLD","height":89});
															thumbnails[1949307] = clik.newPhoto({"id":1949307,"src":"winter fields 5_thumb.JPG","galleries_id":130446,"server_id":15,"link":"photo_1949307.html","width":130,"caption":"Winter Fields 5, SOLD","height":89});
															thumbnails[1949308] = clik.newPhoto({"id":1949308,"src":"winter fields 6_thumb.JPG","galleries_id":130446,"server_id":15,"link":"photo_1949308.html","width":130,"caption":"Winter Fields 6, SOLD","height":90});
															thumbnails[1949311] = clik.newPhoto({"id":1949311,"src":"archive 11_thumb.jpg","galleries_id":130446,"server_id":15,"link":"photo_1949311.html","width":130,"caption":"Helford Passage, £360","height":98});
															thumbnails[1949313] = clik.newPhoto({"id":1949313,"src":"over the fields, maypole green_thumb.jpg","galleries_id":130446,"server_id":15,"link":"photo_1949313.html","width":130,"caption":"Over The Fields, Maypole Green, SOLD","height":96});
															thumbnails[1949314] = clik.newPhoto({"id":1949314,"src":"archive 9_thumb.jpg","galleries_id":130446,"server_id":15,"link":"photo_1949314.html","width":130,"caption":"Archive 9, SOLD","height":83});
															thumbnails[1949315] = clik.newPhoto({"id":1949315,"src":"archive 8_thumb.jpg","galleries_id":130446,"server_id":15,"link":"photo_1949315.html","width":130,"caption":"Archive 8, SOLD","height":89});
															thumbnails[1949316] = clik.newPhoto({"id":1949316,"src":"archive 7_thumb.jpg","galleries_id":130446,"server_id":15,"link":"photo_1949316.html","width":130,"caption":"Archive 7, SOLD","height":88});
															thumbnails[1949317] = clik.newPhoto({"id":1949317,"src":"archive 1_thumb.jpg","galleries_id":130446,"server_id":15,"link":"photo_1949317.html","width":130,"caption":"Across The Spinney II, £240","height":99});
															thumbnails[1949318] = clik.newPhoto({"id":1949318,"src":"archive 2_thumb.jpg","galleries_id":130446,"server_id":15,"link":"photo_1949318.html","width":130,"caption":"Archive 2, SOLD","height":100});
															thumbnails[1949319] = clik.newPhoto({"id":1949319,"src":"archive 3_thumb.jpg","galleries_id":130446,"server_id":15,"link":"photo_1949319.html","width":130,"caption":"Archive 3, SOLD","height":98});
															thumbnails[1949320] = clik.newPhoto({"id":1949320,"src":"archive 4_thumb.jpg","galleries_id":130446,"server_id":15,"link":"photo_1949320.html","width":130,"caption":"Archive 4, SOLD","height":98});
															thumbnails[1949321] = clik.newPhoto({"id":1949321,"src":"archive 5_thumb.jpg","galleries_id":130446,"server_id":15,"link":"photo_1949321.html","width":130,"caption":"Archive 5, SOLD","height":97});
															thumbnails[1949322] = clik.newPhoto({"id":1949322,"src":"archive 6_thumb.jpg","galleries_id":130446,"server_id":15,"link":"photo_1949322.html","width":130,"caption":"Archive 6, SOLD","height":88});
															thumbnails[1949323] = clik.newPhoto({"id":1949323,"src":"archive 10_thumb.jpg","galleries_id":130446,"server_id":15,"link":"photo_1949323.html","width":130,"caption":"Fold, Fallow and Plough, SOLD","height":92});
															thumbnails[1949325] = clik.newPhoto({"id":1949325,"src":"archive 12_thumb.jpg","galleries_id":130446,"server_id":15,"link":"photo_1949325.html","width":130,"caption":"Archive 11, SOLD","height":94});
															thumbnails[1950372] = clik.newPhoto({"id":1950372,"src":"POB 1_thumb.jpg","galleries_id":130600,"server_id":15,"link":"photo_1950372.html","width":130,"caption":"Spring Landscape 1, £320","height":88});
															thumbnails[1950373] = clik.newPhoto({"id":1950373,"src":"POB 2_thumb.jpg","galleries_id":130600,"server_id":15,"link":"photo_1950373.html","width":130,"caption":"Spring Landscape 2, £320","height":87});
															thumbnails[1950376] = clik.newPhoto({"id":1950376,"src":"POB 3_thumb.jpg","galleries_id":130600,"server_id":15,"link":"photo_1950376.html","width":130,"caption":"Spring Landscape 3, £320","height":88});
															thumbnails[1950378] = clik.newPhoto({"id":1950378,"src":"POB 4_thumb.jpg","galleries_id":130600,"server_id":15,"link":"photo_1950378.html","width":130,"caption":"Spring Landscape 4, £320","height":87});
															thumbnails[1950380] = clik.newPhoto({"id":1950380,"src":"POB 5_thumb.jpg","galleries_id":130600,"server_id":15,"link":"photo_1950380.html","width":130,"caption":"Marsh Rain 5, £240","height":130});
															thumbnails[1950381] = clik.newPhoto({"id":1950381,"src":"POB 6_thumb.jpg","galleries_id":130600,"server_id":15,"link":"photo_1950381.html","width":130,"caption":"Marsh Rain 6, £240","height":131});
															thumbnails[1950384] = clik.newPhoto({"id":1950384,"src":"POB 7_thumb.jpg","galleries_id":130600,"server_id":15,"link":"photo_1950384.html","width":130,"caption":"Marsh Rain 7, £240","height":131});
															thumbnails[1950387] = clik.newPhoto({"id":1950387,"src":"POB 9_thumb.jpg","galleries_id":130600,"server_id":15,"link":"photo_1950387.html","width":130,"caption":"Marsh Rain 9, £240","height":130});
															thumbnails[1950391] = clik.newPhoto({"id":1950391,"src":"POB 10_thumb.jpg","galleries_id":130600,"server_id":15,"link":"photo_1950391.html","width":130,"caption":"Norton Marshes 10, £240","height":131});
															thumbnails[1950393] = clik.newPhoto({"id":1950393,"src":"POB 12_thumb.jpg","galleries_id":130600,"server_id":15,"link":"photo_1950393.html","width":130,"caption":"Norton Marshes 12, £240","height":133});
															thumbnails[1950394] = clik.newPhoto({"id":1950394,"src":"POB 13_thumb.jpg","galleries_id":130600,"server_id":15,"link":"photo_1950394.html","width":130,"caption":"Norton Marshes 13, £240","height":134});
															thumbnails[1950395] = clik.newPhoto({"id":1950395,"src":"POB 11_thumb.jpg","galleries_id":130600,"server_id":15,"link":"photo_1950395.html","width":130,"caption":"Norton Marshes 11, £240","height":132});
															thumbnails[3342161] = clik.newPhoto({"id":3342161,"src":"Marsh Hut_thumb.jpg","galleries_id":203883,"server_id":15,"link":"photo_3342161.html","width":130,"caption":"Marsh Hut, SOLD","height":132});
															thumbnails[5653422] = clik.newPhoto({"id":5653422,"src":"bramble_small1_thumb.JPG","galleries_id":203883,"server_id":15,"link":"photo_5653422.html","width":130,"caption":"Bramble, SOLD","height":132});
															thumbnails[5653427] = clik.newPhoto({"id":5653427,"src":"small_marsh_hut_small_thumb.JPG","galleries_id":203883,"server_id":15,"link":"photo_5653427.html","width":130,"caption":"Small Marsh Hut","height":131});
															thumbnails[5653430] = clik.newPhoto({"id":5653430,"src":"southwold_hut_small_thumb.JPG","galleries_id":203883,"server_id":15,"link":"photo_5653430.html","width":130,"caption":"Southwold Hut","height":133});
															thumbnails[6428300] = clik.newPhoto({"id":6428300,"src":"tolworth_thumb.jpg","galleries_id":301285,"server_id":15,"link":"photo_6428300.html","width":130,"caption":"Artwork by Charlotte Evans commissioned for Tolworth Tower reception area.","height":87});
															thumbnails[6428318] = clik.newPhoto({"id":6428318,"src":"centre_point_odyssey_050_F_thumb.jpg","galleries_id":301285,"server_id":15,"link":"photo_6428318.html","width":130,"caption":"Curated exhibition of Colin Self's Odyssey on top floor of iconic Centrepoint building in central London.","height":97});
															thumbnails[6428383] = clik.newPhoto({"id":6428383,"src":"OFF_011_thumb.jpg","galleries_id":301285,"server_id":15,"link":"photo_6428383.html","width":130,"caption":"Developed public art strategy for redevelopment of Duke Street site in central Norwich","height":98});
															thumbnails[6428441] = clik.newPhoto({"id":6428441,"src":"projects_03_to_07_003_thumb.jpg","galleries_id":301285,"server_id":15,"link":"photo_6428441.html","width":130,"caption":"Started and managed Art Factory Studios in South Norwich 2005 - 2008.","height":98});
															thumbnails[6428453] = clik.newPhoto({"id":6428453,"src":"projects_03_to_07_037_thumb.jpg","galleries_id":301285,"server_id":15,"link":"photo_6428453.html","width":130,"caption":"Curated contemporary art exhibition 'Salthouse' in North Norfolk 2006.","height":98});
															thumbnails[6428461] = clik.newPhoto({"id":6428461,"src":"projects_03_to_07_063_thumb.jpg","galleries_id":301285,"server_id":15,"link":"photo_6428461.html","width":130,"caption":"Started and ran Art Dept for Targetfollow, a UK wide commercial property investment and development company 2003 to 2008.","height":87});
															thumbnails[6428466] = clik.newPhoto({"id":6428466,"src":"projects_03_to_07_071_thumb.jpg","galleries_id":301285,"server_id":15,"link":"photo_6428466.html","width":130,"caption":"Managed changing exhibition series for reception of Wembley Point in West London.","height":98});
															thumbnails[6428513] = clik.newPhoto({"id":6428513,"src":"the_course_nicky_thumb.jpg","galleries_id":301285,"server_id":15,"link":"photo_6428513.html","width":130,"caption":"Ran various painting workshops including this most recent one in 2010.","height":98});
															thumbnails[6428522] = clik.newPhoto({"id":6428522,"src":"john_kiki_small_thumb.jpg","galleries_id":301285,"server_id":15,"link":"photo_6428522.html","width":130,"caption":"Created website for artist John Kiki.","height":173});
															thumbnails[1947579] = clik.newPhoto({"id":1947579,"src":"web 1_thumb.jpg","galleries_id":130415,"server_id":15,"link":"photo_1947579.html","width":130,"caption":"Landscape 1, £160","height":91});
															thumbnails[1947690] = clik.newPhoto({"id":1947690,"src":"Nightwalks 1 a_thumb.jpg","galleries_id":130436,"server_id":15,"link":"photo_1947690.html","width":130,"caption":"Nightwalks, Hedge Layers, £320","height":185});
															thumbnails[1947592] = clik.newPhoto({"id":1947592,"src":"web 2_thumb.jpg","galleries_id":130415,"server_id":15,"link":"photo_1947592.html","width":130,"caption":"Landscape 2, £160","height":88});
															thumbnails[1947692] = clik.newPhoto({"id":1947692,"src":"nightwalks 2 a_thumb.jpg","galleries_id":130436,"server_id":15,"link":"photo_1947692.html","width":130,"caption":"Nightwalks 2, £320","height":182});
															thumbnails[1947597] = clik.newPhoto({"id":1947597,"src":"web 3_thumb.jpg","galleries_id":130415,"server_id":15,"link":"photo_1947597.html","width":130,"caption":"Landscape 3, £160","height":90});
															thumbnails[1947700] = clik.newPhoto({"id":1947700,"src":"nightwalks 3 a_thumb.jpg","galleries_id":130436,"server_id":15,"link":"photo_1947700.html","width":130,"caption":"Nightwalks 3, £320","height":182});
															thumbnails[1947628] = clik.newPhoto({"id":1947628,"src":"web 4a_thumb.jpg","galleries_id":130415,"server_id":15,"link":"photo_1947628.html","width":130,"caption":"Landscape 4, £190","height":95});
															thumbnails[1947704] = clik.newPhoto({"id":1947704,"src":"nightwalks 4 a_thumb.jpg","galleries_id":130436,"server_id":15,"link":"photo_1947704.html","width":130,"caption":"Nightwalks, Magenta, £320","height":172});
															thumbnails[1947540] = clik.newPhoto({"id":1947540,"src":"web 5_thumb.jpg","galleries_id":130415,"server_id":15,"link":"photo_1947540.html","width":130,"caption":"Marsh Sunlight, £190","height":95});
															thumbnails[1947710] = clik.newPhoto({"id":1947710,"src":"nightwalks 5 a_thumb.jpg","galleries_id":130436,"server_id":15,"link":"photo_1947710.html","width":130,"caption":"Nightwalks 5, £320","height":182});
															thumbnails[1947559] = clik.newPhoto({"id":1947559,"src":"web 6_thumb.jpg","galleries_id":130415,"server_id":15,"link":"photo_1947559.html","width":130,"caption":"Landscape 6, SOLD","height":95});
															thumbnails[1947551] = clik.newPhoto({"id":1947551,"src":"web 7_thumb.jpg","galleries_id":130415,"server_id":15,"link":"photo_1947551.html","width":130,"caption":"Marsh Storm, SOLD","height":95});
															thumbnails[1947602] = clik.newPhoto({"id":1947602,"src":"web 8_thumb.jpg","galleries_id":130415,"server_id":15,"link":"photo_1947602.html","width":130,"caption":"Landscape 8, SOLD","height":82});
															thumbnails[1947615] = clik.newPhoto({"id":1947615,"src":"web 9_thumb.jpg","galleries_id":130415,"server_id":15,"link":"photo_1947615.html","width":130,"caption":"Landscape 9, SOLD","height":82});
															thumbnails[1947618] = clik.newPhoto({"id":1947618,"src":"web 10_thumb.jpg","galleries_id":130415,"server_id":15,"link":"photo_1947618.html","width":130,"caption":"Landscape 10, SOLD","height":83});
															thumbnails[1947624] = clik.newPhoto({"id":1947624,"src":"web 11_thumb.jpg","galleries_id":130415,"server_id":15,"link":"photo_1947624.html","width":130,"caption":"Landscape 11, SOLD","height":92});
															thumbnails[1947634] = clik.newPhoto({"id":1947634,"src":"web 12_thumb.jpg","galleries_id":130415,"server_id":15,"link":"photo_1947634.html","width":130,"caption":"Landscape 12, £360","height":92});
															thumbnails[1947639] = clik.newPhoto({"id":1947639,"src":"web 13_thumb.jpg","galleries_id":130415,"server_id":15,"link":"photo_1947639.html","width":130,"caption":"Towards Maypole Green, SOLD ","height":95});
															thumbnails[1947642] = clik.newPhoto({"id":1947642,"src":"web 14_thumb.jpg","galleries_id":130415,"server_id":15,"link":"photo_1947642.html","width":130,"caption":"Maypole Green At Dusk, £450","height":96});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  						galleries[301285] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Arts Consultancy","link":"gallery_301285.html","maxRecords":0.0,"photoIDs":[6428300.0,6428318.0,6428383.0,6428441.0,6428453.0,6428461.0,6428466.0,6428513.0,6428522.0],"skipIndex":0,"section_code":"gallery","featured_images":"6428522,6428513,6428466,6428461,6428453,6428441,6428383,6428318,6428300","id":301285,"singleSection":false});				  						galleries[130415] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Paintings On Paper","link":"gallery_130415.html","maxRecords":0.0,"photoIDs":[1947579.0,1947592.0,1947597.0,1947628.0,1947540.0,1947559.0,1947551.0,1947602.0,1947615.0,1947618.0,1947624.0,1947634.0,1947639.0,1947642.0],"skipIndex":0,"section_code":"gallery","featured_images":"1947642,1947639,1947634,1947628,1947624,1947618,1947615,1947602,1947597,1947592","id":130415,"singleSection":false});				  						galleries[203883] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Mixed Media Paintings","link":"gallery_203883.html","maxRecords":0.0,"photoIDs":[3342161.0,5653422.0,5653427.0,5653430.0],"skipIndex":0,"section_code":"gallery","featured_images":"5653430,5653427,5653422,3342161","id":203883,"singleSection":false});				  						galleries[130600] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Paintings On Board","link":"gallery_130600.html","maxRecords":0.0,"photoIDs":[1950372.0,1950373.0,1950376.0,1950378.0,1950380.0,1950381.0,1950384.0,1950387.0,1950391.0,1950393.0,1950394.0,1950395.0],"skipIndex":0,"section_code":"gallery","featured_images":"1950395,1950394,1950393,1950391,1950387,1950384,1950381,1950380,1950378,1950376","id":130600,"singleSection":false});				  						galleries[130446] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Archive","link":"gallery_130446.html","maxRecords":0.0,"photoIDs":[1949303.0,1949304.0,1949305.0,1949306.0,1949307.0,1949308.0,1949311.0,1949313.0,1949314.0,1949315.0,1949316.0,1949317.0,1949318.0,1949319.0,1949320.0,1949321.0,1949322.0,1949323.0,1949325.0],"skipIndex":0,"section_code":"gallery","featured_images":"1949325,1949323,1949322,1949321,1949320,1949319,1949318,1949317,1949316,1949315","id":130446,"singleSection":false});				  						galleries[130436] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Monoprints","link":"gallery_130436.html","maxRecords":0.0,"photoIDs":[1947690.0,1947692.0,1947700.0,1947704.0,1947710.0],"skipIndex":0,"section_code":"gallery","featured_images":"1947710,1947704,1947700,1947692,1947690","id":130436,"singleSection":false});				  						galleries[381498] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Sketches","link":"gallery_381498.html","maxRecords":0.0,"photoIDs":[],"skipIndex":0,"section_code":"gallery","featured_images":"","id":381498,"singleSection":false});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[1] = '5653427,5653422,3342161';
imageSets[3] = '6428522,6428513,6428466,6428461,6428453,6428441,6428383,6428318,6428300,5653430,5653427,5653422,3342161,1950395,1950394,1950393,1950391,1950387,1950384,1950381,1950380,1950378,1950376,1950373,1950372,1949325,1949323,1949322,1949321,1949320,1949319,1949318,1949317,1949316,1949315,1949314,1949313,1949311,1949308,1949307,1949306,1949305,1949304,1949303,1947710,1947704,1947700,1947692,1947690,1947642';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/sarahcannell/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/sarahcannell/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/sarahcannell/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/sarahcannell/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/sarahcannell/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/sarahcannell/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/sarahcannell/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/sarahcannell/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/sarahcannell/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/sarahcannell/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/sarahcannell/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/sarahcannell/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/sarahcannell/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/sarahcannell/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/sarahcannell/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/sarahcannell/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://admin2.clikpic.com/sarahcannell/images';
		break;
	}
		switch (server_id) {
		case 33:
		val = 'http://www8.clikpic.com/sarahcannell/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/sarahcannell/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/sarahcannell/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/sarahcannell/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/sarahcannell/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/sarahcannell/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/sarahcannell/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 = 'Sarah Cannell BA (Hons), PGDip: ' + 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({					href: thumbnails[imageID].fnGalleryLink(gallery_id),					title: galleries[gallery_id].title				});
			}
		}
	}
}

/***************************************************************************
* If we have dynamic HTML, replace the galleries link with a list that     *
* doesn't include thecurrent gallery                                       *
***************************************************************************/
function showGalleries(gallery_id) {
		
	
	if (!basic) {
		temp = '';
		for (i = 0; i < galleries.length; i++) {
						
			
			if (galleries[i].id != gallery_id) {
								
				if (temp != '') {
					temp += ' | ';
				}
								temp += '<a href="' + galleries[i].section_code + '_' + galleries[i].id + '.html">' + galleries[i].title + '</a>';
							}
		}
		document.all.galleryLinks.innerHTML = 'Other galleries: ' + temp;
	}
}

			

