window.thumbnails = {};
															thumbnails[8667237] = clik.newPhoto({"id":8667237,"src":"_MG_4127_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_8667237.html","width":130,"caption":"","height":87});
															thumbnails[8667238] = clik.newPhoto({"id":8667238,"src":"_MG_4150_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_8667238.html","width":130,"caption":"","height":87});
															thumbnails[8667240] = clik.newPhoto({"id":8667240,"src":"_MG_4217_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_8667240.html","width":130,"caption":"","height":195});
															thumbnails[8667241] = clik.newPhoto({"id":8667241,"src":"_MG_4442_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_8667241.html","width":130,"caption":"","height":195});
															thumbnails[8667244] = clik.newPhoto({"id":8667244,"src":"_MG_4543_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_8667244.html","width":130,"caption":"","height":87});
															thumbnails[8667245] = clik.newPhoto({"id":8667245,"src":"back_cover_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_8667245.html","width":130,"caption":"","height":87});
															thumbnails[8667246] = clik.newPhoto({"id":8667246,"src":"Front_cover_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_8667246.html","width":130,"caption":"","height":87});
															thumbnails[8667248] = clik.newPhoto({"id":8667248,"src":"IMG_0264_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_8667248.html","width":130,"caption":"","height":195});
															thumbnails[8667249] = clik.newPhoto({"id":8667249,"src":"IMG_0270_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_8667249.html","width":130,"caption":"","height":87});
															thumbnails[8667250] = clik.newPhoto({"id":8667250,"src":"IMG_0409_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_8667250.html","width":130,"caption":"","height":87});
															thumbnails[8667252] = clik.newPhoto({"id":8667252,"src":"IMG_0423_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_8667252.html","width":130,"caption":"","height":87});
															thumbnails[8667253] = clik.newPhoto({"id":8667253,"src":"IMG_0708_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_8667253.html","width":130,"caption":"","height":87});
															thumbnails[8667255] = clik.newPhoto({"id":8667255,"src":"IMG_0798_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_8667255.html","width":130,"caption":"","height":195});
															thumbnails[8667271] = clik.newPhoto({"id":8667271,"src":"IMG_0930_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_8667271.html","width":130,"caption":"","height":195});
															thumbnails[8667273] = clik.newPhoto({"id":8667273,"src":"IMG_0964_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_8667273.html","width":130,"caption":"","height":195});
															thumbnails[8667274] = clik.newPhoto({"id":8667274,"src":"IMG_1491_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_8667274.html","width":130,"caption":"","height":195});
															thumbnails[8667276] = clik.newPhoto({"id":8667276,"src":"IMG_1637_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_8667276.html","width":130,"caption":"","height":195});
															thumbnails[8667277] = clik.newPhoto({"id":8667277,"src":"IMG_1649_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_8667277.html","width":130,"caption":"","height":87});
															thumbnails[8667278] = clik.newPhoto({"id":8667278,"src":"IMG_1906_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_8667278.html","width":130,"caption":"","height":195});
															thumbnails[8667280] = clik.newPhoto({"id":8667280,"src":"IMG_1948_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_8667280.html","width":130,"caption":"","height":195});
															thumbnails[8667281] = clik.newPhoto({"id":8667281,"src":"IMG_2058_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_8667281.html","width":130,"caption":"","height":87});
															thumbnails[8667289] = clik.newPhoto({"id":8667289,"src":"IMG_2130_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_8667289.html","width":130,"caption":"","height":195});
															thumbnails[8667290] = clik.newPhoto({"id":8667290,"src":"IMG_2152_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_8667290.html","width":130,"caption":"","height":87});
															thumbnails[8667292] = clik.newPhoto({"id":8667292,"src":"IMG_2374_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_8667292.html","width":130,"caption":"","height":87});
															thumbnails[8667293] = clik.newPhoto({"id":8667293,"src":"IMG_2873_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_8667293.html","width":130,"caption":"","height":87});
															thumbnails[8667295] = clik.newPhoto({"id":8667295,"src":"IMG_3037_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_8667295.html","width":130,"caption":"","height":195});
															thumbnails[8667297] = clik.newPhoto({"id":8667297,"src":"IMG_3218_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_8667297.html","width":130,"caption":"","height":87});
															thumbnails[3788334] = clik.newPhoto({"id":3788334,"src":"_MG_0357_copy_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_3788334.html","width":130,"caption":"","height":195});
															thumbnails[3788360] = clik.newPhoto({"id":3788360,"src":"_MG_2327_copy_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_3788360.html","width":130,"caption":"","height":195});
															thumbnails[3788554] = clik.newPhoto({"id":3788554,"src":"_MG_5112_copy_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_3788554.html","width":130,"caption":"","height":195});
															thumbnails[3788555] = clik.newPhoto({"id":3788555,"src":"_MG_6326_copy_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_3788555.html","width":130,"caption":"","height":87});
															thumbnails[3881060] = clik.newPhoto({"id":3881060,"src":"_MG_6937_copy_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_3881060.html","width":130,"caption":"","height":195});
															thumbnails[3881061] = clik.newPhoto({"id":3881061,"src":"_MG_7056_copy_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_3881061.html","width":130,"caption":"","height":87});
															thumbnails[3881078] = clik.newPhoto({"id":3881078,"src":"CL2_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_3881078.html","width":130,"caption":"","height":195});
															thumbnails[3881082] = clik.newPhoto({"id":3881082,"src":"n1_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_3881082.html","width":130,"caption":"","height":196});
															thumbnails[3881084] = clik.newPhoto({"id":3881084,"src":"wed2_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_3881084.html","width":130,"caption":"","height":87});
															thumbnails[3881083] = clik.newPhoto({"id":3881083,"src":"wed1_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_3881083.html","width":130,"caption":"","height":195});
															thumbnails[3881081] = clik.newPhoto({"id":3881081,"src":"es_wed2_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_3881081.html","width":130,"caption":"","height":87});
															thumbnails[3881080] = clik.newPhoto({"id":3881080,"src":"es_wed1_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_3881080.html","width":130,"caption":"","height":87});
															thumbnails[3881077] = clik.newPhoto({"id":3881077,"src":"12_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_3881077.html","width":130,"caption":"","height":195});
															thumbnails[3788559] = clik.newPhoto({"id":3788559,"src":"_MG_6715_copy_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_3788559.html","width":130,"caption":"","height":195});
															thumbnails[3788557] = clik.newPhoto({"id":3788557,"src":"_MG_6504_copy_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_3788557.html","width":130,"caption":"","height":87});
															thumbnails[3788366] = clik.newPhoto({"id":3788366,"src":"_MG_2744_copy_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_3788366.html","width":130,"caption":"","height":195});
															thumbnails[3788358] = clik.newPhoto({"id":3788358,"src":"_MG_2205_copy_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_3788358.html","width":130,"caption":"","height":87});
															thumbnails[3788342] = clik.newPhoto({"id":3788342,"src":"_MG_1408_copy_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_3788342.html","width":130,"caption":"","height":195});
															thumbnails[3788335] = clik.newPhoto({"id":3788335,"src":"_MG_0421_copy_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_3788335.html","width":130,"caption":"","height":87});
															thumbnails[3788322] = clik.newPhoto({"id":3788322,"src":"_MG_0055_copy_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_3788322.html","width":130,"caption":"","height":195});
															thumbnails[3788315] = clik.newPhoto({"id":3788315,"src":"_MG_0037_copy_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_3788315.html","width":130,"caption":"","height":195});
															thumbnails[3788313] = clik.newPhoto({"id":3788313,"src":"_MG_0001_1_copy_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_3788313.html","width":130,"caption":"","height":195});
															thumbnails[3788325] = clik.newPhoto({"id":3788325,"src":"_MG_0130_copy_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_3788325.html","width":130,"caption":"","height":87});
															thumbnails[3788551] = clik.newPhoto({"id":3788551,"src":"_MG_2766_copy_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_3788551.html","width":130,"caption":"","height":87});
															thumbnails[3788553] = clik.newPhoto({"id":3788553,"src":"_MG_5097_copy_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_3788553.html","width":130,"caption":"","height":195});
															thumbnails[3788562] = clik.newPhoto({"id":3788562,"src":"_MG_6751_copy_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_3788562.html","width":130,"caption":"","height":87});
															thumbnails[3881062] = clik.newPhoto({"id":3881062,"src":"_MG_7079_copy_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_3881062.html","width":130,"caption":"","height":87});
															thumbnails[3881079] = clik.newPhoto({"id":3881079,"src":"davesarah_3_5_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_3881079.html","width":130,"caption":"","height":103});
															thumbnails[3881086] = clik.newPhoto({"id":3881086,"src":"wed4_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_3881086.html","width":130,"caption":"","height":75});
															thumbnails[3881064] = clik.newPhoto({"id":3881064,"src":"3_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_3881064.html","width":130,"caption":"","height":195});
															thumbnails[3788563] = clik.newPhoto({"id":3788563,"src":"_MG_6888_copy_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_3788563.html","width":130,"caption":"","height":87});
															thumbnails[3788354] = clik.newPhoto({"id":3788354,"src":"_MG_2201_copy_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_3788354.html","width":130,"caption":"","height":195});
															thumbnails[3788347] = clik.newPhoto({"id":3788347,"src":"_MG_2125_copy_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_3788347.html","width":130,"caption":"","height":87});
															thumbnails[3788349] = clik.newPhoto({"id":3788349,"src":"_MG_2158_copy_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_3788349.html","width":130,"caption":"","height":195});
															thumbnails[3788339] = clik.newPhoto({"id":3788339,"src":"_MG_1048_copy_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_3788339.html","width":130,"caption":"","height":195});
															thumbnails[3788331] = clik.newPhoto({"id":3788331,"src":"_MG_0274_copy_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_3788331.html","width":130,"caption":"","height":87});
															thumbnails[3788318] = clik.newPhoto({"id":3788318,"src":"_MG_0047_copy_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_3788318.html","width":130,"caption":"","height":87});
															thumbnails[3788317] = clik.newPhoto({"id":3788317,"src":"_MG_0042_copy_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_3788317.html","width":130,"caption":"","height":195});
															thumbnails[3788328] = clik.newPhoto({"id":3788328,"src":"_MG_0174_copy_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_3788328.html","width":130,"caption":"","height":87});
															thumbnails[3788343] = clik.newPhoto({"id":3788343,"src":"_MG_1547_copy_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_3788343.html","width":130,"caption":"","height":87});
															thumbnails[3788352] = clik.newPhoto({"id":3788352,"src":"_MG_2160_copy_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_3788352.html","width":130,"caption":"","height":195});
															thumbnails[3788362] = clik.newPhoto({"id":3788362,"src":"_MG_2485_copy_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_3788362.html","width":130,"caption":"","height":195});
															thumbnails[3788363] = clik.newPhoto({"id":3788363,"src":"_MG_2573_copy_thumb.jpg","galleries_id":206148,"server_id":15,"link":"photo_3788363.html","width":130,"caption":"","height":87});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  						galleries[206148] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Gallery 1","link":"gallery.html","maxRecords":0.0,"photoIDs":[8667237.0,8667238.0,8667240.0,8667241.0,8667244.0,8667245.0,8667246.0,8667248.0,8667249.0,8667250.0,8667252.0,8667253.0,8667255.0,8667271.0,8667273.0,8667274.0,8667276.0,8667277.0,8667278.0,8667280.0,8667281.0,8667289.0,8667290.0,8667292.0,8667293.0,8667295.0,8667297.0,3788334.0,3788360.0,3788554.0,3788555.0,3881060.0,3881061.0,3881078.0,3881082.0,3881084.0,3881083.0,3881081.0,3881080.0,3881077.0,3788559.0,3788557.0,3788366.0,3788358.0,3788342.0,3788335.0,3788322.0,3788315.0,3788313.0,3788325.0,3788551.0,3788553.0,3788562.0,3881062.0,3881079.0,3881086.0,3881064.0,3788563.0,3788354.0,3788347.0,3788349.0,3788339.0,3788331.0,3788318.0,3788317.0,3788328.0,3788343.0,3788352.0,3788362.0,3788363.0],"skipIndex":0,"section_code":"gallery","featured_images":"8667297,8667295,8667293,8667292,8667290,8667289,8667281,8667280,8667278,8667277","id":206148,"singleSection":true});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[1] = '8667292,8667290,8667278,8667274,8667273,8667245,8667238,3788360,3788554,3788358,3788347';
imageSets[3] = '8667297,8667295,8667293,8667292,8667290,8667289,8667281,8667280,8667278,8667277,8667276,8667274,8667273,8667271,8667255,8667253,8667252,8667250,8667249,8667248,8667246,8667245,8667244,8667241,8667240,8667238,8667237,3881086,3881084,3881083,3881082,3881081,3881080,3881079,3881078,3881077,3881064,3881062,3881061,3881060,3788563,3788562,3788559,3788557,3788555,3788554,3788553,3788551,3788366,3788363';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 51:
		val = 'http://www12.clikpic.com/secretsmile/images';
		break;
	}
		switch (server_id) {
		case 0:
		val = 'http://www.clikpic.com/secretsmile/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/secretsmile/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/secretsmile/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/secretsmile/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/secretsmile/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/secretsmile/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/secretsmile/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/secretsmile/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/secretsmile/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/secretsmile/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/secretsmile/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/secretsmile/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/secretsmile/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/secretsmile/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/secretsmile/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/secretsmile/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/secretsmile/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/secretsmile/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/secretsmile/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/secretsmile/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/secretsmile/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/secretsmile/images';
		break;
	}
		switch (server_id) {
		case 53:
		val = 'http://images.clikpic.com/secretsmile/images';
		break;
	}
		switch (server_id) {
		case 52:
		val = 'http://tpc22/clikpic/secretsmile/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/secretsmile/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/secretsmile/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 = 'Weddings by Gary: ' + 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.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="gary@image-red.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="gary@image-red.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;
	}
}

			

