window.thumbnails = {};
thumbnails[9171868] = clik.newPhoto({"link":"photo_9171868.html","caption":"Guillemots","height":114,"id":9171868,"server_id":21,"src":"Guillemots_1_thumb.jpg","galleries_id":467671,"width":160});
thumbnails[8895629] = clik.newPhoto({"link":"photo_8895629.html","caption":"Lapwings & Cattle","height":112,"id":8895629,"server_id":21,"src":"Lapwingsandcattle1_thumb.jpg","galleries_id":467671,"width":160});
thumbnails[8895530] = clik.newPhoto({"link":"photo_8895530.html","caption":"Small Thorn Tree","height":190,"id":8895530,"server_id":21,"src":"smallthorntree1_thumb.jpg","galleries_id":467671,"width":160});
thumbnails[8895518] = clik.newPhoto({"link":"photo_8895518.html","caption":"Three Thorn Trees","height":107,"id":8895518,"server_id":21,"src":"threethorntrees_thumb.JPG","galleries_id":467671,"width":160});
thumbnails[8895636] = clik.newPhoto({"link":"photo_8895636.html","caption":"Flow","height":64,"id":8895636,"server_id":21,"src":"Flow_thumb.jpg","galleries_id":467671,"width":160});
thumbnails[8895642] = clik.newPhoto({"link":"photo_8895642.html","caption":"Flow (detail)","height":106,"id":8895642,"server_id":21,"src":"Flowdetail_thumb.jpg","galleries_id":467671,"width":160});
thumbnails[9172052] = clik.newPhoto({"link":"photo_9172052.html","caption":"Front View","height":94,"id":9172052,"server_id":21,"src":"Front_view_1_thumb.JPG","galleries_id":484446,"width":160});
thumbnails[9172226] = clik.newPhoto({"link":"photo_9172226.html","caption":"Strands","height":103,"id":9172226,"server_id":21,"src":"Strands_1_thumb.jpg","galleries_id":484463,"width":160});
thumbnails[9172280] = clik.newPhoto({"link":"photo_9172280.html","caption":"Place Identity Memory exhibition","height":106,"id":9172280,"server_id":21,"src":"PIMinstallation1_1_thumb.jpg","galleries_id":484472,"width":160});
thumbnails[9172590] = clik.newPhoto({"link":"photo_9172590.html","caption":"First Foot","height":107,"id":9172590,"server_id":21,"src":"Stove2_1_thumb.jpg","galleries_id":484486,"width":160});
thumbnails[8895644] = clik.newPhoto({"link":"photo_8895644.html","caption":"Mutable Landscape","height":121,"id":8895644,"server_id":21,"src":"Mutablelandscape_thumb.jpg","galleries_id":467671,"width":160});
thumbnails[8999570] = clik.newPhoto({"link":"photo_8999570.html","caption":"Shag","height":106,"id":8999570,"server_id":21,"src":"Shag_thumb.JPG","galleries_id":467671,"width":160});
thumbnails[8999575] = clik.newPhoto({"link":"photo_8999575.html","caption":"Fulmars","height":118,"id":8999575,"server_id":21,"src":"Fulmars_thumb.JPG","galleries_id":467671,"width":160});
thumbnails[8999507] = clik.newPhoto({"link":"photo_8999507.html","caption":"Leaving Earth","height":87,"id":8999507,"server_id":21,"src":"Leavingearth_thumb.JPG","galleries_id":467671,"width":160});
thumbnails[8999566] = clik.newPhoto({"link":"photo_8999566.html","caption":"Spirit Journey","height":210,"id":8999566,"server_id":21,"src":"Spiritjourney3_thumb.JPG","galleries_id":467671,"width":160});
thumbnails[9171832] = clik.newPhoto({"link":"photo_9171832.html","caption":"Waves","height":183,"id":9171832,"server_id":21,"src":"Waves_1_thumb.JPG","galleries_id":467671,"width":160});
thumbnails[9171828] = clik.newPhoto({"link":"photo_9171828.html","caption":"Waves (detail)","height":105,"id":9171828,"server_id":21,"src":"Wavesdetail_1_thumb.JPG","galleries_id":467671,"width":160});
thumbnails[8895652] = clik.newPhoto({"link":"photo_8895652.html","caption":"Drowned Sailors","height":199,"id":8895652,"server_id":21,"src":"Drownedsailors_thumb.JPG","galleries_id":467671,"width":160});
thumbnails[8895655] = clik.newPhoto({"link":"photo_8895655.html","caption":"Drowned Sailors (detail)","height":137,"id":8895655,"server_id":21,"src":"Drownedsailorsdetail_thumb.JPG","galleries_id":467671,"width":160});
thumbnails[8895648] = clik.newPhoto({"link":"photo_8895648.html","caption":"Stormline","height":112,"id":8895648,"server_id":21,"src":"Stormline_thumb.JPG","galleries_id":467671,"width":160});
thumbnails[9172057] = clik.newPhoto({"link":"photo_9172057.html","caption":"Boundary Fence","height":120,"id":9172057,"server_id":21,"src":"Fence_3_thumb.jpg","galleries_id":484446,"width":160});
thumbnails[9172293] = clik.newPhoto({"link":"photo_9172293.html","caption":"Annabel Ralphs Disappearing Walks","height":106,"id":9172293,"server_id":21,"src":"AnnabelRalphsDisappearing_Walks_1_thumb.jpg","galleries_id":484472,"width":160});
thumbnails[9172337] = clik.newPhoto({"link":"photo_9172337.html","caption":"Magic Power Presence","height":160,"id":9172337,"server_id":21,"src":"MPPcover_1_thumb.JPG","galleries_id":484472,"width":160});
thumbnails[9172600] = clik.newPhoto({"link":"photo_9172600.html","caption":"First Foot","height":107,"id":9172600,"server_id":21,"src":"Stove1_1_thumb.JPG","galleries_id":484486,"width":160});
thumbnails[9172066] = clik.newPhoto({"link":"photo_9172066.html","caption":"Atrium window","height":241,"id":9172066,"server_id":21,"src":"Artium_window_1_thumb.JPG","galleries_id":484446,"width":160});
thumbnails[9171932] = clik.newPhoto({"link":"photo_9171932.html","caption":"Tree","height":120,"id":9171932,"server_id":21,"src":"Tree_1_thumb.JPG","galleries_id":484439,"width":160});
thumbnails[9172071] = clik.newPhoto({"link":"photo_9172071.html","caption":"Totem","height":241,"id":9172071,"server_id":21,"src":"Totem_3_thumb.jpg","galleries_id":484446,"width":160});
thumbnails[9172073] = clik.newPhoto({"link":"photo_9172073.html","caption":"Harp","height":106,"id":9172073,"server_id":21,"src":"Harp_1_thumb.jpg","galleries_id":484446,"width":160});
thumbnails[9171945] = clik.newPhoto({"link":"photo_9171945.html","caption":"Sign Language","height":99,"id":9171945,"server_id":21,"src":"Sign_language_1_thumb.JPG","galleries_id":484439,"width":160});
thumbnails[9171925] = clik.newPhoto({"link":"photo_9171925.html","caption":"ICT Pod","height":101,"id":9171925,"server_id":21,"src":"ICT_pod_2_thumb.JPG","galleries_id":484439,"width":160});
thumbnails[9171916] = clik.newPhoto({"link":"photo_9171916.html","caption":"Interpretation","height":106,"id":9171916,"server_id":21,"src":"Interpretation_1_thumb.jpg","galleries_id":484439,"width":160});
thumbnails[9171911] = clik.newPhoto({"link":"photo_9171911.html","caption":"Abacus","height":120,"id":9171911,"server_id":21,"src":"Abacus_1_thumb.JPG","galleries_id":484439,"width":160});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
galleries[484463] = clik.newGallery({"photoIDs":[9172226],"link":"gallery_484463.html","skipIndex":0,"section_code":"gallery","id":484463,"parentGallery":467672,"featured_images":9172226,"maxRecords":0,"usePopups":false,"singleSection":false,"title":"CatStrand"});galleries[484472] = clik.newGallery({"photoIDs":[9172280,9172293,9172337],"link":"gallery_484472.html","skipIndex":0,"section_code":"gallery","id":484472,"parentGallery":467672,"featured_images":"9172337,9172293,9172280","maxRecords":0,"usePopups":false,"singleSection":false,"title":"Iris"});galleries[467671] = clik.newGallery({"photoIDs":[9171868,8895629,8895530,8895518,8895636,8895642,8895644,8999570,8999575,8999507,8999566,9171832,9171828,8895652,8895655,8895648],"link":"gallery_467671.html","skipIndex":0,"section_code":"gallery","id":467671,"parentGallery":"","featured_images":"9171868,9171832,9171828,8999575,8999570,8999566,8999507,8895655,8895652,8895648","maxRecords":0,"usePopups":false,"singleSection":false,"title":"Studio Work"});galleries[467672] = clik.newGallery({"photoIDs":[],"link":"gallery_467672.html","skipIndex":0,"section_code":"gallery","id":467672,"parentGallery":"","featured_images":"9172600,9172590,9172337,9172293,9172280,9172226,9172073,9172071,9172066,9172057","maxRecords":0,"usePopups":false,"singleSection":false,"title":"Projects"});galleries[484486] = clik.newGallery({"photoIDs":[9172590,9172600],"link":"gallery_484486.html","skipIndex":0,"section_code":"gallery","id":484486,"parentGallery":467672,"featured_images":"9172600,9172590","maxRecords":0,"usePopups":false,"singleSection":false,"title":"The Stove"});galleries[484439] = clik.newGallery({"photoIDs":[9171932,9171945,9171925,9171916,9171911],"link":"gallery_484439.html","skipIndex":0,"section_code":"gallery","id":484439,"parentGallery":467672,"featured_images":"9171945,9171932,9171925,9171916,9171911","maxRecords":0,"usePopups":false,"singleSection":false,"title":"Primary Space"});galleries[484446] = clik.newGallery({"photoIDs":[9172052,9172057,9172066,9172071,9172073],"link":"gallery_484446.html","skipIndex":0,"section_code":"gallery","id":484446,"parentGallery":467672,"featured_images":"9172073,9172071,9172066,9172057,9172052","maxRecords":0,"usePopups":false,"singleSection":false,"title":"The West Centre"});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[3] = '9172600,9172590,9172337,9172293,9172280,9172226,9172073,9172071,9172066,9172057,9172052,9171945,9171932,9171925,9171916,9171911,9171868,9171832,9171828,8999575,8999570,8999566,8999507,8895655,8895652,8895648,8895644,8895642,8895636,8895629,8895530,8895518';
imageSets[1] = '9172600,9172590,9172337,9172293,9172280,9172226,9172073,9172071,9172066,9172057,9172052,9171945,9171932,9171925,9171916,9171911,9171868,9171832,9171828,8999575,8999570,8999566,8999507,8895655,8895652,8895648,8895644,8895642,8895636,8895629,8895530,8895518';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/lindamallett/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/lindamallett/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/lindamallett/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/lindamallett/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/lindamallett/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/lindamallett/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/lindamallett/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/lindamallett/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/lindamallett/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/lindamallett/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/lindamallett/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/lindamallett/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/lindamallett/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/lindamallett/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/lindamallett/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/lindamallett/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/lindamallett/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/lindamallett/images';
		break;
	}
		switch (server_id) {
		case 0:
		val = 'http://www.clikpic.com/lindamallett/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/lindamallett/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/lindamallett/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/lindamallett/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/lindamallett/images';
		break;
	}
		switch (server_id) {
		case 51:
		val = 'http://www12.clikpic.com/lindamallett/images';
		break;
	}
		switch (server_id) {
		case 52:
		val = 'http://tpc22/clikpic/lindamallett/images';
		break;
	}
		switch (server_id) {
		case 53:
		val = 'http://images.clikpic.com/lindamallett/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/lindamallett/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 = 'www.lindamallett.com: ' + 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.item_price !== '') {
			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;
	}
}

		

