window.thumbnails = {};
															thumbnails[8138262] = clik.newPhoto({"id":8138262,"src":"Misty_Trees_1_thumb.jpg","galleries_id":318537,"server_id":32,"link":"photo_8138262.html","width":130,"caption":"Misty Trees","height":130});
															thumbnails[8138268] = clik.newPhoto({"id":8138268,"src":"Moon_rise_and_boat_thumb.jpg","galleries_id":435204,"server_id":32,"link":"photo_8138268.html","width":130,"caption":"Moon rise over boar","height":104});
															thumbnails[8138270] = clik.newPhoto({"id":8138270,"src":"Shell_thumb.jpg","galleries_id":435204,"server_id":32,"link":"photo_8138270.html","width":101,"caption":"Voices on the beach","height":130});
															thumbnails[8138271] = clik.newPhoto({"id":8138271,"src":"Curved_Tunnel_thumb.jpg","galleries_id":435205,"server_id":32,"link":"photo_8138271.html","width":130,"caption":"Tunnel","height":130});
															thumbnails[8364329] = clik.newPhoto({"id":8364329,"src":"6001090278_1ee3a1e28f_thumb.jpg","galleries_id":444049,"server_id":32,"link":"photo_8364329.html","width":130,"caption":"Yosemite half dome","height":103});
															thumbnails[8372092] = clik.newPhoto({"id":8372092,"src":"4460497919_65b43f4af4_thumb.jpg","galleries_id":444309,"server_id":32,"link":"photo_8372092.html","width":128,"caption":"Tulips","height":130});
															thumbnails[8372093] = clik.newPhoto({"id":8372093,"src":"4643043087_9af08667ca_thumb.jpg","galleries_id":318537,"server_id":32,"link":"photo_8372093.html","width":130,"caption":"Morning Calm","height":129});
															thumbnails[8372094] = clik.newPhoto({"id":8372094,"src":"4942524622_4fc4bc5c49_thumb.jpg","galleries_id":444309,"server_id":32,"link":"photo_8372094.html","width":130,"caption":"Moroccan Man","height":130});
															thumbnails[8985151] = clik.newPhoto({"id":8985151,"src":"a1_thumb.jpg","galleries_id":318537,"server_id":32,"link":"photo_8985151.html","width":130,"caption":"Scotland coves","height":130});
															thumbnails[8985155] = clik.newPhoto({"id":8985155,"src":"a2_thumb.jpg","galleries_id":318537,"server_id":32,"link":"photo_8985155.html","width":130,"caption":"Scotland coves","height":130});
															thumbnails[8364320] = clik.newPhoto({"id":8364320,"src":"6001097710_3acb51d4f9_thumb.jpg","galleries_id":444049,"server_id":32,"link":"photo_8364320.html","width":130,"caption":"Yosemite half dome","height":103});
															thumbnails[8364316] = clik.newPhoto({"id":8364316,"src":"6000811377_08269284ed-1_thumb.jpg","galleries_id":444049,"server_id":32,"link":"photo_8364316.html","width":130,"caption":"Grand Canyon North Rim","height":103});
															thumbnails[7027836] = clik.newPhoto({"id":7027836,"src":"cove_thumb.jpg","galleries_id":318537,"server_id":32,"link":"photo_7027836.html","width":130,"caption":"Secret Cove","height":130});
															thumbnails[6042673] = clik.newPhoto({"id":6042673,"src":"4634294779_0d8a6b9a40_thumb.jpg","galleries_id":318537,"server_id":32,"link":"photo_6042673.html","width":130,"caption":"Near Loch Rannoch, Perthshire","height":130});
															thumbnails[7027837] = clik.newPhoto({"id":7027837,"src":"cove2_2EE6B6CE-24E8-5EC4-4FD691472FCBA6B8_thumb.jpg","galleries_id":318537,"server_id":32,"link":"photo_7027837.html","width":130,"caption":"Secret Cove 2","height":130});
															thumbnails[6819281] = clik.newPhoto({"id":6819281,"src":"4949899808_thumb.jpg","galleries_id":318537,"server_id":32,"link":"photo_6819281.html","width":130,"caption":"Scottish Bay","height":130});
															thumbnails[5914720] = clik.newPhoto({"id":5914720,"src":"Secret_Cove_thumb.jpg","galleries_id":318537,"server_id":32,"link":"photo_5914720.html","width":130,"caption":"Siccar Point, Berwickshire","height":130});
															thumbnails[5920002] = clik.newPhoto({"id":5920002,"src":"StAbbs024s_thumb.jpg","galleries_id":318537,"server_id":32,"link":"photo_5920002.html","width":130,"caption":"St Abb's Head, Berwickshire","height":130});
															thumbnails[5914721] = clik.newPhoto({"id":5914721,"src":"Cove2_thumb.jpg","galleries_id":318537,"server_id":32,"link":"photo_5914721.html","width":130,"caption":"Siccar Point, Berwickshire","height":130});
															thumbnails[6437473] = clik.newPhoto({"id":6437473,"src":"4834373222_12d6214693_thumb.jpg","galleries_id":318537,"server_id":32,"link":"photo_6437473.html","width":130,"caption":"View, Barnbougle Castle","height":130});
															thumbnails[8372129] = clik.newPhoto({"id":8372129,"src":"6063546434_6f5fc74a21_thumb.jpg","galleries_id":444049,"server_id":32,"link":"photo_8372129.html","width":101,"caption":"Yosemite Falls","height":130});
															thumbnails[6042639] = clik.newPhoto({"id":6042639,"src":"4634965632_0babaf0c11_b1_thumb.jpg","galleries_id":318537,"server_id":32,"link":"photo_6042639.html","width":130,"caption":"Loch Rannoch, Perthshire","height":128});
															thumbnails[5914633] = clik.newPhoto({"id":5914633,"src":"Cramond3_thumb.jpg","galleries_id":318537,"server_id":32,"link":"photo_5914633.html","width":130,"caption":"Cramond, Edinburgh","height":130});
															thumbnails[6042674] = clik.newPhoto({"id":6042674,"src":"4634657857_66b4696e90_b1_thumb.jpg","galleries_id":318537,"server_id":32,"link":"photo_6042674.html","width":130,"caption":"Loch Rannoch, Perthshire","height":130});
															thumbnails[5939496] = clik.newPhoto({"id":5939496,"src":"StAbbs018_thumb.jpg","galleries_id":318537,"server_id":32,"link":"photo_5939496.html","width":130,"caption":"St Abb's Head, Berwickshire","height":130});
															thumbnails[5914740] = clik.newPhoto({"id":5914740,"src":"Cramond21_thumb.jpg","galleries_id":318537,"server_id":32,"link":"photo_5914740.html","width":130,"caption":"Cramond, Edinburgh","height":130});
															thumbnails[5914634] = clik.newPhoto({"id":5914634,"src":"Cramond4_thumb.jpg","galleries_id":318537,"server_id":32,"link":"photo_5914634.html","width":130,"caption":"Cramond, Edinburgh","height":130});
															thumbnails[8138272] = clik.newPhoto({"id":8138272,"src":"Stirling_Castle_thumb.jpg","galleries_id":318537,"server_id":32,"link":"photo_8138272.html","width":130,"caption":"","height":104});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  						galleries[444049] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"America","link":"gallery_444049.html","maxRecords":0.0,"photoIDs":[8364329.0,8364320.0,8364316.0,8372129.0],"skipIndex":0,"section_code":"gallery","featured_images":8364320.0,"id":444049,"singleSection":false});				  						galleries[318537] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Scotland ","link":"gallery_318537.html","maxRecords":0.0,"photoIDs":[8138262.0,8372093.0,8985151.0,8985155.0,7027836.0,6042673.0,7027837.0,6819281.0,5914720.0,5920002.0,5914721.0,6437473.0,6042639.0,5914633.0,6042674.0,5939496.0,5914740.0,5914634.0,8138272.0],"skipIndex":0,"section_code":"gallery","featured_images":"8985151,7027836","id":318537,"singleSection":false});				  						galleries[435204] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"England ","link":"gallery_435204.html","maxRecords":0.0,"photoIDs":[8138268.0,8138270.0],"skipIndex":0,"section_code":"gallery","featured_images":"8138270,8138268","id":435204,"singleSection":false});				  						galleries[435205] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Urban","link":"gallery_435205.html","maxRecords":0.0,"photoIDs":[8138271.0],"skipIndex":0,"section_code":"gallery","featured_images":8138271.0,"id":435205,"singleSection":false});				  						galleries[444309] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Other","link":"gallery_444309.html","maxRecords":0.0,"photoIDs":[8372092.0,8372094.0],"skipIndex":0,"section_code":"gallery","featured_images":8372092.0,"id":444309,"singleSection":false});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[1] = '8985151,8364320,5920002,5939496';
imageSets[2] = '8985151,8372092,8364320,7027836';
imageSets[3] = '8985155,8985151,8372129,8372094,8372093,8372092,8364329,8364320,8364316,8138272,8138271,8138270,8138268,8138262,7027837,7027836,6819281,6437473,6042674,6042673,6042639,5939496,5920002,5914740,5914721,5914720,5914634,5914633';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 51:
		val = 'http://www12.clikpic.com/westerndavid/images';
		break;
	}
		switch (server_id) {
		case 0:
		val = 'http://www.clikpic.com/westerndavid/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/westerndavid/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/westerndavid/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/westerndavid/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/westerndavid/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/westerndavid/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/westerndavid/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/westerndavid/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/westerndavid/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/westerndavid/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/westerndavid/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/westerndavid/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/westerndavid/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/westerndavid/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/westerndavid/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/westerndavid/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/westerndavid/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/westerndavid/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/westerndavid/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/westerndavid/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/westerndavid/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/westerndavid/images';
		break;
	}
		switch (server_id) {
		case 53:
		val = 'http://images.clikpic.com/westerndavid/images';
		break;
	}
		switch (server_id) {
		case 52:
		val = 'http://tpc22/clikpic/westerndavid/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/westerndavid/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/westerndavid/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 = 'David Pike 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>';
	}
				
	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="WESTERNDAVID">';
			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;
	}
}

			

