window.thumbnails = {};
															thumbnails[3317196] = clik.newPhoto({"id":3317196,"src":"Joy_thumb.JPG","galleries_id":"","server_id":32,"link":"#","width":130,"caption":"Joy","height":113});
															thumbnails[2050763] = clik.newPhoto({"id":2050763,"src":"Banengo_thumb.jpg","galleries_id":201457,"server_id":32,"link":"photo_2050763.html","width":130,"caption":"Banengo","height":102});
															thumbnails[2050767] = clik.newPhoto({"id":2050767,"src":"Conemarra_thumb.JPG","galleries_id":304069,"server_id":32,"link":"photo_2050767.html","width":130,"caption":"Boggy Landscape, Joyce's Country, Ireland","height":109});
															thumbnails[2050768] = clik.newPhoto({"id":2050768,"src":"MountainsandseaWIreland_thumb.JPG","galleries_id":304071,"server_id":32,"link":"photo_2050768.html","width":130,"caption":"Mountains and Sea Western Ireland","height":86});
															thumbnails[2050810] = clik.newPhoto({"id":2050810,"src":"StormoverthePyrenees_thumb.JPG","galleries_id":304068,"server_id":32,"link":"photo_2050810.html","width":130,"caption":"Storm over the Pyrenees","height":87});
															thumbnails[2050814] = clik.newPhoto({"id":2050814,"src":"RockybeachWesternIreland_thumb.JPG","galleries_id":304071,"server_id":32,"link":"photo_2050814.html","width":130,"caption":"Rocky Beach West Ireland","height":131});
															thumbnails[2050816] = clik.newPhoto({"id":2050816,"src":"Langhe_thumb.JPG","galleries_id":304069,"server_id":32,"link":"photo_2050816.html","width":130,"caption":"Langhe 4 ","height":93});
															thumbnails[2050824] = clik.newPhoto({"id":2050824,"src":"Langhe3_thumb.JPG","galleries_id":304069,"server_id":32,"link":"photo_2050824.html","width":130,"caption":"Langhe 3","height":130});
															thumbnails[2050825] = clik.newPhoto({"id":2050825,"src":"Langhe4_thumb.JPG","galleries_id":304069,"server_id":32,"link":"photo_2050825.html","width":130,"caption":"Langhe 1","height":94});
															thumbnails[2050830] = clik.newPhoto({"id":2050830,"src":"PenPonds_thumb.JPG","galleries_id":304069,"server_id":32,"link":"photo_2050830.html","width":130,"caption":"Pen Ponds, Richmond Park ","height":96});
															thumbnails[2050844] = clik.newPhoto({"id":2050844,"src":"SuffolkMarshes2_thumb.jpg","galleries_id":304069,"server_id":32,"link":"photo_2050844.html","width":130,"caption":"Suffolk Marshes","height":100});
															thumbnails[2050853] = clik.newPhoto({"id":2050853,"src":"TheOldManofStorr_thumb.JPG","galleries_id":304069,"server_id":32,"link":"photo_2050853.html","width":130,"caption":"The Old Man of Storr","height":97});
															thumbnails[2063793] = clik.newPhoto({"id":2063793,"src":"Joyce's Country1_thumb.JPG","galleries_id":201457,"server_id":32,"link":"photo_2063793.html","width":130,"caption":"Joyce's Country, Connemara","height":131});
															thumbnails[2063799] = clik.newPhoto({"id":2063799,"src":"Piova_Massaia_2_thumb.jpg","galleries_id":304069,"server_id":32,"link":"photo_2063799.html","width":130,"caption":"Piova Massaia","height":104});
															thumbnails[2063800] = clik.newPhoto({"id":2063800,"src":"Pyrenees storm1_thumb.JPG","galleries_id":304068,"server_id":32,"link":"photo_2063800.html","width":130,"caption":"Storm, Pyrenees","height":131});
															thumbnails[2063802] = clik.newPhoto({"id":2063802,"src":"Skye Outcrop1_thumb.JPG","galleries_id":201457,"server_id":32,"link":"photo_2063802.html","width":130,"caption":"Rocky Outcrop, Skye","height":130});
															thumbnails[2063811] = clik.newPhoto({"id":2063811,"src":"Tall Trees1_thumb.JPG","galleries_id":201457,"server_id":32,"link":"photo_2063811.html","width":130,"caption":"Tall Trees","height":108});
															thumbnails[2063813] = clik.newPhoto({"id":2063813,"src":"Tuffo Church1_thumb.JPG","galleries_id":201457,"server_id":32,"link":"photo_2063813.html","width":130,"caption":"Tuffo Church","height":128});
															thumbnails[3282902] = clik.newPhoto({"id":3282902,"src":"Verde d'estate 2_thumb.jpg","galleries_id":201457,"server_id":32,"link":"photo_3282902.html","width":130,"caption":"Summer Green 2","height":131});
															thumbnails[3310337] = clik.newPhoto({"id":3310337,"src":"Storm over Mull 3_thumb.JPG","galleries_id":304071,"server_id":32,"link":"photo_3310337.html","width":130,"caption":"Storm Over Mull 3","height":102});
															thumbnails[3314288] = clik.newPhoto({"id":3314288,"src":"Cocconato_thumb.jpg","galleries_id":201457,"server_id":32,"link":"photo_3314288.html","width":130,"caption":"Cocconato","height":106});
															thumbnails[3314291] = clik.newPhoto({"id":3314291,"src":"Collina pioggerellina vicino a Brozolo_thumb.jpg","galleries_id":201457,"server_id":32,"link":"photo_3314291.html","width":130,"caption":"Misty hills near Brozolo","height":130});
															thumbnails[3314293] = clik.newPhoto({"id":3314293,"src":"Inishboffin2_thumb.JPG","galleries_id":201457,"server_id":32,"link":"photo_3314293.html","width":130,"caption":"Inishboffin","height":128});
															thumbnails[3314317] = clik.newPhoto({"id":3314317,"src":"La Strada a Cocconato_thumb.jpg","galleries_id":201457,"server_id":32,"link":"photo_3314317.html","width":130,"caption":"The Road to Cocconato","height":130});
															thumbnails[3314366] = clik.newPhoto({"id":3314366,"src":"Montagnevicino Argentera_thumb.JPG","galleries_id":304068,"server_id":32,"link":"photo_3314366.html","width":130,"caption":"Mountains near Argentera","height":103});
															thumbnails[3314497] = clik.newPhoto({"id":3314497,"src":"valle chissone 1_thumb.JPG","galleries_id":304068,"server_id":32,"link":"photo_3314497.html","width":130,"caption":"Valle Chisone 1","height":107});
															thumbnails[3314550] = clik.newPhoto({"id":3314550,"src":"valle chissone 3_thumb.jpg","galleries_id":304068,"server_id":32,"link":"photo_3314550.html","width":130,"caption":"Valle Chisone 3","height":105});
															thumbnails[3314553] = clik.newPhoto({"id":3314553,"src":"valle chissone 4_thumb.jpg","galleries_id":304068,"server_id":32,"link":"photo_3314553.html","width":130,"caption":"Valle Chisone 4","height":103});
															thumbnails[3314565] = clik.newPhoto({"id":3314565,"src":"Robella_thumb.jpg","galleries_id":304069,"server_id":32,"link":"photo_3314565.html","width":130,"caption":"Robella","height":103});
															thumbnails[3314575] = clik.newPhoto({"id":3314575,"src":"Banengo tramonto_thumb.jpg","galleries_id":304069,"server_id":32,"link":"photo_3314575.html","width":130,"caption":"Sunset over Banengo","height":106});
															thumbnails[5389619] = clik.newPhoto({"id":5389619,"src":"Banengo_Nella_Neve_thumb.jpg","galleries_id":201457,"server_id":32,"link":"photo_5389619.html","width":130,"caption":"Banengo Nella Nevica","height":128});
															thumbnails[5389681] = clik.newPhoto({"id":5389681,"src":"Lo_Albero_Nella_Neve_thumb.jpg","galleries_id":304069,"server_id":32,"link":"photo_5389681.html","width":130,"caption":"The Tree in the Snow","height":128});
															thumbnails[5389691] = clik.newPhoto({"id":5389691,"src":"Monferrato__Verde_thumb.jpg","galleries_id":304069,"server_id":32,"link":"photo_5389691.html","width":130,"caption":"Yellow Trees","height":129});
															thumbnails[5389731] = clik.newPhoto({"id":5389731,"src":"Monferrato_Tramonte_dEstate_thumb.jpg","galleries_id":201457,"server_id":32,"link":"photo_5389731.html","width":130,"caption":"Tramonte, Monferrato","height":132});
															thumbnails[5389733] = clik.newPhoto({"id":5389733,"src":"Montiglio_2_thumb.jpg","galleries_id":201457,"server_id":32,"link":"photo_5389733.html","width":130,"caption":"Montiglio","height":131});
															thumbnails[5389736] = clik.newPhoto({"id":5389736,"src":"Piova_Massaia_Nevicata_thumb.jpg","galleries_id":201457,"server_id":32,"link":"photo_5389736.html","width":130,"caption":"Piova Massaia Nevicata","height":128});
															thumbnails[5389750] = clik.newPhoto({"id":5389750,"src":"scarpata_di_tufo_1_thumb.jpg","galleries_id":304070,"server_id":32,"link":"photo_5389750.html","width":130,"caption":"Scarpata di Tufo 4","height":131});
															thumbnails[5389763] = clik.newPhoto({"id":5389763,"src":"Tuffo_Church_3_thumb.jpg","galleries_id":304069,"server_id":32,"link":"photo_5389763.html","width":130,"caption":"Tuffo Church 3","height":132});
															thumbnails[5389783] = clik.newPhoto({"id":5389783,"src":"Twelve_Pins_Joyce_Country_thumb.JPG","galleries_id":201457,"server_id":32,"link":"photo_5389783.html","width":130,"caption":"Twelve Pins, Joyc's Country","height":131});
															thumbnails[5389804] = clik.newPhoto({"id":5389804,"src":"verde_destate_5_thumb.jpg","galleries_id":304070,"server_id":32,"link":"photo_5389804.html","width":130,"caption":"Summer Green 5","height":128});
															thumbnails[5389811] = clik.newPhoto({"id":5389811,"src":"Verde_destate_6_thumb.jpg","galleries_id":304070,"server_id":32,"link":"photo_5389811.html","width":130,"caption":"Summer Green 6","height":129});
															thumbnails[7390294] = clik.newPhoto({"id":7390294,"src":"Val_di_Lanzo_thumb.jpg","galleries_id":304068,"server_id":32,"link":"photo_7390294.html","width":130,"caption":"Val di Lanzo","height":126});
															thumbnails[7391285] = clik.newPhoto({"id":7391285,"src":"Barbaresco_Invernale_thumb.jpg","galleries_id":304069,"server_id":32,"link":"photo_7391285.html","width":130,"caption":"Barbaresco in Winter","height":131});
															thumbnails[7414323] = clik.newPhoto({"id":7414323,"src":"Chiesa_di_Tuffo_4_thumb.jpg","galleries_id":304069,"server_id":32,"link":"photo_7414323.html","width":130,"caption":"Tuffo Church 4","height":128});
															thumbnails[7414353] = clik.newPhoto({"id":7414353,"src":"Padana_Pianura_thumb.jpg","galleries_id":304069,"server_id":32,"link":"photo_7414353.html","width":130,"caption":"Pianura Padana","height":102});
															thumbnails[7450740] = clik.newPhoto({"id":7450740,"src":"Gli_Olivi_thumb.jpg","galleries_id":304069,"server_id":32,"link":"photo_7450740.html","width":130,"caption":"The Olive Trees","height":107});
															thumbnails[7450749] = clik.newPhoto({"id":7450749,"src":"Muresengo_2_thumb.jpg","galleries_id":304069,"server_id":32,"link":"photo_7450749.html","width":130,"caption":"Muresengo 2","height":131});
															thumbnails[7450755] = clik.newPhoto({"id":7450755,"src":"San_Antonio_Monferrato_thumb.jpg","galleries_id":304069,"server_id":32,"link":"photo_7450755.html","width":130,"caption":"San Antonio Monferrato","height":96});
															thumbnails[7450757] = clik.newPhoto({"id":7450757,"src":"Scandeluzza_thumb.jpg","galleries_id":304069,"server_id":32,"link":"photo_7450757.html","width":130,"caption":"Scandeluzza Monferrato","height":96});
															thumbnails[7450758] = clik.newPhoto({"id":7450758,"src":"Chiesa_di_Tuffo_w_colour_thumb.jpg","galleries_id":304069,"server_id":32,"link":"photo_7450758.html","width":130,"caption":"Tuffo Church","height":111});
															thumbnails[7450759] = clik.newPhoto({"id":7450759,"src":"La_Chiesa_nelle_Colline_Monferrate__3_w_colour_thumb.jpg","galleries_id":304069,"server_id":32,"link":"photo_7450759.html","width":130,"caption":"The Church in the Monferrato Hills 3 ","height":95});
															thumbnails[7450760] = clik.newPhoto({"id":7450760,"src":"La_Chiesa_nelle_Colline_Monferrate2_w_colour_thumb.jpg","galleries_id":304069,"server_id":32,"link":"photo_7450760.html","width":130,"caption":"The Church in the Monferrato Hills 2 ","height":88});
															thumbnails[7450763] = clik.newPhoto({"id":7450763,"src":"La_Chiesa_nelle_Colline_Monferrate2_w_colour1_thumb.jpg","galleries_id":304069,"server_id":32,"link":"photo_7450763.html","width":130,"caption":"The Church in the Monferrato Hills  ","height":88});
															thumbnails[7450767] = clik.newPhoto({"id":7450767,"src":"Verso_Bra_da_Cherasco_w_colour_thumb.jpg","galleries_id":304069,"server_id":32,"link":"photo_7450767.html","width":130,"caption":"Towards Bra from Cherasco","height":92});
															thumbnails[7450801] = clik.newPhoto({"id":7450801,"src":"poppies_2_thumb.jpg","galleries_id":304070,"server_id":32,"link":"photo_7450801.html","width":130,"caption":"Hedgerow with Poppies 2","height":92});
															thumbnails[7450872] = clik.newPhoto({"id":7450872,"src":"scarpata_di_tufo_5_thumb.jpg","galleries_id":304070,"server_id":32,"link":"photo_7450872.html","width":130,"caption":"Scarpata di Tufo 5","height":133});
															thumbnails[7450874] = clik.newPhoto({"id":7450874,"src":"Vite_Verde_thumb.jpg","galleries_id":304070,"server_id":32,"link":"photo_7450874.html","width":130,"caption":"Green Vines","height":131});
															thumbnails[7450875] = clik.newPhoto({"id":7450875,"src":"Siepe_destate_3_thumb.jpg","galleries_id":304070,"server_id":32,"link":"photo_7450875.html","width":130,"caption":"Summer Hedgerow 3","height":132});
															thumbnails[7482264] = clik.newPhoto({"id":7482264,"src":"Siepe_destate_con_fiori_bianchi_thumb.jpg","galleries_id":304070,"server_id":32,"link":"photo_7482264.html","width":130,"caption":"Summer Hedgerow with White Flowers","height":131});
															thumbnails[7482280] = clik.newPhoto({"id":7482280,"src":"Vite_Rosso_1_thumb.jpg","galleries_id":304070,"server_id":32,"link":"photo_7482280.html","width":130,"caption":"Red Grape Vines","height":132});
															thumbnails[7482285] = clik.newPhoto({"id":7482285,"src":"Paesaggio_vicino_di_Costigliole_dAsti_thumb.jpg","galleries_id":304069,"server_id":32,"link":"photo_7482285.html","width":130,"caption":"Landscape near Costigliole d’Asti","height":108});
															thumbnails[7482288] = clik.newPhoto({"id":7482288,"src":"Val_di_Lanzo_2_thumb.jpg","galleries_id":304069,"server_id":32,"link":"photo_7482288.html","width":130,"caption":"Val di Lanzo 2","height":130});
															thumbnails[2050807] = clik.newPhoto({"id":2050807,"src":"Kyle Beach_thumb.JPG","galleries_id":304071,"server_id":32,"link":"photo_2050807.html","width":130,"caption":"Kyle Beach West Ireland","height":128});
															thumbnails[3314548] = clik.newPhoto({"id":3314548,"src":"valle chissone 2_thumb.JPG","galleries_id":304068,"server_id":32,"link":"photo_3314548.html","width":130,"caption":"Valle Chisone 2","height":107});
															thumbnails[5389637] = clik.newPhoto({"id":5389637,"src":"casa_vecchia_2_thumb.jpg","galleries_id":304069,"server_id":32,"link":"photo_5389637.html","width":130,"caption":"The Ruined House","height":130});
															thumbnails[5389670] = clik.newPhoto({"id":5389670,"src":"La_Capella_Nella_Neve_thumb.jpg","galleries_id":201457,"server_id":32,"link":"photo_5389670.html","width":130,"caption":"The Chapel in the Snow","height":131});
															thumbnails[5389739] = clik.newPhoto({"id":5389739,"src":"scarpata_di_tufo2_thumb.jpg","galleries_id":304070,"server_id":32,"link":"photo_5389739.html","width":130,"caption":"Scarpata di Tufo 3","height":128});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  						galleries[304069] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Landscapes","link":"gallery_304069.html","maxRecords":0.0,"photoIDs":[2050767.0,2050816.0,2050824.0,2050825.0,2050830.0,2050844.0,2050853.0,2063799.0,3314565.0,3314575.0,5389681.0,5389691.0,5389763.0,7391285.0,7414323.0,7414353.0,7450740.0,7450749.0,7450755.0,7450757.0,7450758.0,7450759.0,7450760.0,7450763.0,7450767.0,7482285.0,7482288.0,5389637.0],"skipIndex":0,"section_code":"gallery","featured_images":"5389637,2050853,2050830,2050767","id":304069,"singleSection":false});				  						galleries[304068] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Mountains","link":"gallery_304068.html","maxRecords":0.0,"photoIDs":[2050810.0,2063800.0,3314366.0,3314497.0,3314550.0,3314553.0,7390294.0,3314548.0],"skipIndex":0,"section_code":"gallery","featured_images":"3314548,2050810","id":304068,"singleSection":false});				  						galleries[304070] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Nature","link":"gallery_304070.html","maxRecords":0.0,"photoIDs":[5389750.0,5389804.0,5389811.0,7450801.0,7450872.0,7450874.0,7450875.0,7482264.0,7482280.0,5389739.0],"skipIndex":0,"section_code":"gallery","featured_images":5389739.0,"id":304070,"singleSection":false});				  						galleries[304071] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Seascapes","link":"gallery_304071.html","maxRecords":0.0,"photoIDs":[2050768.0,2050814.0,3310337.0,2050807.0],"skipIndex":0,"section_code":"gallery","featured_images":2050807.0,"id":304071,"singleSection":false});				  						galleries[201457] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Archives","link":"gallery_201457.html","maxRecords":0.0,"photoIDs":[2050763.0,2063793.0,2063802.0,2063811.0,2063813.0,3282902.0,3314288.0,3314291.0,3314293.0,3314317.0,5389619.0,5389731.0,5389733.0,5389736.0,5389783.0,5389670.0],"skipIndex":0,"section_code":"gallery","featured_images":"5389670,3282902","id":201457,"singleSection":false});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[1] = '2050763';
imageSets[2] = '3317196,3282902,2050853,2050830,2050810,2050767,5389670,5389637,3314548,2050807,5389739';
imageSets[3] = '3310337,2063800,2050853,2050844,2050830';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 51:
		val = 'www12.clikpic.com/joymoore/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/joymoore/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/joymoore/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/joymoore/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/joymoore/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/joymoore/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/joymoore/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/joymoore/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/joymoore/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/joymoore/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/joymoore/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/joymoore/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/joymoore/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/joymoore/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/joymoore/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/joymoore/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/joymoore/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/joymoore/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/joymoore/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/joymoore/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/joymoore/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/joymoore/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/joymoore/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/joymoore/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 = 'Joy Moore Paintings: ' + photoCaption;
			    }
        if (op.$detail.length > 0) {
      	temp = op.nextPhoto.fnGetImageDetails();
	    op.$detail.fadeGalleryDetails(temp, op.speed, function(){
			if (typeof(backgrounds) != 'undefined' && op.nextPhoto == backgrounds[op.nextPhoto.id]) {
				toggleAddToCartConfirm(backgrounds, op.$detail);
			} else if (typeof(photos) != 'undefined' && op.nextPhoto == photos[op.nextPhoto.id]) {
				toggleAddToCartConfirm(photos, op.$detail);
			}
			$('body').trigger('clikUpdate.popup');
	    });
    }
        $(op.$detailContainer).find('.replaceable[class*=replaceable_photo-]').each(function(){
    	var field = clik.getPrefixedClass(this.className, 'replaceable_photo-');
    	if (field in op.nextPhoto) {
    		$(this).fadeGalleryDetails(op.nextPhoto[field], op.speed);
    	}
    }).end().find('.replaceable.photoPayment').fadeGalleryDetails(op.nextPhoto.fnGetPaymentInfo(), op.speed, function(){
		if (typeof(backgrounds) != 'undefined' && op.nextPhoto == backgrounds[op.nextPhoto.id]) {
			toggleAddToCartConfirm(backgrounds, op.$detailContainer);
		} else if (typeof(photos) != 'undefined' && op.nextPhoto == photos[op.nextPhoto.id]) {
			toggleAddToCartConfirm(photos, op.$detailContainer);
		}
		$('body').trigger('clikUpdate.popup');
	});
		if (op.$photo.length > 0) {
		html = $('<img/>',{
			'class': 'mainphoto photo',
			src: photoSrc,
			id: 'mainPic',
			name: 'mainPic',
			width: op.nextPhoto.width,
			height: op.nextPhoto.height,
			alt: photoCaption,
			css: op.css || {}
		});
		if (op.href) {
			if (op.href.match(/<a/)) {
				html = $(op.href).append(html);
			} else {
				html = $('<a/>', {
					href: op.href,
					title: photoCaption
				}).append(html);
			}
		} else {
			html = $('<a/>', {
				title: photoCaption
			}).append(html);
		}
		if (op.speed == 0) {			op.$photo.html(html);			if (op.onBefore) {			  	op.onBefore.apply(op.$photo);			}			if (op.onAfter) {			  	op.onAfter.apply(op.$photo);			}		} else {			op.$photo.stop(true,true).fadeReplaceWith(html,op.speed,'',function(){  				if (op.onAfter) {				  	op.onAfter.apply(this);				}				clik.doColumnResize(false, $(this).add(op.$detail).add(op.$title));			}, op.onBefore);
		}	}
    if (op.field) {
		op.field.value = photoId;
	} else {
		op.$photo.data('image_id', photoId);
    }
        if (!op.speed) {
      	clik.doColumnResize(false, op.$photo.add(op.$detail).add(op.$title));
    }
        
    return html;
	}

/***************************************************************************
* Toggle add to cart confirmation element and set up the click event for   *
* the 'Add to cart' button.                                                *
***************************************************************************/
function toggleAddToCartConfirm(array, root){
	if (typeof(array) !== 'object' || array === null) {
	  	array = photos;
	}
	if (!$(root).length) {		root = $('body');	}	if($('#paymentConfirm', root).length > 0){
		$('#paymentConfirm', root).hide();
		$('#paymentAddButton', root)
		.unbind()
		.click(function(){
						form = $('#paymentForm', root)[0];
			option_id = 0;
			if(form.item_option.value){
				option_id = form.item_option.value;
			}
			if(addItemToBasket(form.item_number.value,array,form.site.value,parseInt(form.quantity.value, 10),option_id)){
				if($.browser.msie){$('#paymentConfirm', root).text('Item added to cart').show();}
				else{
					$('#paymentConfirm', root).text('Item added to cart').fadeIn();
					dspOrderDetails(form.site.value);
				}
			}
			else{
				$('#paymentConfirm', root).text('Item not added - check cookies are enabled in your browser.').fadeIn();
			}
		});
	}
}

/***************************************************************************
* Get payment info for image - add as 'method' to photo object             *
***************************************************************************/
clik.photo.fnGetImageDetails = function(){
	var temp = '';
	if (this.description != '') {
		temp +=  '<div id="imageDescription">' + this.description + '</div>';
	}
		if (this.photo_ref != '') {
		temp += '<div class="imageinfo" id="imageRef"><strong>Ref: </strong>' + this.photo_ref + '</div>';
	}
		if (this.takendate != '') {
		
		temp += '<div class="imageinfo" id="imageDate"><strong>Date: </strong>' + this.takendate + '</div>';
	}
	
	if (this.location != '') {
		
		temp += '<div class="imageinfo" id="imageLocation"><strong>Location: </strong>' +  this.location + '</div>';
	}
	
	if (this.photographer != '') {
		
		temp += '<div class="imageinfo" id="imagePhotographer"><strong>Photographer: </strong>' + this.photographer + '</div>';
	}
				
				if (temp != '') {
		temp += '<div class="spacer"></div>';
	}
	return temp;
};

/***************************************************************************
* Get payment info for image - add as 'method' to photo object             *
***************************************************************************/
clik.photo.fnGetPaymentInfo = function(){
	var temp = '';
	if (this.item_price !== '') {
				temp += '<p>Order this print:</p>';
				temp += '<div class="imageinfo" id="imagePrice"><strong>' + this.purchase_instruction + '</strong> ' + (this.item_price).toFixed(2) + '</div>';
		var item_name  = this.purchase_instruction;
		var amount = (this.item_price).toFixed(2);
		var item_option  = 0;
	}
	else if (this.payment_groups_id !== '') {
		temp += '<p>Buy this print online:</p>';
				temp += '<form id="paymentOptions" style="margin:0px;border:0px;" name="paymentOptions">';
											temp += '<select class="paymentlink" name="payment_options_id" onchange="updateItemValues($(this.form).next(\'#paymentForm\')[0],this.form.payment_options_id.options[this.form.payment_options_id.options.selectedIndex].value);">';
		
		temp += getPaymentOptions(this.payment_groups_id);
		temp += '</select>';
		temp += '</form>';
				var item_option  = paymentGroups[this.payment_groups_id].options[0];
		if(paymentOptions[item_option]){
			var item_name  = paymentOptions[item_option].payment_option;
			var amount =  paymentOptions[item_option].price;
		}
			}
	else {
		
	}
	if (this.item_price !== '' || this.payment_groups_id !== '') {
			temp += '<div class="clearing">&nbsp;</div>';
	}
	return temp;};

/***************************************************************************
* Pick a photo at random from the featured images of a gallery.            *
* Gallery_id = id of gallery to choose,                                    *
* img = reference to html image in                                         *
* which to show image                                                      *
***************************************************************************/
function showGalleryImage(gallery_id, img, updateLink) {
	
	if(img){
		if (location.hash.match('galleries_id=' + gallery_id) && (imageID = location.hash.match('.*photos_id=(.+)$'))) {
		  	imageID = imageID[1];
		} else {
		  	imageID = randomListVal(galleries[gallery_id].featured_images);
		}
		
		if (imageID != 0) {
			img.src = thumbnails[imageID].src;
			img.width = thumbnails[imageID].width;
			img.height = thumbnails[imageID].height;
			img.alt = galleries[gallery_id].title;
			if (updateLink) {
				$(img).parent().attr({					title: galleries[gallery_id].title				}).filter(function(){return this.href;}).attr({					href: thumbnails[imageID].fnGalleryLink(gallery_id)				});
			}
		}
	}
}

/***************************************************************************
* If we have dynamic HTML, replace the galleries link with a list that     *
* doesn't include thecurrent gallery                                       *
***************************************************************************/
function showGalleries(gallery_id) {
		
	
	if (!basic) {
		temp = '';
		for (i = 0; i < galleries.length; i++) {
						
			
			if (galleries[i].id != gallery_id) {
								
				if (temp != '') {
					temp += ' | ';
				}
								temp += '<a href="' + galleries[i].section_code + '_' + galleries[i].id + '.html">' + galleries[i].title + '</a>';
							}
		}
		document.all.galleryLinks.innerHTML = 'Other galleries: ' + temp;
	}
}

			

