window.thumbnails = {};
															thumbnails[5167842] = clik.newPhoto({"id":5167842,"src":"POTY_thumb.jpg","galleries_id":"","server_id":1,"link":"#","width":130,"caption":"","height":31});
															thumbnails[8947499] = clik.newPhoto({"id":8947499,"src":"NX_FB029_TN_thumb.jpg","galleries_id":"","server_id":1,"link":"#","width":130,"caption":"","height":130});
															thumbnails[8153569] = clik.newPhoto({"id":8153569,"src":"McQueens_DSC5791_thumb.jpg","galleries_id":435792,"server_id":1,"link":"photo_8153569.html","width":130,"caption":"McQueens Dairies","height":87});
															thumbnails[8945523] = clik.newPhoto({"id":8945523,"src":"Alfa_Giulietta-3_thumb.jpg","galleries_id":470886,"server_id":1,"link":"photo_8945523.html","width":130,"caption":"Alfa Romeo Guilietta","height":87});
															thumbnails[8157518] = clik.newPhoto({"id":8157518,"src":"RP_DSC3142_thumb.jpg","galleries_id":435792,"server_id":1,"link":"photo_8157518.html","width":130,"caption":"Richmond Park Hotel, Bo'ness","height":87});
															thumbnails[8945734] = clik.newPhoto({"id":8945734,"src":"DQP_AstonMartin-8256-Edit_thumb.jpg","galleries_id":470886,"server_id":1,"link":"photo_8945734.html","width":130,"caption":"Aston Martin Rapide","height":130});
															thumbnails[8157523] = clik.newPhoto({"id":8157523,"src":"RP_DSC4018_thumb.jpg","galleries_id":435792,"server_id":1,"link":"photo_8157523.html","width":130,"caption":"Richmond Park Hotel, Bo'ness","height":87});
															thumbnails[8945614] = clik.newPhoto({"id":8945614,"src":"AudiA7-_thumb.jpg","galleries_id":470886,"server_id":1,"link":"photo_8945614.html","width":130,"caption":"Audi A7","height":87});
															thumbnails[8157530] = clik.newPhoto({"id":8157530,"src":"RP_DSC3925_thumb.jpg","galleries_id":435792,"server_id":1,"link":"photo_8157530.html","width":130,"caption":"Richmond Park Hotel, Bo'ness","height":87});
															thumbnails[8945626] = clik.newPhoto({"id":8945626,"src":"BentlyContGT-1_thumb.jpg","galleries_id":470886,"server_id":1,"link":"photo_8945626.html","width":130,"caption":"Bentley Continental GT","height":87});
															thumbnails[8153573] = clik.newPhoto({"id":8153573,"src":"Wyman-7431_thumb.jpg","galleries_id":435792,"server_id":1,"link":"photo_8153573.html","width":130,"caption":"Wyman Gordon","height":194});
															thumbnails[8945632] = clik.newPhoto({"id":8945632,"src":"BentlyContGT-10_thumb.jpg","galleries_id":470886,"server_id":1,"link":"photo_8945632.html","width":130,"caption":"Bentley Continental GT","height":87});
															thumbnails[8945636] = clik.newPhoto({"id":8945636,"src":"BMW1M_68_thumb.jpg","galleries_id":470886,"server_id":1,"link":"photo_8945636.html","width":130,"caption":"BMW 1 Series M Coupé","height":88});
															thumbnails[8951492] = clik.newPhoto({"id":8951492,"src":"LAB_2259_thumb.jpg","galleries_id":435792,"server_id":1,"link":"photo_8951492.html","width":130,"caption":"Lucy Batt, Glass Design","height":194});
															thumbnails[8945826] = clik.newPhoto({"id":8945826,"src":"Jag-1002-Edit_thumb.jpg","galleries_id":470886,"server_id":1,"link":"photo_8945826.html","width":130,"caption":"Jaguar XK","height":87});
															thumbnails[8945829] = clik.newPhoto({"id":8945829,"src":"Lamborghini_9479_thumb.jpg","galleries_id":470886,"server_id":1,"link":"photo_8945829.html","width":130,"caption":"Lamborghini Gallardo Superleggera","height":87});
															thumbnails[8945822] = clik.newPhoto({"id":8945822,"src":"DQP_Outlander_DSC8930_thumb.jpg","galleries_id":470886,"server_id":1,"link":"photo_8945822.html","width":130,"caption":"Mitsubishi Outlander","height":87});
															thumbnails[8945832] = clik.newPhoto({"id":8945832,"src":"Nissan370Z_-2135-Edit_thumb.jpg","galleries_id":470886,"server_id":1,"link":"photo_8945832.html","width":130,"caption":"Nissan 370Z","height":87});
															thumbnails[8945833] = clik.newPhoto({"id":8945833,"src":"NissanGTR_thumb.jpg","galleries_id":470886,"server_id":1,"link":"photo_8945833.html","width":130,"caption":"Nissan GTR","height":87});
															thumbnails[8946886] = clik.newPhoto({"id":8946886,"src":"NX_BL013_thumb.jpg","galleries_id":435703,"server_id":1,"link":"photo_8946886.html","width":130,"caption":"Blackness castle","height":87});
															thumbnails[8946913] = clik.newPhoto({"id":8946913,"src":"NX_BL006_thumb.jpg","galleries_id":435704,"server_id":1,"link":"photo_8946913.html","width":130,"caption":"Blackness Castle","height":194});
															thumbnails[8946893] = clik.newPhoto({"id":8946893,"src":"NX_CL001_thumb.jpg","galleries_id":435703,"server_id":1,"link":"photo_8946893.html","width":130,"caption":"The Cloch Lighthouse","height":87});
															thumbnails[8947283] = clik.newPhoto({"id":8947283,"src":"NX_CL002_thumb.jpg","galleries_id":435704,"server_id":1,"link":"photo_8947283.html","width":130,"caption":"The Cloch Lighthouse","height":194});
															thumbnails[8946897] = clik.newPhoto({"id":8946897,"src":"NX_FB029_thumb.jpg","galleries_id":435703,"server_id":1,"link":"photo_8946897.html","width":130,"caption":"The Forth Bridge","height":87});
															thumbnails[8947296] = clik.newPhoto({"id":8947296,"src":"NX_GC005_thumb.jpg","galleries_id":435704,"server_id":1,"link":"photo_8947296.html","width":130,"caption":"Buachaille Etive Mor","height":194});
															thumbnails[8946916] = clik.newPhoto({"id":8946916,"src":"NX_CR003_thumb.jpg","galleries_id":435704,"server_id":1,"link":"photo_8946916.html","width":130,"caption":"Cramond Causeway","height":130});
															thumbnails[8946978] = clik.newPhoto({"id":8946978,"src":"NX_FB033_thumb.jpg","galleries_id":435703,"server_id":1,"link":"photo_8946978.html","width":130,"caption":"Forth Road Bridge","height":194});
															thumbnails[8946986] = clik.newPhoto({"id":8946986,"src":"NX_GC002_thumb.jpg","galleries_id":435703,"server_id":1,"link":"photo_8946986.html","width":130,"caption":"The Buachaille Etive Mor","height":194});
															thumbnails[8947289] = clik.newPhoto({"id":8947289,"src":"NX_CR006_thumb.jpg","galleries_id":435704,"server_id":1,"link":"photo_8947289.html","width":130,"caption":"Cramond Marker","height":130});
															thumbnails[8947137] = clik.newPhoto({"id":8947137,"src":"NX_LAWE_002_thumb.jpg","galleries_id":435703,"server_id":1,"link":"photo_8947137.html","width":130,"caption":"Kilchurn Castle, Loch Awe","height":194});
															thumbnails[8947356] = clik.newPhoto({"id":8947356,"src":"NX_NH012_thumb.jpg","galleries_id":435704,"server_id":1,"link":"photo_8947356.html","width":130,"caption":"Platinum Point Posts","height":130});
															thumbnails[8946983] = clik.newPhoto({"id":8946983,"src":"NX_FW001_thumb.jpg","galleries_id":435703,"server_id":1,"link":"photo_8946983.html","width":130,"caption":"The Falkirk Wheel","height":87});
															thumbnails[8947312] = clik.newPhoto({"id":8947312,"src":"NX_HER002_thumb.jpg","galleries_id":435704,"server_id":1,"link":"photo_8947312.html","width":130,"caption":"Falls of Braan","height":194});
															thumbnails[8946993] = clik.newPhoto({"id":8946993,"src":"NX_HER001_thumb.jpg","galleries_id":435703,"server_id":1,"link":"photo_8946993.html","width":130,"caption":"The Hermitage, Dunkeld","height":87});
															thumbnails[8947330] = clik.newPhoto({"id":8947330,"src":"NX_LA007_thumb.jpg","galleries_id":435704,"server_id":1,"link":"photo_8947330.html","width":130,"caption":"Loch Ard Jetty","height":194});
															thumbnails[8947009] = clik.newPhoto({"id":8947009,"src":"NX_LA003_thumb.jpg","galleries_id":435703,"server_id":1,"link":"photo_8947009.html","width":130,"caption":"Loch Ard","height":87});
															thumbnails[8947333] = clik.newPhoto({"id":8947333,"src":"NX_LA009_thumb.jpg","galleries_id":435704,"server_id":1,"link":"photo_8947333.html","width":130,"caption":"Loch Ard Jetty","height":194});
															thumbnails[8947136] = clik.newPhoto({"id":8947136,"src":"NX_LAWE_001_thumb.jpg","galleries_id":435703,"server_id":1,"link":"photo_8947136.html","width":130,"caption":"Kilchurn Castle, Loch Awe","height":87});
															thumbnails[8947374] = clik.newPhoto({"id":8947374,"src":"NX_STM002_thumb.jpg","galleries_id":435704,"server_id":1,"link":"photo_8947374.html","width":130,"caption":"St Monans Breakwater","height":130});
															thumbnails[8947143] = clik.newPhoto({"id":8947143,"src":"NX_LAWE_004_thumb.jpg","galleries_id":435703,"server_id":1,"link":"photo_8947143.html","width":130,"caption":"Kilchurn Castle, Loch Awe","height":87});
															thumbnails[8947153] = clik.newPhoto({"id":8947153,"src":"NX_LAWE_005_thumb.jpg","galleries_id":435703,"server_id":1,"link":"photo_8947153.html","width":130,"caption":"Kilchurn Castle, Loch Awe","height":87});
															thumbnails[8947157] = clik.newPhoto({"id":8947157,"src":"NX_LL01_Edit_thumb.jpg","galleries_id":435703,"server_id":1,"link":"photo_8947157.html","width":130,"caption":"Loch Lomond","height":87});
															thumbnails[8947166] = clik.newPhoto({"id":8947166,"src":"NX_NB0011_thumb.jpg","galleries_id":435703,"server_id":1,"link":"photo_8947166.html","width":130,"caption":"The Old Pier, North Berwick","height":194});
															thumbnails[7379191] = clik.newPhoto({"id":7379191,"src":"Emily-12_600px_thumb.jpg","galleries_id":435322,"server_id":1,"link":"photo_7379191.html","width":130,"caption":"","height":87});
															thumbnails[8151645] = clik.newPhoto({"id":8151645,"src":"DQP_DG9927_crop_thumb.jpg","galleries_id":435322,"server_id":1,"link":"photo_8151645.html","width":130,"caption":"","height":163});
															thumbnails[8287413] = clik.newPhoto({"id":8287413,"src":"Hannah_DSC9164_thumb.jpg","galleries_id":435322,"server_id":1,"link":"photo_8287413.html","width":130,"caption":"","height":195});
															thumbnails[8153554] = clik.newPhoto({"id":8153554,"src":"WymanGordon_TidyArea_Poster_thumb.jpg","galleries_id":435777,"server_id":1,"link":"photo_8153554.html","width":130,"caption":"Wyman Gordon","height":184});
															thumbnails[8947616] = clik.newPhoto({"id":8947616,"src":"Scotsman_AstonMartin_Cover1_thumb.jpg","galleries_id":435774,"server_id":1,"link":"photo_8947616.html","width":130,"caption":"The Scotsman Motoring Supplement","height":156});
															thumbnails[8947626] = clik.newPhoto({"id":8947626,"src":"Scotsman_Audi_A7_thumb.jpg","galleries_id":435774,"server_id":1,"link":"photo_8947626.html","width":130,"caption":"The Scotsman Motoring Supplement","height":82});
															thumbnails[8947627] = clik.newPhoto({"id":8947627,"src":"Scotsman_BentlyFeature1_thumb.jpg","galleries_id":435774,"server_id":1,"link":"photo_8947627.html","width":130,"caption":"The Scotsman Motoring Supplement","height":78});
															thumbnails[8947629] = clik.newPhoto({"id":8947629,"src":"Scotsman_BMW1_thumb.jpg","galleries_id":435774,"server_id":1,"link":"photo_8947629.html","width":130,"caption":"The Scotsman Motoring Supplement","height":81});
															thumbnails[8947634] = clik.newPhoto({"id":8947634,"src":"Scotsman_Jags_Nov11_thumb.jpg","galleries_id":435774,"server_id":1,"link":"photo_8947634.html","width":130,"caption":"The Scotsman Motoring Supplement","height":40});
															thumbnails[8947636] = clik.newPhoto({"id":8947636,"src":"Scotsman_Lamborghini1_thumb.jpg","galleries_id":435774,"server_id":1,"link":"photo_8947636.html","width":130,"caption":"The Scotsman Motoring Supplement","height":156});
															thumbnails[8947638] = clik.newPhoto({"id":8947638,"src":"Scotsman_Nissan370z_thumb.jpg","galleries_id":435774,"server_id":1,"link":"photo_8947638.html","width":130,"caption":"The Scotsman Motoring Supplement","height":41});
															thumbnails[8947640] = clik.newPhoto({"id":8947640,"src":"Scotsman_Outlander_thumb.jpg","galleries_id":435774,"server_id":1,"link":"photo_8947640.html","width":130,"caption":"The Scotsman Motoring Supplement","height":41});
															thumbnails[8947643] = clik.newPhoto({"id":8947643,"src":"Scotsman_Pulse_Alfa1_thumb.jpg","galleries_id":435774,"server_id":1,"link":"photo_8947643.html","width":130,"caption":"The Pulse Magazine","height":175});
															thumbnails[8157566] = clik.newPhoto({"id":8157566,"src":"BlackRiver_thumb.jpg","galleries_id":435798,"server_id":1,"link":"photo_8157566.html","width":130,"caption":"Quintessentially Liquid Magazine","height":87});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  						galleries[435774] = clik.newGallery({"parentGallery":"","usePopups":true,"title":"Automotive","link":"section522692_435774.html","maxRecords":0.0,"photoIDs":[8947616.0,8947626.0,8947627.0,8947629.0,8947634.0,8947636.0,8947638.0,8947640.0,8947643.0],"skipIndex":0,"section_code":"section522692","featured_images":8947616.0,"id":435774,"singleSection":false});				  						galleries[470886] = clik.newGallery({"parentGallery":"","usePopups":true,"title":"Automotive","link":"section522576.html","maxRecords":0.0,"photoIDs":[8945523.0,8945734.0,8945614.0,8945626.0,8945632.0,8945636.0,8945826.0,8945829.0,8945822.0,8945832.0,8945833.0],"skipIndex":0,"section_code":"section522576","featured_images":"8945833,8945832,8945829,8945826,8945822,8945734,8945636,8945632,8945626,8945614","id":470886,"singleSection":true});				  						galleries[435703] = clik.newGallery({"parentGallery":"","usePopups":true,"title":"Colour","link":"section307145_435703.html","maxRecords":0.0,"photoIDs":[8946886.0,8946893.0,8946897.0,8946978.0,8946986.0,8947137.0,8946983.0,8946993.0,8947009.0,8947136.0,8947143.0,8947153.0,8947157.0,8947166.0],"skipIndex":0,"section_code":"section307145","featured_images":8947499,"id":435703,"singleSection":false});				  						galleries[435777] = clik.newGallery({"parentGallery":"","usePopups":true,"title":"Commercial","link":"section522692_435777.html","maxRecords":0.0,"photoIDs":[8153554.0],"skipIndex":0,"section_code":"section522692","featured_images":8153554.0,"id":435777,"singleSection":false});				  						galleries[435792] = clik.newGallery({"parentGallery":"","usePopups":true,"title":"Commercial","link":"section522662.html","maxRecords":0.0,"photoIDs":[8153569.0,8157518.0,8157523.0,8157530.0,8153573.0,8951492.0],"skipIndex":0,"section_code":"section522662","featured_images":8153573.0,"id":435792,"singleSection":true});				  						galleries[435798] = clik.newGallery({"parentGallery":"","usePopups":true,"title":"Landscapes","link":"section522692_435798.html","maxRecords":0.0,"photoIDs":[8157566.0],"skipIndex":0,"section_code":"section522692","featured_images":8157566.0,"id":435798,"singleSection":false});				  						galleries[435704] = clik.newGallery({"parentGallery":"","usePopups":true,"title":"Mono","link":"section307145_435704.html","maxRecords":0.0,"photoIDs":[8946913.0,8947283.0,8947296.0,8946916.0,8947289.0,8947356.0,8947312.0,8947330.0,8947333.0,8947374.0],"skipIndex":0,"section_code":"section307145","featured_images":8946916.0,"id":435704,"singleSection":false});				  						galleries[435322] = clik.newGallery({"parentGallery":"","usePopups":true,"title":"People","link":"gallery.html","maxRecords":0.0,"photoIDs":[7379191.0,8151645.0,8287413.0],"skipIndex":0,"section_code":"gallery","featured_images":"8287413,8151645,7379191","id":435322,"singleSection":true});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[1] = '8945826';
imageSets[2] = '8947616,8153554,8946897,8946916,8153573';
imageSets[3] = '8951492,8947643,8947640,8947638,8947636,8947634,8947629,8947627,8947626,8947616,8947499,8947374,8947356,8947333,8947330,8947312,8947296,8947289,8947283,8947166,8947157,8947153,8947143,8947137,8947136,8947009,8946993,8946986,8946983,8946978,8946916,8946913,8946897,8946893,8946886,8945833,8945832,8945829,8945826,8945822,8945734,8945636,8945632,8945626,8945614,8945523,8287413,8157566,8157530,8157523';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 51:
		val = 'http://www12.clikpic.com/dqueenan/images';
		break;
	}
		switch (server_id) {
		case 0:
		val = 'http://www.clikpic.com/dqueenan/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/dqueenan/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/dqueenan/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/dqueenan/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/dqueenan/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/dqueenan/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/dqueenan/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/dqueenan/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/dqueenan/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/dqueenan/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/dqueenan/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/dqueenan/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/dqueenan/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/dqueenan/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/dqueenan/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/dqueenan/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/dqueenan/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/dqueenan/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/dqueenan/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/dqueenan/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/dqueenan/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/dqueenan/images';
		break;
	}
		switch (server_id) {
		case 53:
		val = 'http://images.clikpic.com/dqueenan/images';
		break;
	}
		switch (server_id) {
		case 52:
		val = 'http://tpc22/clikpic/dqueenan/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/dqueenan/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/dqueenan/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 += 'section522576.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 && 'section522576' != '') {
					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 Queenan 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>';
	}
				
	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="daqueenan@blueyonder.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="daqueenan@blueyonder.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;
	}
}

			

