window.thumbnails = new Object();
												thumbnails[5115239] = new thumbnail(5115239,'','Winter Leaves','PF-38-Winter_Leaves_BW_thumb.jpg',130, 94,1,'#');
												thumbnails[5115268] = new thumbnail(5115268,'','Herbs & Spices','PF-35-Herbs__Spices_thumb.jpg',130, 94,1,'#');
												thumbnails[5114723] = new thumbnail(5114723,'397028','Mitford Castle','PF-257-Mitford_Castle_thumb.jpg',130, 86,1,'photo_5114723.html');
												thumbnails[5114746] = new thumbnail(5114746,'397022','Dunstanburgh Castle from Embleton Bay','PF-234-Dunstanburgh_Castle_thumb.jpg',130, 92,1,'photo_5114746.html');
												thumbnails[5115207] = new thumbnail(5115207,'285712','Alpine Reflections near Bresslauer Hütte, Vent, Austria','PF-170-Alpine_Reflections_thumb.jpg',130, 93,1,'photo_5115207.html');
												thumbnails[6397867] = new thumbnail(6397867,'397026','Tyne Bridge in Morning Fog, Newcastle upon Tyne','PF-277-Tyne_Bridge_thumb.jpg',130, 86,1,'photo_6397867.html');
												thumbnails[5114787] = new thumbnail(5114787,'397028','River Font in Mitford','PF-255-River_Wansbeck_Mitford_thumb.jpg',86, 130,1,'photo_5114787.html');
												thumbnails[5115272] = new thumbnail(5115272,'397022','St Mary\'s Lighthouse, Whitley Bay','PF-50-St_Marys_Lighthouse_thumb.jpg',130, 72,1,'photo_5115272.html');
												thumbnails[5115324] = new thumbnail(5115324,'285712','Winter in Hintertux, Tirol, Austria','PF-166-Hintertux_Tirol_Austria_Mono_thumb.jpg',130, 59,1,'photo_5115324.html');
												thumbnails[7158369] = new thumbnail(7158369,'397026','Tyne Bridge, Newcastle','PF-212-Tyne_Bridge_Newcastle_thumb.jpg',130, 43,1,'photo_7158369.html');
												thumbnails[5115217] = new thumbnail(5115217,'397028','Sunset over Howden Reservoir','PF-115-Sunset_over_Howden_Reservoir_thumb.jpg',94, 130,1,'photo_5115217.html');
												thumbnails[5115232] = new thumbnail(5115232,'285712','Horses in the Massief de Néouvielle, Pyrenees','PF-36-Horses_in_the_Massief_de_Néouvielle_Pyrenees_thumb.jpg',130, 94,1,'photo_5115232.html');
												thumbnails[5115294] = new thumbnail(5115294,'397022','Dunstanburgh Castle','PF-99-Dunstanburgh_Castle_from_Embleton_Bay_thumb.jpg',93, 130,1,'photo_5115294.html');
												thumbnails[7158557] = new thumbnail(7158557,'397026','Millenium Bridge, Gateshead','PF-313-Millenium_Bridge_Newcastle_thumb.jpg',129, 130,1,'photo_7158557.html');
												thumbnails[5114818] = new thumbnail(5114818,'397028','Tree & Posts','PF-239-Tree__Posts_BW_thumb.jpg',130, 92,1,'photo_5114818.html');
												thumbnails[5115270] = new thumbnail(5115270,'285712','Zeller See, Austria','PF-46-Zell_am_See_Asutria_thumb.jpg',130, 94,1,'photo_5115270.html');
												thumbnails[5115282] = new thumbnail(5115282,'397026','Fog on the Tyne Bridge, Newcastle upon Tyne','PF-278-Tyne_Bridge_thumb.jpg',86, 130,1,'photo_5115282.html');
												thumbnails[5114437] = new thumbnail(5114437,'285712','Wallfahrtskirche Heiligenblut & Großglockner, Austria','PF-18-Heiligenblut_thumb.jpg',130, 92,1,'photo_5114437.html');
												thumbnails[5115283] = new thumbnail(5115283,'397028','Tree & Moon','PF-92-Tree__Moon_Maplebeck_thumb.jpg',130, 86,1,'photo_5115283.html');
												thumbnails[5115285] = new thumbnail(5115285,'397022','Moon over Whitley Bay','PF-64-Whitley_Bay1_thumb.jpg',130, 130,1,'photo_5115285.html');
												thumbnails[7158517] = new thumbnail(7158517,'397026','Millennium Bridge, Gateshead','PF-306-Millennium_Bridge_Gateshead_thumb.jpg',130, 86,1,'photo_7158517.html');
												thumbnails[5106809] = new thumbnail(5106809,'397028','Canoes on Buttermere, Lake District','PF-15-Buttermere_thumb.jpg',130, 74,1,'photo_5106809.html');
												thumbnails[5114677] = new thumbnail(5114677,'397022','Alone','PF-264-Alone_thumb.jpg',92, 130,1,'photo_5114677.html');
												thumbnails[5114781] = new thumbnail(5114781,'397026','Telford Bridge, Morpeth','PF-250-Telford_Bridge_Morpeth_thumb.jpg',130, 86,1,'photo_5114781.html');
												thumbnails[7501719] = new thumbnail(7501719,'285712','The Austrian Alps from the air','PF-218-Alps_thumb.jpg',130, 92,1,'photo_7501719.html');
												thumbnails[5106741] = new thumbnail(5106741,'397028','Hope Valley, Peak District','PF-9-Hope_Valley_thumb.jpg',130, 59,1,'photo_5106741.html');
												thumbnails[5114646] = new thumbnail(5114646,'397022','Beach Huts at Blyth South Beach','PF-270-Beach_Huts_thumb.jpg',130, 92,1,'photo_5114646.html');
												thumbnails[7158483] = new thumbnail(7158483,'397026','Tyne Bridge, Newcastle','PF-286-Tyne_Bridge_Newcastle_thumb.jpg',130, 86,1,'photo_7158483.html');
												thumbnails[5114665] = new thumbnail(5114665,'397022','Sunset','PF-265-Sunset_BW_thumb.jpg',92, 130,1,'photo_5114665.html');
												thumbnails[5115214] = new thumbnail(5115214,'397028','Curbar Edge, Peak District','PF-140-Curbar_Edge_thumb.jpg',130, 93,1,'photo_5115214.html');
												thumbnails[7158491] = new thumbnail(7158491,'397026','Tyne Bridge, Newcastle','PF-287-Tyne_Bridge_Newcastle_thumb.jpg',130, 86,1,'photo_7158491.html');
												thumbnails[5114695] = new thumbnail(5114695,'397022','Bamburgh Castle','PF-259-Bamburgh_Castle_thumb.jpg',130, 86,1,'photo_5114695.html');
												thumbnails[5114779] = new thumbnail(5114779,'397026','Telford Bridge & St Georges Church, Morpeth ','PF-249-_Telford_Bridge_Morpeth_thumb.jpg',86, 130,1,'photo_5114779.html');
												thumbnails[5115290] = new thumbnail(5115290,'397028','Barn','PF-121-Barn__Trees_thumb.jpg',130, 95,1,'photo_5115290.html');
												thumbnails[5114691] = new thumbnail(5114691,'397022','Dunstanburgh Castle','PF-260-Dunstanburgh_Castle-2_thumb.jpg',130, 49,1,'photo_5114691.html');
												thumbnails[5115227] = new thumbnail(5115227,'397028','Hope Valley','PF-32-Hope_Valley_thumb.jpg',130, 39,1,'photo_5115227.html');
												thumbnails[6397928] = new thumbnail(6397928,'397026','High Level Bridge in Fog, Newcastle upon Tyne','PF-276-High_Level_Bridge_thumb.jpg',130, 86,1,'photo_6397928.html');
												thumbnails[5115267] = new thumbnail(5115267,'397028','Trees at Sunset','PF-43-Three_Trees_at_Sunset_thumb.jpg',130, 93,1,'photo_5115267.html');
												thumbnails[7158410] = new thumbnail(7158410,'397022','Bamburgh Castle, Northumberland','PF-263-Bamburgh_Castle_thumb.jpg',130, 92,1,'photo_7158410.html');
												thumbnails[7158540] = new thumbnail(7158540,'397026','Tyne Bridge, Newcastle','PF-309-Tyne_Bridge_Newcastle_thumb.jpg',130, 86,1,'photo_7158540.html');
												thumbnails[5114652] = new thumbnail(5114652,'397028','Wooden Posts ','PF-268-Wooden_Posts_BW_thumb.jpg',92, 130,1,'photo_5114652.html');
												thumbnails[7158439] = new thumbnail(7158439,'397022','Seaton Sluice, Northumberland','PF-271-Seaton_Sluice_B87A9EF6-24E8-5EC4-4F75D0D095F90B39_thumb.jpg',130, 86,1,'photo_7158439.html');
												thumbnails[7360078] = new thumbnail(7360078,'397026','Tyne Bridge, Newcastle','PF-277-Tyne_Bridge_E3190B0B-1EC9-D45B-1C461B6EC012BE76_thumb.jpg',130, 86,1,'photo_7360078.html');
												thumbnails[5115192] = new thumbnail(5115192,'397028','Cold Forest','PF-196-Cold_Forest_thumb.jpg',130, 49,1,'photo_5115192.html');
												thumbnails[5115218] = new thumbnail(5115218,'397022','Sunrise at Spurn Head, Humberside','PF-116-Sunrise_at_Spurn_head_Humberside_thumb.jpg',130, 87,1,'photo_5115218.html');
												thumbnails[7360100] = new thumbnail(7360100,'397026','Tyne Bridges, Newcastle','PF-329-Tyne_Bridges_Newcastle_thumb.jpg',130, 86,1,'photo_7360100.html');
												thumbnails[5114393] = new thumbnail(5114393,'397022','Sea defenses at Spurn Head','PF-2-Spurn_Head_Mono-Edit_thumb.jpg',130, 63,1,'photo_5114393.html');
												thumbnails[5115320] = new thumbnail(5115320,'397028','Row of Trees','PF-157-Row_of_Trees_thumb.jpg',130, 93,1,'photo_5115320.html');
												thumbnails[7360103] = new thumbnail(7360103,'397026','Tyne Bridge, Newcastle','PF-320-Tyne_Bridge_Newcastle_thumb.jpg',130, 58,1,'photo_7360103.html');
												thumbnails[5114407] = new thumbnail(5114407,'397028','Fountains Abbey, North Yorkshire','PF-10-Fountains_Abbey_thumb.jpg',130, 59,1,'photo_5114407.html');
												thumbnails[5114657] = new thumbnail(5114657,'397022','Sea Defenses at Spurn Head','PF-266-Sea_Defenses_BW_thumb.jpg',130, 92,1,'photo_5114657.html');
												thumbnails[5101028] = new thumbnail(5101028,'397028','Barn','PF-4-Barn_thumb.jpg',130, 86,1,'photo_5101028.html');
												thumbnails[5115233] = new thumbnail(5115233,'397022','Sunset under the Humber Bridge','PF-37-Sunset_over_Humber_Bridge_thumb.jpg',130, 93,1,'photo_5115233.html');
												thumbnails[5115406] = new thumbnail(5115406,'397028','Sunlit Fence','PF-273-Sunlit_Fence_thumb.jpg',130, 62,1,'photo_5115406.html');
												thumbnails[7158455] = new thumbnail(7158455,'397022','Bamburgh Castle, Northumberland','PF-282-Bamburgh_Castle-Edit_thumb.jpg',130, 39,1,'photo_7158455.html');
												thumbnails[5115280] = new thumbnail(5115280,'397022','St Mary\'s Lighthouse, Whitley Bay','PF-56-St_Marys_Lighthouse_thumb.jpg',86, 130,1,'photo_5115280.html');
												thumbnails[5115293] = new thumbnail(5115293,'397028','Tree & Moon, Maplebeck','PF-93-Tree__Moon_Maplebeck_thumb.jpg',130, 86,1,'photo_5115293.html');
												thumbnails[5114409] = new thumbnail(5114409,'397028','Fountains Abbey, North Yorkshire','PF-11-Fountains_Abbey_thumb.jpg',130, 59,1,'photo_5114409.html');
												thumbnails[5114810] = new thumbnail(5114810,'397022','Seaton Sluice, Northumberland','PF-271-Seaton_Sluice_thumb.jpg',130, 86,1,'photo_5114810.html');
												thumbnails[5114769] = new thumbnail(5114769,'397022','St Mary\'s Lighthouse, Whitley Bay','PF-233-St_Marys_Lighthouse_thumb.jpg',130, 92,1,'photo_5114769.html');
												thumbnails[5114772] = new thumbnail(5114772,'397028','Tree in Black & White','PF-232-Tree_BW1_thumb.jpg',130, 92,1,'photo_5114772.html');
												thumbnails[5114684] = new thumbnail(5114684,'397022','Dunstanburgh Castle from Embleton Bay, Northumberland','PF-261-Dunstanburgh_Castle_thumb.jpg',130, 49,1,'photo_5114684.html');
												thumbnails[5115116] = new thumbnail(5115116,'397028','Stepping Stones','PF-210-Stepping_Stones_thumb.jpg',98, 130,1,'photo_5115116.html');
												thumbnails[7158478] = new thumbnail(7158478,'397028','Warkworth Castle, Northumberland','PF-285-Warkworth_Castle_thumb.jpg',130, 86,1,'photo_7158478.html');
												thumbnails[7158505] = new thumbnail(7158505,'397022','Dunstanburgh Castle from Embleton Bay','PF-289-Dunstanburgh_Castle_thumb.jpg',130, 86,1,'photo_7158505.html');
												thumbnails[5115396] = new thumbnail(5115396,'397028','Rainbow over Derwent Water, Peak District','PF-57-Rainbow_over_Derwent_Water_Peak_District_thumb.jpg',130, 65,1,'photo_5115396.html');
												thumbnails[7158459] = new thumbnail(7158459,'397022','Bamburgh Castle, Northumberland','PF-283-Bamburgh_Castle-Edit_thumb.jpg',130, 86,1,'photo_7158459.html');
												thumbnails[5115205] = new thumbnail(5115205,'397028','Single Tree in Field','PF-201-Tree_thumb.jpg',130, 86,1,'photo_5115205.html');
												thumbnails[5115220] = new thumbnail(5115220,'397022','Geese in Flight, Northumbrian Coast','PF-25-Birds_thumb.jpg',130, 86,1,'photo_5115220.html');
												thumbnails[5115286] = new thumbnail(5115286,'397022','Dunstanburgh Castle from Embleton Golf Course','PF-71-Dunstanburgh_Castle_thumb.jpg',130, 57,1,'photo_5115286.html');
												thumbnails[5115316] = new thumbnail(5115316,'397028','Endless Path Near Ingleborough, Yorkshire Dales','PF-153-Endless_Path_thumb.jpg',93, 130,1,'photo_5115316.html');
												thumbnails[5115172] = new thumbnail(5115172,'397028','Fountains Abbey, North Yorkshire','PF-208-Fountains_Abbey_thumb.jpg',92, 130,1,'photo_5115172.html');
												thumbnails[5115240] = new thumbnail(5115240,'397022','Lone Drum on the Beach at Spurn Head, Humberside','PF-40-Lone_Drum_on_a_Beach_thumb.jpg',130, 92,1,'photo_5115240.html');
												thumbnails[5115274] = new thumbnail(5115274,'397028','Eyam Moor, Peak District','PF-274-Eyam_Moor_thumb.jpg',130, 92,1,'photo_5115274.html');
												thumbnails[5114649] = new thumbnail(5114649,'397022','St Mary\'s Lighthouse, Whitley Bay, Northumberland','PF-269-St_Marys_Lighthouse_thumb.jpg',130, 58,1,'photo_5114649.html');
												thumbnails[5115318] = new thumbnail(5115318,'397028','Derelict Shack ','PF-187-Shack_4_thumb.jpg',86, 130,1,'photo_5115318.html');
												thumbnails[5115226] = new thumbnail(5115226,'397022','Dunstanburgh Castle from Embleton Bay, Northumberland Coast','PF-26-Dunstanburgh_Castle_thumb.jpg',87, 130,1,'photo_5115226.html');
												thumbnails[7360209] = new thumbnail(7360209,'397028','Winter Landscape, Morpeth','PF-317-Winter_Landscape_Morpeth_thumb.jpg',130, 67,1,'photo_7360209.html');
												thumbnails[5115315] = new thumbnail(5115315,'397022','Symmetry of Sea Defences at Spurn Head, Humberside','PF-117-Symmetry_Spurn_Head_thumb.jpg',130, 92,1,'photo_5115315.html');
												thumbnails[5114844] = new thumbnail(5114844,'397022','Dunstanbusrgh Castle from South (Craster)','PF-244-Dunstanburgh_Castle_thumb.jpg',130, 92,1,'photo_5114844.html');
												thumbnails[7158512] = new thumbnail(7158512,'397022','Dunstanburgh Castle, Northumberland','PF-305-Dunstanburgh_Castle_thumb.jpg',86, 130,1,'photo_7158512.html');
												thumbnails[5115275] = new thumbnail(5115275,'397022','St Mary\'s Lighthouse, Whitley Bay, Northumberland','PF-53-St_Marys_Lighthouse_thumb.jpg',86, 130,1,'photo_5115275.html');
												thumbnails[7360084] = new thumbnail(7360084,'397022','Lindisfarne Castle, Holy Island','PF-335-Lindisfarne_Castle_thumb.jpg',86, 130,1,'photo_7360084.html');
												thumbnails[7360122] = new thumbnail(7360122,'397022','South Beach, Blyth','PF-314-South_Beach_Blyth_BW_thumb.jpg',130, 47,1,'photo_7360122.html');
												thumbnails[7360180] = new thumbnail(7360180,'397022','Bamburgh Castle, Northumberland','PF-332-Bamburgh_Castle_thumb.jpg',130, 94,1,'photo_7360180.html');
												thumbnails[7360197] = new thumbnail(7360197,'397022','Beach Huts, South Beach, Blyth','PF-316-Beach_Huts_South_Beach_Blyth_thumb.jpg',130, 28,1,'photo_7360197.html');
												thumbnails[7360223] = new thumbnail(7360223,'397022','Bamburgh Castle, Northumberland','PF-322-Bamburgh_Castle_thumb.jpg',130, 86,1,'photo_7360223.html');

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  					galleries[397022] = new gallery(397022,'7360223,7360197,7360180,7360122,7360084,7158512,7158505,7158459,7158455,7158439','Coast','section342670',[5114746,5115272,5115294,5115285,5114677,5114646,5114665,5114695,5114691,7158410,7158439,5115218,5114393,5114657,5115233,7158455,5115280,5114810,5114769,5114684,7158505,7158459,5115220,5115286,5115240,5114649,5115226,5115315,5114844,7158512,5115275,7360084,7360122,7360180,7360197,7360223],0, 0, '', 'section342670_397022.html',0,0);
				  					galleries[285712] = new gallery(285712,'7501719,5115324,5115270,5115232,5115207,5114437','Mountains','section342670',[5115207,5115324,5115232,5115270,5114437,7501719],0, 0, '', 'section342670_285712.html',0,0);
				  					galleries[397026] = new gallery(397026,'7360103,7360100,7360078,7158557,7158540,7158517,7158491,7158483,7158369,6397928','Urban','section342670',[6397867,7158369,7158557,5115282,7158517,5114781,7158483,7158491,5114779,6397928,7158540,7360078,7360100,7360103],0, 0, '', 'section342670_397026.html',0,0);
				  					galleries[397028] = new gallery(397028,'7360209,7158478,5115406,5115396,5115320,5115318,5115316,5115293,5115290,5115283','Country','section342670',[5114723,5114787,5115217,5114818,5115283,5106809,5106741,5115214,5115290,5115227,5115267,5114652,5115192,5115320,5114407,5101028,5115406,5115293,5114409,5114772,5115116,7158478,5115396,5115205,5115316,5115172,5115274,5115318,7360209],0, 0, '', 'section342670_397028.html',0,0);
/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = new Object();
imageSets[1] = '5115272,5114818,5114746';
imageSets[3] = '7501719,7360223,7360209,7360197,7360180,7360122,7360103,7360100,7360084,7360078,7158557,7158540,7158517,7158512,7158505,7158491,7158483,7158478,7158459,7158455,7158439,7158410,7158369,6397928,6397867,5115406,5115396,5115324,5115320,5115318,5115316,5115315,5115294,5115293,5115290,5115286,5115285,5115283,5115282,5115280,5115275,5115274,5115272,5115270,5115268,5115267,5115240,5115239,5115233,5115232';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/franksmelt/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/franksmelt/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/franksmelt/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/franksmelt/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/franksmelt/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/franksmelt/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/franksmelt/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/franksmelt/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/franksmelt/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/franksmelt/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/franksmelt/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/franksmelt/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/franksmelt/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/franksmelt/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/franksmelt/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://admin2.clikpic.com/franksmelt/images';
		break;
	}
		switch (server_id) {
		case 33:
		val = 'http://www8.clikpic.com/franksmelt/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/franksmelt/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/franksmelt/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/franksmelt/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/franksmelt/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/franksmelt/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 += 'section342670.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 && 'section342670' != '') {
					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:'',
                    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 (!basic) {
    if (op.updateHash && clik.getIDInUrl(location.href,'photo') != op.nextPhoto.id) {
		clik.changeHash('photos_id=' + op.nextPhoto.id, true);
    }
				
    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));		  $('body').trigger('clikUpdate');		}, op.onBefore);
      }    }
    	if (op.field) {
		op.field.value = photoId;
	} else {
		op.$photo.data('image_id', photoId);
    }
	    if (op.$title.length > 0) {
  		op.$title.fadeGalleryDetails(photoCaption, op.speed);
    }
        if (op.updateDocumentTitle) {
						  document.title = 'Frank Smelt Photography: ' + photoCaption;
			    }
        if (op.$detail.length > 0) {
      temp = op.nextPhoto.fnGetImageDetails();
	    op.$detail.fadeGalleryDetails(temp, op.speed, function(){
	    var options = {};	    	      	      resizePhotoInfo(options);
        if (typeof(backgrounds) != 'undefined' && op.nextPhoto == backgrounds[op.nextPhoto.id]) {
  	      toggleAddToCartConfirm(backgrounds);
  	    } else if (typeof(photos) != 'undefined' && op.nextPhoto == photos[op.nextPhoto.id]) {
  	      toggleAddToCartConfirm(photos);
  	    }
	    });
    }
        if (!op.speed) {      clik.doColumnResize(false, op.$photo.add(op.$detail).add(op.$title));      $('body').trigger('clikUpdate');    }        
    return html;			}
	else {
				
		window.location = 'photo_' + nextPhoto.id + '.html';
	}
		
}

/***************************************************************************
* Toggle add to cart confirmation element and set up the click event for   *
* the 'Add to cart' button.                                                *
***************************************************************************/
function toggleAddToCartConfirm(array){
  if (typeof(array) !== 'object') {
    array = photos;
  }
	if($('#paymentConfirm').length > 0){
		$('#paymentConfirm').hide();
		$('#paymentAddButton')
		.unbind()
		.click(function(){
						form = document.getElementById('paymentForm');
			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').text('Item added to cart').show();}
				else{
					$('#paymentConfirm').text('Item added to cart').fadeIn();
					dspOrderDetails(form.site.value);
				}
			}
			else{
				$('#paymentConfirm').text('Item not added - check cookies are enabled in your browser.').fadeIn();
			}
		});
	}
}
/***************************************************************************
* Get payment info for image - add as 'method' to photo object             *
***************************************************************************/
photo.prototype.fnGetImageDetails = function(){
	var temp = '';
	if (this.description != '') {
		temp = temp +  '<p id="imageDescription">' + this.description + '</p>';
	}
		if (this.photo_ref != '') {
		temp = temp + '<p class="imageinfo" id="imageRef"><strong>Ref: </strong>' + this.photo_ref + '</p>';
	}
		if (this.takendate != '') {
				
		temp = temp + '<p class="imageinfo" id="imageDate"><strong>Date: </strong>' + this.takendate + '</p>';
	}
	
	if (this.location != '') {
				
		temp = temp + '<p class="imageinfo" id="imageLocation"><strong>Location: </strong>' +  this.location + '</p>';
	}
	
	if (this.photographer != '') {
				
		temp = temp + '<p class="imageinfo" id="imagePhotographer"><strong>Photographer: </strong>' + this.photographer + '</p>';
	}
					
				if (temp != '') {
		temp = temp + '<div class="spacer"></div>';
	}
	return temp;
};

/***************************************************************************
* Get payment info for image - add as 'method' to photo object             *
***************************************************************************/
photo.prototype.fnGetPaymentInfo = function(){
	var temp = '';
	if (this.item_price !== '') {
				temp = temp + '<p>Order this print:</p>';
				temp = temp + '<p class="imageinfo" id="imagePrice"><strong>' + this.purchase_instruction + '</strong> &pound;' + (this.item_price).toFixed(2) + '</p>';
		var item_name  = this.purchase_instruction;
		var amount = (this.item_price).toFixed(2);
		var item_option  = 0;
	}
	else if (this.payment_groups_id !== '') {
		temp = temp + '<p>Buy this print online:</p>';
				temp = temp + '<form id="paymentOptions" style="margin:0px;border:0px;" name="paymentOptions">';
											temp = temp + '<select class="paymentlink" name="payment_options_id" onchange="updateItemValues(document.forms.paymentForm,this.form.payment_options_id.options[this.form.payment_options_id.options.selectedIndex].value);">';
				
		temp = temp + getPaymentOptions(this.payment_groups_id);
		temp = temp + '</select>';
		temp = 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 = temp + '<form id="paymentForm" style="margin:0px;border:0px;" name="paymentForm" target="_blank" action="https://www.paypal.com/cgi-bin/webscr" method="post">';
	temp = 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 = temp + '<input type="hidden" name="cmd" value="_cart">';
	temp = temp + '<input type="hidden" name="business" value="frank-smelt@hotmail.com">';
	temp = temp + '<input type="hidden" name="currency_code" value="GBP">';
	temp = temp + '<input type="hidden" name="add" value="1">';
					temp = temp + '<input type="hidden" name="amount" value="'+amount+'">';
	temp = temp + '<input type="hidden" name="item_number" value="'+ref+'">';
					temp = temp + '<input type=\"Submit\" value=\"Add to cart\" id=\"paymentAddButton\" class=\"button\" onmouseover=\"this.className=\'buttonHi\';\" onmouseout=\"this.className=\'button\';\">';
									temp = temp + '</form>';
								temp = temp + '<form id="paymentCartForm" style="margin:0px;" name="paymentCartForm" target="_blank" action="https://www.paypal.com/cgi-bin/webscr" method="post">';
	temp = temp + '<input type="hidden" name="cmd" value="_cart">';
	temp = temp + '<input type="hidden" name="business" value="frank-smelt@hotmail.com">';
	temp = temp + '<input type="hidden" name="display" value="1">';
	temp = temp + '<input type=\"Submit\" value=\"View cart\" id=\"paymentViewButton\" class=\"button\" onmouseover=\"this.className=\'buttonHi\';\" onmouseout=\"this.className=\'button\';\">';
	temp = temp + '</form>';
							temp = 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 + ' | ';
				}
				temp = temp + '<a href="' + galleries[i].section_code + '_' + galleries[i].id + '.html">' + galleries[i].title + '</a>';
			}
		}
		document.all.galleryLinks.innerHTML = 'Other galleries: ' + temp;
	}
}

			

