window.thumbnails = {};
															thumbnails[3817092] = clik.newPhoto({"id":3817092,"src":"123112_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":87});
															thumbnails[5153250] = clik.newPhoto({"id":5153250,"src":"NOR_24_thumb.JPG","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"The dome of St Paul's Cathedral","height":87});
															thumbnails[5687010] = clik.newPhoto({"id":5687010,"src":"_MG_6010_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"Beach huts Charmouth (137)","height":126});
															thumbnails[5687026] = clik.newPhoto({"id":5687026,"src":"circles_6_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"Circles IV (104)","height":130});
															thumbnails[5687029] = clik.newPhoto({"id":5687029,"src":"egg_11_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"Egg IX (165)","height":128});
															thumbnails[5687033] = clik.newPhoto({"id":5687033,"src":"red_apple_1_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"Pink Lady I (153","height":130});
															thumbnails[5916190] = clik.newPhoto({"id":5916190,"src":"141_web_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"Black Dutch Tulips (141)","height":131});
															thumbnails[5916198] = clik.newPhoto({"id":5916198,"src":"145_web1_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"Hove Beach Huts (154)","height":129});
															thumbnails[5916276] = clik.newPhoto({"id":5916276,"src":"177_web1_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"Deckchairs on Brighton Pier (177)","height":129});
															thumbnails[5916348] = clik.newPhoto({"id":5916348,"src":"Battersea_1_228_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"Battersea Power Station II (228)","height":130});
															thumbnails[5916361] = clik.newPhoto({"id":5916361,"src":"Brighton_Pier_229_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"Brighton Pier (229)","height":60});
															thumbnails[5916381] = clik.newPhoto({"id":5916381,"src":"173_WEB_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"Limes III (173)","height":130});
															thumbnails[5919051] = clik.newPhoto({"id":5919051,"src":"149_web_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"Hove Beach Hut (149)","height":130});
															thumbnails[5919054] = clik.newPhoto({"id":5919054,"src":"storm_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"Brighton on a Stormy Day (234)","height":130});
															thumbnails[5919067] = clik.newPhoto({"id":5919067,"src":"web_210_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"Shiraz (210","height":130});
															thumbnails[3098740] = clik.newPhoto({"id":3098740,"src":"travel1_thumb.jpg","galleries_id":189866,"server_id":5,"link":"photo_3098740.html","width":130,"caption":"Water Lilies . Malaysia","height":130});
															thumbnails[3099347] = clik.newPhoto({"id":3099347,"src":"(131)1_thumb.jpg","galleries_id":189866,"server_id":5,"link":"photo_3099347.html","width":130,"caption":"Florence . Italy","height":60});
															thumbnails[3099349] = clik.newPhoto({"id":3099349,"src":"(133)_thumb.JPG","galleries_id":189866,"server_id":5,"link":"photo_3099349.html","width":130,"caption":"Olympics Games . Athens","height":53});
															thumbnails[3099367] = clik.newPhoto({"id":3099367,"src":"(141)_thumb.JPG","galleries_id":189866,"server_id":5,"link":"photo_3099367.html","width":130,"caption":"The Grand Canal . Venice","height":174});
															thumbnails[3099368] = clik.newPhoto({"id":3099368,"src":"(168)2_thumb.JPG","galleries_id":189866,"server_id":5,"link":"photo_3099368.html","width":130,"caption":"Vineyards & the Andes . Chile","height":181});
															thumbnails[3099370] = clik.newPhoto({"id":3099370,"src":"(169)_thumb.jpg","galleries_id":189866,"server_id":5,"link":"photo_3099370.html","width":130,"caption":"Rows of vines in the Adelaide Hills . South Australia","height":81});
															thumbnails[3099378] = clik.newPhoto({"id":3099378,"src":"(165)_thumb.jpg","galleries_id":189866,"server_id":5,"link":"photo_3099378.html","width":130,"caption":"Dawn in the Barossa Valley . South Australia","height":98});
															thumbnails[3130626] = clik.newPhoto({"id":3130626,"src":"(142)_thumb.jpg","galleries_id":189866,"server_id":5,"link":"photo_3130626.html","width":130,"caption":"Almond blossom in Southern Spain","height":97});
															thumbnails[3130659] = clik.newPhoto({"id":3130659,"src":"bloody unilever_thumb.jpg","galleries_id":189862,"server_id":5,"link":"photo_3130659.html","width":130,"caption":"Becel Pro-activ . Loman Street Studio . Unilever","height":128});
															thumbnails[3130669] = clik.newPhoto({"id":3130669,"src":"(111)_thumb.jpg","galleries_id":189330,"server_id":5,"link":"photo_3130669.html","width":130,"caption":"Private Commission","height":195});
															thumbnails[8975972] = clik.newPhoto({"id":8975972,"src":"a_FCA429D7-24E8-5EC4-4F5970A29CE7111B_thumb.jpg","galleries_id":472435,"server_id":5,"link":"photo_8975972.html","width":130,"caption":"","height":130});
															thumbnails[3094676] = clik.newPhoto({"id":3094676,"src":"(179)_thumb.jpg","galleries_id":189863,"server_id":5,"link":"photo_3094676.html","width":130,"caption":"Glass of champagne . Veuve Clicquot","height":195});
															thumbnails[3094781] = clik.newPhoto({"id":3094781,"src":"(113)1_thumb.jpg","galleries_id":189862,"server_id":5,"link":"photo_3094781.html","width":130,"caption":"Indian curry spices","height":177});
															thumbnails[3098757] = clik.newPhoto({"id":3098757,"src":"lifestyle_thumb.jpg","galleries_id":189331,"server_id":5,"link":"photo_3098757.html","width":130,"caption":"Master bathroom suite . West London","height":130});
															thumbnails[3098781] = clik.newPhoto({"id":3098781,"src":"(108)2_thumb.jpg","galleries_id":189330,"server_id":5,"link":"photo_3098781.html","width":130,"caption":"James","height":177});
															thumbnails[3098986] = clik.newPhoto({"id":3098986,"src":"(221)_thumb.jpg","galleries_id":190126,"server_id":5,"link":"photo_3098986.html","width":130,"caption":"eScala","height":195});
															thumbnails[3968564] = clik.newPhoto({"id":3968564,"src":"11_thumb.jpg","galleries_id":190099,"server_id":5,"link":"photo_3968564.html","width":130,"caption":"","height":195});
															thumbnails[3094681] = clik.newPhoto({"id":3094681,"src":"(115)_thumb.JPG","galleries_id":189330,"server_id":5,"link":"photo_3094681.html","width":130,"caption":"Peter Jackson . Fosters EMEA","height":195});
															thumbnails[3099631] = clik.newPhoto({"id":3099631,"src":"(350)_thumb.JPG","galleries_id":190126,"server_id":5,"link":"photo_3099631.html","width":130,"caption":"The Banqueting House . Inn or Out","height":173});
															thumbnails[3099691] = clik.newPhoto({"id":3099691,"src":"(269)_thumb.JPG","galleries_id":189862,"server_id":5,"link":"photo_3099691.html","width":130,"caption":"King prawns on a banana leaf . Bon Ton","height":173});
															thumbnails[3968567] = clik.newPhoto({"id":3968567,"src":"15_thumb.JPG","galleries_id":190099,"server_id":5,"link":"photo_3968567.html","width":130,"caption":"","height":195});
															thumbnails[3098765] = clik.newPhoto({"id":3098765,"src":"helen_thumb.jpg","galleries_id":189330,"server_id":5,"link":"photo_3098765.html","width":130,"caption":"Helen","height":130});
															thumbnails[3098979] = clik.newPhoto({"id":3098979,"src":"(130)_thumb.JPG","galleries_id":189331,"server_id":5,"link":"photo_3098979.html","width":130,"caption":"Hotel de Paris . Monaco","height":174});
															thumbnails[3099010] = clik.newPhoto({"id":3099010,"src":"(152)_thumb.jpg","galleries_id":189331,"server_id":5,"link":"photo_3099010.html","width":130,"caption":"Drawing room - Central London","height":173});
															thumbnails[3099658] = clik.newPhoto({"id":3099658,"src":"(164)_thumb.JPG","galleries_id":189863,"server_id":5,"link":"photo_3099658.html","width":130,"caption":"Old bottles . Cognac Frapin ","height":195});
															thumbnails[3099661] = clik.newPhoto({"id":3099661,"src":"(246)_thumb.jpg","galleries_id":189863,"server_id":5,"link":"photo_3099661.html","width":130,"caption":"Wine glasses by Erika Lagerbielke for Orrefors","height":195});
															thumbnails[3099684] = clik.newPhoto({"id":3099684,"src":"(147)_thumb.JPG","galleries_id":189862,"server_id":5,"link":"photo_3099684.html","width":130,"caption":"Summer Pudding . Lena Bjorck ","height":195});
															thumbnails[3968569] = clik.newPhoto({"id":3968569,"src":"22_thumb.JPG","galleries_id":190099,"server_id":5,"link":"photo_3968569.html","width":130,"caption":"","height":195});
															thumbnails[3098768] = clik.newPhoto({"id":3098768,"src":"(116)_thumb.JPG","galleries_id":189330,"server_id":5,"link":"photo_3098768.html","width":130,"caption":"Mike","height":195});
															thumbnails[3098999] = clik.newPhoto({"id":3098999,"src":"_MG_2302_thumb.jpg","galleries_id":189331,"server_id":5,"link":"photo_3098999.html","width":130,"caption":"The Old Sail Loft","height":87});
															thumbnails[3099083] = clik.newPhoto({"id":3099083,"src":"(205)_thumb.jpg","galleries_id":190126,"server_id":5,"link":"photo_3099083.html","width":130,"caption":"Champagne Lanson . Ladies Day Newmarket","height":195});
															thumbnails[3099662] = clik.newPhoto({"id":3099662,"src":"(164)1_thumb.JPG","galleries_id":189863,"server_id":5,"link":"photo_3099662.html","width":130,"caption":"Shiraz pouring into a glass . Penfolds","height":189});
															thumbnails[3968572] = clik.newPhoto({"id":3968572,"src":"35_thumb.jpg","galleries_id":190099,"server_id":5,"link":"photo_3968572.html","width":130,"caption":"","height":195});
															thumbnails[3098775] = clik.newPhoto({"id":3098775,"src":"(151)_thumb.jpg","galleries_id":189330,"server_id":5,"link":"photo_3098775.html","width":130,"caption":"Anna","height":86});
															thumbnails[3099017] = clik.newPhoto({"id":3099017,"src":"(127)_thumb.JPG","galleries_id":189331,"server_id":5,"link":"photo_3099017.html","width":130,"caption":"Drawing room . The Goring Hotel","height":87});
															thumbnails[3099632] = clik.newPhoto({"id":3099632,"src":"(426)_thumb.JPG","galleries_id":190126,"server_id":5,"link":"photo_3099632.html","width":130,"caption":"The Veuve Clicqout Gold Cup polo finals","height":108});
															thumbnails[3099655] = clik.newPhoto({"id":3099655,"src":"(102)4_thumb.jpg","galleries_id":189863,"server_id":5,"link":"photo_3099655.html","width":130,"caption":"Gin & tonic with slices of lime","height":200});
															thumbnails[3099688] = clik.newPhoto({"id":3099688,"src":"(319)_thumb.JPG","galleries_id":189862,"server_id":5,"link":"photo_3099688.html","width":130,"caption":"Chicken & ham pie . Lena Björck","height":151});
															thumbnails[3968573] = clik.newPhoto({"id":3968573,"src":"38_thumb.JPG","galleries_id":190099,"server_id":5,"link":"photo_3968573.html","width":130,"caption":"","height":179});
															thumbnails[3094780] = clik.newPhoto({"id":3094780,"src":"(114)_thumb.jpg","galleries_id":189862,"server_id":5,"link":"photo_3094780.html","width":130,"caption":"Double vanilla cupcake","height":195});
															thumbnails[3098862] = clik.newPhoto({"id":3098862,"src":"121_thumb.jpg","galleries_id":189330,"server_id":5,"link":"photo_3098862.html","width":130,"caption":"Jo","height":98});
															thumbnails[3099006] = clik.newPhoto({"id":3099006,"src":"_MG_2341_thumb.jpg","galleries_id":189331,"server_id":5,"link":"photo_3099006.html","width":130,"caption":"Country Kitchen in Arundel, West Sussex","height":87});
															thumbnails[3099636] = clik.newPhoto({"id":3099636,"src":"(544)_thumb.JPG","galleries_id":190126,"server_id":5,"link":"photo_3099636.html","width":130,"caption":"The Gold Cup . Veuve Clicquot Gold Cup polo finals","height":93});
															thumbnails[3099648] = clik.newPhoto({"id":3099648,"src":"(176)_thumb.jpg","galleries_id":189863,"server_id":5,"link":"photo_3099648.html","width":130,"caption":"Paradiso mineral water . Carniche Alps","height":129});
															thumbnails[3968575] = clik.newPhoto({"id":3968575,"src":"49_thumb.jpg","galleries_id":190099,"server_id":5,"link":"photo_3968575.html","width":130,"caption":"","height":96});
															thumbnails[3098751] = clik.newPhoto({"id":3098751,"src":"food_thumb.jpg","galleries_id":189862,"server_id":5,"link":"photo_3098751.html","width":130,"caption":"Fresh figs . Stockfood","height":130});
															thumbnails[3098997] = clik.newPhoto({"id":3098997,"src":"(144)_thumb.jpg","galleries_id":189331,"server_id":5,"link":"photo_3098997.html","width":130,"caption":"Villa Gallici . Aix en Provence","height":98});
															thumbnails[3099063] = clik.newPhoto({"id":3099063,"src":"(168)1_thumb.jpg","galleries_id":190126,"server_id":5,"link":"photo_3099063.html","width":130,"caption":"Örebro castle . Sweden","height":130});
															thumbnails[3099645] = clik.newPhoto({"id":3099645,"src":"(161)_thumb.jpg","galleries_id":189863,"server_id":5,"link":"photo_3099645.html","width":130,"caption":"Bottles of chardonnay . Louis Latour","height":103});
															thumbnails[3099665] = clik.newPhoto({"id":3099665,"src":"(107)2_thumb.jpg","galleries_id":189330,"server_id":5,"link":"photo_3099665.html","width":130,"caption":"Bruce","height":173});
															thumbnails[3968578] = clik.newPhoto({"id":3968578,"src":"wedding_intro_thumb.jpg","galleries_id":190099,"server_id":5,"link":"photo_3968578.html","width":130,"caption":"","height":130});
															thumbnails[3098749] = clik.newPhoto({"id":3098749,"src":"drink_thumb.jpg","galleries_id":189863,"server_id":5,"link":"photo_3098749.html","width":130,"caption":"Bombay Sapphire","height":130});
															thumbnails[3098989] = clik.newPhoto({"id":3098989,"src":"(212)_thumb.jpg","galleries_id":190126,"server_id":5,"link":"photo_3098989.html","width":130,"caption":"Victoria & Albert Museum . Rolls-Royce PLC \/ Inn or Out","height":173});
															thumbnails[3099014] = clik.newPhoto({"id":3099014,"src":"(108)4_thumb.jpg","galleries_id":189331,"server_id":5,"link":"photo_3099014.html","width":130,"caption":"Country property . Bath","height":96});
															thumbnails[3099687] = clik.newPhoto({"id":3099687,"src":"(314)_thumb.JPG","galleries_id":189862,"server_id":5,"link":"photo_3099687.html","width":130,"caption":"Caesar salad . Lena Björck","height":172});
															thumbnails[3968576] = clik.newPhoto({"id":3968576,"src":"50_thumb.jpg","galleries_id":190099,"server_id":5,"link":"photo_3968576.html","width":130,"caption":"","height":87});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  						galleries[472435] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"VIDEO SHOWREEL","link":"gallery_472435.html","maxRecords":0.0,"photoIDs":[8975972.0],"skipIndex":0,"section_code":"gallery","featured_images":8975972.0,"id":472435,"singleSection":false});				  						galleries[189330] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"PEOPLE","link":"gallery_189330.html","maxRecords":0.0,"photoIDs":[3130669.0,3098781.0,3094681.0,3098765.0,3098768.0,3098775.0,3098862.0,3099665.0],"skipIndex":0,"section_code":"gallery","featured_images":3098765.0,"id":189330,"singleSection":false});				  						galleries[189866] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"travel","link":"gallery_189866.html","maxRecords":0.0,"photoIDs":[3098740.0,3099347.0,3099349.0,3099367.0,3099368.0,3099370.0,3099378.0,3130626.0],"skipIndex":0,"section_code":"gallery","featured_images":3098740.0,"id":189866,"singleSection":false});				  						galleries[189331] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"LIFESTYLE","link":"gallery_189331.html","maxRecords":0.0,"photoIDs":[3098757.0,3098979.0,3099010.0,3098999.0,3099017.0,3099006.0,3098997.0,3099014.0],"skipIndex":0,"section_code":"gallery","featured_images":3098757.0,"id":189331,"singleSection":false});				  						galleries[189863] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"DRINK","link":"gallery_189863.html","maxRecords":0.0,"photoIDs":[3094676.0,3099658.0,3099661.0,3099662.0,3099655.0,3099648.0,3099645.0,3098749.0],"skipIndex":0,"section_code":"gallery","featured_images":3098749.0,"id":189863,"singleSection":false});				  						galleries[189862] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"FOOD","link":"gallery_189862.html","maxRecords":0.0,"photoIDs":[3130659.0,3094781.0,3099691.0,3099684.0,3099688.0,3094780.0,3098751.0,3099687.0],"skipIndex":0,"section_code":"gallery","featured_images":3098751.0,"id":189862,"singleSection":false});				  						galleries[190126] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"events","link":"gallery_190126.html","maxRecords":0.0,"photoIDs":[3098986.0,3099631.0,3099083.0,3099632.0,3099636.0,3099063.0,3098989.0],"skipIndex":0,"section_code":"gallery","featured_images":3099063.0,"id":190126,"singleSection":false});				  						galleries[190099] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Weddings","link":"gallery_190099.html","maxRecords":0.0,"photoIDs":[3968564.0,3968567.0,3968569.0,3968572.0,3968573.0,3968575.0,3968578.0,3968576.0],"skipIndex":0,"section_code":"gallery","featured_images":3968578.0,"id":190099,"singleSection":false});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[1] = '5919067,5919054,5919051,5916381,5916361,5916348,5916198,5916190,5687029';
imageSets[2] = '8975972,5919067,5919054,5919051,5916381,5916348,5916198,5916190,3098740,3098757,3098765,3968578,3099063,3098751,3098749';
imageSets[3] = '5916348,5687029';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 51:
		val = 'http://www12.clikpic.com/stevenmorris/images';
		break;
	}
		switch (server_id) {
		case 0:
		val = 'http://www.clikpic.com/stevenmorris/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/stevenmorris/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/stevenmorris/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/stevenmorris/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/stevenmorris/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/stevenmorris/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/stevenmorris/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/stevenmorris/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/stevenmorris/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/stevenmorris/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/stevenmorris/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/stevenmorris/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/stevenmorris/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/stevenmorris/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/stevenmorris/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/stevenmorris/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/stevenmorris/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/stevenmorris/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/stevenmorris/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/stevenmorris/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/stevenmorris/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/stevenmorris/images';
		break;
	}
		switch (server_id) {
		case 53:
		val = 'http://images.clikpic.com/stevenmorris/images';
		break;
	}
		switch (server_id) {
		case 52:
		val = 'http://tpc22/clikpic/stevenmorris/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/stevenmorris/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/stevenmorris/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 = 'Steven Morris: ' + 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="updateCartValue($(this.form).next(\'#paymentForm\')[0],this.form.payment_options_id.options[this.form.payment_options_id.options.selectedIndex].value); if(divShowing(\'paymentConfirm\')){fadeOut(\'paymentConfirm\', 3)};">';
		
		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">';
			temp += '	<input type="hidden" name="item_option" value="' + item_option + '">';
			temp += '	<input type="hidden" name="site" value="STEVENMORRIS">';
			temp += '	<input type="hidden" name="item_number" value="'+ this.id +'">';
			temp += '	<input type="hidden" name="quantity" value="1">';
						temp += '	<input value="Add to cart" id="paymentAddButton" class="button" onmouseover="this.className=\'buttonHi\'\;" onmouseout="this.className=\'button\'\;" type="Button">';
							temp += '	<input value="View cart" id="paymentViewButton" class="button" onmouseover="this.className=\'buttonHi\';" onmouseout="this.className=\'button\';" type="Button" onclick="javascript:window.location=\'cart.html\'">';
			temp += '</form>';
						temp += '<div class="clearing">&nbsp;</div>';
			temp += '<div id="confirmContainer">';
			temp += '<div id="paymentConfirm">Item added to cart</div>';
			temp += '</div>';
			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;
	}
}

			

