window.thumbnails = {};
															thumbnails[4055376] = clik.newPhoto({"id":4055376,"src":"MiniReflectioncopyrightprotected2009_thumb.JPG","galleries_id":243105,"server_id":15,"link":"photo_4055376.html","width":130,"caption":"Mini Reflection   £300","height":174});
															thumbnails[4055384] = clik.newPhoto({"id":4055384,"src":"TheFoyerbyRobertCordingleycopyrightprotected2009_thumb.JPG","galleries_id":243105,"server_id":15,"link":"photo_4055384.html","width":130,"caption":"The Foyer £300","height":108});
															thumbnails[4099974] = clik.newPhoto({"id":4099974,"src":"BeachHutIByRobertCordingleycopyrightprotected2009_thumb.JPG","galleries_id":243865,"server_id":15,"link":"photo_4099974.html","width":130,"caption":"Beach Hut I  sold","height":163});
															thumbnails[4806012] = clik.newPhoto({"id":4806012,"src":"For_web_Copy_of_waterloo__by_R_Cordingley_copyright_protected_2009_thumb.jpg","galleries_id":243105,"server_id":15,"link":"photo_4806012.html","width":130,"caption":"Waterloo sold","height":138});
															thumbnails[4864162] = clik.newPhoto({"id":4864162,"src":"Hong_Kong_by_Robert_Cordingley_copyright_protected_2009_thumb.jpg","galleries_id":243105,"server_id":15,"link":"photo_4864162.html","width":130,"caption":"Hong Kong I  £300","height":100});
															thumbnails[5461886] = clik.newPhoto({"id":5461886,"src":"Digger_Reflection_Camden_by_Robert_Cordingley_copyright_protected_2010_thumb.jpg","galleries_id":243105,"server_id":15,"link":"photo_5461886.html","width":130,"caption":"Digger, Camden Town Reflection £700","height":129});
															thumbnails[5461954] = clik.newPhoto({"id":5461954,"src":"Fish_Reflection_by_Robert_Cordingley_for_web_copyright_protected_20101_thumb.jpg","galleries_id":243865,"server_id":15,"link":"photo_5461954.html","width":130,"caption":"Fish Reflection   £300","height":130});
															thumbnails[5663713] = clik.newPhoto({"id":5663713,"src":"cookham_bridge_for_web_copyright_protected_Rcordingley2010_thumb.jpg","galleries_id":243865,"server_id":15,"link":"photo_5663713.html","width":130,"caption":"Cookham Bridge  sold","height":94});
															thumbnails[5831029] = clik.newPhoto({"id":5831029,"src":"The_Barbican_copyright_protected_2010_by_Robert_Cordingley_thumb.jpg","galleries_id":243865,"server_id":15,"link":"photo_5831029.html","width":130,"caption":"Yellow Boat  £500","height":183});
															thumbnails[5839772] = clik.newPhoto({"id":5839772,"src":"Devon_Coastline_by_Robert_Cordingley_copyright_protected_2010_thumb.jpg","galleries_id":243865,"server_id":15,"link":"photo_5839772.html","width":130,"caption":"Devon Coastline   £500","height":181});
															thumbnails[5839794] = clik.newPhoto({"id":5839794,"src":"Streetscene_by_Robert_Cordingley_copyright_protected_2010_thumb.jpg","galleries_id":243105,"server_id":15,"link":"photo_5839794.html","width":130,"caption":"Streetscene £400","height":153});
															thumbnails[5840023] = clik.newPhoto({"id":5840023,"src":"New_Image_thumb.JPG","galleries_id":330454,"server_id":15,"link":"photo_5840023.html","width":130,"caption":"Rob at work ","height":141});
															thumbnails[5840028] = clik.newPhoto({"id":5840028,"src":"photo_with_paintings_2010_thumb.jpg","galleries_id":330454,"server_id":15,"link":"photo_5840028.html","width":130,"caption":"","height":194});
															thumbnails[5840031] = clik.newPhoto({"id":5840031,"src":"Plymouth_Affordable_art_fair_2009_thumb.jpg","galleries_id":330454,"server_id":15,"link":"photo_5840031.html","width":130,"caption":"Plymouth Art Fair","height":98});
															thumbnails[5840038] = clik.newPhoto({"id":5840038,"src":"chelsea_and_westminster_Hospital_2010_thumb.jpg","galleries_id":330454,"server_id":15,"link":"photo_5840038.html","width":130,"caption":"Chelsea and Westmister Show","height":98});
															thumbnails[5840053] = clik.newPhoto({"id":5840053,"src":"photo_of_studio_thumb.JPG","galleries_id":330454,"server_id":15,"link":"photo_5840053.html","width":130,"caption":"Rob at work","height":87});
															thumbnails[5840057] = clik.newPhoto({"id":5840057,"src":"Timmy_Mallett1_thumb.jpg","galleries_id":330454,"server_id":15,"link":"photo_5840057.html","width":130,"caption":"Timmy Mallett visits Rob's exhibition at Cookham","height":173});
															thumbnails[5840727] = clik.newPhoto({"id":5840727,"src":"The_Barbican_Series_II_thumb.jpg","galleries_id":243865,"server_id":15,"link":"photo_5840727.html","width":130,"caption":"Blue boat   £575","height":195});
															thumbnails[5840741] = clik.newPhoto({"id":5840741,"src":"The_Barbican_Series_III_thumb.jpg","galleries_id":243865,"server_id":15,"link":"photo_5840741.html","width":130,"caption":"Three Boats   £425","height":93});
															thumbnails[6651649] = clik.newPhoto({"id":6651649,"src":"For_website_david_gray_portrait_copyright_protected_2010_thumb.jpg","galleries_id":363778,"server_id":15,"link":"photo_6651649.html","width":130,"caption":"A Portrait of Painter David Gray 2010","height":98});
															thumbnails[6657487] = clik.newPhoto({"id":6657487,"src":"for_website_david_gray_portrait__by_R_Cordingley_copyright_protected_2010_thumb.jpg","galleries_id":363778,"server_id":15,"link":"photo_6657487.html","width":130,"caption":"David Gray","height":174});
															thumbnails[8329274] = clik.newPhoto({"id":8329274,"src":"Puffins_thumb.jpg","galleries_id":243106,"server_id":15,"link":"photo_8329274.html","width":130,"caption":"Puffins   £395","height":105});
															thumbnails[8397000] = clik.newPhoto({"id":8397000,"src":"Becky_at_South_Stacks_fro_web_copyright_protected_rcordingley_2011_thumb.jpg","galleries_id":243106,"server_id":15,"link":"photo_8397000.html","width":130,"caption":"South Stacks   £1200","height":168});
															thumbnails[8397006] = clik.newPhoto({"id":8397006,"src":"Royal_Naval_College_Dartmouth_R.Cordingley_copyright_protected_2011_thumb.jpg","galleries_id":243106,"server_id":15,"link":"photo_8397006.html","width":130,"caption":"Dartmouth Royal Naval College   £500","height":64});
															thumbnails[8397011] = clik.newPhoto({"id":8397011,"src":"Dartmouth_castle_thumb.jpg","galleries_id":243106,"server_id":15,"link":"photo_8397011.html","width":130,"caption":"Dartmouth castle   £295","height":103});
															thumbnails[8399892] = clik.newPhoto({"id":8399892,"src":"Appledore_Quay_copyright_protected_RCordingley_2011_thumb.jpg","galleries_id":243106,"server_id":15,"link":"photo_8399892.html","width":130,"caption":"Appledore Quay   £200","height":169});
															thumbnails[8399894] = clik.newPhoto({"id":8399894,"src":"Appledore_thumb.jpg","galleries_id":243106,"server_id":15,"link":"photo_8399894.html","width":130,"caption":"Instow   £275","height":157});
															thumbnails[8399896] = clik.newPhoto({"id":8399896,"src":"Barbican_Flags_thumb.jpg","galleries_id":243106,"server_id":15,"link":"photo_8399896.html","width":130,"caption":"Flags, The Barbican   £475","height":179});
															thumbnails[8399897] = clik.newPhoto({"id":8399897,"src":"Barbican_Red_Boat_R.Cordingley_copyright_protected_2011_thumb.jpg","galleries_id":243106,"server_id":15,"link":"photo_8399897.html","width":130,"caption":"The Barbican   £300","height":156});
															thumbnails[8399899] = clik.newPhoto({"id":8399899,"src":"Barbican_red_boat_thumb.jpg","galleries_id":243106,"server_id":15,"link":"photo_8399899.html","width":130,"caption":"Red Boat  £475","height":184});
															thumbnails[8399900] = clik.newPhoto({"id":8399900,"src":"Beach_Huts_RCordingley_copyright_protected_2011_thumb.jpg","galleries_id":243106,"server_id":15,"link":"photo_8399900.html","width":130,"caption":"Beach Huts  £35","height":123});
															thumbnails[8399901] = clik.newPhoto({"id":8399901,"src":"beach_huts_thumb.jpg","galleries_id":243106,"server_id":15,"link":"photo_8399901.html","width":130,"caption":"Beach Huts £125","height":106});
															thumbnails[8399903] = clik.newPhoto({"id":8399903,"src":"Burgh_Island_RCordingley_copyright_protected_2011_thumb.jpg","galleries_id":243106,"server_id":15,"link":"photo_8399903.html","width":130,"caption":"Burgh Island  £225","height":115});
															thumbnails[8399905] = clik.newPhoto({"id":8399905,"src":"crab_sketch_thumb.jpg","galleries_id":243106,"server_id":15,"link":"photo_8399905.html","width":130,"caption":"Crab Sketch   £150","height":102});
															thumbnails[8399907] = clik.newPhoto({"id":8399907,"src":"Dartmouth_Ferry_for_web_R._Cordingley_copyright_protected_2011_thumb.jpg","galleries_id":243106,"server_id":15,"link":"photo_8399907.html","width":130,"caption":"Tug Boat £200","height":107});
															thumbnails[8399909] = clik.newPhoto({"id":8399909,"src":"DSCF6781_thumb.jpg","galleries_id":243106,"server_id":15,"link":"photo_8399909.html","width":130,"caption":"The Barbican - Sketch  £100","height":110});
															thumbnails[8399910] = clik.newPhoto({"id":8399910,"src":"DSCF6782_thumb.jpg","galleries_id":243106,"server_id":15,"link":"photo_8399910.html","width":130,"caption":"Three Boats   £425","height":102});
															thumbnails[8399913] = clik.newPhoto({"id":8399913,"src":"DSCF6784_thumb.jpg","galleries_id":243106,"server_id":15,"link":"photo_8399913.html","width":130,"caption":"John Dory  £375","height":105});
															thumbnails[8399915] = clik.newPhoto({"id":8399915,"src":"Fish_thumb.jpg","galleries_id":243106,"server_id":15,"link":"photo_8399915.html","width":130,"caption":"Red Mullet  £85","height":50});
															thumbnails[8399918] = clik.newPhoto({"id":8399918,"src":"green_blue_barbican_thumb.jpg","galleries_id":243106,"server_id":15,"link":"photo_8399918.html","width":130,"caption":"Two Boats £295","height":109});
															thumbnails[8399920] = clik.newPhoto({"id":8399920,"src":"Hartland_copyright_protected_RCordingley_2011_thumb.jpg","galleries_id":243106,"server_id":15,"link":"photo_8399920.html","width":130,"caption":"Hartland Quay  £400","height":98});
															thumbnails[8399921] = clik.newPhoto({"id":8399921,"src":"Henley_on_Thames__rcordingley_Copyright_protected_2011_thumb.jpg","galleries_id":243106,"server_id":15,"link":"photo_8399921.html","width":130,"caption":"Henley on Thames  £295","height":98});
															thumbnails[8399925] = clik.newPhoto({"id":8399925,"src":"Large_Devon_coastline_copyright_protected_RCordingley_2011_thumb.jpg","galleries_id":243106,"server_id":15,"link":"photo_8399925.html","width":130,"caption":"Devon Coastline   £500","height":171});
															thumbnails[8399928] = clik.newPhoto({"id":8399928,"src":"Lobster_Copyright_protected_RCordingley2011_thumb.jpg","galleries_id":243106,"server_id":15,"link":"photo_8399928.html","width":130,"caption":"Lobster  £475","height":69});
															thumbnails[8399932] = clik.newPhoto({"id":8399932,"src":"Rowing_Boats_27061FBF-24E8-5EC4-4FAB9B7F21761A8F_thumb.jpg","galleries_id":243106,"server_id":15,"link":"photo_8399932.html","width":130,"caption":"Rowing Boats  £500","height":98});
															thumbnails[8399935] = clik.newPhoto({"id":8399935,"src":"Small_Beach_Hut_copyright_protected_RCordingley_2011_thumb.jpg","galleries_id":243106,"server_id":15,"link":"photo_8399935.html","width":130,"caption":"Beach Hut  £45","height":173});
															thumbnails[8399939] = clik.newPhoto({"id":8399939,"src":"Small_seascape_RCordingley_copyright_protected_2011_thumb.jpg","galleries_id":243106,"server_id":15,"link":"photo_8399939.html","width":130,"caption":"Coastline  £300","height":156});
															thumbnails[8399943] = clik.newPhoto({"id":8399943,"src":"Taw_and_Torridge_RCoridngley_Copyright_protected_2011_thumb.jpg","galleries_id":243106,"server_id":15,"link":"photo_8399943.html","width":130,"caption":"The Taw and Torridge   £55","height":167});
															thumbnails[8399949] = clik.newPhoto({"id":8399949,"src":"The_Barbican_blue_boat_RCordingley_copyright_protected_2011_thumb.jpg","galleries_id":243106,"server_id":15,"link":"photo_8399949.html","width":130,"caption":"Blue Boat II  £200","height":145});
															thumbnails[8399952] = clik.newPhoto({"id":8399952,"src":"The_Barbican_yellow_version_RCordingley_copyright_protected_2011_thumb.jpg","galleries_id":243106,"server_id":15,"link":"photo_8399952.html","width":130,"caption":"Yellow Boat II   £700","height":171});
															thumbnails[8399956] = clik.newPhoto({"id":8399956,"src":"The_Barbican_Series_RCordingley_Copyright_Protected_thumb.jpg","galleries_id":243106,"server_id":15,"link":"photo_8399956.html","width":130,"caption":"Blue Boat £575","height":179});
															thumbnails[8399971] = clik.newPhoto({"id":8399971,"src":"Yellow_boat_barbican_thumb.jpg","galleries_id":243106,"server_id":15,"link":"photo_8399971.html","width":130,"caption":"Yellow Boat  £500","height":174});
															thumbnails[8403048] = clik.newPhoto({"id":8403048,"src":"crab_thumb.jpg","galleries_id":243106,"server_id":15,"link":"photo_8403048.html","width":130,"caption":"The Crab   £500","height":99});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  						galleries[243105] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Cityscapes","link":"gallery_243105.html","maxRecords":0.0,"photoIDs":[4055376.0,4055384.0,4806012.0,4864162.0,5461886.0,5839794.0],"skipIndex":0,"section_code":"gallery","featured_images":"5461886,4806012","id":243105,"singleSection":false});				  						galleries[243865] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Waterside","link":"gallery_243865.html","maxRecords":0.0,"photoIDs":[4099974.0,5461954.0,5663713.0,5831029.0,5839772.0,5840727.0,5840741.0],"skipIndex":0,"section_code":"gallery","featured_images":5840727.0,"id":243865,"singleSection":false});				  						galleries[330454] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Photos ","link":"gallery_330454.html","maxRecords":0.0,"photoIDs":[5840023.0,5840028.0,5840031.0,5840038.0,5840053.0,5840057.0],"skipIndex":0,"section_code":"gallery","featured_images":"5840057,5840053,5840038,5840031,5840028,5840023","id":330454,"singleSection":false});				  						galleries[243106] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Coastal Vision","link":"gallery_243106.html","maxRecords":0.0,"photoIDs":[8329274.0,8397000.0,8397006.0,8397011.0,8399892.0,8399894.0,8399896.0,8399897.0,8399899.0,8399900.0,8399901.0,8399903.0,8399905.0,8399907.0,8399909.0,8399910.0,8399913.0,8399915.0,8399918.0,8399920.0,8399921.0,8399925.0,8399928.0,8399932.0,8399935.0,8399939.0,8399943.0,8399949.0,8399952.0,8399956.0,8399971.0,8403048.0],"skipIndex":0,"section_code":"gallery","featured_images":8329274.0,"id":243106,"singleSection":false});				  						galleries[363778] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Portraits","link":"gallery_363778.html","maxRecords":0.0,"photoIDs":[6651649.0,6657487.0],"skipIndex":0,"section_code":"gallery","featured_images":"6657487,6651649","id":363778,"singleSection":false});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[1] = '8397000,8329274,5840023';
imageSets[2] = '8329274,5840727,5461886,4806012';
imageSets[3] = '5840741,5461886,4864162';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 51:
		val = 'www12.clikpic.com/RobertIC/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/RobertIC/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/RobertIC/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/RobertIC/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/RobertIC/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/RobertIC/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/RobertIC/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/RobertIC/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/RobertIC/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/RobertIC/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/RobertIC/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/RobertIC/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/RobertIC/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/RobertIC/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/RobertIC/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/RobertIC/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/RobertIC/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/RobertIC/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/RobertIC/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/RobertIC/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/RobertIC/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/RobertIC/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/RobertIC/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/RobertIC/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 = 'Oil Paintings By Robert Cordingley: ' + photoCaption;
			    }
        if (op.$detail.length > 0) {
      	temp = op.nextPhoto.fnGetImageDetails();
	    op.$detail.fadeGalleryDetails(temp, op.speed, function(){
			if (typeof(backgrounds) != 'undefined' && op.nextPhoto == backgrounds[op.nextPhoto.id]) {
				toggleAddToCartConfirm(backgrounds, op.$detail);
			} else if (typeof(photos) != 'undefined' && op.nextPhoto == photos[op.nextPhoto.id]) {
				toggleAddToCartConfirm(photos, op.$detail);
			}
			$('body').trigger('clikUpdate.popup');
	    });
    }
        $(op.$detailContainer).find('.replaceable[class*=replaceable_photo-]').each(function(){
    	var field = clik.getPrefixedClass(this.className, 'replaceable_photo-');
    	if (field in op.nextPhoto) {
    		$(this).fadeGalleryDetails(op.nextPhoto[field], op.speed);
    	}
    }).end().find('.replaceable.photoPayment').fadeGalleryDetails(op.nextPhoto.fnGetPaymentInfo(), op.speed, function(){
		if (typeof(backgrounds) != 'undefined' && op.nextPhoto == backgrounds[op.nextPhoto.id]) {
			toggleAddToCartConfirm(backgrounds, op.$detailContainer);
		} else if (typeof(photos) != 'undefined' && op.nextPhoto == photos[op.nextPhoto.id]) {
			toggleAddToCartConfirm(photos, op.$detailContainer);
		}
		$('body').trigger('clikUpdate.popup');
	});
		if (op.$photo.length > 0) {
		html = $('<img/>',{
			'class': 'mainphoto photo',
			src: photoSrc,
			id: 'mainPic',
			name: 'mainPic',
			width: op.nextPhoto.width,
			height: op.nextPhoto.height,
			alt: photoCaption,
			css: op.css || {}
		});
		if (op.href) {
			if (op.href.match(/<a/)) {
				html = $(op.href).append(html);
			} else {
				html = $('<a/>', {
					href: op.href,
					title: photoCaption
				}).append(html);
			}
		} else {
			html = $('<a/>', {
				title: photoCaption
			}).append(html);
		}
		if (op.speed == 0) {			op.$photo.html(html);			if (op.onBefore) {			  	op.onBefore.apply(op.$photo);			}			if (op.onAfter) {			  	op.onAfter.apply(op.$photo);			}		} else {			op.$photo.stop(true,true).fadeReplaceWith(html,op.speed,'',function(){  				if (op.onAfter) {				  	op.onAfter.apply(this);				}				clik.doColumnResize(false, $(this).add(op.$detail).add(op.$title));			}, op.onBefore);
		}	}
    if (op.field) {
		op.field.value = photoId;
	} else {
		op.$photo.data('image_id', photoId);
    }
        if (!op.speed) {
      	clik.doColumnResize(false, op.$photo.add(op.$detail).add(op.$title));
    }
        
    return html;
	}

/***************************************************************************
* Toggle add to cart confirmation element and set up the click event for   *
* the 'Add to cart' button.                                                *
***************************************************************************/
function toggleAddToCartConfirm(array, root){
	if (typeof(array) !== 'object' || array === null) {
	  	array = photos;
	}
	if (!$(root).length) {		root = $('body');	}	if($('#paymentConfirm', root).length > 0){
		$('#paymentConfirm', root).hide();
		$('#paymentAddButton', root)
		.unbind()
		.click(function(){
						form = $('#paymentForm', root)[0];
			option_id = 0;
			if(form.item_option.value){
				option_id = form.item_option.value;
			}
			if(addItemToBasket(form.item_number.value,array,form.site.value,parseInt(form.quantity.value, 10),option_id)){
				if($.browser.msie){$('#paymentConfirm', root).text('Item added to cart').show();}
				else{
					$('#paymentConfirm', root).text('Item added to cart').fadeIn();
					dspOrderDetails(form.site.value);
				}
			}
			else{
				$('#paymentConfirm', root).text('Item not added - check cookies are enabled in your browser.').fadeIn();
			}
		});
	}
}

/***************************************************************************
* Get payment info for image - add as 'method' to photo object             *
***************************************************************************/
clik.photo.fnGetImageDetails = function(){
	var temp = '';
	if (this.description != '') {
		temp +=  '<div id="imageDescription">' + this.description + '</div>';
	}
		if (this.photo_ref != '') {
		temp += '<div class="imageinfo" id="imageRef"><strong>Ref: </strong>' + this.photo_ref + '</div>';
	}
		if (this.takendate != '') {
		
		temp += '<div class="imageinfo" id="imageDate"><strong>Date: </strong>' + this.takendate + '</div>';
	}
	
	if (this.location != '') {
		
		temp += '<div class="imageinfo" id="imageLocation"><strong>Location: </strong>' +  this.location + '</div>';
	}
	
	if (this.photographer != '') {
		
		temp += '<div class="imageinfo" id="imagePhotographer"><strong>Photographer: </strong>' + this.photographer + '</div>';
	}
				
				if (temp != '') {
		temp += '<div class="spacer"></div>';
	}
	return temp;
};

/***************************************************************************
* Get payment info for image - add as 'method' to photo object             *
***************************************************************************/
clik.photo.fnGetPaymentInfo = function(){
	var temp = '';
	if (this.item_price !== '') {
				temp += '<p>Order this print:</p>';
				temp += '<div class="imageinfo" id="imagePrice"><strong>' + this.purchase_instruction + '</strong> ' + (this.item_price).toFixed(2) + '</div>';
		var item_name  = this.purchase_instruction;
		var amount = (this.item_price).toFixed(2);
		var item_option  = 0;
	}
	else if (this.payment_groups_id !== '') {
		temp += '<p>Buy this print online:</p>';
				temp += '<form id="paymentOptions" style="margin:0px;border:0px;" name="paymentOptions">';
											temp += '<select class="paymentlink" name="payment_options_id" onchange="updateItemValues($(this.form).next(\'#paymentForm\')[0],this.form.payment_options_id.options[this.form.payment_options_id.options.selectedIndex].value);">';
		
		temp += getPaymentOptions(this.payment_groups_id);
		temp += '</select>';
		temp += '</form>';
				var item_option  = paymentGroups[this.payment_groups_id].options[0];
		if(paymentOptions[item_option]){
			var item_name  = paymentOptions[item_option].payment_option;
			var amount =  paymentOptions[item_option].price;
		}
			}
	else {
		
	}
	if (this.item_price !== '' || this.payment_groups_id !== '') {
			temp += '<div class="clearing">&nbsp;</div>';
	}
	return temp;};

/***************************************************************************
* Pick a photo at random from the featured images of a gallery.            *
* Gallery_id = id of gallery to choose,                                    *
* img = reference to html image in                                         *
* which to show image                                                      *
***************************************************************************/
function showGalleryImage(gallery_id, img, updateLink) {
	
	if(img){
		if (location.hash.match('galleries_id=' + gallery_id) && (imageID = location.hash.match('.*photos_id=(.+)$'))) {
		  	imageID = imageID[1];
		} else {
		  	imageID = randomListVal(galleries[gallery_id].featured_images);
		}
		
		if (imageID != 0) {
			img.src = thumbnails[imageID].src;
			img.width = thumbnails[imageID].width;
			img.height = thumbnails[imageID].height;
			img.alt = galleries[gallery_id].title;
			if (updateLink) {
				$(img).parent().attr({					title: galleries[gallery_id].title				}).filter(function(){return this.href;}).attr({					href: thumbnails[imageID].fnGalleryLink(gallery_id)				});
			}
		}
	}
}

/***************************************************************************
* If we have dynamic HTML, replace the galleries link with a list that     *
* doesn't include thecurrent gallery                                       *
***************************************************************************/
function showGalleries(gallery_id) {
		
	
	if (!basic) {
		temp = '';
		for (i = 0; i < galleries.length; i++) {
						
			
			if (galleries[i].id != gallery_id) {
								
				if (temp != '') {
					temp += ' | ';
				}
								temp += '<a href="' + galleries[i].section_code + '_' + galleries[i].id + '.html">' + galleries[i].title + '</a>';
							}
		}
		document.all.galleryLinks.innerHTML = 'Other galleries: ' + temp;
	}
}

			

