window.thumbnails = {};
															thumbnails[3115765] = clik.newPhoto({"id":3115765,"src":"IMG_3286_thumb.jpg","galleries_id":"","server_id":32,"link":"#","width":130,"caption":"","height":87});
															thumbnails[3095817] = clik.newPhoto({"id":3095817,"src":"IMG_2985_thumb.jpg","galleries_id":189676,"server_id":32,"link":"photo_3095817.html","width":130,"caption":"","height":107});
															thumbnails[3095837] = clik.newPhoto({"id":3095837,"src":"IMG_3011_thumb.jpg","galleries_id":189676,"server_id":32,"link":"photo_3095837.html","width":130,"caption":"","height":149});
															thumbnails[3095846] = clik.newPhoto({"id":3095846,"src":"IMG_3103_thumb.jpg","galleries_id":385178,"server_id":32,"link":"photo_3095846.html","width":130,"caption":"","height":174});
															thumbnails[3095857] = clik.newPhoto({"id":3095857,"src":"IMG_3114_thumb.jpg","galleries_id":385178,"server_id":32,"link":"photo_3095857.html","width":130,"caption":"","height":165});
															thumbnails[3115808] = clik.newPhoto({"id":3115808,"src":"IMG_3119_thumb.jpg","galleries_id":385178,"server_id":32,"link":"photo_3115808.html","width":130,"caption":"","height":96});
															thumbnails[3116475] = clik.newPhoto({"id":3116475,"src":"bestfriends_thumb.jpg","galleries_id":189676,"server_id":32,"link":"photo_3116475.html","width":130,"caption":"","height":109});
															thumbnails[3116479] = clik.newPhoto({"id":3116479,"src":"pageboy_thumb.jpg","galleries_id":385178,"server_id":32,"link":"photo_3116479.html","width":130,"caption":"","height":150});
															thumbnails[3218928] = clik.newPhoto({"id":3218928,"src":"IMG_6299_thumb.jpg","galleries_id":189676,"server_id":32,"link":"photo_3218928.html","width":130,"caption":"","height":109});
															thumbnails[3400581] = clik.newPhoto({"id":3400581,"src":"IMG_8582_thumb.jpg","galleries_id":189676,"server_id":32,"link":"photo_3400581.html","width":130,"caption":"","height":83});
															thumbnails[5240861] = clik.newPhoto({"id":5240861,"src":"IMG_0060_thumb.jpg","galleries_id":189676,"server_id":32,"link":"photo_5240861.html","width":130,"caption":"","height":140});
															thumbnails[5851696] = clik.newPhoto({"id":5851696,"src":"IMG_7409_thumb.jpg","galleries_id":189676,"server_id":32,"link":"photo_5851696.html","width":130,"caption":"","height":93});
															thumbnails[5851702] = clik.newPhoto({"id":5851702,"src":"IMG_7192_thumb.jpg","galleries_id":189676,"server_id":32,"link":"photo_5851702.html","width":130,"caption":"","height":189});
															thumbnails[5851734] = clik.newPhoto({"id":5851734,"src":"IMG_7253_thumb.jpg","galleries_id":189676,"server_id":32,"link":"photo_5851734.html","width":130,"caption":"","height":177});
															thumbnails[5851742] = clik.newPhoto({"id":5851742,"src":"IMG_7260_thumb.jpg","galleries_id":189676,"server_id":32,"link":"photo_5851742.html","width":130,"caption":"","height":112});
															thumbnails[6084502] = clik.newPhoto({"id":6084502,"src":"IMG_7523_thumb.jpg","galleries_id":189676,"server_id":32,"link":"photo_6084502.html","width":130,"caption":"","height":134});
															thumbnails[6440744] = clik.newPhoto({"id":6440744,"src":"IMG_7562-1_thumb.jpg","galleries_id":385178,"server_id":32,"link":"photo_6440744.html","width":130,"caption":"","height":186});
															thumbnails[6440746] = clik.newPhoto({"id":6440746,"src":"IMG_7586-1_thumb.jpg","galleries_id":385178,"server_id":32,"link":"photo_6440746.html","width":130,"caption":"","height":78});
															thumbnails[6440748] = clik.newPhoto({"id":6440748,"src":"IMG_7638-1_thumb.jpg","galleries_id":385178,"server_id":32,"link":"photo_6440748.html","width":130,"caption":"","height":103});
															thumbnails[6440750] = clik.newPhoto({"id":6440750,"src":"IMG_7749-1_thumb.jpg","galleries_id":385178,"server_id":32,"link":"photo_6440750.html","width":130,"caption":"","height":94});
															thumbnails[6440752] = clik.newPhoto({"id":6440752,"src":"IMG_7807-1_thumb.jpg","galleries_id":385178,"server_id":32,"link":"photo_6440752.html","width":130,"caption":"","height":77});
															thumbnails[6440756] = clik.newPhoto({"id":6440756,"src":"IMG_7848-1_thumb.jpg","galleries_id":385178,"server_id":32,"link":"photo_6440756.html","width":130,"caption":"","height":122});
															thumbnails[6440758] = clik.newPhoto({"id":6440758,"src":"IMG_7887-1_thumb.jpg","galleries_id":385178,"server_id":32,"link":"photo_6440758.html","width":130,"caption":"","height":87});
															thumbnails[6440763] = clik.newPhoto({"id":6440763,"src":"IMG_7996-1_thumb.jpg","galleries_id":385178,"server_id":32,"link":"photo_6440763.html","width":130,"caption":"","height":94});
															thumbnails[6440766] = clik.newPhoto({"id":6440766,"src":"IMG_8010-1_thumb.jpg","galleries_id":385178,"server_id":32,"link":"photo_6440766.html","width":130,"caption":"","height":147});
															thumbnails[6440767] = clik.newPhoto({"id":6440767,"src":"IMG_8075-1_thumb.jpg","galleries_id":385178,"server_id":32,"link":"photo_6440767.html","width":130,"caption":"","height":129});
															thumbnails[7120851] = clik.newPhoto({"id":7120851,"src":"IMG_8744_thumb.jpg","galleries_id":189676,"server_id":32,"link":"photo_7120851.html","width":130,"caption":"","height":101});
															thumbnails[7120852] = clik.newPhoto({"id":7120852,"src":"IMG_8808_thumb.jpg","galleries_id":189676,"server_id":32,"link":"photo_7120852.html","width":130,"caption":"","height":104});
															thumbnails[7120854] = clik.newPhoto({"id":7120854,"src":"IMG_8913_thumb.jpg","galleries_id":385178,"server_id":32,"link":"photo_7120854.html","width":130,"caption":"","height":105});
															thumbnails[7120859] = clik.newPhoto({"id":7120859,"src":"IMG_8916_thumb.jpg","galleries_id":385178,"server_id":32,"link":"photo_7120859.html","width":130,"caption":"","height":111});
															thumbnails[7120862] = clik.newPhoto({"id":7120862,"src":"IMG_8988_thumb.jpg","galleries_id":385178,"server_id":32,"link":"photo_7120862.html","width":130,"caption":"","height":105});
															thumbnails[7120866] = clik.newPhoto({"id":7120866,"src":"IMG_9002_thumb.jpg","galleries_id":189676,"server_id":32,"link":"photo_7120866.html","width":130,"caption":"","height":201});
															thumbnails[7120870] = clik.newPhoto({"id":7120870,"src":"IMG_9080_thumb.jpg","galleries_id":189676,"server_id":32,"link":"photo_7120870.html","width":130,"caption":"","height":181});
															thumbnails[7120965] = clik.newPhoto({"id":7120965,"src":"IMG_3122_thumb.jpg","galleries_id":385178,"server_id":32,"link":"photo_7120965.html","width":130,"caption":"","height":120});
															thumbnails[7120972] = clik.newPhoto({"id":7120972,"src":"IMG_7681_thumb.jpg","galleries_id":385178,"server_id":32,"link":"photo_7120972.html","width":130,"caption":"","height":86});
															thumbnails[7120989] = clik.newPhoto({"id":7120989,"src":"IMG_7694_thumb.jpg","galleries_id":385178,"server_id":32,"link":"photo_7120989.html","width":130,"caption":"","height":117});
															thumbnails[7120991] = clik.newPhoto({"id":7120991,"src":"IMG_7883_thumb.jpg","galleries_id":385178,"server_id":32,"link":"photo_7120991.html","width":130,"caption":"","height":98});
															thumbnails[7254210] = clik.newPhoto({"id":7254210,"src":"IMG_0033_thumb.jpg","galleries_id":385178,"server_id":32,"link":"photo_7254210.html","width":130,"caption":"","height":78});
															thumbnails[7284207] = clik.newPhoto({"id":7284207,"src":"IMG_0020-1_thumb.jpg","galleries_id":385178,"server_id":32,"link":"photo_7284207.html","width":130,"caption":"","height":187});
															thumbnails[7284256] = clik.newPhoto({"id":7284256,"src":"IMG_97402_thumb.jpg","galleries_id":385178,"server_id":32,"link":"photo_7284256.html","width":130,"caption":"","height":87});
															thumbnails[7305204] = clik.newPhoto({"id":7305204,"src":"IMG_9951-1_thumb.jpg","galleries_id":385178,"server_id":32,"link":"photo_7305204.html","width":130,"caption":"","height":91});
															thumbnails[7318877] = clik.newPhoto({"id":7318877,"src":"IMG_9703_thumb.jpg","galleries_id":385178,"server_id":32,"link":"photo_7318877.html","width":130,"caption":"","height":111});
															thumbnails[7318883] = clik.newPhoto({"id":7318883,"src":"IMG_0041_thumb.jpg","galleries_id":385178,"server_id":32,"link":"photo_7318883.html","width":130,"caption":"","height":100});
															thumbnails[7318886] = clik.newPhoto({"id":7318886,"src":"IMG_0223_thumb.jpg","galleries_id":385178,"server_id":32,"link":"photo_7318886.html","width":130,"caption":"","height":120});
															thumbnails[7318891] = clik.newPhoto({"id":7318891,"src":"IMG_00481_thumb.jpg","galleries_id":385178,"server_id":32,"link":"photo_7318891.html","width":130,"caption":"","height":98});
															thumbnails[7318895] = clik.newPhoto({"id":7318895,"src":"IMG_9789_thumb.jpg","galleries_id":385178,"server_id":32,"link":"photo_7318895.html","width":130,"caption":"","height":152});
															thumbnails[7318896] = clik.newPhoto({"id":7318896,"src":"IMG_9847_thumb.jpg","galleries_id":385178,"server_id":32,"link":"photo_7318896.html","width":130,"caption":"","height":100});
															thumbnails[7325122] = clik.newPhoto({"id":7325122,"src":"IMG_0604_thumb.jpg","galleries_id":385178,"server_id":32,"link":"photo_7325122.html","width":130,"caption":"","height":204});
															thumbnails[7456739] = clik.newPhoto({"id":7456739,"src":"IMG_0618-1_thumb.jpg","galleries_id":385178,"server_id":32,"link":"photo_7456739.html","width":130,"caption":"","height":83});
															thumbnails[7456828] = clik.newPhoto({"id":7456828,"src":"IMG_0698_thumb.jpg","galleries_id":385178,"server_id":32,"link":"photo_7456828.html","width":130,"caption":"","height":126});
															thumbnails[7456837] = clik.newPhoto({"id":7456837,"src":"IMG_0517_thumb.jpg","galleries_id":385178,"server_id":32,"link":"photo_7456837.html","width":130,"caption":"","height":163});
															thumbnails[7456843] = clik.newPhoto({"id":7456843,"src":"IMG_0637_thumb.jpg","galleries_id":385178,"server_id":32,"link":"photo_7456843.html","width":130,"caption":"","height":103});
															thumbnails[7456848] = clik.newPhoto({"id":7456848,"src":"IMG_0665_thumb.jpg","galleries_id":385178,"server_id":32,"link":"photo_7456848.html","width":130,"caption":"","height":75});
															thumbnails[7456851] = clik.newPhoto({"id":7456851,"src":"IMG_9744_thumb.jpg","galleries_id":385178,"server_id":32,"link":"photo_7456851.html","width":130,"caption":"","height":98});
															thumbnails[7515074] = clik.newPhoto({"id":7515074,"src":"IMG_0310_thumb.jpg","galleries_id":385178,"server_id":32,"link":"photo_7515074.html","width":130,"caption":"","height":193});
															thumbnails[8226980] = clik.newPhoto({"id":8226980,"src":"IMG_2350-1_thumb.jpg","galleries_id":385178,"server_id":32,"link":"photo_8226980.html","width":130,"caption":"","height":162});
															thumbnails[8227030] = clik.newPhoto({"id":8227030,"src":"IMG_2336_thumb.jpg","galleries_id":385178,"server_id":32,"link":"photo_8227030.html","width":130,"caption":"","height":195});
															thumbnails[8227234] = clik.newPhoto({"id":8227234,"src":"IMG_2313_thumb.jpg","galleries_id":385178,"server_id":32,"link":"photo_8227234.html","width":130,"caption":"","height":85});
															thumbnails[8310536] = clik.newPhoto({"id":8310536,"src":"IMG_2508_thumb.jpg","galleries_id":385178,"server_id":32,"link":"photo_8310536.html","width":130,"caption":"","height":103});
															thumbnails[8784819] = clik.newPhoto({"id":8784819,"src":"IMG_3219_thumb.jpg","galleries_id":385178,"server_id":32,"link":"photo_8784819.html","width":130,"caption":"","height":88});
															thumbnails[8784871] = clik.newPhoto({"id":8784871,"src":"IMG_3059_thumb.jpg","galleries_id":385178,"server_id":32,"link":"photo_8784871.html","width":130,"caption":"","height":86});
															thumbnails[8804265] = clik.newPhoto({"id":8804265,"src":"IMG_3260_thumb.jpg","galleries_id":385178,"server_id":32,"link":"photo_8804265.html","width":130,"caption":"","height":183});
															thumbnails[8837204] = clik.newPhoto({"id":8837204,"src":"IMG_3750_9EFE33D9-24E8-5EC4-4F1C3056A8E42A0D_thumb.jpg","galleries_id":385178,"server_id":32,"link":"photo_8837204.html","width":130,"caption":"","height":169});
															thumbnails[8837216] = clik.newPhoto({"id":8837216,"src":"IMG_3853_9F2820C4-24E8-5EC4-4F3981125C185D40_thumb.jpg","galleries_id":385178,"server_id":32,"link":"photo_8837216.html","width":130,"caption":"","height":174});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  						galleries[385178] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Weddings and Engagements","link":"gallery_385178.html","maxRecords":0.0,"photoIDs":[3095846.0,3095857.0,3115808.0,3116479.0,6440744.0,6440746.0,6440748.0,6440750.0,6440752.0,6440756.0,6440758.0,6440763.0,6440766.0,6440767.0,7120854.0,7120859.0,7120862.0,7120965.0,7120972.0,7120989.0,7120991.0,7254210.0,7284207.0,7284256.0,7305204.0,7318877.0,7318883.0,7318886.0,7318891.0,7318895.0,7318896.0,7325122.0,7456739.0,7456828.0,7456837.0,7456843.0,7456848.0,7456851.0,7515074.0,8226980.0,8227030.0,8227234.0,8310536.0,8784819.0,8784871.0,8804265.0,8837204.0,8837216.0],"skipIndex":0,"section_code":"gallery","featured_images":"8837216,8837204,8804265,8784871,8784819,8310536,8227234,8227030,8226980,7515074,7456851,7456848,7456843,7456837,7456828,7456739,7325122,7318896,7318895,7318891,7318886,7318883,7318877,7305204,7284256,7284207,7254210,7120991,7120989,7120972,7120965,7120862,7120859,7120854,6440766,6440763,6440758,6440756,6440752,6440750,6440748,6440746,6440744,3095857,3095846","id":385178,"singleSection":false});				  						galleries[189676] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"People and Pets","link":"gallery_189676.html","maxRecords":0.0,"photoIDs":[3095817.0,3095837.0,3116475.0,3218928.0,3400581.0,5240861.0,5851696.0,5851702.0,5851734.0,5851742.0,6084502.0,7120851.0,7120852.0,7120866.0,7120870.0],"skipIndex":0,"section_code":"gallery","featured_images":"7120870,7120866,7120852,7120851,3116475","id":189676,"singleSection":false});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[1] = '8837216,8837204,8804265,8784871,8784819,8310536,8227234,8227030,8226980,7515074,7456851,7456848,7456843,7456837,7456828,7456739,7325122,7318896,7318895,7318891,7318886,7318883,7318877,7305204,7284256,7284207,7254210,7120991,7120989,7120972,7120965,7120870,7120866,7120862,7120859,7120854,7120852,7120851,6440763,6440758,6440756,6440752,6440750,6440748,6440746,6440744,3400581,3218928,3116475,3095857';
imageSets[2] = '8837216,8837204,8804265,8784871,8784819,8310536,8227234,8227030,8226980,7515074,7456851,7456848,7456843,7456837,7456828,7456739,7325122,7318896,7318895,7318891,7318886,7318883,7318877,7305204,7284256,7284207,7254210,7120991,7120989,7120972,7120965,7120870,7120866,7120862,7120859,7120854,7120852,7120851,6440766,6440763,6440758,6440756,6440752,6440750,6440748,6440746,6440744,3116475,3095857,3095846';
imageSets[3] = '8837216,8837204,8804265,8784871,8784819,8310536,8227234,8227030,8226980,7515074,7456851,7456848,7456843,7456837,7456828,7456739,7325122,7318896,7318895,7318891,7318886,7318883,7318877,7305204,7284256,7284207,7254210,6440766,6440763,6440758,6440756,6440752,6440750,6440748,6440746,6440744,3116475,3095857';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 51:
		val = 'http://www12.clikpic.com/kimcraik/images';
		break;
	}
		switch (server_id) {
		case 0:
		val = 'http://www.clikpic.com/kimcraik/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/kimcraik/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/kimcraik/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/kimcraik/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/kimcraik/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/kimcraik/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/kimcraik/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/kimcraik/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/kimcraik/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/kimcraik/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/kimcraik/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/kimcraik/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/kimcraik/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/kimcraik/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/kimcraik/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/kimcraik/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/kimcraik/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/kimcraik/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/kimcraik/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/kimcraik/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/kimcraik/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/kimcraik/images';
		break;
	}
		switch (server_id) {
		case 53:
		val = 'http://images.clikpic.com/kimcraik/images';
		break;
	}
		switch (server_id) {
		case 52:
		val = 'http://tpc22/clikpic/kimcraik/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/kimcraik/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/kimcraik/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 = 'Kim Craik 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;
	}
}

			

