window.thumbnails = {};
															thumbnails[4639812] = clik.newPhoto({"id":4639812,"src":"AMADEUS_DB_214_thumb.jpg","galleries_id":267638,"server_id":18,"link":"photo_4639812.html","width":130,"caption":"","height":106});
															thumbnails[4639814] = clik.newPhoto({"id":4639814,"src":"BABY_SHOW_2008_33_thumb.jpg","galleries_id":267638,"server_id":18,"link":"photo_4639814.html","width":130,"caption":"","height":106});
															thumbnails[4639817] = clik.newPhoto({"id":4639817,"src":"BABY_SHOW_2008_134_thumb.jpg","galleries_id":267638,"server_id":18,"link":"photo_4639817.html","width":130,"caption":"","height":106});
															thumbnails[4639819] = clik.newPhoto({"id":4639819,"src":"C__G_02_thumb.jpg","galleries_id":267690,"server_id":18,"link":"photo_4639819.html","width":130,"caption":"","height":106});
															thumbnails[4639842] = clik.newPhoto({"id":4639842,"src":"C__G_05_thumb.jpg","galleries_id":267690,"server_id":18,"link":"photo_4639842.html","width":130,"caption":"","height":106});
															thumbnails[4639849] = clik.newPhoto({"id":4639849,"src":"C__G_33_thumb.jpg","galleries_id":267690,"server_id":18,"link":"photo_4639849.html","width":130,"caption":"","height":106});
															thumbnails[4639856] = clik.newPhoto({"id":4639856,"src":"CARRS_DB_018_thumb.jpg","galleries_id":267637,"server_id":18,"link":"photo_4639856.html","width":130,"caption":"","height":106});
															thumbnails[4640075] = clik.newPhoto({"id":4640075,"src":"CHAMBER_21_thumb.jpg","galleries_id":267638,"server_id":18,"link":"photo_4640075.html","width":130,"caption":"","height":106});
															thumbnails[4640079] = clik.newPhoto({"id":4640079,"src":"CHAMPIONSHIP_DB_071_thumb.jpg","galleries_id":267637,"server_id":18,"link":"photo_4640079.html","width":130,"caption":"","height":106});
															thumbnails[4640083] = clik.newPhoto({"id":4640083,"src":"CHOKOLIT_DB_05_thumb.jpg","galleries_id":267637,"server_id":18,"link":"photo_4640083.html","width":130,"caption":"","height":106});
															thumbnails[4640085] = clik.newPhoto({"id":4640085,"src":"CONFIDENT_COLLECTING_002_thumb.jpg","galleries_id":267638,"server_id":18,"link":"photo_4640085.html","width":130,"caption":"","height":106});
															thumbnails[4640087] = clik.newPhoto({"id":4640087,"src":"COURAGE_DB_67_thumb.jpg","galleries_id":267691,"server_id":18,"link":"photo_4640087.html","width":130,"caption":"","height":106});
															thumbnails[4640089] = clik.newPhoto({"id":4640089,"src":"DIRECT_LINE_PARTY_07_thumb.jpg","galleries_id":267638,"server_id":18,"link":"photo_4640089.html","width":130,"caption":"","height":106});
															thumbnails[4640092] = clik.newPhoto({"id":4640092,"src":"DIRECT_LINE_PARTY_66_thumb.jpg","galleries_id":267638,"server_id":18,"link":"photo_4640092.html","width":130,"caption":"","height":106});
															thumbnails[4640095] = clik.newPhoto({"id":4640095,"src":"DJB040_thumb.jpg","galleries_id":267637,"server_id":18,"link":"photo_4640095.html","width":130,"caption":"","height":106});
															thumbnails[4640099] = clik.newPhoto({"id":4640099,"src":"DJB140_thumb.jpg","galleries_id":267637,"server_id":18,"link":"photo_4640099.html","width":130,"caption":"","height":106});
															thumbnails[4640106] = clik.newPhoto({"id":4640106,"src":"DJB_707_thumb.jpg","galleries_id":267637,"server_id":18,"link":"photo_4640106.html","width":130,"caption":"","height":106});
															thumbnails[4640110] = clik.newPhoto({"id":4640110,"src":"DJB_1633_thumb.jpg","galleries_id":267690,"server_id":18,"link":"photo_4640110.html","width":130,"caption":"","height":106});
															thumbnails[4640113] = clik.newPhoto({"id":4640113,"src":"DJB_1640_thumb.jpg","galleries_id":267690,"server_id":18,"link":"photo_4640113.html","width":130,"caption":"","height":106});
															thumbnails[4640115] = clik.newPhoto({"id":4640115,"src":"DJB_1776_thumb.jpg","galleries_id":267690,"server_id":18,"link":"photo_4640115.html","width":130,"caption":"","height":106});
															thumbnails[4640117] = clik.newPhoto({"id":4640117,"src":"DJB_2527_thumb.jpg","galleries_id":267638,"server_id":18,"link":"photo_4640117.html","width":130,"caption":"","height":106});
															thumbnails[4640119] = clik.newPhoto({"id":4640119,"src":"DJB_3101_thumb.jpg","galleries_id":267637,"server_id":18,"link":"photo_4640119.html","width":130,"caption":"","height":106});
															thumbnails[4640121] = clik.newPhoto({"id":4640121,"src":"DJB_3979_thumb.jpg","galleries_id":267637,"server_id":18,"link":"photo_4640121.html","width":130,"caption":"","height":106});
															thumbnails[4640123] = clik.newPhoto({"id":4640123,"src":"DJB_4054_thumb.jpg","galleries_id":267637,"server_id":18,"link":"photo_4640123.html","width":130,"caption":"","height":106});
															thumbnails[4640125] = clik.newPhoto({"id":4640125,"src":"DJB_6287_thumb.jpg","galleries_id":267691,"server_id":18,"link":"photo_4640125.html","width":130,"caption":"","height":106});
															thumbnails[4640204] = clik.newPhoto({"id":4640204,"src":"DJB_6393_thumb.jpg","galleries_id":267691,"server_id":18,"link":"photo_4640204.html","width":130,"caption":"","height":106});
															thumbnails[4640206] = clik.newPhoto({"id":4640206,"src":"DJB_7311_thumb.jpg","galleries_id":267691,"server_id":18,"link":"photo_4640206.html","width":130,"caption":"","height":106});
															thumbnails[4640208] = clik.newPhoto({"id":4640208,"src":"DJB_7352_thumb.jpg","galleries_id":267638,"server_id":18,"link":"photo_4640208.html","width":130,"caption":"","height":106});
															thumbnails[4640209] = clik.newPhoto({"id":4640209,"src":"DJB_8461_thumb.jpg","galleries_id":267638,"server_id":18,"link":"photo_4640209.html","width":130,"caption":"","height":106});
															thumbnails[4640211] = clik.newPhoto({"id":4640211,"src":"DJB_9136_thumb.jpg","galleries_id":267691,"server_id":18,"link":"photo_4640211.html","width":130,"caption":"","height":106});
															thumbnails[4640212] = clik.newPhoto({"id":4640212,"src":"DSE_1181_thumb.jpg","galleries_id":267692,"server_id":18,"link":"photo_4640212.html","width":130,"caption":"","height":106});
															thumbnails[4640213] = clik.newPhoto({"id":4640213,"src":"DSE_1182_thumb.jpg","galleries_id":267692,"server_id":18,"link":"photo_4640213.html","width":130,"caption":"","height":106});
															thumbnails[4640214] = clik.newPhoto({"id":4640214,"src":"DSE_1196_thumb.jpg","galleries_id":267692,"server_id":18,"link":"photo_4640214.html","width":130,"caption":"","height":106});
															thumbnails[4640215] = clik.newPhoto({"id":4640215,"src":"DSE_1576_thumb.jpg","galleries_id":267637,"server_id":18,"link":"photo_4640215.html","width":130,"caption":"","height":106});
															thumbnails[4640216] = clik.newPhoto({"id":4640216,"src":"DSE_1611_thumb.jpg","galleries_id":267637,"server_id":18,"link":"photo_4640216.html","width":130,"caption":"","height":106});
															thumbnails[4640217] = clik.newPhoto({"id":4640217,"src":"DSE_1615_thumb.jpg","galleries_id":267691,"server_id":18,"link":"photo_4640217.html","width":130,"caption":"","height":106});
															thumbnails[4640219] = clik.newPhoto({"id":4640219,"src":"DSE_1619_thumb.jpg","galleries_id":267637,"server_id":18,"link":"photo_4640219.html","width":130,"caption":"","height":106});
															thumbnails[4640221] = clik.newPhoto({"id":4640221,"src":"DSE_1884_thumb.jpg","galleries_id":267692,"server_id":18,"link":"photo_4640221.html","width":130,"caption":"","height":106});
															thumbnails[4640224] = clik.newPhoto({"id":4640224,"src":"DSE_1900_thumb.jpg","galleries_id":267637,"server_id":18,"link":"photo_4640224.html","width":130,"caption":"","height":106});
															thumbnails[4640226] = clik.newPhoto({"id":4640226,"src":"GALA_096_thumb.jpg","galleries_id":267638,"server_id":18,"link":"photo_4640226.html","width":130,"caption":"","height":106});
															thumbnails[4640227] = clik.newPhoto({"id":4640227,"src":"img356_thumb.jpg","galleries_id":267637,"server_id":18,"link":"photo_4640227.html","width":130,"caption":"","height":106});
															thumbnails[4640228] = clik.newPhoto({"id":4640228,"src":"img358_thumb.jpg","galleries_id":267637,"server_id":18,"link":"photo_4640228.html","width":130,"caption":"","height":106});
															thumbnails[4640230] = clik.newPhoto({"id":4640230,"src":"KAY__RICHARD_062_thumb.jpg","galleries_id":267690,"server_id":18,"link":"photo_4640230.html","width":130,"caption":"","height":106});
															thumbnails[4640232] = clik.newPhoto({"id":4640232,"src":"KAY__RICHARD_104_thumb.jpg","galleries_id":267690,"server_id":18,"link":"photo_4640232.html","width":130,"caption":"","height":106});
															thumbnails[4640233] = clik.newPhoto({"id":4640233,"src":"KAY__RICHARD_140_thumb.jpg","galleries_id":267690,"server_id":18,"link":"photo_4640233.html","width":130,"caption":"","height":106});
															thumbnails[4640234] = clik.newPhoto({"id":4640234,"src":"LLOYDS_TSB_17_thumb.jpg","galleries_id":267638,"server_id":18,"link":"photo_4640234.html","width":130,"caption":"","height":106});
															thumbnails[4640235] = clik.newPhoto({"id":4640235,"src":"micro_thumb.jpg","galleries_id":267637,"server_id":18,"link":"photo_4640235.html","width":130,"caption":"","height":106});
															thumbnails[4640255] = clik.newPhoto({"id":4640255,"src":"MULLER_FILM_05_thumb.jpg","galleries_id":267638,"server_id":18,"link":"photo_4640255.html","width":130,"caption":"","height":106});
															thumbnails[4640257] = clik.newPhoto({"id":4640257,"src":"ROB_LISA_DB_076_thumb.jpg","galleries_id":267690,"server_id":18,"link":"photo_4640257.html","width":130,"caption":"","height":106});
															thumbnails[4640259] = clik.newPhoto({"id":4640259,"src":"ROB_LISA_DB_099_thumb.jpg","galleries_id":267690,"server_id":18,"link":"photo_4640259.html","width":130,"caption":"","height":106});
															thumbnails[4640260] = clik.newPhoto({"id":4640260,"src":"RUSKIN__DB_002_thumb.jpg","galleries_id":267637,"server_id":18,"link":"photo_4640260.html","width":130,"caption":"","height":106});
															thumbnails[4640263] = clik.newPhoto({"id":4640263,"src":"RUSKIN__DB_025_thumb.jpg","galleries_id":267637,"server_id":18,"link":"photo_4640263.html","width":130,"caption":"","height":106});
															thumbnails[4640991] = clik.newPhoto({"id":4640991,"src":"DSC_1419_thumb.jpg","galleries_id":267690,"server_id":18,"link":"photo_4640991.html","width":130,"caption":"","height":106});
															thumbnails[4641002] = clik.newPhoto({"id":4641002,"src":"DSC_1436_thumb.jpg","galleries_id":267690,"server_id":18,"link":"photo_4641002.html","width":130,"caption":"","height":106});
															thumbnails[4641008] = clik.newPhoto({"id":4641008,"src":"DSC_1481_thumb.jpg","galleries_id":267690,"server_id":18,"link":"photo_4641008.html","width":130,"caption":"","height":106});
															thumbnails[4641012] = clik.newPhoto({"id":4641012,"src":"wed_2_thumb.jpg","galleries_id":267690,"server_id":18,"link":"photo_4641012.html","width":130,"caption":"","height":106});
															thumbnails[4641018] = clik.newPhoto({"id":4641018,"src":"wed_5_thumb.jpg","galleries_id":267690,"server_id":18,"link":"photo_4641018.html","width":130,"caption":"","height":106});
															thumbnails[4641286] = clik.newPhoto({"id":4641286,"src":"DSE_129_thumb.jpg","galleries_id":267692,"server_id":18,"link":"photo_4641286.html","width":130,"caption":"","height":106});
															thumbnails[4641288] = clik.newPhoto({"id":4641288,"src":"DSE_162_thumb.jpg","galleries_id":267692,"server_id":18,"link":"photo_4641288.html","width":130,"caption":"","height":106});
															thumbnails[4641289] = clik.newPhoto({"id":4641289,"src":"DJB_38_thumb.jpg","galleries_id":267692,"server_id":18,"link":"photo_4641289.html","width":130,"caption":"","height":106});
															thumbnails[4641290] = clik.newPhoto({"id":4641290,"src":"DSE_348_thumb.jpg","galleries_id":267638,"server_id":18,"link":"photo_4641290.html","width":130,"caption":"","height":106});
															thumbnails[4641335] = clik.newPhoto({"id":4641335,"src":"DJB_842_thumb.jpg","galleries_id":267638,"server_id":18,"link":"photo_4641335.html","width":130,"caption":"","height":106});
															thumbnails[4641336] = clik.newPhoto({"id":4641336,"src":"DJB_866_thumb.jpg","galleries_id":267637,"server_id":18,"link":"photo_4641336.html","width":130,"caption":"","height":106});
															thumbnails[4641340] = clik.newPhoto({"id":4641340,"src":"DJB_941_thumb.jpg","galleries_id":267691,"server_id":18,"link":"photo_4641340.html","width":130,"caption":"","height":106});
															thumbnails[4641344] = clik.newPhoto({"id":4641344,"src":"DJB_1042_thumb.jpg","galleries_id":267691,"server_id":18,"link":"photo_4641344.html","width":130,"caption":"","height":106});
															thumbnails[4641500] = clik.newPhoto({"id":4641500,"src":"DSE_891_thumb.jpg","galleries_id":267637,"server_id":18,"link":"photo_4641500.html","width":130,"caption":"","height":106});
															thumbnails[4641502] = clik.newPhoto({"id":4641502,"src":"DSE_865_thumb.jpg","galleries_id":267637,"server_id":18,"link":"photo_4641502.html","width":130,"caption":"","height":106});
															thumbnails[4645991] = clik.newPhoto({"id":4645991,"src":"DSE_764_thumb.jpg","galleries_id":267692,"server_id":18,"link":"photo_4645991.html","width":130,"caption":"","height":106});
															thumbnails[4645997] = clik.newPhoto({"id":4645997,"src":"DJB_337_thumb.jpg","galleries_id":267692,"server_id":18,"link":"photo_4645997.html","width":130,"caption":"","height":106});
															thumbnails[4744931] = clik.newPhoto({"id":4744931,"src":"DJB_3638_thumb.jpg","galleries_id":267691,"server_id":18,"link":"photo_4744931.html","width":130,"caption":"","height":106});
															thumbnails[4793078] = clik.newPhoto({"id":4793078,"src":"WOLVES_V_OXFORD_8990_02_thumb.jpg","galleries_id":267691,"server_id":18,"link":"photo_4793078.html","width":130,"caption":"","height":106});
															thumbnails[8703478] = clik.newPhoto({"id":8703478,"src":"DSE_5884_thumb.jpg","galleries_id":267637,"server_id":18,"link":"photo_8703478.html","width":130,"caption":"","height":106});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  						galleries[267692] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Aerial","link":"gallery_267692.html","maxRecords":0.0,"photoIDs":[4640212.0,4640213.0,4640214.0,4640221.0,4641286.0,4641288.0,4641289.0,4645991.0,4645997.0],"skipIndex":0,"section_code":"gallery","featured_images":"4645997,4645991,4641289,4641288,4641286,4640221,4640214,4640213,4640212","id":267692,"singleSection":false});				  						galleries[267691] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Sport","link":"gallery_267691.html","maxRecords":0.0,"photoIDs":[4640087.0,4640125.0,4640204.0,4640206.0,4640211.0,4640217.0,4641340.0,4641344.0,4744931.0,4793078.0],"skipIndex":0,"section_code":"gallery","featured_images":"4793078,4744931,4641344,4641340,4640217,4640211,4640206,4640204,4640125,4640087","id":267691,"singleSection":false});				  						galleries[267690] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Wedding","link":"gallery_267690.html","maxRecords":0.0,"photoIDs":[4639819.0,4639842.0,4639849.0,4640110.0,4640113.0,4640115.0,4640230.0,4640232.0,4640233.0,4640257.0,4640259.0,4640991.0,4641002.0,4641008.0,4641012.0,4641018.0],"skipIndex":0,"section_code":"gallery","featured_images":"4641018,4641012,4641008,4641002,4640991,4640259,4640257,4640233,4640232,4640230","id":267690,"singleSection":false});				  						galleries[267637] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"News","link":"gallery_267637.html","maxRecords":0.0,"photoIDs":[4639856.0,4640079.0,4640083.0,4640095.0,4640099.0,4640106.0,4640119.0,4640121.0,4640123.0,4640215.0,4640216.0,4640219.0,4640224.0,4640227.0,4640228.0,4640235.0,4640260.0,4640263.0,4641336.0,4641500.0,4641502.0,8703478.0],"skipIndex":0,"section_code":"gallery","featured_images":"8703478,4641502,4641500,4641336,4640263,4640260,4640235,4640228,4640227,4640224","id":267637,"singleSection":false});				  						galleries[267638] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"PR","link":"gallery_267638.html","maxRecords":0.0,"photoIDs":[4639812.0,4639814.0,4639817.0,4640075.0,4640085.0,4640089.0,4640092.0,4640117.0,4640208.0,4640209.0,4640226.0,4640234.0,4640255.0,4641290.0,4641335.0],"skipIndex":0,"section_code":"gallery","featured_images":"4641335,4641290,4640255,4640234,4640226,4640209,4640208,4640117,4640092,4640089","id":267638,"singleSection":false});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[1] = '8703478,4641500,4641336,4641335,4641290,4641289,4640234,4640226,4640219,4640215,4640212,4640208,4640117,4640095,4639856';
imageSets[3] = '4640235';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 51:
		val = 'www12.clikpic.com/dbagnall/images';
		break;
	}
		switch (server_id) {
		case 0:
		val = 'http://www.clikpic.com/dbagnall/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/dbagnall/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/dbagnall/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/dbagnall/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/dbagnall/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/dbagnall/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/dbagnall/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/dbagnall/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/dbagnall/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/dbagnall/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/dbagnall/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/dbagnall/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/dbagnall/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/dbagnall/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/dbagnall/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/dbagnall/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/dbagnall/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/dbagnall/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/dbagnall/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/dbagnall/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/dbagnall/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/dbagnall/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/dbagnall/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/dbagnall/images';
		break;
	}
		return val;
}

/***************************************************************************
* img = reference to image object in which to show image                   *
***************************************************************************/
function showHomeImage(img) {
	imageID = randomListVal('');
	if (!basic) {
		img.src = photos[imageID].src;
		img.width = photos[imageID].width;
		img.height = photos[imageID].height;
		img.parentNode.title = img.alt = photos[imageID].caption;
	} else {
		newImage = new Image(photos[imageID].width,photos[imageID].height);
		newImage.src = photos[imageID].src;
		document.images[img.name] = newImage;
		
	}
}

function getHomeImageLink(imageID) {
  	var href='', photo = backgrounds && backgrounds[imageID];
	if(photo){
		if (photo && photo.galleries_id != '') {
  			href = photo.fnGalleryLink();
  		}
  		  		else {
  				href += 'gallery.html';
  	  		}
	}
    return href;
}

/***************************************************************************
* Show a random image on home page from featured images                    *
***************************************************************************/
function showHomeImageInline(el, image_sets_id, href) {
	
	var css = {}, imageID,
	    imageSetsId = 1;
	if(image_sets_id){
		imageSetsId = image_sets_id;
	}
	imageID = randomListVal(imageSets[imageSetsId]);
	if (href == null && 'gallery' != '') {
					href = getHomeImageLink(imageID);
	}
	
	updateImage({nextPhoto: backgrounds[imageID], img:el.find('img')[0],
                $photo:el, $title:$('#homeimageTitleContainer'), $detail:$('#homeimageDetailsContainer'),                speed:0, href:href, css:css, onAfter: function(){                  this.closest('.contentsection').doManualAlign({				    inner: 'img',				    crop: 'a'				  });                }              });
}

/***************************************************************************
* Set 'img' to be a new image given its photo() object                     *
***************************************************************************/
function updateImage (options) {
	var defaults = {nextPhoto:'',field:'',img:'',$photo:'',$title:'',$detail:'',$detailContainer:'',
                    updateDocumentTitle:false,speed:0,href:false,css:false,updateHash:false,onAfter:null,onBefore:null},
		op = $.extend({},defaults,options),
		html = '', temp = '',
		photoId = op.nextPhoto.id,
		photoCaption = ''+op.nextPhoto.caption,
		photoSrc = op.nextPhoto.src;
	
	if (op.updateHash && clik.getIDInUrl(location.href,'photo') != op.nextPhoto.id) {
		clik.changeHash('photos_id=' + op.nextPhoto.id, true);
	}
		
	    if (op.$title.length > 0) {
  		op.$title.fadeGalleryDetails(photoCaption, op.speed);
    }
        if (op.updateDocumentTitle) {
						  document.title = 'David Bagnall 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.payment_groups_id !== '') {
		temp += '<p>Buy this print online:</p>';
				temp += '<form id="paymentOptions" style="margin:0px;border:0px;" name="paymentOptions">';
											temp += '<select class="paymentlink" name="payment_options_id" onchange="updateItemValues($(this.form).next(\'#paymentForm\')[0],this.form.payment_options_id.options[this.form.payment_options_id.options.selectedIndex].value);">';
		
		temp += getPaymentOptions(this.payment_groups_id);
		temp += '</select>';
		temp += '</form>';
				var item_option  = paymentGroups[this.payment_groups_id].options[0];
		if(paymentOptions[item_option]){
			var item_name  = paymentOptions[item_option].payment_option;
			var amount =  paymentOptions[item_option].price;
		}
			}
	else {
		
	}
	if (this.item_price !== '' || this.payment_groups_id !== '') {
			temp += '<div class="clearing">&nbsp;</div>';
	}
	return temp;};

/***************************************************************************
* Pick a photo at random from the featured images of a gallery.            *
* Gallery_id = id of gallery to choose,                                    *
* img = reference to html image in                                         *
* which to show image                                                      *
***************************************************************************/
function showGalleryImage(gallery_id, img, updateLink) {
	
	if(img){
		if (location.hash.match('galleries_id=' + gallery_id) && (imageID = location.hash.match('.*photos_id=(.+)$'))) {
		  	imageID = imageID[1];
		} else {
		  	imageID = randomListVal(galleries[gallery_id].featured_images);
		}
		
		if (imageID != 0) {
			img.src = thumbnails[imageID].src;
			img.width = thumbnails[imageID].width;
			img.height = thumbnails[imageID].height;
			img.alt = galleries[gallery_id].title;
			if (updateLink) {
				$(img).parent().attr({					title: galleries[gallery_id].title				}).filter(function(){return this.href;}).attr({					href: thumbnails[imageID].fnGalleryLink(gallery_id)				});
			}
		}
	}
}

/***************************************************************************
* If we have dynamic HTML, replace the galleries link with a list that     *
* doesn't include thecurrent gallery                                       *
***************************************************************************/
function showGalleries(gallery_id) {
		
	
	if (!basic) {
		temp = '';
		for (i = 0; i < galleries.length; i++) {
						
			
			if (galleries[i].id != gallery_id) {
								
				if (temp != '') {
					temp += ' | ';
				}
								temp += '<a href="' + galleries[i].section_code + '_' + galleries[i].id + '.html">' + galleries[i].title + '</a>';
							}
		}
		document.all.galleryLinks.innerHTML = 'Other galleries: ' + temp;
	}
}

			

