window.thumbnails = {};
thumbnails[7381677] = clik.newPhoto({"link":"photo_7381677.html","caption":"Spring in a Scottish woodland","height":102,"id":7381677,"server_id":21,"src":"spring_woods_MO210_thumb.jpg","galleries_id":399158,"width":130});
thumbnails[7381687] = clik.newPhoto({"link":"photo_7381687.html","caption":"Go with the Flow","height":130,"id":7381687,"server_id":21,"src":"Padley_MO22_thumb.jpg","galleries_id":399158,"width":103});
thumbnails[7381699] = clik.newPhoto({"link":"photo_7381699.html","caption":"Perfectly still","height":130,"id":7381699,"server_id":21,"src":"Meniscus4_thumb.jpg","galleries_id":399158,"width":94});
thumbnails[7381706] = clik.newPhoto({"link":"photo_7381706.html","caption":"Late summer Hydrangea","height":130,"id":7381706,"server_id":21,"src":"3988_Flowers_LC21_thumb.jpg","galleries_id":399159,"width":130});
thumbnails[7381711] = clik.newPhoto({"link":"photo_7381711.html","caption":"Purple cone-flower","height":130,"id":7381711,"server_id":21,"src":"2388_Flowers_LC21_thumb.jpg","galleries_id":399159,"width":130});
thumbnails[7381717] = clik.newPhoto({"link":"photo_7381717.html","caption":"Scabious","height":130,"id":7381717,"server_id":21,"src":"2246_flowers_LC21_thumb.jpg","galleries_id":399159,"width":130});
thumbnails[7381721] = clik.newPhoto({"link":"photo_7381721.html","caption":"Echinops ritro","height":130,"id":7381721,"server_id":21,"src":"2152_flowers_LC21_thumb.jpg","galleries_id":399159,"width":130});
thumbnails[7381727] = clik.newPhoto({"link":"photo_7381727.html","caption":"Geranium Johnson's Blue","height":130,"id":7381727,"server_id":21,"src":"1853_Flowers3_thumb.jpg","galleries_id":399159,"width":130});
thumbnails[7381739] = clik.newPhoto({"link":"photo_7381739.html","caption":"Hot summer","height":130,"id":7381739,"server_id":21,"src":"2642_flower_thumb.jpg","galleries_id":399159,"width":130});
thumbnails[7385262] = clik.newPhoto({"link":"photo_7385262.html","caption":"Eigg and Rum","height":97,"id":7385262,"server_id":21,"src":"Eigg--Rhum_2_thumb.jpg","galleries_id":399942,"width":130});
thumbnails[7388150] = clik.newPhoto({"link":"photo_7388150.html","caption":"Arran shore","height":130,"id":7388150,"server_id":21,"src":"Arran-shore_thumb.jpg","galleries_id":399158,"width":100});
thumbnails[7388152] = clik.newPhoto({"link":"photo_7388152.html","caption":"Incoming tide","height":130,"id":7388152,"server_id":21,"src":"Imachar-pebbles_crop_thumb.jpg","galleries_id":399158,"width":130});
thumbnails[7398481] = clik.newPhoto({"link":"photo_7398481.html","caption":"November bales","height":98,"id":7398481,"server_id":21,"src":"November-Bales_thumb.jpg","galleries_id":399942,"width":130});
thumbnails[7398484] = clik.newPhoto({"link":"photo_7398484.html","caption":"Severn Bridge","height":95,"id":7398484,"server_id":21,"src":"SevernBridge_thumb.jpg","galleries_id":399942,"width":130});
thumbnails[7398486] = clik.newPhoto({"link":"photo_7398486.html","caption":"Fiddens Bay at sunset","height":97,"id":7398486,"server_id":21,"src":"Pink_thumb.jpg","galleries_id":399942,"width":130});
thumbnails[7440502] = clik.newPhoto({"link":"photo_7440502.html","caption":"Sand dunes, North Uist","height":130,"id":7440502,"server_id":21,"src":"NUist_beach_thumb.jpg","galleries_id":399942,"width":102});
thumbnails[7440509] = clik.newPhoto({"link":"photo_7440509.html","caption":"Dawn on Rannoch Moor, Scotland","height":103,"id":7440509,"server_id":21,"src":"Rannoch_MO_thumb.jpg","galleries_id":399942,"width":130});
thumbnails[7440513] = clik.newPhoto({"link":"photo_7440513.html","caption":"Thornwick Bay, North Yorkshire","height":130,"id":7440513,"server_id":21,"src":"Thornwick016_thumb.jpg","galleries_id":399158,"width":103});
thumbnails[8481087] = clik.newPhoto({"link":"photo_8481087.html","caption":"Waterfall, Glen Etive","height":130,"id":8481087,"server_id":21,"src":"etive_waterfall_thumb.jpg","galleries_id":399158,"width":103});
thumbnails[8481109] = clik.newPhoto({"link":"photo_8481109.html","caption":"Leaf fall, Exmoor","height":130,"id":8481109,"server_id":21,"src":"Leaf_fall_Exmoor_thumb.jpg","galleries_id":399158,"width":96});
thumbnails[8565915] = clik.newPhoto({"link":"photo_8565915.html","caption":"Craigellachie Autumn","height":130,"id":8565915,"server_id":21,"src":"Aviemore_thumb.jpg","galleries_id":399942,"width":96});
thumbnails[8565938] = clik.newPhoto({"link":"photo_8565938.html","caption":"Soft dawn, Derwentwater","height":130,"id":8565938,"server_id":21,"src":"birchbranch_thumb.jpg","galleries_id":399942,"width":98});
thumbnails[8565942] = clik.newPhoto({"link":"photo_8565942.html","caption":"Borrowdale Wall","height":130,"id":8565942,"server_id":21,"src":"Borrowdale_Wall_thumb.jpg","galleries_id":399158,"width":96});
thumbnails[8565946] = clik.newPhoto({"link":"photo_8565946.html","caption":"Winter dawn, Coniston","height":96,"id":8565946,"server_id":21,"src":"Coniston_Dawn_thumb.jpg","galleries_id":399942,"width":130});
thumbnails[8681963] = clik.newPhoto({"link":"photo_8681963.html","caption":"Bridging the Gap","height":130,"id":8681963,"server_id":21,"src":"Bridging_the_gap1_thumb.jpg","galleries_id":452765,"width":104});
thumbnails[8681970] = clik.newPhoto({"link":"photo_8681970.html","caption":"Hebridean Coast","height":101,"id":8681970,"server_id":21,"src":"Hebridean_coast1_thumb.jpg","galleries_id":399942,"width":130});
thumbnails[8681973] = clik.newPhoto({"link":"photo_8681973.html","caption":"Softening the Blow","height":130,"id":8681973,"server_id":21,"src":"Softening_the_blow1_thumb.jpg","galleries_id":452765,"width":102});
thumbnails[8682000] = clik.newPhoto({"link":"photo_8682000.html","caption":"Autumn in Glencoe","height":130,"id":8682000,"server_id":21,"src":"Glencoe_grass_thumb.jpg","galleries_id":399158,"width":102});
thumbnails[8481101] = clik.newPhoto({"link":"photo_8481101.html","caption":"Taking Hold","height":130,"id":8481101,"server_id":21,"src":"LE_0016Borrowdale_thumb.jpg","galleries_id":452765,"width":96});
thumbnails[8481125] = clik.newPhoto({"link":"photo_8481125.html","caption":"Quarry 1","height":130,"id":8481125,"server_id":21,"src":"Quarry1_thumb.jpg","galleries_id":452765,"width":96});
thumbnails[8565950] = clik.newPhoto({"link":"photo_8565950.html","caption":"Fragile environment","height":130,"id":8565950,"server_id":21,"src":"MossRigg_thumb.jpg","galleries_id":452765,"width":96});
thumbnails[8565934] = clik.newPhoto({"link":"photo_8565934.html","caption":"Banishead","height":130,"id":8565934,"server_id":21,"src":"Bannishead_thumb.jpg","galleries_id":452765,"width":99});
thumbnails[8565925] = clik.newPhoto({"link":"photo_8565925.html","caption":"Quarry 2","height":130,"id":8565925,"server_id":21,"src":"Ballachulish_thumb.jpg","galleries_id":452765,"width":98});
thumbnails[8565968] = clik.newPhoto({"link":"photo_8565968.html","caption":"Waterfall, Cwmorthin","height":130,"id":8565968,"server_id":21,"src":"Cwmorthin_fall_thumb.jpg","galleries_id":452765,"width":102});
thumbnails[7381693] = clik.newPhoto({"link":"photo_7381693.html","caption":"Lily Pond","height":103,"id":7381693,"server_id":21,"src":"LilyPond_MO21_thumb.jpg","galleries_id":452765,"width":130});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
galleries[399158] = clik.newGallery({"photoIDs":[7381677,7381687,7381699,7388150,7388152,7440513,8481087,8481109,8565942,8682000],"link":"gallery_399158.html","skipIndex":0,"section_code":"gallery","id":399158,"parentGallery":"","featured_images":"8565942,8481109,8481087,7440513,7388152,7388150,7381687,7381677","maxRecords":0,"usePopups":false,"singleSection":false,"title":"Nearscapes"});galleries[399942] = clik.newGallery({"photoIDs":[7385262,7398481,7398484,7398486,7440502,7440509,8565915,8565938,8565946,8681970],"link":"gallery_399942.html","skipIndex":0,"section_code":"gallery","id":399942,"parentGallery":"","featured_images":"8681970,8565946,8565938,8565915,7440509,7440502,7398486,7398484,7385262","maxRecords":0,"usePopups":false,"singleSection":false,"title":"Landscapes"});galleries[452765] = clik.newGallery({"photoIDs":[8681963,8681973,8481101,8481125,8565950,8565934,8565925,8565968,7381693],"link":"gallery_452765.html","skipIndex":0,"section_code":"gallery","id":452765,"parentGallery":"","featured_images":"8681973,8681963,8565968,8565934,8565925,8481125,8481101","maxRecords":0,"usePopups":false,"singleSection":false,"title":"Quarryscapes"});galleries[399159] = clik.newGallery({"photoIDs":[7381706,7381711,7381717,7381721,7381727,7381739],"link":"gallery_399159.html","skipIndex":0,"section_code":"gallery","id":399159,"parentGallery":"","featured_images":"7381721,7381717,7381711,7381706","maxRecords":0,"usePopups":false,"singleSection":false,"title":"Gardenscapes"});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[3] = '7398486,7398481';
imageSets[2] = '8681973,8681970,8681963,8565946,8565942,8565938,8565915,8481109,8481087,7440513,7440509,7440502,7398486,7398484,7388152,7388150,7385262,7381721,7381717,7381711,7381706,7381687,7381677,8481101,8481125,8565934,8565925,8565968';
imageSets[1] = '8565938,8481109,7440502,7381687,7381677,8481125,7381693';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/LynneEvans/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/LynneEvans/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/LynneEvans/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/LynneEvans/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/LynneEvans/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/LynneEvans/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/LynneEvans/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/LynneEvans/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/LynneEvans/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/LynneEvans/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/LynneEvans/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/LynneEvans/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/LynneEvans/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/LynneEvans/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/LynneEvans/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/LynneEvans/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/LynneEvans/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/LynneEvans/images';
		break;
	}
		switch (server_id) {
		case 0:
		val = 'http://www.clikpic.com/LynneEvans/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/LynneEvans/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/LynneEvans/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/LynneEvans/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/LynneEvans/images';
		break;
	}
		switch (server_id) {
		case 51:
		val = 'www12.clikpic.com/LynneEvans/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/LynneEvans/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 = 'e-SCAPE images: ' + 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;
	}
}

		

