window.thumbnails = {};
															thumbnails[2422189] = clik.newPhoto({"id":2422189,"src":"Affront-To-Memory_thumb.gif","galleries_id":156542,"server_id":32,"link":"photo_2422189.html","width":130,"caption":"Affront to Memory","height":94});
															thumbnails[2422204] = clik.newPhoto({"id":2422204,"src":"Enter-MG_thumb.gif","galleries_id":156956,"server_id":32,"link":"photo_2422204.html","width":130,"caption":"ENTER","height":129});
															thumbnails[2422270] = clik.newPhoto({"id":2422270,"src":"Difficult-relationship_thumb.gif","galleries_id":156565,"server_id":32,"link":"photo_2422270.html","width":130,"caption":"Difficult Relationship","height":94});
															thumbnails[2429114] = clik.newPhoto({"id":2429114,"src":"Awkward-Moment_thumb.gif","galleries_id":156565,"server_id":32,"link":"photo_2429114.html","width":130,"caption":"Awkward Moment","height":183});
															thumbnails[2429206] = clik.newPhoto({"id":2429206,"src":"Ascent1_thumb.gif","galleries_id":156956,"server_id":32,"link":"photo_2429206.html","width":130,"caption":"ASCENT","height":132});
															thumbnails[2429234] = clik.newPhoto({"id":2429234,"src":"Above-and-Beyond1_thumb.gif","galleries_id":156956,"server_id":32,"link":"photo_2429234.html","width":130,"caption":"","height":130});
															thumbnails[2429270] = clik.newPhoto({"id":2429270,"src":"Forgotten-But-Not-Gone_thumb.gif","galleries_id":156542,"server_id":32,"link":"photo_2429270.html","width":130,"caption":"FORGOTTEN BUT NOT GONE","height":94});
															thumbnails[2429274] = clik.newPhoto({"id":2429274,"src":"Hidden-Depths_thumb.gif","galleries_id":156565,"server_id":32,"link":"photo_2429274.html","width":130,"caption":"HIDDEN DEPTHS","height":94});
															thumbnails[2429276] = clik.newPhoto({"id":2429276,"src":"Improved-Communication-1_thumb.gif","galleries_id":156542,"server_id":32,"link":"photo_2429276.html","width":130,"caption":"IMPROVED COMMUNICATION","height":94});
															thumbnails[2429278] = clik.newPhoto({"id":2429278,"src":"In-Black-and-White-1_thumb.gif","galleries_id":156542,"server_id":32,"link":"photo_2429278.html","width":130,"caption":"IN BLACK AND WHITE","height":95});
															thumbnails[2429324] = clik.newPhoto({"id":2429324,"src":"Positioning_thumb.gif","galleries_id":156565,"server_id":32,"link":"photo_2429324.html","width":130,"caption":"POSITIONING","height":94});
															thumbnails[2429326] = clik.newPhoto({"id":2429326,"src":"Precarious-Incident_thumb.gif","galleries_id":156542,"server_id":32,"link":"photo_2429326.html","width":130,"caption":"PRECARIOUS INCIDENT","height":94});
															thumbnails[2429330] = clik.newPhoto({"id":2429330,"src":"Relative-Strengths-1_thumb.gif","galleries_id":156542,"server_id":32,"link":"photo_2429330.html","width":130,"caption":"RELATIVE STRENGTHS","height":94});
															thumbnails[2429372] = clik.newPhoto({"id":2429372,"src":"Icon_thumb.gif","galleries_id":156956,"server_id":32,"link":"photo_2429372.html","width":130,"caption":"ICON","height":134});
															thumbnails[2429376] = clik.newPhoto({"id":2429376,"src":"In-The-Wrong_thumb.gif","galleries_id":156956,"server_id":32,"link":"photo_2429376.html","width":130,"caption":"IN THE WRONG","height":130});
															thumbnails[2429379] = clik.newPhoto({"id":2429379,"src":"Move-On_thumb.gif","galleries_id":156956,"server_id":32,"link":"photo_2429379.html","width":130,"caption":"MOVE ON","height":129});
															thumbnails[2429384] = clik.newPhoto({"id":2429384,"src":"Silly-Point_thumb.gif","galleries_id":156565,"server_id":32,"link":"photo_2429384.html","width":130,"caption":"SILLY POINT","height":188});
															thumbnails[2429829] = clik.newPhoto({"id":2429829,"src":"Watershed-1_thumb.gif","galleries_id":156542,"server_id":32,"link":"photo_2429829.html","width":130,"caption":"WATERSHED","height":94});
															thumbnails[2429831] = clik.newPhoto({"id":2429831,"src":"Vital-Signs-1_thumb.gif","galleries_id":156542,"server_id":32,"link":"photo_2429831.html","width":130,"caption":"VITAL SIGNS","height":94});
															thumbnails[2429835] = clik.newPhoto({"id":2429835,"src":"This-Pathetic-Enclosure-1_thumb.gif","galleries_id":156542,"server_id":32,"link":"photo_2429835.html","width":130,"caption":"THIS PATHETIC ENCLOSURE","height":92});
															thumbnails[2429837] = clik.newPhoto({"id":2429837,"src":"The-Hidden-Accomplice-1_thumb.gif","galleries_id":156542,"server_id":32,"link":"photo_2429837.html","width":130,"caption":"THE HIDDEN ACCOMPLICE","height":92});
															thumbnails[2637025] = clik.newPhoto({"id":2637025,"src":"An-Outlook_thumb.gif","galleries_id":156565,"server_id":32,"link":"photo_2637025.html","width":130,"caption":"An Outlook","height":65});
															thumbnails[2637030] = clik.newPhoto({"id":2637030,"src":"barrier_thumb.gif","galleries_id":156565,"server_id":32,"link":"photo_2637030.html","width":130,"caption":"Barrier","height":55});
															thumbnails[2637034] = clik.newPhoto({"id":2637034,"src":"Compartments_thumb.gif","galleries_id":156565,"server_id":32,"link":"photo_2637034.html","width":130,"caption":"Compartments","height":61});
															thumbnails[2421083] = clik.newPhoto({"id":2421083,"src":"APresence1_thumb.gif","galleries_id":156542,"server_id":32,"link":"photo_2421083.html","width":130,"caption":"A PRESENCE","height":93});
															thumbnails[2421070] = clik.newPhoto({"id":2421070,"src":"AccidentalIntrusion1_thumb.gif","galleries_id":156542,"server_id":32,"link":"photo_2421070.html","width":130,"caption":"ACCIDENTAL INTRUSION","height":94});
															thumbnails[2429260] = clik.newPhoto({"id":2429260,"src":"Always-Greener_thumb.gif","galleries_id":158122,"server_id":32,"link":"photo_2429260.html","width":130,"caption":"Always Greener<br>\r\n<br>\r\n","height":94});
															thumbnails[4165185] = clik.newPhoto({"id":4165185,"src":"Michael_Griffiths_Out_of_No_thumb.gif","galleries_id":158123,"server_id":32,"link":"photo_4165185.html","width":130,"caption":"Out Of Nowhere","height":107});
															thumbnails[2637042] = clik.newPhoto({"id":2637042,"src":"Haven-_thumb.gif","galleries_id":158122,"server_id":32,"link":"photo_2637042.html","width":130,"caption":"Haven","height":96});
															thumbnails[2429322] = clik.newPhoto({"id":2429322,"src":"Moving-and-Shaking_thumb.gif","galleries_id":158122,"server_id":32,"link":"photo_2429322.html","width":130,"caption":"Moving and Shaking<br>\r\n","height":100});
															thumbnails[3347133] = clik.newPhoto({"id":3347133,"src":"Hit-And-Miss_thumb.gif","galleries_id":158122,"server_id":32,"link":"photo_3347133.html","width":130,"caption":"Hit and Miss","height":96});
															thumbnails[4165371] = clik.newPhoto({"id":4165371,"src":"Michael_Griffiths_Conduit1_thumb.gif","galleries_id":158123,"server_id":32,"link":"photo_4165371.html","width":130,"caption":"Conduit","height":107});
															thumbnails[3347136] = clik.newPhoto({"id":3347136,"src":"Near-And-Far_thumb.gif","galleries_id":158122,"server_id":32,"link":"photo_3347136.html","width":130,"caption":"Near And Far","height":95});
															thumbnails[3347139] = clik.newPhoto({"id":3347139,"src":"Shadow-Of-A-Doubt_thumb.gif","galleries_id":158122,"server_id":32,"link":"photo_3347139.html","width":130,"caption":"Shadow Of A Doubt","height":100});
															thumbnails[3347142] = clik.newPhoto({"id":3347142,"src":"Shed-Load_thumb.gif","galleries_id":158122,"server_id":32,"link":"photo_3347142.html","width":130,"caption":"Shed Load","height":96});
															thumbnails[3347143] = clik.newPhoto({"id":3347143,"src":"Three-Things_thumb.gif","galleries_id":158122,"server_id":32,"link":"photo_3347143.html","width":130,"caption":"Three Things","height":96});
															thumbnails[3347149] = clik.newPhoto({"id":3347149,"src":"Untitled_thumb.gif","galleries_id":158122,"server_id":32,"link":"photo_3347149.html","width":130,"caption":"Untitled","height":96});
															thumbnails[3347095] = clik.newPhoto({"id":3347095,"src":"13_thumb.X.08.gif","galleries_id":158122,"server_id":32,"link":"photo_3347095.html","width":130,"caption":"6.10.08","height":96});
															thumbnails[3347118] = clik.newPhoto({"id":3347118,"src":"27_thumb.XI.08.gif","galleries_id":158122,"server_id":32,"link":"photo_3347118.html","width":130,"caption":"Weak Green Thing","height":97});
															thumbnails[3130634] = clik.newPhoto({"id":3130634,"src":"trialdrawing2_thumb.gif","galleries_id":158122,"server_id":32,"link":"photo_3130634.html","width":130,"caption":"Figure and Ground","height":96});
															thumbnails[3130603] = clik.newPhoto({"id":3130603,"src":"trial-drawing_thumb.gif","galleries_id":158122,"server_id":32,"link":"photo_3130603.html","width":130,"caption":"4.11.08","height":97});
															thumbnails[3331507] = clik.newPhoto({"id":3331507,"src":"27_thumb.X.08.gif","galleries_id":158122,"server_id":32,"link":"photo_3331507.html","width":130,"caption":"27.10.08<br>\r\n","height":97});
															thumbnails[4165229] = clik.newPhoto({"id":4165229,"src":"Michael_Griffiths_Reflectio_thumb.gif","galleries_id":158123,"server_id":32,"link":"photo_4165229.html","width":130,"caption":"Reflection","height":109});
															thumbnails[3347127] = clik.newPhoto({"id":3347127,"src":"Dogma_thumb.gif","galleries_id":158122,"server_id":32,"link":"photo_3347127.html","width":130,"caption":"Dogma","height":98});
															thumbnails[3347132] = clik.newPhoto({"id":3347132,"src":"Echo_thumb.gif","galleries_id":158122,"server_id":32,"link":"photo_3347132.html","width":130,"caption":"Echo","height":95});
															thumbnails[3347099] = clik.newPhoto({"id":3347099,"src":"24_thumb.VIII.08.gif","galleries_id":158122,"server_id":32,"link":"photo_3347099.html","width":130,"caption":"Flying And Failing","height":96});
															thumbnails[4165369] = clik.newPhoto({"id":4165369,"src":"Michael_Griffiths_Fielded1_thumb.gif","galleries_id":158123,"server_id":32,"link":"photo_4165369.html","width":130,"caption":"Fielded","height":100});
															thumbnails[4165236] = clik.newPhoto({"id":4165236,"src":"Michael_Griffiths_Terroir1_thumb.gif","galleries_id":158123,"server_id":32,"link":"photo_4165236.html","width":130,"caption":"Terroir","height":111});
															thumbnails[3347144] = clik.newPhoto({"id":3347144,"src":"Untitled-(big)_thumb.gif","galleries_id":158122,"server_id":32,"link":"photo_3347144.html","width":130,"caption":"Untitled","height":102});
															thumbnails[4165321] = clik.newPhoto({"id":4165321,"src":"Michael_Griffiths_Interfere_thumb.gif","galleries_id":158123,"server_id":32,"link":"photo_4165321.html","width":130,"caption":"Interference","height":110});
															thumbnails[4165212] = clik.newPhoto({"id":4165212,"src":"Michael_Griffiths_From_The__thumb.gif","galleries_id":158123,"server_id":32,"link":"photo_4165212.html","width":130,"caption":"From The Heart","height":108});
															thumbnails[4165373] = clik.newPhoto({"id":4165373,"src":"Michael_Griffiths_Strange_P_thumb.gif","galleries_id":158123,"server_id":32,"link":"photo_4165373.html","width":130,"caption":"Strange Place","height":107});
															thumbnails[6575389] = clik.newPhoto({"id":6575389,"src":"MG_PassingThrough455x61_thumb.jpg","galleries_id":158123,"server_id":32,"link":"photo_6575389.html","width":130,"caption":"Passing Through","height":98});
															thumbnails[6575402] = clik.newPhoto({"id":6575402,"src":"MG_Place_455x61_thumb.jpg","galleries_id":158123,"server_id":32,"link":"photo_6575402.html","width":130,"caption":"Place","height":96});
															thumbnails[6575409] = clik.newPhoto({"id":6575409,"src":"MG_Two_Enclosures_38x56_thumb.jpg","galleries_id":158123,"server_id":32,"link":"photo_6575409.html","width":130,"caption":"Two Enclosures","height":88});
															thumbnails[6575414] = clik.newPhoto({"id":6575414,"src":"MG_ForAllWeKnow_38x56_thumb.jpg","galleries_id":158123,"server_id":32,"link":"photo_6575414.html","width":130,"caption":"For All We Know","height":89});
															thumbnails[6575420] = clik.newPhoto({"id":6575420,"src":"MG_Forgiveness_38x56_thumb.jpg","galleries_id":158123,"server_id":32,"link":"photo_6575420.html","width":130,"caption":"Forgiveness","height":89});
															thumbnails[6575426] = clik.newPhoto({"id":6575426,"src":"MG_Valid_38x56_thumb.jpg","galleries_id":158123,"server_id":32,"link":"photo_6575426.html","width":130,"caption":"Valid","height":88});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  						galleries[158123] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"PAINTINGS","link":"gallery_158123.html","maxRecords":0.0,"photoIDs":[4165185.0,4165371.0,4165229.0,4165369.0,4165236.0,4165321.0,4165212.0,4165373.0,6575389.0,6575402.0,6575409.0,6575414.0,6575420.0,6575426.0],"skipIndex":0,"section_code":"gallery","featured_images":"6575426,6575420,6575414,6575409,6575402,6575389,4165373,4165371,4165369,4165321","id":158123,"singleSection":false});				  						galleries[158122] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"DRAWINGS","link":"gallery_158122.html","maxRecords":0.0,"photoIDs":[2429260.0,2637042.0,2429322.0,3347133.0,3347136.0,3347139.0,3347142.0,3347143.0,3347149.0,3347095.0,3347118.0,3130634.0,3130603.0,3331507.0,3347127.0,3347132.0,3347099.0,3347144.0],"skipIndex":0,"section_code":"gallery","featured_images":3347095.0,"id":158122,"singleSection":false});				  						galleries[156542] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"UNTHINKABLE","link":"gallery_156542.html","maxRecords":0.0,"photoIDs":[2422189.0,2429270.0,2429276.0,2429278.0,2429326.0,2429330.0,2429829.0,2429831.0,2429835.0,2429837.0,2421083.0,2421070.0],"skipIndex":0,"section_code":"gallery","featured_images":"2429837,2429835,2429831,2429829,2429330,2429326,2429278,2429276,2429270,2422189","id":156542,"singleSection":false});				  						galleries[156956] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"MINIATURE PRINTS","link":"gallery_156956.html","maxRecords":0.0,"photoIDs":[2422204.0,2429206.0,2429234.0,2429372.0,2429376.0,2429379.0],"skipIndex":0,"section_code":"gallery","featured_images":"2429379,2429376,2429372,2429234,2429206,2422204","id":156956,"singleSection":false});				  						galleries[156565] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"OTHER PRINTS","link":"gallery_156565.html","maxRecords":0.0,"photoIDs":[2422270.0,2429114.0,2429274.0,2429324.0,2429384.0,2637025.0,2637030.0,2637034.0],"skipIndex":0,"section_code":"gallery","featured_images":"2637034,2637030,2637025,2429384,2429324,2429274,2429114,2422270","id":156565,"singleSection":false});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[1] = '6575389,6575402,6575409,6575414,6575420,6575426';
imageSets[2] = '3347095';
imageSets[3] = '6575426,6575420,6575414,6575409,6575402,6575389,4165373,4165371,4165369,4165321,4165236,4165229,4165212,4165185,3347149,3347144,3347143,3347142,3347139,3347136,3347133,3347132,3347127,3347118,3347099,3347095,3331507,3130634,3130603,2637042,2637034,2637030,2637025,2429837,2429835,2429831,2429829,2429384,2429379,2429376,2429372,2429330,2429326,2429324,2429322,2429278,2429276,2429274,2429270,2429260';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 51:
		val = 'http://www12.clikpic.com/mikegriffithsis/images';
		break;
	}
		switch (server_id) {
		case 0:
		val = 'http://www.clikpic.com/mikegriffithsis/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/mikegriffithsis/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/mikegriffithsis/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/mikegriffithsis/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/mikegriffithsis/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/mikegriffithsis/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/mikegriffithsis/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/mikegriffithsis/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/mikegriffithsis/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/mikegriffithsis/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/mikegriffithsis/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/mikegriffithsis/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/mikegriffithsis/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/mikegriffithsis/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/mikegriffithsis/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/mikegriffithsis/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/mikegriffithsis/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/mikegriffithsis/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/mikegriffithsis/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/mikegriffithsis/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/mikegriffithsis/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/mikegriffithsis/images';
		break;
	}
		switch (server_id) {
		case 53:
		val = 'http://images.clikpic.com/mikegriffithsis/images';
		break;
	}
		switch (server_id) {
		case 52:
		val = 'http://tpc22/clikpic/mikegriffithsis/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/mikegriffithsis/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/mikegriffithsis/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 = 'Michael Griffiths: ' + 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;
	}
}

			

