window.thumbnails = {};
															thumbnails[7247680] = clik.newPhoto({"id":7247680,"src":"020111_3918_thumb.jpg","galleries_id":440485,"server_id":15,"link":"photo_7247680.html","width":130,"caption":"Simon & Charlie","height":97});
															thumbnails[8311655] = clik.newPhoto({"id":8311655,"src":"110810_1768Norm_Over_Under_tonemapped_thumb.jpg","galleries_id":440485,"server_id":15,"link":"photo_8311655.html","width":130,"caption":"Aberdare in the mist","height":86});
															thumbnails[8312209] = clik.newPhoto({"id":8312209,"src":"010811_6643Norm_Over_Under_tonemapped_thumb.jpg","galleries_id":440485,"server_id":15,"link":"photo_8312209.html","width":130,"caption":"Work in progress","height":102});
															thumbnails[8312214] = clik.newPhoto({"id":8312214,"src":"020311_4971Norm_Over1_Under1_tonemapped_thumb.jpg","galleries_id":440485,"server_id":15,"link":"photo_8312214.html","width":130,"caption":"I'm watching you","height":68});
															thumbnails[8312219] = clik.newPhoto({"id":8312219,"src":"040610_0167Norm_Over_Under_tonemapped_tonemapped_tonemapped_thumb.jpg","galleries_id":440485,"server_id":15,"link":"photo_8312219.html","width":130,"caption":"The Blacksmith","height":86});
															thumbnails[8312225] = clik.newPhoto({"id":8312225,"src":"110910_1697Norm_Over_Under_tonemapped_thumb.jpg","galleries_id":440485,"server_id":15,"link":"photo_8312225.html","width":130,"caption":"Sheep Portrait","height":84});
															thumbnails[8312229] = clik.newPhoto({"id":8312229,"src":"161010_1957Norm_Over1_Under2_tonemapped_thumb.jpg","galleries_id":440485,"server_id":15,"link":"photo_8312229.html","width":130,"caption":"Alert","height":106});
															thumbnails[8312232] = clik.newPhoto({"id":8312232,"src":"280711_6674Norm_Over_Under_tonemapped_thumb.jpg","galleries_id":440485,"server_id":15,"link":"photo_8312232.html","width":130,"caption":"Brecon Beacons","height":86});
															thumbnails[8312237] = clik.newPhoto({"id":8312237,"src":"300611_6278Normal_Over_Under_tonemapped_thumb.jpg","galleries_id":440485,"server_id":15,"link":"photo_8312237.html","width":130,"caption":"Brecon Beacons","height":86});
															thumbnails[8312241] = clik.newPhoto({"id":8312241,"src":"CwmdarePark_030Norm_Over_Under_tonemapped_thumb.jpg","galleries_id":440485,"server_id":15,"link":"photo_8312241.html","width":130,"caption":"Dare Valley Park","height":86});
															thumbnails[8312243] = clik.newPhoto({"id":8312243,"src":"DSC_7534_007Norm_Over_Under_fused_thumb.jpg","galleries_id":440485,"server_id":15,"link":"photo_8312243.html","width":130,"caption":"Mumbles Lighthouse","height":86});
															thumbnails[8312248] = clik.newPhoto({"id":8312248,"src":"DSC_7591_064Norm_Over_Under_tonemapped_thumb.jpg","galleries_id":440485,"server_id":15,"link":"photo_8312248.html","width":130,"caption":"Mumbles Lighthouse","height":86});
															thumbnails[8312250] = clik.newPhoto({"id":8312250,"src":"DSC_7962_038Norm_Over_Under_tonemapped_thumb.jpg","galleries_id":440485,"server_id":15,"link":"photo_8312250.html","width":130,"caption":"Brecon Beacons","height":86});
															thumbnails[8312253] = clik.newPhoto({"id":8312253,"src":"DSC_8071_083Norm_Over_Under_tonemapped_thumb.jpg","galleries_id":440485,"server_id":15,"link":"photo_8312253.html","width":130,"caption":"The Market","height":86});
															thumbnails[8312256] = clik.newPhoto({"id":8312256,"src":"DSC_8124_034Norm_Over_Under_tonemapped_thumb.jpg","galleries_id":440485,"server_id":15,"link":"photo_8312256.html","width":130,"caption":"Motorbike Display","height":86});
															thumbnails[8312261] = clik.newPhoto({"id":8312261,"src":"DSC_9137_027Norm_Over_Under_tonemapped_thumb.jpg","galleries_id":440485,"server_id":15,"link":"photo_8312261.html","width":130,"caption":"Cyfartha Castle","height":86});
															thumbnails[8312266] = clik.newPhoto({"id":8312266,"src":"DSC_9607Norm_Over_Under_fused_thumb.jpg","galleries_id":440485,"server_id":15,"link":"photo_8312266.html","width":130,"caption":"Bluebells","height":86});
															thumbnails[8336168] = clik.newPhoto({"id":8336168,"src":"DSC_2501EbbwValeChurch_thumb.jpg","galleries_id":440485,"server_id":15,"link":"photo_8336168.html","width":130,"caption":"Ebbw Vale Church","height":191});
															thumbnails[8694383] = clik.newPhoto({"id":8694383,"src":"270811_6885Norm_Over3_Under2_fused_thumb.jpg","galleries_id":440485,"server_id":15,"link":"photo_8694383.html","width":130,"caption":"Cardiff Arcade","height":196});
															thumbnails[8694389] = clik.newPhoto({"id":8694389,"src":"Tour_W_Wales_14Sep2011_0694_thumb.jpg","galleries_id":440485,"server_id":15,"link":"photo_8694389.html","width":130,"caption":"Neolithic Burial Mound","height":83});
															thumbnails[8694390] = clik.newPhoto({"id":8694390,"src":"West_Wales_09Sep2011_0054N_O1_U2_tonemapped_thumb.jpg","galleries_id":440485,"server_id":15,"link":"photo_8694390.html","width":130,"caption":"West Wales Church","height":86});
															thumbnails[8694392] = clik.newPhoto({"id":8694392,"src":"DSC_8818Norm_Over1_Under1_tonemapped_thumb.jpg","galleries_id":440485,"server_id":15,"link":"photo_8694392.html","width":130,"caption":"Mermaid, Spain","height":177});
															thumbnails[8694393] = clik.newPhoto({"id":8694393,"src":"270811_6878_fused_thumb.jpg","galleries_id":440485,"server_id":15,"link":"photo_8694393.html","width":130,"caption":"Shopping","height":111});
															thumbnails[8694394] = clik.newPhoto({"id":8694394,"src":"DSC_8704_Over2_Under2_tonemapped_thumb.jpg","galleries_id":440485,"server_id":15,"link":"photo_8694394.html","width":130,"caption":"I photograph you, You Photograph me.","height":165});
															thumbnails[8694395] = clik.newPhoto({"id":8694395,"src":"West_Wales_10Sep2011_0256TM_thumb.jpg","galleries_id":440485,"server_id":15,"link":"photo_8694395.html","width":130,"caption":"Let's go fly a kite","height":87});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  						galleries[440485] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Paul's Images","link":"gallery.html","maxRecords":0.0,"photoIDs":[7247680.0,8311655.0,8312209.0,8312214.0,8312219.0,8312225.0,8312229.0,8312232.0,8312237.0,8312241.0,8312243.0,8312248.0,8312250.0,8312253.0,8312256.0,8312261.0,8312266.0,8336168.0,8694383.0,8694389.0,8694390.0,8694392.0,8694393.0,8694394.0,8694395.0],"skipIndex":0,"section_code":"gallery","featured_images":"8694395,8694394,8694393,8694392,8694390,8694389,8694383,8336168,8312266,8312261","id":440485,"singleSection":true});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[1] = '8312229';
imageSets[3] = '8694395,8694394,8694393,8694392,8694390,8694389,8694383,8336168,8312266,8312261,8312256,8312253,8312250,8312248,8312243,8312241,8312237,8312232,8312229,8312225,8312219,8312214,8312209,8311655,7247680';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 51:
		val = 'http://www12.clikpic.com/paulpowell/images';
		break;
	}
		switch (server_id) {
		case 0:
		val = 'http://www.clikpic.com/paulpowell/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/paulpowell/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/paulpowell/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/paulpowell/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/paulpowell/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/paulpowell/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/paulpowell/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/paulpowell/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/paulpowell/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/paulpowell/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/paulpowell/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/paulpowell/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/paulpowell/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/paulpowell/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/paulpowell/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/paulpowell/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/paulpowell/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/paulpowell/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/paulpowell/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/paulpowell/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/paulpowell/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/paulpowell/images';
		break;
	}
		switch (server_id) {
		case 53:
		val = 'http://images.clikpic.com/paulpowell/images';
		break;
	}
		switch (server_id) {
		case 52:
		val = 'http://tpc22/clikpic/paulpowell/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/paulpowell/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/paulpowell/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 = 'Editorial Photographer & Writer : ' + 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;
	}
}

			

