window.thumbnails = new Object();
												thumbnails[3340440] = new thumbnail(3340440,'203644','','Pete_thumb.jpg',130, 130,15,'																			photo_3340440.html');
												thumbnails[3361921] = new thumbnail(3361921,'203655','','bea2_thumb.jpg',130, 100,15,'																			photo_3361921.html');
												thumbnails[3361858] = new thumbnail(3361858,'203655','','Gulls_thumb.jpg',130, 85,15,'																			photo_3361858.html');
												thumbnails[3338790] = new thumbnail(3338790,'203656','','bloke-11x14_thumb.jpg',130, 166,15,'																			photo_3338790.html');
												thumbnails[3338927] = new thumbnail(3338927,'203654','bt','Bt_thumb.jpg',130, 123,15,'																			photo_3338927.html');
												thumbnails[3340412] = new thumbnail(3340412,'203644','','Alec_thumb.jpg',130, 153,15,'																			photo_3340412.html');
												thumbnails[3340576] = new thumbnail(3340576,'203645','','Roses_thumb.jpg',130, 165,15,'																			photo_3340576.html');
												thumbnails[7226648] = new thumbnail(7226648,'390414','','otter_thumb.jpg',130, 93,15,'																			photo_7226648.html');
												thumbnails[3340581] = new thumbnail(3340581,'203645','','fishscales_thumb.jpg',130, 102,15,'																			photo_3340581.html');
												thumbnails[3361748] = new thumbnail(3361748,'203656','','Oldman_thumb.jpg',130, 169,15,'																			photo_3361748.html');
												thumbnails[3338955] = new thumbnail(3338955,'203654','dca','DCABoys_thumb.jpg',130, 130,15,'																			photo_3338955.html');
												thumbnails[3340583] = new thumbnail(3340583,'203645','','Grolsch_thumb.jpg',130, 102,15,'																			photo_3340583.html');
												thumbnails[3340585] = new thumbnail(3340585,'203645','','makeup1_thumb.jpg',130, 165,15,'																			photo_3340585.html');
												thumbnails[3338951] = new thumbnail(3338951,'203654','esf','J_thumb.Laingtraining5.jpg',130, 193,15,'																			photo_3338951.html');
												thumbnails[3361761] = new thumbnail(3361761,'203656','','Walkers_thumb.jpg',130, 166,15,'																			photo_3361761.html');
												thumbnails[3361714] = new thumbnail(3361714,'203656','','Station_thumb.jpg',130, 95,15,'																			photo_3361714.html');
												thumbnails[3338628] = new thumbnail(3338628,'203655','','Tape-Measure_thumb.jpg',130, 103,15,'																			photo_3338628.html');
												thumbnails[3340584] = new thumbnail(3340584,'203645','','hugo_thumb.JPEG',130, 165,15,'																			photo_3340584.html');
												thumbnails[3338631] = new thumbnail(3338631,'203655','','LifeBuoy_thumb.jpg',130, 103,15,'																			photo_3338631.html');
												thumbnails[3340442] = new thumbnail(3340442,'203644','','Rob_thumb.jpg',130, 143,15,'																			photo_3340442.html');
												thumbnails[3361710] = new thumbnail(3361710,'203656','','sky-walk_thumb.jpg',130, 83,15,'																			photo_3361710.html');
												thumbnails[7226802] = new thumbnail(7226802,'390414','','corncrake_thumb.jpg',130, 102,15,'																			photo_7226802.html');
												thumbnails[3340605] = new thumbnail(3340605,'203645','','Shoe_thumb.jpg',130, 165,15,'																			photo_3340605.html');
												thumbnails[3361860] = new thumbnail(3361860,'203655','','Pool_thumb.jpg',130, 130,15,'																			photo_3361860.html');
												thumbnails[3338654] = new thumbnail(3338654,'203655','','Promenade_thumb.jpg',130, 104,15,'																			photo_3338654.html');
												thumbnails[3362001] = new thumbnail(3362001,'203645','','Fridge_thumb.jpg',130, 173,15,'																			photo_3362001.html');
												thumbnails[3402203] = new thumbnail(3402203,'203656','','treesurgeon1_thumb.jpg',130, 87,15,'																			photo_3402203.html');
												thumbnails[3340601] = new thumbnail(3340601,'203645','','Poison_thumb.jpg',130, 165,15,'																			photo_3340601.html');
												thumbnails[3361870] = new thumbnail(3361870,'203655','','lido_thumb.jpg',130, 130,15,'																			photo_3361870.html');
												thumbnails[3338793] = new thumbnail(3338793,'203656','','Crouching-Man1_thumb.jpg',130, 102,15,'																			photo_3338793.html');
												thumbnails[3361819] = new thumbnail(3361819,'203655','','Rocks1_thumb.jpg',130, 166,15,'																			photo_3361819.html');
												thumbnails[3340579] = new thumbnail(3340579,'203645','','Bud_thumb.jpg',130, 165,15,'																			photo_3340579.html');
												thumbnails[3404175] = new thumbnail(3404175,'203656','','hill_thumb.jpg',130, 130,15,'																			photo_3404175.html');
												thumbnails[3338940] = new thumbnail(3338940,'203654','hertz','Hertzbadges_thumb.jpg',130, 102,15,'																			photo_3338940.html');
												thumbnails[3338648] = new thumbnail(3338648,'203655','','Man&Boy_thumb.jpg',130, 103,15,'																			photo_3338648.html');
												thumbnails[3338792] = new thumbnail(3338792,'203656','','DogWalker1_thumb.jpg',130, 103,15,'																			photo_3338792.html');
												thumbnails[3338932] = new thumbnail(3338932,'203654','lilli shirts','Classicfitted_thumb.jpg',130, 193,15,'																			photo_3338932.html');
												thumbnails[7226864] = new thumbnail(7226864,'390414','','rabbit_thumb.jpg',130, 104,15,'																			photo_7226864.html');
												thumbnails[3340464] = new thumbnail(3340464,'203644','','Philbedge_thumb.jpg',130, 177,15,'																			photo_3340464.html');
												thumbnails[3338935] = new thumbnail(3338935,'203644','','lilishirts3_thumb.jpg',130, 189,15,'																			photo_3338935.html');
												thumbnails[3340439] = new thumbnail(3340439,'203644','','Rick_thumb.jpg',130, 130,15,'																			photo_3340439.html');
												thumbnails[3338644] = new thumbnail(3338644,'203655','','Sea-walking_thumb.jpg',130, 49,15,'																			photo_3338644.html');
												thumbnails[3338943] = new thumbnail(3338943,'203654','media audits','Buses_thumb.jpg',130, 87,15,'																			photo_3338943.html');
												thumbnails[3338947] = new thumbnail(3338947,'203654','media audits','Newspaper_thumb.jpg',130, 100,15,'																			photo_3338947.html');
												thumbnails[3340476] = new thumbnail(3340476,'203644','','Sylvana_thumb.jpg',130, 120,15,'																			photo_3340476.html');
												thumbnails[3338594] = new thumbnail(3338594,'203655','','Beach_thumb.jpg',130, 29,15,'																			photo_3338594.html');
												thumbnails[3340452] = new thumbnail(3340452,'203644','','Ben_thumb.jpg',130, 165,15,'																			photo_3340452.html');
												thumbnails[3338802] = new thumbnail(3338802,'203656','','SleepingMan_thumb.jpg',130, 82,15,'																			photo_3338802.html');
												thumbnails[3358431] = new thumbnail(3358431,'203655','','boat1_thumb.jpg',130, 195,15,'																			photo_3358431.html');
												thumbnails[3338821] = new thumbnail(3338821,'203656','','FeedingtheBirds_thumb.jpg',130, 54,15,'																			photo_3338821.html');
												thumbnails[3358504] = new thumbnail(3358504,'203654','comedating.com','Dating1_thumb.jpg',130, 206,15,'																			photo_3358504.html');
												thumbnails[3338822] = new thumbnail(3338822,'203656','','Birds_thumb.jpg',130, 32,15,'																			photo_3338822.html');
												thumbnails[3361804] = new thumbnail(3361804,'203645','','goals1_thumb.jpg',130, 166,15,'																			photo_3361804.html');
												thumbnails[3361807] = new thumbnail(3361807,'203645','','goals2_thumb.jpg',130, 165,15,'																			photo_3361807.html');
												thumbnails[3362141] = new thumbnail(3362141,'203645','','trees_thumb.jpg',130, 70,15,'																			photo_3362141.html');

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  					galleries[203656] = new gallery(203656,'3338802','street life','gallery',[3338790,3361748,3361761,3361714,3361710,3402203,3338793,3404175,3338792,3338802,3338821,3338822],0, 0, '', '																																																																																																							gallery_203656.html',0,0);
				  					galleries[390414] = new gallery(390414,'7226802,7226648','nature','gallery',[7226648,7226802,7226864],0, 0, '', '																																																																																																							gallery_390414.html',0,0);
				  					galleries[203655] = new gallery(203655,'3338648','coastal','gallery',[3361921,3361858,3338628,3338631,3361860,3338654,3361870,3361819,3338648,3338644,3338594,3358431],0, 0, '', '																																																																																																							gallery_203655.html',0,0);
				  					galleries[203644] = new gallery(203644,'3340476,3340464,3340452,3340442,3340440,3340439,3340412,3338935','portraits','gallery',[3340440,3340412,3340442,3340464,3338935,3340439,3340476,3340452],0, 0, '', '																																																																																																							gallery_203644.html',0,0);
				  					galleries[203645] = new gallery(203645,'3362141,3362001,3361807,3361804,3340605,3340601,3340585,3340584,3340583,3340581','still life','gallery',[3340576,3340581,3340583,3340585,3340584,3340605,3362001,3340601,3340579,3361804,3361807,3362141],0, 0, '', '																																																																																																							gallery_203645.html',0,0);
				  					galleries[203654] = new gallery(203654,'3338927','commissions','gallery',[3338927,3338955,3338951,3338940,3338932,3338943,3338947,3358504],0, 0, '', '																																																																																																							gallery_203654.html',0,0);
/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = new Object();
imageSets[1] = '7226802,7226648,3402203,3361921,3361858,3361714,3338943,3338802,3338648,3338628';
imageSets[2] = '7226802,7226648,3338927,3338802,3338648';
imageSets[3] = '7226864,7226802,7226648,3404175,3402203,3362141,3362001,3361921,3361870,3361860,3361858,3361819,3361807,3361804,3361761,3361748,3361714,3361710,3358504,3358431,3340605,3340601,3340585,3340584,3340583,3340581,3340579,3340576,3340476,3340464,3340452,3340442,3340440,3340439,3340412,3338955,3338951,3338947,3338943,3338940,3338935,3338932,3338927,3338822,3338821,3338802,3338793,3338792,3338790,3338654';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/leemcpherson/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/leemcpherson/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/leemcpherson/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/leemcpherson/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/leemcpherson/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/leemcpherson/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/leemcpherson/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/leemcpherson/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/leemcpherson/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/leemcpherson/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/leemcpherson/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/leemcpherson/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/leemcpherson/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/leemcpherson/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/leemcpherson/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://admin2.clikpic.com/leemcpherson/images';
		break;
	}
		switch (server_id) {
		case 33:
		val = 'http://www8.clikpic.com/leemcpherson/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/leemcpherson/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/leemcpherson/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/leemcpherson/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/leemcpherson/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/leemcpherson/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:'',
                    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 (!basic) {
    if (op.updateHash && clik.getIDInUrl(location.href,'photo') != op.nextPhoto.id) {
		clik.changeHash('photos_id=' + op.nextPhoto.id, true);
    }
				
    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.$title.length > 0) {
  		op.$title.fadeGalleryDetails(photoCaption, op.speed);
    }
        if (op.updateDocumentTitle) {
						  document.title = 'lee mcpherson photography: ' + photoCaption;
			    }
        if (op.$detail.length > 0) {
      temp = op.nextPhoto.fnGetImageDetails();
	    op.$detail.fadeGalleryDetails(temp, op.speed, function(){
	    var options = {};	    	      	      resizePhotoInfo(options);
        if (typeof(backgrounds) != 'undefined' && op.nextPhoto == backgrounds[op.nextPhoto.id]) {
  	      toggleAddToCartConfirm(backgrounds);
  	    } else if (typeof(photos) != 'undefined' && op.nextPhoto == photos[op.nextPhoto.id]) {
  	      toggleAddToCartConfirm(photos);
  	    }
	    });
    }
        if (!op.speed) {      clik.doColumnResize(false, op.$photo.add(op.$detail).add(op.$title));    }        
    return html;			}
	else {
				
		window.location = 'photo_' + nextPhoto.id + '.html';
	}
		
}

/***************************************************************************
* Toggle add to cart confirmation element and set up the click event for   *
* the 'Add to cart' button.                                                *
***************************************************************************/
function toggleAddToCartConfirm(array){
  if (typeof(array) !== 'object') {
    array = photos;
  }
	if($('#paymentConfirm').length > 0){
		$('#paymentConfirm').hide();
		$('#paymentAddButton')
		.unbind()
		.click(function(){
						form = document.getElementById('paymentForm');
			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').text('Item added to cart').show();}
				else{
					$('#paymentConfirm').text('Item added to cart').fadeIn();
					dspOrderDetails(form.site.value);
				}
			}
			else{
				$('#paymentConfirm').text('Item not added - check cookies are enabled in your browser.').fadeIn();
			}
		});
	}
}
/***************************************************************************
* Get payment info for image - add as 'method' to photo object             *
***************************************************************************/
photo.prototype.fnGetImageDetails = function(){
	var temp = '';
	if (this.description != '') {
		temp = temp +  '<p id="imageDescription">' + this.description + '</p>';
	}
		if (this.photo_ref != '') {
		temp = temp + '<p class="imageinfo" id="imageRef"><strong>Ref: </strong>' + this.photo_ref + '</p>';
	}
		if (this.takendate != '') {
				
		temp = temp + '<p class="imageinfo" id="imageDate"><strong>Date: </strong>' + this.takendate + '</p>';
	}
	
	if (this.location != '') {
				
		temp = temp + '<p class="imageinfo" id="imageLocation"><strong>Location: </strong>' +  this.location + '</p>';
	}
	
	if (this.photographer != '') {
				
		temp = temp + '<p class="imageinfo" id="imagePhotographer"><strong>Photographer: </strong>' + this.photographer + '</p>';
	}
					
				if (temp != '') {
		temp = temp + '<div class="spacer"></div>';
	}
	return temp;
};

/***************************************************************************
* Get payment info for image - add as 'method' to photo object             *
***************************************************************************/
photo.prototype.fnGetPaymentInfo = function(){
	var temp = '';
	if (this.item_price !== '') {
				temp = temp + '<p>Order this print:</p>';
				temp = temp + '<p class="imageinfo" id="imagePrice"><strong>' + this.purchase_instruction + '</strong> 							' + (this.item_price).toFixed(2) + '</p>';
		var item_name  = this.purchase_instruction;
		var amount = (this.item_price).toFixed(2);
		var item_option  = 0;
	}
	else if (this.payment_groups_id !== '') {
		temp = temp + '<p>Buy this print online:</p>';
				temp = temp + '<form id="paymentOptions" style="margin:0px;border:0px;" name="paymentOptions">';
											temp = temp + '<select class="paymentlink" name="payment_options_id" onchange="updateItemValues(document.forms.paymentForm,this.form.payment_options_id.options[this.form.payment_options_id.options.selectedIndex].value);">';
				
		temp = temp + getPaymentOptions(this.payment_groups_id);
		temp = temp + '</select>';
		temp = 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 = 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({            href: thumbnails[imageID].fnGalleryLink(gallery_id),            title: galleries[gallery_id].title          });
        }
							}
										}
}

/***************************************************************************
* 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 + ' | ';
				}
				temp = temp + '<a href="' + galleries[i].section_code + '_' + galleries[i].id + '.html">' + galleries[i].title + '</a>';
			}
		}
		document.all.galleryLinks.innerHTML = 'Other galleries: ' + temp;
	}
}

			

