window.thumbnails = {};
															thumbnails[2195954] = clik.newPhoto({"id":2195954,"src":"Rebecca-and-Thomas-20080517_thumb.jpg","galleries_id":145286,"server_id":1,"link":"photo_2195954.html","width":104,"caption":"","height":130});
															thumbnails[2196067] = clik.newPhoto({"id":2196067,"src":"Rebecca-and-Thomas-200805171_thumb.jpg","galleries_id":145286,"server_id":1,"link":"photo_2196067.html","width":104,"caption":"","height":130});
															thumbnails[2196198] = clik.newPhoto({"id":2196198,"src":"Rebecca-and-Thomas-200805173_thumb.jpg","galleries_id":145286,"server_id":1,"link":"photo_2196198.html","width":130,"caption":"","height":86});
															thumbnails[2196212] = clik.newPhoto({"id":2196212,"src":"Rebecca-and-Thomas-200805174_thumb.jpg","galleries_id":145286,"server_id":1,"link":"photo_2196212.html","width":104,"caption":"","height":130});
															thumbnails[2201235] = clik.newPhoto({"id":2201235,"src":"Rebecca-and-Thomas-200805175_thumb.jpg","galleries_id":145286,"server_id":1,"link":"photo_2201235.html","width":104,"caption":"","height":130});
															thumbnails[2201280] = clik.newPhoto({"id":2201280,"src":"Rebecca-and-Thomas-200805176_thumb.jpg","galleries_id":145286,"server_id":1,"link":"photo_2201280.html","width":104,"caption":"","height":130});
															thumbnails[2201449] = clik.newPhoto({"id":2201449,"src":"Rebecca-and-Thomas-200805178_thumb.jpg","galleries_id":145286,"server_id":1,"link":"photo_2201449.html","width":130,"caption":"","height":104});
															thumbnails[2226203] = clik.newPhoto({"id":2226203,"src":"Rebecca-and-Thomas-2008051711_thumb.jpg","galleries_id":145286,"server_id":1,"link":"photo_2226203.html","width":130,"caption":"","height":99});
															thumbnails[2226218] = clik.newPhoto({"id":2226218,"src":"Rebecca-and-Thomas-2008051712_thumb.jpg","galleries_id":145286,"server_id":1,"link":"photo_2226218.html","width":86,"caption":"","height":130});
															thumbnails[2508338] = clik.newPhoto({"id":2508338,"src":"WED_6795-Edit_thumb.jpg","galleries_id":160795,"server_id":1,"link":"photo_2508338.html","width":130,"caption":"","height":86});
															thumbnails[2508502] = clik.newPhoto({"id":2508502,"src":"WED_7199-Edit-2_thumb.jpg","galleries_id":160795,"server_id":1,"link":"photo_2508502.html","width":130,"caption":"","height":84});
															thumbnails[2508554] = clik.newPhoto({"id":2508554,"src":"WED_6415-Edit-Edit_thumb.jpg","galleries_id":160795,"server_id":1,"link":"photo_2508554.html","width":130,"caption":"","height":104});
															thumbnails[2509736] = clik.newPhoto({"id":2509736,"src":"WED_6592-Edit_thumb.jpg","galleries_id":160795,"server_id":1,"link":"photo_2509736.html","width":130,"caption":"","height":104});
															thumbnails[2509763] = clik.newPhoto({"id":2509763,"src":"WED_6804-Edit_thumb.jpg","galleries_id":160795,"server_id":1,"link":"photo_2509763.html","width":104,"caption":"","height":130});
															thumbnails[2509794] = clik.newPhoto({"id":2509794,"src":"WED_6875-Edit_thumb.jpg","galleries_id":160795,"server_id":1,"link":"photo_2509794.html","width":130,"caption":"","height":104});
															thumbnails[2513084] = clik.newPhoto({"id":2513084,"src":"WED_6851-Edit_thumb.jpg","galleries_id":160795,"server_id":1,"link":"photo_2513084.html","width":104,"caption":"","height":130});
															thumbnails[2513117] = clik.newPhoto({"id":2513117,"src":"WED_7269-Edit-Edit_thumb.jpg","galleries_id":160795,"server_id":1,"link":"photo_2513117.html","width":130,"caption":"","height":62});
															thumbnails[2513325] = clik.newPhoto({"id":2513325,"src":"WED_7280-Edit_thumb.jpg","galleries_id":160795,"server_id":1,"link":"photo_2513325.html","width":130,"caption":"","height":78});
															thumbnails[2962003] = clik.newPhoto({"id":2962003,"src":"David&Kate - 002_thumb.jpg","galleries_id":182453,"server_id":1,"link":"photo_2962003.html","width":86,"caption":"","height":130});
															thumbnails[4441049] = clik.newPhoto({"id":4441049,"src":"Jo_and_Pete_-_Facebook_-_012_thumb.jpg","galleries_id":255876,"server_id":1,"link":"photo_4441049.html","width":87,"caption":"","height":130});
															thumbnails[2962013] = clik.newPhoto({"id":2962013,"src":"David&Kate - 006_thumb.jpg","galleries_id":182453,"server_id":1,"link":"photo_2962013.html","width":86,"caption":"","height":130});
															thumbnails[4441051] = clik.newPhoto({"id":4441051,"src":"Jo_and_Pete_-_Facebook_-_002_thumb.jpg","galleries_id":255876,"server_id":1,"link":"photo_4441051.html","width":83,"caption":"","height":130});
															thumbnails[2962011] = clik.newPhoto({"id":2962011,"src":"David&Kate - 005_thumb.jpg","galleries_id":182453,"server_id":1,"link":"photo_2962011.html","width":86,"caption":"","height":130});
															thumbnails[4441053] = clik.newPhoto({"id":4441053,"src":"Jo_and_Pete_-_Facebook_-_003_thumb.jpg","galleries_id":255876,"server_id":1,"link":"photo_4441053.html","width":87,"caption":"","height":130});
															thumbnails[2962008] = clik.newPhoto({"id":2962008,"src":"David&Kate - 004_thumb.jpg","galleries_id":182453,"server_id":1,"link":"photo_2962008.html","width":86,"caption":"","height":130});
															thumbnails[4441057] = clik.newPhoto({"id":4441057,"src":"Jo_and_Pete_-_Facebook_-_005_thumb.jpg","galleries_id":255876,"server_id":1,"link":"photo_4441057.html","width":87,"caption":"","height":130});
															thumbnails[2962004] = clik.newPhoto({"id":2962004,"src":"David&Kate - 003_thumb.jpg","galleries_id":182453,"server_id":1,"link":"photo_2962004.html","width":86,"caption":"","height":130});
															thumbnails[4441071] = clik.newPhoto({"id":4441071,"src":"Jo_and_Pete_-_Facebook_-_007_thumb.jpg","galleries_id":255876,"server_id":1,"link":"photo_4441071.html","width":87,"caption":"","height":130});
															thumbnails[2962023] = clik.newPhoto({"id":2962023,"src":"David&Kate - 009_thumb.jpg","galleries_id":182453,"server_id":1,"link":"photo_2962023.html","width":86,"caption":"","height":130});
															thumbnails[4441073] = clik.newPhoto({"id":4441073,"src":"Jo_and_Pete_-_Facebook_-_010_thumb.jpg","galleries_id":255876,"server_id":1,"link":"photo_4441073.html","width":87,"caption":"","height":130});
															thumbnails[3425208] = clik.newPhoto({"id":3425208,"src":"Kerry and Chris - 013_thumb.jpg","galleries_id":209334,"server_id":1,"link":"photo_3425208.html","width":86,"caption":"","height":130});
															thumbnails[2962016] = clik.newPhoto({"id":2962016,"src":"David&Kate - 007_thumb.jpg","galleries_id":182453,"server_id":1,"link":"photo_2962016.html","width":130,"caption":"","height":86});
															thumbnails[4441075] = clik.newPhoto({"id":4441075,"src":"Jo_and_Pete_-_Facebook_-_011_thumb.jpg","galleries_id":255876,"server_id":1,"link":"photo_4441075.html","width":87,"caption":"","height":130});
															thumbnails[2961996] = clik.newPhoto({"id":2961996,"src":"David&Kate - 001_thumb.jpg","galleries_id":182453,"server_id":1,"link":"photo_2961996.html","width":130,"caption":"","height":86});
															thumbnails[3425064] = clik.newPhoto({"id":3425064,"src":"Kerry and Chris - 003_thumb.jpg","galleries_id":209334,"server_id":1,"link":"photo_3425064.html","width":130,"caption":"","height":86});
															thumbnails[2962061] = clik.newPhoto({"id":2962061,"src":"David&Kate - 011_thumb.jpg","galleries_id":182453,"server_id":1,"link":"photo_2962061.html","width":130,"caption":"","height":92});
															thumbnails[3425114] = clik.newPhoto({"id":3425114,"src":"Kerry and Chris - 006_thumb.jpg","galleries_id":209334,"server_id":1,"link":"photo_3425114.html","width":86,"caption":"","height":130});
															thumbnails[4441083] = clik.newPhoto({"id":4441083,"src":"Jo_and_Pete_-_Facebook_-_009_thumb.jpg","galleries_id":255876,"server_id":1,"link":"photo_4441083.html","width":87,"caption":"","height":130});
															thumbnails[4441084] = clik.newPhoto({"id":4441084,"src":"Jo_and_Pete_-_Facebook_-_013_thumb.jpg","galleries_id":255876,"server_id":1,"link":"photo_4441084.html","width":87,"caption":"","height":130});
															thumbnails[3425060] = clik.newPhoto({"id":3425060,"src":"Kerry and Chris - 001_thumb.jpg","galleries_id":209334,"server_id":1,"link":"photo_3425060.html","width":130,"caption":"","height":86});
															thumbnails[3425109] = clik.newPhoto({"id":3425109,"src":"Kerry and Chris - 005_thumb.jpg","galleries_id":209334,"server_id":1,"link":"photo_3425109.html","width":130,"caption":"","height":86});
															thumbnails[3425117] = clik.newPhoto({"id":3425117,"src":"Kerry and Chris - 007_thumb.jpg","galleries_id":209334,"server_id":1,"link":"photo_3425117.html","width":130,"caption":"","height":86});
															thumbnails[3425124] = clik.newPhoto({"id":3425124,"src":"Kerry and Chris - 009_thumb.jpg","galleries_id":209334,"server_id":1,"link":"photo_3425124.html","width":130,"caption":"","height":86});
															thumbnails[3425131] = clik.newPhoto({"id":3425131,"src":"Kerry and Chris - 010_thumb.jpg","galleries_id":209334,"server_id":1,"link":"photo_3425131.html","width":130,"caption":"","height":86});
															thumbnails[3425132] = clik.newPhoto({"id":3425132,"src":"Kerry and Chris - 011_thumb.jpg","galleries_id":209334,"server_id":1,"link":"photo_3425132.html","width":130,"caption":"","height":86});
															thumbnails[8587718] = clik.newPhoto({"id":8587718,"src":"20111008_194353_thumb.jpg","galleries_id":456685,"server_id":1,"link":"photo_8587718.html","width":88,"caption":"","height":130});
															thumbnails[8587721] = clik.newPhoto({"id":8587721,"src":"20111008_1834532_thumb.jpg","galleries_id":456685,"server_id":1,"link":"photo_8587721.html","width":88,"caption":"","height":130});
															thumbnails[8587724] = clik.newPhoto({"id":8587724,"src":"20111008_191540_thumb.jpg","galleries_id":456685,"server_id":1,"link":"photo_8587724.html","width":88,"caption":"","height":130});
															thumbnails[1661141] = clik.newPhoto({"id":1661141,"src":"Autumn Light_thumb.jpg","galleries_id":111969,"server_id":1,"link":"photo_1661141.html","width":104,"caption":"","height":130});
															thumbnails[1661146] = clik.newPhoto({"id":1661146,"src":"All Roads Lead To1_thumb.jpg","galleries_id":111969,"server_id":1,"link":"photo_1661146.html","width":130,"caption":"","height":104});
															thumbnails[1661148] = clik.newPhoto({"id":1661148,"src":"Autumn Steps_thumb.jpg","galleries_id":111969,"server_id":1,"link":"photo_1661148.html","width":104,"caption":"","height":130});
															thumbnails[1661152] = clik.newPhoto({"id":1661152,"src":"Central Park_thumb.jpg","galleries_id":111969,"server_id":1,"link":"photo_1661152.html","width":130,"caption":"","height":104});
															thumbnails[1661153] = clik.newPhoto({"id":1661153,"src":"Dreaming of the Sea_thumb.jpg","galleries_id":111969,"server_id":1,"link":"photo_1661153.html","width":130,"caption":"","height":104});
															thumbnails[1661155] = clik.newPhoto({"id":1661155,"src":"Landrover Safari_thumb.jpg","galleries_id":111969,"server_id":1,"link":"photo_1661155.html","width":130,"caption":"","height":104});
															thumbnails[1661159] = clik.newPhoto({"id":1661159,"src":"New York Sunset_thumb.jpg","galleries_id":112059,"server_id":1,"link":"photo_1661159.html","width":130,"caption":"","height":52});
															thumbnails[1661162] = clik.newPhoto({"id":1661162,"src":"Salzburg by Night_thumb.jpg","galleries_id":112059,"server_id":1,"link":"photo_1661162.html","width":130,"caption":"","height":52});
															thumbnails[1661163] = clik.newPhoto({"id":1661163,"src":"Yellow Cab_thumb.jpg","galleries_id":111969,"server_id":1,"link":"photo_1661163.html","width":130,"caption":"","height":104});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  						galleries[111969] = clik.newGallery({"parentGallery":"","usePopups":true,"title":"Landscapes","link":"section203525_111969.html","maxRecords":0.0,"photoIDs":[1661141.0,1661146.0,1661148.0,1661152.0,1661153.0,1661155.0,1661163.0],"skipIndex":0,"section_code":"section203525","featured_images":"1661163,1661155,1661153,1661152,1661148,1661146,1661141","id":111969,"singleSection":false});				  						galleries[112059] = clik.newGallery({"parentGallery":"","usePopups":true,"title":"Panoramas","link":"section203525_112059.html","maxRecords":0.0,"photoIDs":[1661159.0,1661162.0],"skipIndex":0,"section_code":"section203525","featured_images":"1661162,1661159","id":112059,"singleSection":false});				  						galleries[456685] = clik.newGallery({"parentGallery":"","usePopups":true,"title":"Photobooth","link":"section552729.html","maxRecords":0.0,"photoIDs":[8587718.0,8587721.0,8587724.0],"skipIndex":0,"section_code":"section552729","featured_images":"8587724,8587721,8587718","id":456685,"singleSection":true});				  						galleries[255876] = clik.newGallery({"parentGallery":"","usePopups":true,"title":"Jo and Peter","link":"Gallery_255876.html","maxRecords":0.0,"photoIDs":[4441049.0,4441051.0,4441053.0,4441057.0,4441071.0,4441073.0,4441075.0,4441083.0,4441084.0],"skipIndex":0,"section_code":"Gallery","featured_images":"4441084,4441083,4441049","id":255876,"singleSection":false});				  						galleries[209334] = clik.newGallery({"parentGallery":"","usePopups":true,"title":"Kerry and Chris","link":"Gallery_209334.html","maxRecords":0.0,"photoIDs":[3425208.0,3425064.0,3425114.0,3425060.0,3425109.0,3425117.0,3425124.0,3425131.0,3425132.0],"skipIndex":0,"section_code":"Gallery","featured_images":"3425208,3425132,3425131,3425124,3425117,3425114,3425109,3425064,3425060","id":209334,"singleSection":false});				  						galleries[182453] = clik.newGallery({"parentGallery":"","usePopups":true,"title":"Kate and David","link":"Gallery_182453.html","maxRecords":0.0,"photoIDs":[2962003.0,2962013.0,2962011.0,2962008.0,2962004.0,2962023.0,2962016.0,2961996.0,2962061.0],"skipIndex":0,"section_code":"Gallery","featured_images":"2962061,2962023,2962016,2962013,2962011,2962008,2962004,2962003,2961996","id":182453,"singleSection":false});				  						galleries[160795] = clik.newGallery({"parentGallery":"","usePopups":true,"title":"Isla and Ed","link":"Gallery_160795.html","maxRecords":0.0,"photoIDs":[2508338.0,2508502.0,2508554.0,2509736.0,2509763.0,2509794.0,2513084.0,2513117.0,2513325.0],"skipIndex":0,"section_code":"Gallery","featured_images":"2513325,2513117,2513084,2509794,2509763,2509736,2508554,2508502,2508338","id":160795,"singleSection":false});				  						galleries[145286] = clik.newGallery({"parentGallery":"","usePopups":true,"title":"Rebecca and Thomas","link":"Gallery_145286.html","maxRecords":0.0,"photoIDs":[2195954.0,2196067.0,2196198.0,2196212.0,2201235.0,2201280.0,2201449.0,2226203.0,2226218.0],"skipIndex":0,"section_code":"Gallery","featured_images":"2226218,2226203,2201449,2201280,2201235,2196212,2196198,2196067,2195954","id":145286,"singleSection":false});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[1] = '2513325,2513117,2513084,2509794,2509763,2509736,2508554,2508502,2508338,4441049,2962003,2962013,2962011,2962008,2962004,2962023,3425208,2962016,2961996,3425064,2962061,4441083,3425114,4441084,3425060,3425109,3425117,3425124,3425131,3425132';
imageSets[2] = '2513325,2513117,2513084,2509794,2509763,2509736,2508554,2508502,2508338,2226218,2226203,2201449,2201280,2201235,2196212,2196198,2196067,2195954,1661163,1661162,1661159,1661155,1661153,1661152,1661148,1661146,1661141,4441049,2962003,2962013,2962011,2962008,2962004,2962023,3425208,2962016,2961996,3425064,2962061,4441083,3425114,4441084,3425060,3425109,3425117,3425124,3425131,3425132';
imageSets[3] = '4441049,2962003,2962013,2962011,2962008,2962004,2962016,2961996,2962061,4441083,4441084';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 51:
		val = 'http://www12.clikpic.com/geoffwilkins/images';
		break;
	}
		switch (server_id) {
		case 0:
		val = 'http://www.clikpic.com/geoffwilkins/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/geoffwilkins/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/geoffwilkins/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/geoffwilkins/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/geoffwilkins/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/geoffwilkins/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/geoffwilkins/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/geoffwilkins/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/geoffwilkins/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/geoffwilkins/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/geoffwilkins/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/geoffwilkins/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/geoffwilkins/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/geoffwilkins/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/geoffwilkins/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/geoffwilkins/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/geoffwilkins/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/geoffwilkins/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/geoffwilkins/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/geoffwilkins/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/geoffwilkins/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/geoffwilkins/images';
		break;
	}
		switch (server_id) {
		case 53:
		val = 'http://images.clikpic.com/geoffwilkins/images';
		break;
	}
		switch (server_id) {
		case 52:
		val = 'http://tpc22/clikpic/geoffwilkins/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/geoffwilkins/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/geoffwilkins/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 = 'Petaverde Photography - the look of love: ' + 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="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 += '<form id="paymentForm" style="margin:0px;border:0px;" name="paymentForm" target="_blank" action="https://www.paypal.com/cgi-bin/webscr" method="post">';
			temp += '<input type="hidden" name="item_name" value="'+item_name+'">';
			ref = '';
			if(this.photo_ref != ''){
				ref = this.photo_ref+' - '+this.caption;
			}
			else{
				ref = this.id+' - '+this.caption;
			}
			price = amount;								temp += '<input type="hidden" name="cmd" value="_cart">';
					temp += '<input type="hidden" name="business" value="geoff@petaverde.co.uk">';
					temp += '<input type="hidden" name="currency_code" value="GBP">';
					temp += '<input type="hidden" name="add" value="1">';
													temp += '<input type="hidden" name="amount" value="'+amount+'">';
					temp += '<input type="hidden" name="item_number" value="'+ref+'">';
													temp += '<input type=\"Submit\" value=\"Add to cart\" id=\"paymentAddButton\" class=\"button\" onmouseover=\"this.className=\'buttonHi\';\" onmouseout=\"this.className=\'button\';\">';
										temp += '</form>';
										temp += '<form id="paymentCartForm" style="margin:0px;" name="paymentCartForm" target="_blank" action="https://www.paypal.com/cgi-bin/webscr" method="post">';
				temp += '<input type="hidden" name="cmd" value="_cart">';
				temp += '<input type="hidden" name="business" value="geoff@petaverde.co.uk">';
				temp += '<input type="hidden" name="display" value="1">';
				temp += '<input type=\"Submit\" value=\"View cart\" id=\"paymentViewButton\" class=\"button\" onmouseover=\"this.className=\'buttonHi\';\" onmouseout=\"this.className=\'button\';\">';
				temp += '</form>';
						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;
	}
}

			

