window.thumbnails = {};
															thumbnails[5676048] = clik.newPhoto({"id":5676048,"src":"welcome_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":87});
															thumbnails[5676130] = clik.newPhoto({"id":5676130,"src":"welcome2_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":73});
															thumbnails[5676399] = clik.newPhoto({"id":5676399,"src":"bio_thumb.JPG","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":87});
															thumbnails[6938812] = clik.newPhoto({"id":6938812,"src":"DSC_28901_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":86});
															thumbnails[8944661] = clik.newPhoto({"id":8944661,"src":"_DSC4330_thumb.jpg","galleries_id":319485,"server_id":5,"link":"photo_8944661.html","width":130,"caption":"secret message","height":98});
															thumbnails[9001583] = clik.newPhoto({"id":9001583,"src":"_DSC4313_thumb.jpg","galleries_id":319485,"server_id":5,"link":"photo_9001583.html","width":130,"caption":"siblings","height":86});
															thumbnails[8944656] = clik.newPhoto({"id":8944656,"src":"_DSC4232_thumb.jpg","galleries_id":319492,"server_id":5,"link":"photo_8944656.html","width":130,"caption":"richard bach","height":73});
															thumbnails[8944658] = clik.newPhoto({"id":8944658,"src":"_DSC4244_thumb.jpg","galleries_id":319485,"server_id":5,"link":"photo_8944658.html","width":130,"caption":"in haven","height":87});
															thumbnails[8697521] = clik.newPhoto({"id":8697521,"src":"molina_thumb.jpg","galleries_id":407888,"server_id":5,"link":"photo_8697521.html","width":130,"caption":"faint","height":86});
															thumbnails[8555080] = clik.newPhoto({"id":8555080,"src":"test-giglio_thumb.jpg","galleries_id":319485,"server_id":5,"link":"photo_8555080.html","width":130,"caption":"a mirror for the sun","height":73});
															thumbnails[8555082] = clik.newPhoto({"id":8555082,"src":"_DSC4147_thumb.jpg","galleries_id":319485,"server_id":5,"link":"photo_8555082.html","width":130,"caption":"deep end","height":87});
															thumbnails[8555087] = clik.newPhoto({"id":8555087,"src":"silent_thumb.jpg","galleries_id":319492,"server_id":5,"link":"photo_8555087.html","width":130,"caption":"wept herself to sleep","height":73});
															thumbnails[8555089] = clik.newPhoto({"id":8555089,"src":"rivers_thumb.jpg","galleries_id":319492,"server_id":5,"link":"photo_8555089.html","width":130,"caption":"celestial rivers","height":73});
															thumbnails[7909714] = clik.newPhoto({"id":7909714,"src":"birth_fr_thumb.jpg","galleries_id":319492,"server_id":5,"link":"photo_7909714.html","width":130,"caption":"birth","height":98});
															thumbnails[7522093] = clik.newPhoto({"id":7522093,"src":"_DSC3824_thumb.jpg","galleries_id":319492,"server_id":5,"link":"photo_7522093.html","width":130,"caption":"reach out","height":195});
															thumbnails[7522091] = clik.newPhoto({"id":7522091,"src":"_DSC3705_thumb.jpg","galleries_id":319492,"server_id":5,"link":"photo_7522091.html","width":130,"caption":"voiceless words","height":86});
															thumbnails[8555015] = clik.newPhoto({"id":8555015,"src":"lio_tm_thumb.jpg","galleries_id":319485,"server_id":5,"link":"photo_8555015.html","width":130,"caption":"how it came undone","height":87});
															thumbnails[7522090] = clik.newPhoto({"id":7522090,"src":"DSC_3191_thumb.JPG","galleries_id":319484,"server_id":5,"link":"photo_7522090.html","width":130,"caption":"skylocked","height":86});
															thumbnails[6938687] = clik.newPhoto({"id":6938687,"src":"DSC_3154_thumb.jpg","galleries_id":319484,"server_id":5,"link":"photo_6938687.html","width":130,"caption":"the colours","height":86});
															thumbnails[6938711] = clik.newPhoto({"id":6938711,"src":"DSC_3174b_thumb.jpg","galleries_id":319484,"server_id":5,"link":"photo_6938711.html","width":130,"caption":"pollen dream","height":86});
															thumbnails[6938640] = clik.newPhoto({"id":6938640,"src":"DSC_3006_thumb.jpg","galleries_id":319492,"server_id":5,"link":"photo_6938640.html","width":130,"caption":"lizard's tail","height":86});
															thumbnails[6938675] = clik.newPhoto({"id":6938675,"src":"DSC_2976_thumb.jpg","galleries_id":319484,"server_id":5,"link":"photo_6938675.html","width":130,"caption":"after the rain","height":86});
															thumbnails[6938635] = clik.newPhoto({"id":6938635,"src":"DSC_2890_thumb.jpg","galleries_id":319492,"server_id":5,"link":"photo_6938635.html","width":130,"caption":"remembrance","height":86});
															thumbnails[6938645] = clik.newPhoto({"id":6938645,"src":"DSC_2843_thumb.jpg","galleries_id":319484,"server_id":5,"link":"photo_6938645.html","width":130,"caption":"einsam","height":87});
															thumbnails[6938647] = clik.newPhoto({"id":6938647,"src":"DSC_2851_thumb.jpg","galleries_id":319484,"server_id":5,"link":"photo_6938647.html","width":130,"caption":"ephemeral","height":86});
															thumbnails[6938649] = clik.newPhoto({"id":6938649,"src":"DSC_2859_thumb.jpg","galleries_id":319484,"server_id":5,"link":"photo_6938649.html","width":130,"caption":"ye olde world","height":87});
															thumbnails[5782631] = clik.newPhoto({"id":5782631,"src":"DSC_2403c_thumb.jpg","galleries_id":319485,"server_id":5,"link":"photo_5782631.html","width":130,"caption":"douglas's broken arm","height":86});
															thumbnails[5782619] = clik.newPhoto({"id":5782619,"src":"DSC_2487c_thumb.jpg","galleries_id":319492,"server_id":5,"link":"photo_5782619.html","width":130,"caption":"mono no aware","height":73});
															thumbnails[5782608] = clik.newPhoto({"id":5782608,"src":"DSC_2542c_thumb.jpg","galleries_id":319484,"server_id":5,"link":"photo_5782608.html","width":130,"caption":"for vic","height":86});
															thumbnails[7522123] = clik.newPhoto({"id":7522123,"src":"_DSC3844_thumb.jpg","galleries_id":407888,"server_id":5,"link":"photo_7522123.html","width":130,"caption":"fall gently","height":86});
															thumbnails[5634302] = clik.newPhoto({"id":5634302,"src":"001_thumb.jpg","galleries_id":319484,"server_id":5,"link":"photo_5634302.html","width":130,"caption":"out of the blue","height":73});
															thumbnails[7522102] = clik.newPhoto({"id":7522102,"src":"_DSC3840_thumb.jpg","galleries_id":407888,"server_id":5,"link":"photo_7522102.html","width":130,"caption":"violently, delicately","height":98});
															thumbnails[5634309] = clik.newPhoto({"id":5634309,"src":"002_thumb.jpg","galleries_id":319484,"server_id":5,"link":"photo_5634309.html","width":130,"caption":"november 6th 2009","height":87});
															thumbnails[7522134] = clik.newPhoto({"id":7522134,"src":"_DSC3843_thumb.jpg","galleries_id":407888,"server_id":5,"link":"photo_7522134.html","width":130,"caption":"winter reverse","height":86});
															thumbnails[5634314] = clik.newPhoto({"id":5634314,"src":"003_thumb.jpg","galleries_id":319484,"server_id":5,"link":"photo_5634314.html","width":130,"caption":"ray of light","height":73});
															thumbnails[5634352] = clik.newPhoto({"id":5634352,"src":"004_thumb.jpg","galleries_id":319484,"server_id":5,"link":"photo_5634352.html","width":130,"caption":"ascensional","height":73});
															thumbnails[5634358] = clik.newPhoto({"id":5634358,"src":"005_thumb.jpg","galleries_id":319484,"server_id":5,"link":"photo_5634358.html","width":130,"caption":"a vision","height":80});
															thumbnails[5634360] = clik.newPhoto({"id":5634360,"src":"006_thumb.jpg","galleries_id":319484,"server_id":5,"link":"photo_5634360.html","width":130,"caption":"another vision","height":86});
															thumbnails[5634363] = clik.newPhoto({"id":5634363,"src":"007_thumb.jpg","galleries_id":319484,"server_id":5,"link":"photo_5634363.html","width":130,"caption":"cloudiness","height":87});
															thumbnails[5634418] = clik.newPhoto({"id":5634418,"src":"008_thumb.jpg","galleries_id":319484,"server_id":5,"link":"photo_5634418.html","width":130,"caption":"impressione","height":86});
															thumbnails[5634438] = clik.newPhoto({"id":5634438,"src":"009_thumb.jpg","galleries_id":319484,"server_id":5,"link":"photo_5634438.html","width":130,"caption":"revelation","height":86});
															thumbnails[5634460] = clik.newPhoto({"id":5634460,"src":"010_thumb.jpg","galleries_id":319484,"server_id":5,"link":"photo_5634460.html","width":130,"caption":"wake","height":73});
															thumbnails[5634467] = clik.newPhoto({"id":5634467,"src":"011_thumb.jpg","galleries_id":319484,"server_id":5,"link":"photo_5634467.html","width":130,"caption":"morning: mourning","height":87});
															thumbnails[5635076] = clik.newPhoto({"id":5635076,"src":"012_thumb.jpg","galleries_id":319485,"server_id":5,"link":"photo_5635076.html","width":130,"caption":"shipwreck","height":86});
															thumbnails[5635077] = clik.newPhoto({"id":5635077,"src":"013_thumb.jpg","galleries_id":319485,"server_id":5,"link":"photo_5635077.html","width":130,"caption":"twilight","height":87});
															thumbnails[5635080] = clik.newPhoto({"id":5635080,"src":"014_thumb.jpg","galleries_id":319485,"server_id":5,"link":"photo_5635080.html","width":130,"caption":"all is still","height":73});
															thumbnails[5635091] = clik.newPhoto({"id":5635091,"src":"015_thumb.jpg","galleries_id":319485,"server_id":5,"link":"photo_5635091.html","width":130,"caption":"magic door","height":87});
															thumbnails[5635094] = clik.newPhoto({"id":5635094,"src":"016_thumb.jpg","galleries_id":319485,"server_id":5,"link":"photo_5635094.html","width":130,"caption":"cotton path","height":86});
															thumbnails[5635108] = clik.newPhoto({"id":5635108,"src":"017_thumb.jpg","galleries_id":319485,"server_id":5,"link":"photo_5635108.html","width":130,"caption":"yonder","height":86});
															thumbnails[5635133] = clik.newPhoto({"id":5635133,"src":"018_thumb.jpg","galleries_id":319485,"server_id":5,"link":"photo_5635133.html","width":130,"caption":"altocumuli","height":73});
															thumbnails[5635138] = clik.newPhoto({"id":5635138,"src":"019_thumb.jpg","galleries_id":319485,"server_id":5,"link":"photo_5635138.html","width":130,"caption":"plunge","height":73});
															thumbnails[5635141] = clik.newPhoto({"id":5635141,"src":"020_thumb.jpg","galleries_id":319485,"server_id":5,"link":"photo_5635141.html","width":130,"caption":"gabriel's conjecture","height":98});
															thumbnails[5635144] = clik.newPhoto({"id":5635144,"src":"021_thumb.jpg","galleries_id":319485,"server_id":5,"link":"photo_5635144.html","width":130,"caption":"this sadness","height":73});
															thumbnails[5635149] = clik.newPhoto({"id":5635149,"src":"022_thumb.jpg","galleries_id":319485,"server_id":5,"link":"photo_5635149.html","width":130,"caption":"faro","height":86});
															thumbnails[5635155] = clik.newPhoto({"id":5635155,"src":"023_thumb.jpg","galleries_id":319485,"server_id":5,"link":"photo_5635155.html","width":130,"caption":"restlessness","height":73});
															thumbnails[5635159] = clik.newPhoto({"id":5635159,"src":"024_thumb.jpg","galleries_id":319485,"server_id":5,"link":"photo_5635159.html","width":130,"caption":"pastel","height":87});
															thumbnails[5635265] = clik.newPhoto({"id":5635265,"src":"025_thumb.jpg","galleries_id":319492,"server_id":5,"link":"photo_5635265.html","width":130,"caption":"dim echo from the silentscape","height":73});
															thumbnails[5635270] = clik.newPhoto({"id":5635270,"src":"026_thumb.jpg","galleries_id":319492,"server_id":5,"link":"photo_5635270.html","width":130,"caption":"float","height":87});
															thumbnails[5635277] = clik.newPhoto({"id":5635277,"src":"027_thumb.jpg","galleries_id":319492,"server_id":5,"link":"photo_5635277.html","width":130,"caption":"polar","height":87});
															thumbnails[5635279] = clik.newPhoto({"id":5635279,"src":"028_thumb.jpg","galleries_id":319492,"server_id":5,"link":"photo_5635279.html","width":130,"caption":"cocoon","height":98});
															thumbnails[5635290] = clik.newPhoto({"id":5635290,"src":"0291_thumb.jpg","galleries_id":319492,"server_id":5,"link":"photo_5635290.html","width":130,"caption":"oro","height":87});
															thumbnails[5635296] = clik.newPhoto({"id":5635296,"src":"030_thumb.jpg","galleries_id":319492,"server_id":5,"link":"photo_5635296.html","width":130,"caption":"watermark","height":86});
															thumbnails[5635306] = clik.newPhoto({"id":5635306,"src":"030_2_thumb.jpg","galleries_id":319492,"server_id":5,"link":"photo_5635306.html","width":130,"caption":"from a window","height":86});
															thumbnails[5635319] = clik.newPhoto({"id":5635319,"src":"031_thumb.jpg","galleries_id":319492,"server_id":5,"link":"photo_5635319.html","width":130,"caption":"enchanted forest","height":195});
															thumbnails[5635362] = clik.newPhoto({"id":5635362,"src":"034_thumb.jpg","galleries_id":319492,"server_id":5,"link":"photo_5635362.html","width":130,"caption":"leaving time","height":86});
															thumbnails[5635367] = clik.newPhoto({"id":5635367,"src":"035_thumb.jpg","galleries_id":319492,"server_id":5,"link":"photo_5635367.html","width":130,"caption":"overcast","height":86});
															thumbnails[5635467] = clik.newPhoto({"id":5635467,"src":"039_thumb.jpg","galleries_id":319492,"server_id":5,"link":"photo_5635467.html","width":130,"caption":"nostalgia","height":73});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  						galleries[319484] = clik.newGallery({"parentGallery":"","usePopups":true,"title":"Gallery 1: Nimbonaut","link":"gallery_319484.html","maxRecords":0.0,"photoIDs":[7522090.0,6938687.0,6938711.0,6938675.0,6938645.0,6938647.0,6938649.0,5782608.0,5634302.0,5634309.0,5634314.0,5634352.0,5634358.0,5634360.0,5634363.0,5634418.0,5634438.0,5634460.0,5634467.0],"skipIndex":0,"section_code":"gallery","featured_images":5634363.0,"id":319484,"singleSection":false});				  						galleries[319485] = clik.newGallery({"parentGallery":"","usePopups":true,"title":"Gallery 2: Imbarcadero","link":"gallery_319485.html","maxRecords":0.0,"photoIDs":[8944661.0,9001583.0,8944658.0,8555080.0,8555082.0,8555015.0,5782631.0,5635076.0,5635077.0,5635080.0,5635091.0,5635094.0,5635108.0,5635133.0,5635138.0,5635141.0,5635144.0,5635149.0,5635155.0,5635159.0],"skipIndex":0,"section_code":"gallery","featured_images":8555082.0,"id":319485,"singleSection":false});				  						galleries[319492] = clik.newGallery({"parentGallery":"","usePopups":true,"title":"Gallery 3: Dreamscaping","link":"gallery_319492.html","maxRecords":0.0,"photoIDs":[8944656.0,8555087.0,8555089.0,7909714.0,7522093.0,7522091.0,6938640.0,6938635.0,5782619.0,5635265.0,5635270.0,5635277.0,5635279.0,5635290.0,5635296.0,5635306.0,5635319.0,5635362.0,5635367.0,5635467.0],"skipIndex":0,"section_code":"gallery","featured_images":8555089.0,"id":319492,"singleSection":false});				  						galleries[407888] = clik.newGallery({"parentGallery":"","usePopups":true,"title":"Gallery 4: Dream of Thaw","link":"gallery_407888.html","maxRecords":0.0,"photoIDs":[8697521.0,7522123.0,7522102.0,7522134.0],"skipIndex":0,"section_code":"gallery","featured_images":7522123.0,"id":407888,"singleSection":false});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[1] = '5676130';
imageSets[2] = '8555089,8555082,7522123,5634363';
imageSets[3] = '6938812,5676399,5676130,5676048,5634302,5634309,5634314,5634352,5634358,5634360,5634363,5634418,5634438,5634460,5634467,5635076,5635080,5635091,5635094,5635108,5635133,5635138,5635141,5635144,5635149,5635155,5635159,5635265,5635270,5635277,5635279,5635290,5635296,5635306,5635319,5635362,5635367,5635467';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 51:
		val = 'http://www12.clikpic.com/valentiniphotography/images';
		break;
	}
		switch (server_id) {
		case 0:
		val = 'http://www.clikpic.com/valentiniphotography/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/valentiniphotography/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/valentiniphotography/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/valentiniphotography/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/valentiniphotography/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/valentiniphotography/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/valentiniphotography/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/valentiniphotography/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/valentiniphotography/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/valentiniphotography/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/valentiniphotography/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/valentiniphotography/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/valentiniphotography/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/valentiniphotography/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/valentiniphotography/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/valentiniphotography/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/valentiniphotography/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/valentiniphotography/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/valentiniphotography/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/valentiniphotography/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/valentiniphotography/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/valentiniphotography/images';
		break;
	}
		switch (server_id) {
		case 53:
		val = 'http://images.clikpic.com/valentiniphotography/images';
		break;
	}
		switch (server_id) {
		case 52:
		val = 'http://tpc22/clikpic/valentiniphotography/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/valentiniphotography/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/valentiniphotography/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 = 'Luca Valentini Dreamscape Photography: ' + 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.item_price !== '') {
			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;
	}
}

			

