window.thumbnails = {};
															thumbnails[1770256] = clik.newPhoto({"id":1770256,"src":"edart pics 049_thumb.jpg","galleries_id":"","server_id":1,"link":"#","width":130,"caption":"","height":129});
															thumbnails[738513] = clik.newPhoto({"id":738513,"src":"142_thumb.jpg","galleries_id":57034,"server_id":1,"link":"photo_738513.html","width":130,"caption":"The 19th of December, Oil on Canvas, 120x60cm","height":52});
															thumbnails[738528] = clik.newPhoto({"id":738528,"src":"50x40cm Oil on Canvas22_thumb.JPG","galleries_id":57034,"server_id":1,"link":"photo_738528.html","width":130,"caption":"Evening on Berneray, Oil on Canvas, 40x50cm","height":92});
															thumbnails[738588] = clik.newPhoto({"id":738588,"src":"new pics oct06 004_thumb.jpg","galleries_id":57034,"server_id":1,"link":"photo_738588.html","width":130,"caption":"1st of October Portree, Oil on Canvas, 79x64cm","height":110});
															thumbnails[738599] = clik.newPhoto({"id":738599,"src":"clearing skies outer hebrides3_thumb.jpg","galleries_id":57034,"server_id":1,"link":"photo_738599.html","width":130,"caption":"Clearing Skies Outer Hebrides, 60x50cm","height":101});
															thumbnails[738603] = clik.newPhoto({"id":738603,"src":"75x60cm Oil on Canvas4_thumb.jpg","galleries_id":57034,"server_id":1,"link":"photo_738603.html","width":130,"caption":"A Break in the Clouds, Oil on Canvas, 78x60cm","height":97});
															thumbnails[738608] = clik.newPhoto({"id":738608,"src":"161_thumb.jpg","galleries_id":57040,"server_id":1,"link":"photo_738608.html","width":130,"caption":"Light showers, Hebrides, Oil on Canvas, 120x60cm","height":50});
															thumbnails[738847] = clik.newPhoto({"id":738847,"src":"HaymarketI1_thumb.jpg","galleries_id":55483,"server_id":1,"link":"photo_738847.html","width":130,"caption":"Haymarket II, Oil on Canvas, 90x95cm","height":132});
															thumbnails[738851] = clik.newPhoto({"id":738851,"src":"From Devon pl (oil on canvas) 65x85cm1_thumb.jpg","galleries_id":55483,"server_id":1,"link":"photo_738851.html","width":130,"caption":"Haymarket, Oil on Canvas, 75x95cm","height":149});
															thumbnails[738857] = clik.newPhoto({"id":738857,"src":"mayfield1_thumb.jpg","galleries_id":55483,"server_id":1,"link":"photo_738857.html","width":130,"caption":"Mayfield, Oil on Canvas, 60x50cm","height":89});
															thumbnails[738861] = clik.newPhoto({"id":738861,"src":"shoe box1_thumb.jpg","galleries_id":55483,"server_id":1,"link":"photo_738861.html","width":130,"caption":"The Bad Deal, 65x50cm, Oil on Canvas","height":85});
															thumbnails[738864] = clik.newPhoto({"id":738864,"src":"los alamos1_thumb.jpg","galleries_id":55483,"server_id":1,"link":"photo_738864.html","width":130,"caption":"Los Alamos, Oil on Canvas, 140x90cm","height":97});
															thumbnails[738882] = clik.newPhoto({"id":738882,"src":"side window5_thumb.jpg","galleries_id":55483,"server_id":1,"link":"photo_738882.html","width":130,"caption":"Side Window, Oil on Canvas, 75x95cm","height":147});
															thumbnails[738890] = clik.newPhoto({"id":738890,"src":"mums1_thumb.jpg","galleries_id":55483,"server_id":1,"link":"photo_738890.html","width":130,"caption":"Empty Swimming Pool, Oil on Board, 60x40cm","height":83});
															thumbnails[738897] = clik.newPhoto({"id":738897,"src":"still morningIII2_thumb.JPG","galleries_id":57040,"server_id":1,"link":"photo_738897.html","width":130,"caption":"Still Morning, Oil on Canvas, 120x60cm","height":50});
															thumbnails[750261] = clik.newPhoto({"id":750261,"src":"7am harris_thumb.jpg","galleries_id":57034,"server_id":1,"link":"photo_750261.html","width":130,"caption":"7am on Harris, Oil on Canvas.60x50cm","height":101});
															thumbnails[843486] = clik.newPhoto({"id":843486,"src":"new pics oct06 009_thumb.jpg","galleries_id":57034,"server_id":1,"link":"photo_843486.html","width":130,"caption":"Early Evening Outer Hebrides, Oil on Canvas, 89x95cm","height":130});
															thumbnails[848191] = clik.newPhoto({"id":848191,"src":"lakes etc 0731_thumb.jpg","galleries_id":57040,"server_id":1,"link":"photo_848191.html","width":130,"caption":"Evening Sun, Plockton, Oil on Canvas,45x54cm","height":128});
															thumbnails[848203] = clik.newPhoto({"id":848203,"src":"o2_thumb.jpg","galleries_id":57040,"server_id":1,"link":"photo_848203.html","width":130,"caption":"Plockton Towards Loch Carron, Oil on Canvas, 80x50cm","height":88});
															thumbnails[848207] = clik.newPhoto({"id":848207,"src":"arbroath and owens work 0262_thumb.jpg","galleries_id":57040,"server_id":1,"link":"photo_848207.html","width":130,"caption":"Ben Hope, Oil on Canvas, 70x54cm","height":107});
															thumbnails[1114693] = clik.newPhoto({"id":1114693,"src":"100x40cm_thumb. Oil on Canvas.jpg","galleries_id":57040,"server_id":1,"link":"photo_1114693.html","width":130,"caption":"Passing showers, Inverpolly, Oil on Canvas, 100x40cm","height":52});
															thumbnails[1186244] = clik.newPhoto({"id":1186244,"src":"new for fotheringham 022_thumb.jpg","galleries_id":57040,"server_id":1,"link":"photo_1186244.html","width":130,"caption":"8am Loch Tay","height":64});
															thumbnails[3199030] = clik.newPhoto({"id":3199030,"src":"Loch Lurgainn from Stac Pollaidh, Oil on Canvas, 70x35cm_thumb.jpg","galleries_id":57040,"server_id":1,"link":"photo_3199030.html","width":130,"caption":"Loch Luirgainn from Stac Pollaidh, Oil on Canvas, 70x35cm","height":64});
															thumbnails[3199033] = clik.newPhoto({"id":3199033,"src":"Early Morning, Glen Finnan_thumb. Oil on Canvas, 70x50cm.jpg","galleries_id":57040,"server_id":1,"link":"photo_3199033.html","width":130,"caption":"Early Morning Glenfinnan, Oil on Canvas, 70x50ccm ","height":93});
															thumbnails[3199164] = clik.newPhoto({"id":3199164,"src":"tighnabruich 075_thumb.jpg","galleries_id":57034,"server_id":1,"link":"photo_3199164.html","width":130,"caption":"9pm Loch Coruisk. Oil on Canvas. 70x35cm","height":64});
															thumbnails[3199306] = clik.newPhoto({"id":3199306,"src":"tighnabruich 079_thumb.jpg","galleries_id":195582,"server_id":1,"link":"photo_3199306.html","width":130,"caption":"Tips of Bordoy and Kunoy. Oil on Board. 50x60cm","height":148});
															thumbnails[3199344] = clik.newPhoto({"id":3199344,"src":"tighnabruich 067_thumb.jpg","galleries_id":195582,"server_id":1,"link":"photo_3199344.html","width":130,"caption":"Vidareidi Church. Oil on Canvas. 40x35cm","height":108});
															thumbnails[3199413] = clik.newPhoto({"id":3199413,"src":"commission 4 001_thumb.jpg","galleries_id":195582,"server_id":1,"link":"photo_3199413.html","width":130,"caption":"Clearing Storm over Vidareidi . Oil on Canvas. 120x90cm","height":82});
															thumbnails[3199527] = clik.newPhoto({"id":3199527,"src":"scotart 3_thumb.jpg","galleries_id":57034,"server_id":1,"link":"photo_3199527.html","width":130,"caption":"Broadford Bay. Oil on Canvas. 65x35cm","height":46});
															thumbnails[3199530] = clik.newPhoto({"id":3199530,"src":"Still  Evening, Loch Eilt_thumb. Oil on Canvas. £680.00.jpg","galleries_id":57040,"server_id":1,"link":"photo_3199530.html","width":130,"caption":"Still Evening, Loch Eilt. Oil on Canvas. 45x55cm","height":96});
															thumbnails[3199535] = clik.newPhoto({"id":3199535,"src":"Shift of Seasons, Ben Hope_thumb. Oil on Canvas. £900.00.jpg","galleries_id":57040,"server_id":1,"link":"photo_3199535.html","width":130,"caption":"Shift of Seasons, Ben Hope. Oil on Canvas. 80x60cm","height":108});
															thumbnails[3995208] = clik.newPhoto({"id":3995208,"src":"High_RannagulzionOil_on_Canvas21000dk_thumb.jpg","galleries_id":57043,"server_id":1,"link":"photo_3995208.html","width":130,"caption":"High Rannagulzion, Oil on Canvas, 120x150cm","height":95});
															thumbnails[3995636] = clik.newPhoto({"id":3995636,"src":"Mains_of_PersieOil_on_Canvas19000dk_thumb.jpg","galleries_id":57043,"server_id":1,"link":"photo_3995636.html","width":130,"caption":"Mains of Persie, Oil on Canvas, 100x150cm","height":87});
															thumbnails[4544949] = clik.newPhoto({"id":4544949,"src":"gertrude1_thumb.jpg","galleries_id":195582,"server_id":1,"link":"photo_4544949.html","width":130,"caption":"Mykines","height":109});
															thumbnails[4544954] = clik.newPhoto({"id":4544954,"src":"gertrude2_thumb.jpg","galleries_id":195582,"server_id":1,"link":"photo_4544954.html","width":130,"caption":"Hvannasund","height":65});
															thumbnails[4544957] = clik.newPhoto({"id":4544957,"src":"gertrude3_thumb.jpg","galleries_id":195582,"server_id":1,"link":"photo_4544957.html","width":130,"caption":"","height":64});
															thumbnails[4544960] = clik.newPhoto({"id":4544960,"src":"gertrude4_thumb.jpg","galleries_id":195582,"server_id":1,"link":"photo_4544960.html","width":130,"caption":"Kalsoy","height":93});
															thumbnails[4544965] = clik.newPhoto({"id":4544965,"src":"gertrude6_thumb.jpg","galleries_id":195582,"server_id":1,"link":"photo_4544965.html","width":130,"caption":"","height":104});
															thumbnails[4544968] = clik.newPhoto({"id":4544968,"src":"gertrude9_thumb.jpg","galleries_id":195582,"server_id":1,"link":"photo_4544968.html","width":130,"caption":"Over Eidi","height":106});
															thumbnails[4544971] = clik.newPhoto({"id":4544971,"src":"gertrude10_thumb.jpg","galleries_id":195582,"server_id":1,"link":"photo_4544971.html","width":130,"caption":"","height":93});
															thumbnails[4544972] = clik.newPhoto({"id":4544972,"src":"gertrude11_thumb.jpg","galleries_id":195582,"server_id":1,"link":"photo_4544972.html","width":130,"caption":"","height":105});
															thumbnails[4544974] = clik.newPhoto({"id":4544974,"src":"gertrude12_thumb.jpg","galleries_id":195582,"server_id":1,"link":"photo_4544974.html","width":130,"caption":"","height":65});
															thumbnails[4544975] = clik.newPhoto({"id":4544975,"src":"gertrude13_thumb.jpg","galleries_id":195582,"server_id":1,"link":"photo_4544975.html","width":130,"caption":"","height":86});
															thumbnails[4556193] = clik.newPhoto({"id":4556193,"src":"gertrude18_thumb.jpg","galleries_id":195582,"server_id":1,"link":"photo_4556193.html","width":130,"caption":"In Hvannasund","height":93});
															thumbnails[5840566] = clik.newPhoto({"id":5840566,"src":"Cateran_Trail_thumb.JPG","galleries_id":57043,"server_id":1,"link":"photo_5840566.html","width":130,"caption":"Newton of Gorthie. Oil on Canvas. 150x120cm","height":107});
															thumbnails[5840599] = clik.newPhoto({"id":5840599,"src":"The_Farm_Stead_Kirkton_of_Glen_Isla_Oil_on_Canvas_79x69cm_Framed_thumb.JPG","galleries_id":57043,"server_id":1,"link":"photo_5840599.html","width":130,"caption":"The Farmstead, Kirkton of Glenisla. Oil on Canvas. 50x60cm","height":108});
															thumbnails[6701325] = clik.newPhoto({"id":6701325,"src":"Cochrage_MuirOil_on_Canvas1200_thumb.JPG","galleries_id":57043,"server_id":1,"link":"photo_6701325.html","width":130,"caption":"Cochrage Muir. Oil on Canvas. ","height":98});
															thumbnails[7918816] = clik.newPhoto({"id":7918816,"src":"website_work_001_thumb.JPG","galleries_id":426840,"server_id":1,"link":"photo_7918816.html","width":130,"caption":"Big Sand. Oil and Acrylic on Board. 60x50cm.","height":115});
															thumbnails[7918899] = clik.newPhoto({"id":7918899,"src":"work_for_websire_001_thumb.JPG","galleries_id":426840,"server_id":1,"link":"photo_7918899.html","width":130,"caption":"Torridon Peaks. Oil and Acrylic on Board. 61x42cm","height":89});
															thumbnails[7918939] = clik.newPhoto({"id":7918939,"src":"work_for_websire_002_thumb.JPG","galleries_id":426840,"server_id":1,"link":"photo_7918939.html","width":130,"caption":"Torridon from Strath Bay. Oil and Acrylic on Board. 61x40cm. ","height":85});
															thumbnails[7918959] = clik.newPhoto({"id":7918959,"src":"work_for_websire_004_thumb.JPG","galleries_id":426840,"server_id":1,"link":"photo_7918959.html","width":130,"caption":"Gairloch. Oil and Acrylic on Board. 61x38cm. ","height":78});
															thumbnails[7919654] = clik.newPhoto({"id":7919654,"src":"website_work_004_thumb.JPG","galleries_id":426840,"server_id":1,"link":"photo_7919654.html","width":130,"caption":"Gairloch From Applecross. Oil and Acrylic on Canvas. 67x46cm.","height":89});
															thumbnails[7919679] = clik.newPhoto({"id":7919679,"src":"website_work_0031_thumb.JPG","galleries_id":426840,"server_id":1,"link":"photo_7919679.html","width":130,"caption":"Mellon Udrigle. Oil and Acrylic on Board. 61x42cm.","height":88});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  						galleries[57043] = clik.newGallery({"parentGallery":56905,"usePopups":false,"title":"Angus Glens and the Mearns","link":"gallery_57043.html","maxRecords":0.0,"photoIDs":[3995208.0,3995636.0,5840566.0,5840599.0,6701325.0],"skipIndex":0,"section_code":"gallery","featured_images":"3995636,3995208","id":57043,"singleSection":false});				  						galleries[55483] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Cityscape","link":"gallery_55483.html","maxRecords":0.0,"photoIDs":[738847.0,738851.0,738857.0,738861.0,738864.0,738882.0,738890.0],"skipIndex":0,"section_code":"gallery","featured_images":738851.0,"id":55483,"singleSection":false});				  						galleries[195582] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Faroe Islands","link":"gallery_195582.html","maxRecords":0.0,"photoIDs":[3199306.0,3199344.0,3199413.0,4544949.0,4544954.0,4544957.0,4544960.0,4544965.0,4544968.0,4544971.0,4544972.0,4544974.0,4544975.0,4556193.0],"skipIndex":0,"section_code":"gallery","featured_images":"4556193,4544975,4544974,4544972,4544971,4544968,4544965,4544960,4544957,4544954","id":195582,"singleSection":false});				  						galleries[57034] = clik.newGallery({"parentGallery":56905,"usePopups":false,"title":"Islands","link":"gallery_57034.html","maxRecords":0.0,"photoIDs":[738513.0,738528.0,738588.0,738599.0,738603.0,750261.0,843486.0,3199164.0,3199527.0],"skipIndex":0,"section_code":"gallery","featured_images":"3199527,843486","id":57034,"singleSection":false});				  						galleries[57040] = clik.newGallery({"parentGallery":56905,"usePopups":false,"title":"North West Scotland","link":"gallery_57040.html","maxRecords":0.0,"photoIDs":[738608.0,738897.0,848191.0,848203.0,848207.0,1114693.0,1186244.0,3199030.0,3199033.0,3199530.0,3199535.0],"skipIndex":0,"section_code":"gallery","featured_images":1114693.0,"id":57040,"singleSection":false});				  						galleries[56905] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Scottish landscape","link":"gallery_56905.html","maxRecords":0.0,"photoIDs":[],"skipIndex":0,"section_code":"gallery","featured_images":"3995636,3995208,3199527,1114693,843486","id":56905,"singleSection":false});				  						galleries[426840] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Work For Sale","link":"gallery_426840.html","maxRecords":0.0,"photoIDs":[7918816.0,7918899.0,7918939.0,7918959.0,7919654.0,7919679.0],"skipIndex":0,"section_code":"gallery","featured_images":"7919679,7919654,7918959,7918939,7918899,7918816","id":426840,"singleSection":false});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[1] = '4556193,4544965,4544957,4544949,3995636,3995208';
imageSets[2] = '3995636,3995208,3199527,1114693,843486,738851';
imageSets[3] = '4544949';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 51:
		val = 'http://www12.clikpic.com/owenhen/images';
		break;
	}
		switch (server_id) {
		case 0:
		val = 'http://www.clikpic.com/owenhen/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/owenhen/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/owenhen/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/owenhen/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/owenhen/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/owenhen/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/owenhen/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/owenhen/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/owenhen/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/owenhen/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/owenhen/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/owenhen/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/owenhen/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/owenhen/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/owenhen/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/owenhen/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/owenhen/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/owenhen/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/owenhen/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/owenhen/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/owenhen/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/owenhen/images';
		break;
	}
		switch (server_id) {
		case 53:
		val = 'http://images.clikpic.com/owenhen/images';
		break;
	}
		switch (server_id) {
		case 52:
		val = 'http://tpc22/clikpic/owenhen/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/owenhen/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/owenhen/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 = 'Owen Henderson Art: ' + 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;
	}
}

			

