window.thumbnails = {};
															thumbnails[5059364] = clik.newPhoto({"id":5059364,"src":"Gum-cleaners_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":121,"caption":"Gum Cleaners","height":80});
															thumbnails[5059366] = clik.newPhoto({"id":5059366,"src":"Toy-Town-Station_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":53,"caption":"Toy Town Station","height":80});
															thumbnails[5059368] = clik.newPhoto({"id":5059368,"src":"Oven-Cleaners_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":119,"caption":"Oven Cleaners","height":80});
															thumbnails[5059444] = clik.newPhoto({"id":5059444,"src":"Only-supposed-to-blow-the-doors-off_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":118,"caption":"Only Supposed to Blow the Doors Off!","height":80});
															thumbnails[8242907] = clik.newPhoto({"id":8242907,"src":"_MG_0644rt2alteredfnl_thumb.jpg","galleries_id":285364,"server_id":5,"link":"photo_8242907.html","width":100,"caption":"In Isolation","height":100});
															thumbnails[8534080] = clik.newPhoto({"id":8534080,"src":"_MG_1974rt-shrp_thumb.jpg","galleries_id":285363,"server_id":35,"link":"photo_8534080.html","width":67,"caption":"The road out","height":100});
															thumbnails[8577528] = clik.newPhoto({"id":8577528,"src":"_MG_1984rt2_thumb.jpg","galleries_id":381914,"server_id":35,"link":"photo_8577528.html","width":150,"caption":"","height":100});
															thumbnails[5354192] = clik.newPhoto({"id":5354192,"src":"20100108_4838-fin1_thumb.jpg","galleries_id":285363,"server_id":5,"link":"photo_5354192.html","width":160,"caption":"Sunset over Snow","height":95});
															thumbnails[6999688] = clik.newPhoto({"id":6999688,"src":"Harry-Final_thumb.jpg","galleries_id":381914,"server_id":37,"link":"photo_6999688.html","width":138,"caption":"","height":100});
															thumbnails[5551661] = clik.newPhoto({"id":5551661,"src":"EK_thumb.jpg","galleries_id":285363,"server_id":5,"link":"photo_5551661.html","width":120,"caption":"East Kilbride Village","height":80});
															thumbnails[7054699] = clik.newPhoto({"id":7054699,"src":"_MG_0743-fnl_thumb.jpg","galleries_id":381914,"server_id":37,"link":"photo_7054699.html","width":100,"caption":"","height":100});
															thumbnails[5043734] = clik.newPhoto({"id":5043734,"src":"Skye11_thumb.jpg","galleries_id":285363,"server_id":5,"link":"photo_5043734.html","width":121,"caption":"Old Man of Storr, Skye","height":80});
															thumbnails[8242975] = clik.newPhoto({"id":8242975,"src":"_MG_0684rtcol_thumb.jpg","galleries_id":285364,"server_id":5,"link":"photo_8242975.html","width":72,"caption":"","height":100});
															thumbnails[8577531] = clik.newPhoto({"id":8577531,"src":"_MG_1259rt1_thumb.jpg","galleries_id":453461,"server_id":35,"link":"photo_8577531.html","width":143,"caption":"","height":100});
															thumbnails[8577986] = clik.newPhoto({"id":8577986,"src":"_MG_0324rt_thumb.jpg","galleries_id":381914,"server_id":37,"link":"photo_8577986.html","width":100,"caption":"","height":100});
															thumbnails[8591972] = clik.newPhoto({"id":8591972,"src":"_MG_2036_thumb.jpg","galleries_id":454411,"server_id":37,"link":"photo_8591972.html","width":67,"caption":"","height":100});
															thumbnails[6999691] = clik.newPhoto({"id":6999691,"src":"_MG_7996-rt_thumb.jpg","galleries_id":381914,"server_id":37,"link":"photo_6999691.html","width":159,"caption":"","height":100});
															thumbnails[8577530] = clik.newPhoto({"id":8577530,"src":"_MG_1651rt-flat-shrp-1_thumb.jpg","galleries_id":381914,"server_id":35,"link":"photo_8577530.html","width":67,"caption":"","height":100});
															thumbnails[7054925] = clik.newPhoto({"id":7054925,"src":"_MG_0606fnl_thumb.jpg","galleries_id":381914,"server_id":5,"link":"photo_7054925.html","width":67,"caption":"","height":100});
															thumbnails[5043864] = clik.newPhoto({"id":5043864,"src":"Glasgownight_thumb.jpg","galleries_id":285410,"server_id":5,"link":"photo_5043864.html","width":120,"caption":"Glasgow by Night","height":80});
															thumbnails[5059578] = clik.newPhoto({"id":5059578,"src":"Abandonment_thumb.jpg","galleries_id":286292,"server_id":5,"link":"photo_5059578.html","width":58,"caption":"Abandonment","height":80});
															thumbnails[5354183] = clik.newPhoto({"id":5354183,"src":"tree-1_thumb.jpg","galleries_id":285363,"server_id":5,"link":"photo_5354183.html","width":130,"caption":"A Foggy Day in my Local Town","height":73});
															thumbnails[6999693] = clik.newPhoto({"id":6999693,"src":"_MG_0020rt_thumb.jpg","galleries_id":381914,"server_id":19,"link":"photo_6999693.html","width":150,"caption":"","height":100});
															thumbnails[7055266] = clik.newPhoto({"id":7055266,"src":"_MG_0258rt_thumb.jpg","galleries_id":381914,"server_id":37,"link":"photo_7055266.html","width":150,"caption":"","height":100});
															thumbnails[8242977] = clik.newPhoto({"id":8242977,"src":"_MG_0679rt2_thumb.jpg","galleries_id":285364,"server_id":5,"link":"photo_8242977.html","width":149,"caption":"Banjo Pier, Cornwall","height":100});
															thumbnails[8577532] = clik.newPhoto({"id":8577532,"src":"_MG_8659rt_thumb.jpg","galleries_id":453461,"server_id":35,"link":"photo_8577532.html","width":150,"caption":"","height":100});
															thumbnails[8591973] = clik.newPhoto({"id":8591973,"src":"_MG_2047_thumb.jpg","galleries_id":454411,"server_id":37,"link":"photo_8591973.html","width":67,"caption":"","height":100});
															thumbnails[8243071] = clik.newPhoto({"id":8243071,"src":"_MG_0720rt2fnl_thumb.jpg","galleries_id":285364,"server_id":5,"link":"photo_8243071.html","width":71,"caption":"","height":100});
															thumbnails[6999700] = clik.newPhoto({"id":6999700,"src":"Bob-Final-Final_thumb.jpg","galleries_id":286292,"server_id":5,"link":"photo_6999700.html","width":72,"caption":"","height":100});
															thumbnails[6999938] = clik.newPhoto({"id":6999938,"src":"20100427_5260_thumb.jpg","galleries_id":285410,"server_id":5,"link":"photo_6999938.html","width":119,"caption":"Old and New","height":80});
															thumbnails[8243079] = clik.newPhoto({"id":8243079,"src":"_MG_0727rtfnl_thumb.jpg","galleries_id":285364,"server_id":5,"link":"photo_8243079.html","width":153,"caption":"","height":100});
															thumbnails[7555931] = clik.newPhoto({"id":7555931,"src":"Groynes_thumb.jpg","galleries_id":285364,"server_id":5,"link":"photo_7555931.html","width":133,"caption":"Calming","height":100});
															thumbnails[8591974] = clik.newPhoto({"id":8591974,"src":"_MG_2055_thumb.jpg","galleries_id":454411,"server_id":37,"link":"photo_8591974.html","width":150,"caption":"","height":100});
															thumbnails[5043707] = clik.newPhoto({"id":5043707,"src":"Lewis_20090911_2272-rt_thumb.jpg","galleries_id":381914,"server_id":37,"link":"photo_5043707.html","width":66,"caption":"","height":100});
															thumbnails[8243233] = clik.newPhoto({"id":8243233,"src":"_MG_8377rt-sqr_thumb.jpg","galleries_id":285364,"server_id":5,"link":"photo_8243233.html","width":100,"caption":"Twin Peaks","height":100});
															thumbnails[6999608] = clik.newPhoto({"id":6999608,"src":"20100306_4945rt_thumb.jpg","galleries_id":381914,"server_id":19,"link":"photo_6999608.html","width":71,"caption":"","height":100});
															thumbnails[5059583] = clik.newPhoto({"id":5059583,"src":"Caught-in-the-Corridor_thumb.jpg","galleries_id":286292,"server_id":5,"link":"photo_5059583.html","width":56,"caption":"Caught in the Corridor","height":80});
															thumbnails[8577534] = clik.newPhoto({"id":8577534,"src":"_MG_8964rt2fin_thumb.jpg","galleries_id":453461,"server_id":35,"link":"photo_8577534.html","width":73,"caption":"","height":100});
															thumbnails[8591975] = clik.newPhoto({"id":8591975,"src":"_MG_2087_thumb.jpg","galleries_id":454411,"server_id":37,"link":"photo_8591975.html","width":69,"caption":"","height":100});
															thumbnails[5551355] = clik.newPhoto({"id":5551355,"src":"_MG_7400-rt-k_thumb.jpg","galleries_id":381914,"server_id":19,"link":"photo_5551355.html","width":100,"caption":"","height":100});
															thumbnails[8591976] = clik.newPhoto({"id":8591976,"src":"_MG_2097_thumb.jpg","galleries_id":454411,"server_id":37,"link":"photo_8591976.html","width":141,"caption":"","height":100});
															thumbnails[8577536] = clik.newPhoto({"id":8577536,"src":"_MG_8794rt_thumb.jpg","galleries_id":453461,"server_id":35,"link":"photo_8577536.html","width":137,"caption":"","height":100});
															thumbnails[8239650] = clik.newPhoto({"id":8239650,"src":"_MG_1205rt_thumb.jpg","galleries_id":453461,"server_id":5,"link":"photo_8239650.html","width":150,"caption":"","height":100});
															thumbnails[5167465] = clik.newPhoto({"id":5167465,"src":"Derelict_thumb.jpg","galleries_id":286292,"server_id":5,"link":"photo_5167465.html","width":120,"caption":"Derelict","height":80});
															thumbnails[8577538] = clik.newPhoto({"id":8577538,"src":"_MG_9766_thumb.jpg","galleries_id":453461,"server_id":35,"link":"photo_8577538.html","width":132,"caption":"","height":100});
															thumbnails[8591978] = clik.newPhoto({"id":8591978,"src":"_MG_2103_thumb.jpg","galleries_id":454411,"server_id":37,"link":"photo_8591978.html","width":67,"caption":"","height":100});
															thumbnails[8591979] = clik.newPhoto({"id":8591979,"src":"_MG_2109_thumb.jpg","galleries_id":454411,"server_id":37,"link":"photo_8591979.html","width":160,"caption":"","height":98});
															thumbnails[6999640] = clik.newPhoto({"id":6999640,"src":"20100306_4901rt_thumb.jpg","galleries_id":381914,"server_id":19,"link":"photo_6999640.html","width":71,"caption":"","height":100});
															thumbnails[5551347] = clik.newPhoto({"id":5551347,"src":"_MG_0489fnl_thumb.jpg","galleries_id":381914,"server_id":19,"link":"photo_5551347.html","width":67,"caption":"","height":100});
															thumbnails[5551357] = clik.newPhoto({"id":5551357,"src":"_MG_0432rt_thumb.jpg","galleries_id":381914,"server_id":19,"link":"photo_5551357.html","width":139,"caption":"","height":100});
															thumbnails[5551371] = clik.newPhoto({"id":5551371,"src":"20100104_4745-rt_thumb.jpg","galleries_id":381914,"server_id":19,"link":"photo_5551371.html","width":150,"caption":"","height":100});
															thumbnails[8650222] = clik.newPhoto({"id":8650222,"src":"_MG_2302_thumb.jpg","galleries_id":381914,"server_id":19,"link":"photo_8650222.html","width":143,"caption":"","height":100});
															thumbnails[5551374] = clik.newPhoto({"id":5551374,"src":"_MG_2220_thumb.jpg","galleries_id":381914,"server_id":19,"link":"photo_5551374.html","width":67,"caption":"","height":100});
															thumbnails[8650224] = clik.newPhoto({"id":8650224,"src":"_MG_2333_thumb.jpg","galleries_id":381914,"server_id":19,"link":"photo_8650224.html","width":149,"caption":"","height":100});
															thumbnails[8572992] = clik.newPhoto({"id":8572992,"src":"_MG_1463_thumb.jpg","galleries_id":381914,"server_id":38,"link":"photo_8572992.html","width":66,"caption":"","height":100});
															thumbnails[8572993] = clik.newPhoto({"id":8572993,"src":"_MG_1544_thumb.jpg","galleries_id":381914,"server_id":38,"link":"photo_8572993.html","width":145,"caption":"","height":100});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  						galleries[381914] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Portraiture","link":"gallery_381914.html","maxRecords":0.0,"photoIDs":[8577528.0,6999688.0,7054699.0,8577986.0,6999691.0,8577530.0,7054925.0,6999693.0,7055266.0,5043707.0,6999608.0,5551355.0,6999640.0,5551347.0,5551357.0,5551371.0,8650222.0,5551374.0,8650224.0,8572992.0,8572993.0],"skipIndex":0,"section_code":"gallery","featured_images":"8577528,7055266,6999693","id":381914,"singleSection":false});				  						galleries[285363] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Landscapes","link":"gallery_285363.html","maxRecords":0.0,"photoIDs":[8534080.0,5354192.0,5551661.0,5043734.0,5354183.0],"skipIndex":0,"section_code":"gallery","featured_images":"8534080,5354192,5354183,5043734","id":285363,"singleSection":false});				  						galleries[285364] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Seascapes","link":"gallery_285364.html","maxRecords":0.0,"photoIDs":[8242907.0,8242975.0,8242977.0,8243071.0,8243079.0,7555931.0,8243233.0],"skipIndex":0,"section_code":"gallery","featured_images":8242907.0,"id":285364,"singleSection":false});				  						galleries[454411] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"the Country","link":"gallery_454411.html","maxRecords":0.0,"photoIDs":[8591972.0,8591973.0,8591974.0,8591975.0,8591976.0,8591978.0,8591979.0],"skipIndex":0,"section_code":"gallery","featured_images":8591974.0,"id":454411,"singleSection":false});				  						galleries[285410] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"About Town","link":"gallery_285410.html","maxRecords":0.0,"photoIDs":[5043864.0,6999938.0],"skipIndex":0,"section_code":"gallery","featured_images":5043864.0,"id":285410,"singleSection":false});				  						galleries[286292] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Mood","link":"gallery_286292.html","maxRecords":0.0,"photoIDs":[5059578.0,6999700.0,5059583.0,5167465.0],"skipIndex":0,"section_code":"gallery","featured_images":5059578.0,"id":286292,"singleSection":false});				  						galleries[453461] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Events","link":"gallery_453461.html","maxRecords":0.0,"photoIDs":[8577531.0,8577532.0,8577534.0,8577536.0,8239650.0,8577538.0],"skipIndex":0,"section_code":"gallery","featured_images":8577531.0,"id":453461,"singleSection":false});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[1] = '8577528,5043734,7054925,7055266';
imageSets[2] = '8577528,8534080,8242907,5354192,8577531,5043734,7055266,6999693,5354183,5059578,5043864,8591974,5059368';
imageSets[3] = '8650224,8650222,8591979,8591978,8591976,8591975,8591974,8591973,8591972,8577986,8577538,8577536,8577534,8577532,8577531,8577530,8577528,8572993,8572992,8534080,8243233,8243079,8243071,8242977,8242975,8242907,8239650,7555931,7055266,7054925,7054699,6999938,6999700,6999693,6999691,6999688,6999640,6999608,5551661,5551374,5551371,5551357,5551355,5551347,5354192,5354183,5167465,5059583,5059578,5059444';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 51:
		val = 'www12.clikpic.com/scottsmac/images';
		break;
	}
		switch (server_id) {
		case 0:
		val = 'www.clikpic.com/scottsmac/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/scottsmac/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/scottsmac/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/scottsmac/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/scottsmac/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/scottsmac/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/scottsmac/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/scottsmac/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/scottsmac/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/scottsmac/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/scottsmac/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/scottsmac/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/scottsmac/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/scottsmac/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/scottsmac/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/scottsmac/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/scottsmac/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/scottsmac/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/scottsmac/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/scottsmac/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/scottsmac/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/scottsmac/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/scottsmac/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/scottsmac/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 = 'Scott Macmillan Photography LimeGreenImages: ' + 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> &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="scottsmac@sky.com">';
					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="scottsmac@sky.com">';
				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;
	}
}

			

