window.thumbnails = {};
thumbnails[8520582] = clik.newPhoto({"link":"#","caption":"cup","height":67,"id":8520582,"server_id":21,"src":"_beached_lamb-2161_thumb.jpg","galleries_id":"","width":100});
thumbnails[8291207] = clik.newPhoto({"link":"#","caption":"The Beached Lamb Cafe, Newquay","height":67,"id":8291207,"server_id":21,"src":"_beached_lamb-201_thumb.jpg","galleries_id":"","width":100});
thumbnails[8291208] = clik.newPhoto({"link":"#","caption":"The Beached Lamb Cafe, Newquay","height":67,"id":8291208,"server_id":21,"src":"_beached_lamb-202_thumb.jpg","galleries_id":"","width":100});
thumbnails[8685730] = clik.newPhoto({"link":"#","caption":"","height":67,"id":8685730,"server_id":21,"src":"weddings-109_thumb.jpg","galleries_id":"","width":100});
thumbnails[8685738] = clik.newPhoto({"link":"#","caption":"","height":67,"id":8685738,"server_id":21,"src":"weddings-117_thumb.jpg","galleries_id":"","width":100});
thumbnails[8291209] = clik.newPhoto({"link":"#","caption":"The Beached Lamb Cafe, Newquay","height":67,"id":8291209,"server_id":21,"src":"_beached_lamb-203_thumb.jpg","galleries_id":"","width":100});
thumbnails[8685724] = clik.newPhoto({"link":"#","caption":"","height":67,"id":8685724,"server_id":21,"src":"weddings-103_thumb.jpg","galleries_id":"","width":100});
thumbnails[8685727] = clik.newPhoto({"link":"#","caption":"","height":67,"id":8685727,"server_id":21,"src":"weddings-106_thumb.jpg","galleries_id":"","width":100});
thumbnails[8685742] = clik.newPhoto({"link":"#","caption":"","height":67,"id":8685742,"server_id":21,"src":"weddings-121_thumb.jpg","galleries_id":"","width":100});
thumbnails[8291210] = clik.newPhoto({"link":"#","caption":"The Beached Lamb Cafe, Newquay","height":67,"id":8291210,"server_id":21,"src":"_beached_lamb-204_thumb.jpg","galleries_id":"","width":100});
thumbnails[8685725] = clik.newPhoto({"link":"#","caption":"","height":67,"id":8685725,"server_id":21,"src":"weddings-104_thumb.jpg","galleries_id":"","width":100});
thumbnails[8685743] = clik.newPhoto({"link":"#","caption":"","height":67,"id":8685743,"server_id":21,"src":"weddings-122_thumb.jpg","galleries_id":"","width":100});
thumbnails[8685750] = clik.newPhoto({"link":"#","caption":"","height":67,"id":8685750,"server_id":21,"src":"weddings-129_thumb.jpg","galleries_id":"","width":100});
thumbnails[8291211] = clik.newPhoto({"link":"#","caption":"The Beached Lamb Cafe, Newquay","height":67,"id":8291211,"server_id":21,"src":"_beached_lamb-205_thumb.jpg","galleries_id":"","width":100});
thumbnails[8291212] = clik.newPhoto({"link":"#","caption":"The Beached Lamb Cafe, Newquay","height":67,"id":8291212,"server_id":21,"src":"_beached_lamb-206_thumb.jpg","galleries_id":"","width":100});
thumbnails[8685726] = clik.newPhoto({"link":"#","caption":"","height":67,"id":8685726,"server_id":21,"src":"weddings-105_thumb.jpg","galleries_id":"","width":100});
thumbnails[8685746] = clik.newPhoto({"link":"#","caption":"","height":67,"id":8685746,"server_id":21,"src":"weddings-125_thumb.jpg","galleries_id":"","width":100});
thumbnails[8132303] = clik.newPhoto({"link":"#","caption":"wurlygig","height":75,"id":8132303,"server_id":21,"src":"wurlygig_thumb.jpg","galleries_id":"","width":100});
thumbnails[8291213] = clik.newPhoto({"link":"#","caption":"The Beached Lamb Cafe, Newquay","height":67,"id":8291213,"server_id":21,"src":"_beached_lamb-207_thumb.jpg","galleries_id":"","width":100});
thumbnails[8685732] = clik.newPhoto({"link":"#","caption":"","height":67,"id":8685732,"server_id":21,"src":"weddings-111_thumb.jpg","galleries_id":"","width":100});
thumbnails[8685733] = clik.newPhoto({"link":"#","caption":"","height":67,"id":8685733,"server_id":21,"src":"weddings-112_thumb.jpg","galleries_id":"","width":100});
thumbnails[8685749] = clik.newPhoto({"link":"#","caption":"","height":67,"id":8685749,"server_id":21,"src":"weddings-128_thumb.jpg","galleries_id":"","width":100});
thumbnails[8291214] = clik.newPhoto({"link":"#","caption":"The Beached Lamb Cafe, Newquay","height":67,"id":8291214,"server_id":21,"src":"_beached_lamb-208_thumb.jpg","galleries_id":"","width":100});
thumbnails[8685731] = clik.newPhoto({"link":"#","caption":"","height":67,"id":8685731,"server_id":21,"src":"weddings-110_thumb.jpg","galleries_id":"","width":100});
thumbnails[8291215] = clik.newPhoto({"link":"#","caption":"The Beached Lamb Cafe, Newquay","height":67,"id":8291215,"server_id":21,"src":"_beached_lamb-209_thumb.jpg","galleries_id":"","width":100});
thumbnails[8685728] = clik.newPhoto({"link":"#","caption":"","height":67,"id":8685728,"server_id":21,"src":"weddings-107_thumb.jpg","galleries_id":"","width":100});
thumbnails[8291216] = clik.newPhoto({"link":"#","caption":"The Beached Lamb Cafe, Newquay","height":67,"id":8291216,"server_id":21,"src":"_beached_lamb-210_thumb.jpg","galleries_id":"","width":100});
thumbnails[8685723] = clik.newPhoto({"link":"#","caption":"","height":67,"id":8685723,"server_id":21,"src":"weddings-101_thumb.jpg","galleries_id":"","width":100});
thumbnails[8291217] = clik.newPhoto({"link":"#","caption":"The Beached Lamb Cafe, Newquay","height":67,"id":8291217,"server_id":21,"src":"_beached_lamb-211_thumb.jpg","galleries_id":"","width":100});
thumbnails[8685729] = clik.newPhoto({"link":"#","caption":"","height":67,"id":8685729,"server_id":21,"src":"weddings-108_thumb.jpg","galleries_id":"","width":100});
thumbnails[8685734] = clik.newPhoto({"link":"#","caption":"","height":67,"id":8685734,"server_id":21,"src":"weddings-113_thumb.jpg","galleries_id":"","width":100});
thumbnails[8685745] = clik.newPhoto({"link":"#","caption":"","height":67,"id":8685745,"server_id":21,"src":"weddings-124_thumb.jpg","galleries_id":"","width":100});
thumbnails[8291218] = clik.newPhoto({"link":"#","caption":"The Beached Lamb Cafe, Newquay","height":67,"id":8291218,"server_id":21,"src":"_beached_lamb-212_thumb.jpg","galleries_id":"","width":100});
thumbnails[8685735] = clik.newPhoto({"link":"#","caption":"","height":67,"id":8685735,"server_id":21,"src":"weddings-114_thumb.jpg","galleries_id":"","width":100});
thumbnails[8291219] = clik.newPhoto({"link":"#","caption":"The Beached Lamb Cafe, Newquay","height":67,"id":8291219,"server_id":21,"src":"_beached_lamb-213_thumb.jpg","galleries_id":"","width":100});
thumbnails[8291220] = clik.newPhoto({"link":"#","caption":" The Beached Lamb Cafe, Newquay","height":67,"id":8291220,"server_id":21,"src":"_beached_lamb-214_thumb.jpg","galleries_id":"","width":100});
thumbnails[8685748] = clik.newPhoto({"link":"#","caption":"","height":67,"id":8685748,"server_id":21,"src":"weddings-127_thumb.jpg","galleries_id":"","width":100});
thumbnails[8291221] = clik.newPhoto({"link":"#","caption":"The Beached Lamb Cafe, Newquay","height":67,"id":8291221,"server_id":21,"src":"_beached_lamb-215_thumb.jpg","galleries_id":"","width":100});
thumbnails[8291222] = clik.newPhoto({"link":"#","caption":" beached lamb-216","height":67,"id":8291222,"server_id":21,"src":"_beached_lamb-216_thumb.jpg","galleries_id":"","width":100});
thumbnails[8291223] = clik.newPhoto({"link":"#","caption":" beached lamb-217","height":67,"id":8291223,"server_id":21,"src":"_beached_lamb-217_thumb.jpg","galleries_id":"","width":100});
thumbnails[8685739] = clik.newPhoto({"link":"#","caption":"","height":67,"id":8685739,"server_id":21,"src":"weddings-118_thumb.jpg","galleries_id":"","width":100});
thumbnails[8685736] = clik.newPhoto({"link":"#","caption":"","height":67,"id":8685736,"server_id":21,"src":"weddings-115_thumb.jpg","galleries_id":"","width":100});
thumbnails[8685737] = clik.newPhoto({"link":"#","caption":"","height":67,"id":8685737,"server_id":21,"src":"weddings-116_thumb.jpg","galleries_id":"","width":100});
thumbnails[8685741] = clik.newPhoto({"link":"#","caption":"","height":67,"id":8685741,"server_id":21,"src":"weddings-120_thumb.jpg","galleries_id":"","width":100});
thumbnails[8685744] = clik.newPhoto({"link":"#","caption":"","height":67,"id":8685744,"server_id":21,"src":"weddings-123_thumb.jpg","galleries_id":"","width":100});
thumbnails[8685751] = clik.newPhoto({"link":"#","caption":"","height":67,"id":8685751,"server_id":21,"src":"weddings-130_thumb.jpg","galleries_id":"","width":100});
thumbnails[8685740] = clik.newPhoto({"link":"#","caption":"","height":67,"id":8685740,"server_id":21,"src":"weddings-119_thumb.jpg","galleries_id":"","width":100});
thumbnails[8685747] = clik.newPhoto({"link":"#","caption":"","height":67,"id":8685747,"server_id":21,"src":"weddings-126_thumb.jpg","galleries_id":"","width":100});
thumbnails[8685752] = clik.newPhoto({"link":"#","caption":"","height":67,"id":8685752,"server_id":21,"src":"weddings-131_thumb.jpg","galleries_id":"","width":100});
thumbnails[8685753] = clik.newPhoto({"link":"#","caption":"","height":67,"id":8685753,"server_id":21,"src":"weddings-132_thumb.jpg","galleries_id":"","width":100});
thumbnails[8685754] = clik.newPhoto({"link":"#","caption":"","height":67,"id":8685754,"server_id":21,"src":"weddings-133_thumb.jpg","galleries_id":"","width":100});
thumbnails[8132297] = clik.newPhoto({"link":"#","caption":"Dreamyoga","height":75,"id":8132297,"server_id":21,"src":"dreamyoga_thumb.jpg","galleries_id":"","width":100});
thumbnails[8132299] = clik.newPhoto({"link":"#","caption":"Perfectly Preserved","height":100,"id":8132299,"server_id":21,"src":"perfectly_preserved_thumb.jpg","galleries_id":"","width":100});
thumbnails[8685843] = clik.newPhoto({"link":"photo_8685843.html","caption":"Circ de Gavarnie, France","height":67,"id":8685843,"server_id":21,"src":"approach_to_circ_4F57D081-24E8-5EC4-4F0D37DBB33DA748_thumb.jpg","galleries_id":434643,"width":100});
thumbnails[8685844] = clik.newPhoto({"link":"photo_8685844.html","caption":"Bedruthan Steps, Cornwall","height":67,"id":8685844,"server_id":21,"src":"bedruthan_steps_thumb.jpg","galleries_id":434643,"width":100});
thumbnails[8685845] = clik.newPhoto({"link":"photo_8685845.html","caption":"River Dee, Scotland","height":67,"id":8685845,"server_id":21,"src":"cairngorm_4F57D5A1-24E8-5EC4-4FD50EB2FB59573F_thumb.jpg","galleries_id":434643,"width":100});
thumbnails[8685846] = clik.newPhoto({"link":"photo_8685846.html","caption":"Low key tree","height":67,"id":8685846,"server_id":21,"src":"low_key_tree_4F57D812-24E8-5EC4-4F3D84B319D095B6_thumb.jpg","galleries_id":434643,"width":100});
thumbnails[8685848] = clik.newPhoto({"link":"photo_8685848.html","caption":"Lusty Glaze, Newquay","height":67,"id":8685848,"server_id":21,"src":"lusty_glaze_4F57DD14-24E8-5EC4-4FA81044212A0BE8_thumb.jpg","galleries_id":434643,"width":100});
thumbnails[8685849] = clik.newPhoto({"link":"photo_8685849.html","caption":"Lone surfer, Lusty Glaze","height":67,"id":8685849,"server_id":21,"src":"lusty_surfer_thumb.jpg","galleries_id":434643,"width":100});
thumbnails[8685850] = clik.newPhoto({"link":"photo_8685850.html","caption":"Tolcarne Beach, Newquay","height":67,"id":8685850,"server_id":21,"src":"mias_hat_thumb.jpg","galleries_id":434643,"width":100});
thumbnails[8685851] = clik.newPhoto({"link":"photo_8685851.html","caption":"Scafell, Lake District","height":67,"id":8685851,"server_id":21,"src":"scafell_4F57E810-24E8-5EC4-4F76403831B2D26E_thumb.jpg","galleries_id":434643,"width":100});
thumbnails[8685852] = clik.newPhoto({"link":"photo_8685852.html","caption":"Sheepstor, Dartmoor","height":67,"id":8685852,"server_id":21,"src":"sheepstor_thumb.jpg","galleries_id":434643,"width":100});
thumbnails[8685853] = clik.newPhoto({"link":"photo_8685853.html","caption":"Sheepstor Valley, Dartmoor","height":67,"id":8685853,"server_id":21,"src":"sheepstor_valley_thumb.jpg","galleries_id":434643,"width":100});
thumbnails[8685854] = clik.newPhoto({"link":"photo_8685854.html","caption":"Sunset in Pendle","height":67,"id":8685854,"server_id":21,"src":"sunset_4F57F02E-24E8-5EC4-4F6B261B37FBF03C_thumb.jpg","galleries_id":434643,"width":100});
thumbnails[8685855] = clik.newPhoto({"link":"photo_8685855.html","caption":"Towan Headland","height":67,"id":8685855,"server_id":21,"src":"tolcarne_dusk_thumb.jpg","galleries_id":434643,"width":100});
thumbnails[8685856] = clik.newPhoto({"link":"photo_8685856.html","caption":"Sunset on Tolcarne","height":67,"id":8685856,"server_id":21,"src":"tolcarne_sunset_thumb.jpg","galleries_id":434643,"width":100});
thumbnails[8685857] = clik.newPhoto({"link":"photo_8685857.html","caption":"Surfer, Towan Beach, Newquay","height":67,"id":8685857,"server_id":21,"src":"towan_surfer_thumb.jpg","galleries_id":434643,"width":100});
thumbnails[8685858] = clik.newPhoto({"link":"photo_8685858.html","caption":"Treyarnon Bay, Cornwall","height":67,"id":8685858,"server_id":21,"src":"treyarnon_4F57FD8C-24E8-5EC4-4FFEA02328E88652_thumb.jpg","galleries_id":434643,"width":100});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
galleries[434643] = clik.newGallery({"photoIDs":[8685843,8685844,8685845,8685846,8685848,8685849,8685850,8685851,8685852,8685853,8685854,8685855,8685856,8685857,8685858],"link":"gallery.html","skipIndex":0,"section_code":"gallery","id":434643,"parentGallery":"","featured_images":"8685858,8685857,8685856,8685855,8685854,8685853,8685852,8685851,8685850,8685849","maxRecords":0,"usePopups":false,"singleSection":true,"title":"Landscapes"});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[3] = '8685724,8685723';
imageSets[1] = '8685730,8685738,8685727,8685724,8685742,8685725,8685750,8685743,8685726,8685746,8685732,8685749,8685733,8685731,8685728,8685723,8685729,8685734,8685745,8685735,8685748,8685739,8685736,8685737,8685741,8685744,8685751,8685740,8685747,8685752,8685753,8685754';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/iplested/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/iplested/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/iplested/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/iplested/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/iplested/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/iplested/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/iplested/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/iplested/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/iplested/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/iplested/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/iplested/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/iplested/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/iplested/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/iplested/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/iplested/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/iplested/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/iplested/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/iplested/images';
		break;
	}
		switch (server_id) {
		case 0:
		val = 'http://www.clikpic.com/iplested/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/iplested/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/iplested/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/iplested/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/iplested/images';
		break;
	}
		switch (server_id) {
		case 51:
		val = 'http://www12.clikpic.com/iplested/images';
		break;
	}
		switch (server_id) {
		case 52:
		val = 'http://tpc22/clikpic/iplested/images';
		break;
	}
		switch (server_id) {
		case 53:
		val = 'http://images.clikpic.com/iplested/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/iplested/images';
		break;
	}
		return val;
}

/***************************************************************************
* img = reference to image object in which to show image                   *
***************************************************************************/
function showHomeImage(img) {
	imageID = randomListVal('');
	if (!basic) {
		img.src = photos[imageID].src;
		img.width = photos[imageID].width;
		img.height = photos[imageID].height;
		img.parentNode.title = img.alt = photos[imageID].caption;
	} else {
		newImage = new Image(photos[imageID].width,photos[imageID].height);
		newImage.src = photos[imageID].src;
		document.images[img.name] = newImage;
		
	}
}

function getHomeImageLink(imageID) {
  	var href='', photo = (backgrounds || photos || {})[imageID];
	if(photo){
		if (photo && photo.galleries_id != '') {
  			href = photo.fnGalleryLink();
  		}
  		  		else {
  				href += 'gallery.html';
  	  		}
	}
    return href;
}

/***************************************************************************
* Show a random image on home page from featured images                    *
***************************************************************************/
function showHomeImageInline(el, image_sets_id, href) {
	
	var css = {}, imageID,
	    imageSetsId = 1;
	if(image_sets_id){
		imageSetsId = image_sets_id;
	}
	imageID = randomListVal(imageSets[imageSetsId]);
	if (href == null && 'gallery' != '') {
					href = getHomeImageLink(imageID);
	}
	
	updateImage({nextPhoto: backgrounds[imageID], img:el.find('img')[0],
                $photo:el, $title:$('#homeimageTitleContainer'), $detail:$('#homeimageDetailsContainer'),                speed:0, href:href, css:css, onAfter: function(){                  this.closest('.contentsection').doManualAlign({				    inner: 'img',				    crop: 'a'				  });                }              });
}

/***************************************************************************
* Set 'img' to be a new image given its photo() object                     *
***************************************************************************/
function updateImage (options) {
	var defaults = {nextPhoto:'',field:'',img:'',$photo:'',$title:'',$detail:'',$detailContainer:'',
                    updateDocumentTitle:false,speed:0,href:false,css:false,updateHash:false,onAfter:null,onBefore:null},
		op = $.extend({},defaults,options),
		html = '', temp = '',
		photoId = op.nextPhoto.id,
		photoCaption = ''+op.nextPhoto.caption,
		photoSrc = op.nextPhoto.src;
	
	if (op.updateHash && clik.getIDInUrl(location.href,'photo') != op.nextPhoto.id) {
		clik.changeHash('photos_id=' + op.nextPhoto.id, true);
	}
		
	    if (op.$title.length > 0) {
  		op.$title.fadeGalleryDetails(photoCaption, op.speed);
    }
        if (op.updateDocumentTitle) {
				  document.title = ': ' + 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="updateCartValue($(this.form).next(\'#paymentForm\')[0],this.form.payment_options_id.options[this.form.payment_options_id.options.selectedIndex].value); if(divShowing(\'paymentConfirm\')){fadeOut(\'paymentConfirm\', 3)};">';
		
		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">';
			temp += '	<input type="hidden" name="item_option" value="' + item_option + '">';
			temp += '	<input type="hidden" name="site" value="IPLESTED">';
			temp += '	<input type="hidden" name="item_number" value="'+ this.id +'">';
			temp += '	<input type="hidden" name="quantity" value="1">';
						temp += '	<input value="Add to cart" id="paymentAddButton" class="button" onmouseover="this.className=\'buttonHi\'\;" onmouseout="this.className=\'button\'\;" type="Button">';
							temp += '	<input value="View cart" id="paymentViewButton" class="button" onmouseover="this.className=\'buttonHi\';" onmouseout="this.className=\'button\';" type="Button" onclick="javascript:window.location=\'cart.html\'">';
			temp += '</form>';
						temp += '<div class="clearing">&nbsp;</div>';
			temp += '<div id="confirmContainer">';
			temp += '<div id="paymentConfirm">Item added to cart</div>';
			temp += '</div>';
			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;
	}
}

		

