window.thumbnails = new Object();
												thumbnails[1179534] = new thumbnail(1179534,'82798','OAKSPARKLE','OAKSPARKLE2_thumb.jpg',130, 173,15,'photo_1179534.html');
												thumbnails[1298444] = new thumbnail(1298444,'82798','FINRISE1','FINRISE12_thumb.jpg',130, 97,15,'photo_1298444.html');
												thumbnails[1298445] = new thumbnail(1298445,'82798','CORTONRISE','CORTONRISE1_thumb.jpg',130, 43,15,'photo_1298445.html');
												thumbnails[1298448] = new thumbnail(1298448,'82798','TRINGSET','TRINGSET1_thumb.jpg',130, 98,15,'photo_1298448.html');
												thumbnails[1298452] = new thumbnail(1298452,'82798','HEDGEMOON','HEDGEMOON1_thumb.jpg',130, 98,15,'photo_1298452.html');
												thumbnails[1298455] = new thumbnail(1298455,'82798','OAKSHADOW','OAKSHADOW1_thumb.jpg',130, 359,15,'photo_1298455.html');
												thumbnails[1298469] = new thumbnail(1298469,'82798','EVENING','EVENING3_thumb.jpg',130, 173,15,'photo_1298469.html');
												thumbnails[1298499] = new thumbnail(1298499,'82798','FINRISE2','FINRISE25_thumb.jpg',130, 98,15,'photo_1298499.html');
												thumbnails[1298506] = new thumbnail(1298506,'129306','RACECAR','RACECAR2_thumb.jpg',130, 98,15,'photo_1298506.html');
												thumbnails[1298520] = new thumbnail(1298520,'82801','FASTP','FASTP_thumb.jpg',130, 81,15,'photo_1298520.html');
												thumbnails[1298522] = new thumbnail(1298522,'82801','HLUMP','HLUMP_thumb.jpg',130, 98,15,'photo_1298522.html');
												thumbnails[1298527] = new thumbnail(1298527,'82801','CHARGERS','CHARGERS2_thumb.jpg',130, 173,15,'photo_1298527.html');
												thumbnails[1298528] = new thumbnail(1298528,'82801','MOTHS9','MOTHS9_thumb.jpg',130, 106,15,'photo_1298528.html');
												thumbnails[1298529] = new thumbnail(1298529,'82801','DIVE','DIVE2_thumb.jpg',130, 165,15,'photo_1298529.html');
												thumbnails[1298531] = new thumbnail(1298531,'82801','HSHINE','HSHINE3_thumb.jpg',130, 248,15,'photo_1298531.html');
												thumbnails[1298533] = new thumbnail(1298533,'82801','MOTHSKY','MOTHSKY_thumb.jpg',130, 82,15,'photo_1298533.html');
												thumbnails[1298535] = new thumbnail(1298535,'82801','BEACHED','BEACHED2_thumb.jpg',130, 173,15,'photo_1298535.html');
												thumbnails[1298536] = new thumbnail(1298536,'82801','SCRAMBLE','SCRAMBLE1_thumb.jpg',130, 99,15,'photo_1298536.html');
												thumbnails[1298547] = new thumbnail(1298547,'82818','IRISSURPRISE','IRISSURPRISE4_thumb.jpg',130, 173,15,'photo_1298547.html');
												thumbnails[1298586] = new thumbnail(1298586,'82801','WHEELSTOP','WHEELSTOP3_thumb.jpg',130, 173,15,'photo_1298586.html');
												thumbnails[1298603] = new thumbnail(1298603,'82800','LUCA','LUCA3_thumb.jpg',130, 173,15,'photo_1298603.html');
												thumbnails[1298616] = new thumbnail(1298616,'82800','ASTAR','ASTAR2_thumb.jpg',130, 173,15,'photo_1298616.html');
												thumbnails[1323624] = new thumbnail(1323624,'82818','MR&MRS','MR&MRS2_thumb.jpg',130, 165,15,'photo_1323624.html');
												thumbnails[1323627] = new thumbnail(1323627,'82818','BEECHNUTS','BEECHNUTS1_thumb.jpg',130, 86,15,'photo_1323627.html');
												thumbnails[1323628] = new thumbnail(1323628,'82818','DEADPINE','DEADPINE_thumb.jpg',130, 98,15,'photo_1323628.html');
												thumbnails[1323633] = new thumbnail(1323633,'82818','CLOUD2','CLOUD21_thumb.jpg',130, 103,15,'photo_1323633.html');
												thumbnails[1323635] = new thumbnail(1323635,'82818','CLOUD3','CLOUD31_thumb.jpg',130, 103,15,'photo_1323635.html');
												thumbnails[1323638] = new thumbnail(1323638,'82818','OLDWILLOW','OLDWILLOW_thumb.jpg',130, 49,15,'photo_1323638.html');
												thumbnails[1323642] = new thumbnail(1323642,'82818','ORCHID2','ORCHID2_thumb.jpg',130, 150,15,'photo_1323642.html');
												thumbnails[1323647] = new thumbnail(1323647,'82818','ORCHID1','ORCHID12_thumb.jpg',130, 98,15,'photo_1323647.html');
												thumbnails[1323649] = new thumbnail(1323649,'82818','LOST','LOST_thumb.jpg',130, 47,15,'photo_1323649.html');
												thumbnails[1323653] = new thumbnail(1323653,'82818','OAKCLUSTER','OAKCLUSTER_thumb.jpg',130, 61,15,'photo_1323653.html');
												thumbnails[1323656] = new thumbnail(1323656,'82818','3OFAKIND','3OFAKIND_thumb.jpg',130, 98,15,'photo_1323656.html');
												thumbnails[1323657] = new thumbnail(1323657,'82818','PONYFRAME','PONYFRAME1_thumb.jpg',130, 173,15,'photo_1323657.html');
												thumbnails[1323660] = new thumbnail(1323660,'82818','ISPY','ISPY1_thumb.jpg',130, 193,15,'photo_1323660.html');
												thumbnails[1323664] = new thumbnail(1323664,'82818','CLOUD1','CLOUD11_thumb.jpg',130, 98,15,'photo_1323664.html');
												thumbnails[1323670] = new thumbnail(1323670,'82800','CHEEKY','CHEEKY2_thumb.jpg',130, 113,15,'photo_1323670.html');
												thumbnails[1323675] = new thumbnail(1323675,'82800','THISWAY','THISWAY2_thumb.jpg',130, 170,15,'photo_1323675.html');
												thumbnails[1323678] = new thumbnail(1323678,'82800','CHATCHME','CATCHME1_thumb.jpg',130, 98,15,'photo_1323678.html');
												thumbnails[1323714] = new thumbnail(1323714,'82800','IWON','IWON1_thumb.jpg',130, 98,15,'photo_1323714.html');
												thumbnails[1323721] = new thumbnail(1323721,'82800','SHAKIN','SHAKIN1_thumb.jpg',130, 79,15,'photo_1323721.html');
												thumbnails[1323729] = new thumbnail(1323729,'82800','CHILLY','CHILLY1_thumb.jpg',130, 98,15,'photo_1323729.html');
												thumbnails[1323735] = new thumbnail(1323735,'82800','HIJUMP','HIJUMP1_thumb.jpg',130, 79,15,'photo_1323735.html');
												thumbnails[1323926] = new thumbnail(1323926,'82798','PINKMOON','PINKMOON_thumb.jpg',130, 95,15,'photo_1323926.html');
												thumbnails[1543715] = new thumbnail(1543715,'82798','STAROAK','STAROAK_thumb.jpg',130, 173,15,'photo_1543715.html');
												thumbnails[1675256] = new thumbnail(1675256,'82818','OAKMAN','OAKMAN1_thumb.jpg',130, 96,15,'photo_1675256.html');
												thumbnails[1676395] = new thumbnail(1676395,'82798','BLUEWOOD','BLUEWOOD-copy_thumb.jpg',130, 130,15,'photo_1676395.html');
												thumbnails[1676683] = new thumbnail(1676683,'129306','SENNA','SENNA1_thumb.jpg',130, 73,15,'photo_1676683.html');
												thumbnails[1676881] = new thumbnail(1676881,'82818','STRIKE','STRIKE1_thumb.jpg',130, 61,15,'photo_1676881.html');
												thumbnails[1795453] = new thumbnail(1795453,'82800','DJHANDS','DJHANDS-copy_thumb.jpg',130, 130,15,'photo_1795453.html');
												thumbnails[1795655] = new thumbnail(1795655,'82798','1STLIGHT','1STLIGHT-copy_thumb.jpg',130, 92,15,'photo_1795655.html');
												thumbnails[1799715] = new thumbnail(1799715,'129306','JRSUZ','JRSUZ_thumb.jpg',130, 181,15,'photo_1799715.html');
												thumbnails[1799720] = new thumbnail(1799720,'129306','SURFIN','SURFIN_1_thumb.jpg',130, 89,15,'photo_1799720.html');
												thumbnails[1809967] = new thumbnail(1809967,'129306','FERR','FERR4_thumb.jpg',130, 101,15,'photo_1809967.html');
												thumbnails[1809969] = new thumbnail(1809969,'129306','JAG','JAG3_thumb.jpg',130, 85,15,'photo_1809969.html');
												thumbnails[1812043] = new thumbnail(1812043,'129306','LEEDH','LEEDH_thumb.gif',130, 130,15,'photo_1812043.html');
												thumbnails[1812168] = new thumbnail(1812168,'129306','6-OFBEST','6-OFBEST_thumb.jpg',130, 201,15,'photo_1812168.html');
												thumbnails[1812169] = new thumbnail(1812169,'129306','CAP65','CAP65_thumb.jpg',130, 83,15,'photo_1812169.html');
												thumbnails[1812602] = new thumbnail(1812602,'129306','MCLN','MCLN_thumb.jpg',130, 82,15,'photo_1812602.html');
												thumbnails[1812743] = new thumbnail(1812743,'129306','EYES','EYES_thumb.jpg',130, 84,15,'photo_1812743.html');
												thumbnails[1814506] = new thumbnail(1814506,'129306','ROOT','ROOT_thumb.jpg',130, 130,15,'photo_1814506.html');
												thumbnails[1829221] = new thumbnail(1829221,'129306','TOS52','TOS524_thumb.jpg',130, 93,15,'photo_1829221.html');
												thumbnails[1830904] = new thumbnail(1830904,'129306','100BL','100BL_thumb.jpg',130, 84,15,'photo_1830904.html');
												thumbnails[1830905] = new thumbnail(1830905,'129306','FAB','FAB_thumb.jpg',130, 83,15,'photo_1830905.html');
												thumbnails[1831184] = new thumbnail(1831184,'129306','DUAL','DUAL_thumb.jpg',130, 41,15,'photo_1831184.html');
												thumbnails[1835924] = new thumbnail(1835924,'129306','GNIX','GNIX_thumb.jpg',130, 130,15,'photo_1835924.html');
												thumbnails[1856519] = new thumbnail(1856519,'129306','HEADON','HEADON_thumb.jpg',130, 61,15,'photo_1856519.html');
												thumbnails[1856617] = new thumbnail(1856617,'129306','FINNJP','FINNJP_thumb.jpg',130, 110,15,'photo_1856617.html');
												thumbnails[1927645] = new thumbnail(1927645,'82798','BELLPATH','BBELLPATH_thumb.jpg',130, 370,15,'photo_1927645.html');
												thumbnails[1927764] = new thumbnail(1927764,'129306','HODS100','HODS1003_thumb.jpg',130, 213,15,'photo_1927764.html');
												thumbnails[2058180] = new thumbnail(2058180,'82798','STORM1','STORM1_thumb.jpg',130, 96,15,'photo_2058180.html');
												thumbnails[2058348] = new thumbnail(2058348,'82798','STORM3','STORM3_thumb.jpg',130, 188,15,'photo_2058348.html');
												thumbnails[2058452] = new thumbnail(2058452,'82798','CORTON','CORTON_thumb.jpg',130, 98,15,'photo_2058452.html');
												thumbnails[2072610] = new thumbnail(2072610,'82801','MBELL','MBELL_thumb.jpg',130, 98,15,'photo_2072610.html');
												thumbnails[2491011] = new thumbnail(2491011,'82818','YOUNGJACK','YOUNGJACK_thumb.jpg',130, 173,15,'photo_2491011.html');
												thumbnails[2491050] = new thumbnail(2491050,'129306','COLIN','COLIN_thumb.jpg',130, 113,15,'photo_2491050.html');
												thumbnails[2491151] = new thumbnail(2491151,'129306','DA1','DA1_thumb.jpg',130, 135,15,'photo_2491151.html');
												thumbnails[2491153] = new thumbnail(2491153,'129306','DA2','DA2_thumb.jpg',130, 137,15,'photo_2491153.html');
												thumbnails[2491155] = new thumbnail(2491155,'129306','DA3','DA3_thumb.jpg',130, 88,15,'photo_2491155.html');
												thumbnails[2491159] = new thumbnail(2491159,'129306','KEVIN','KEVIN_thumb.jpg',130, 98,15,'photo_2491159.html');
												thumbnails[2491161] = new thumbnail(2491161,'129306','PM','PM_thumb.jpg',130, 104,15,'photo_2491161.html');

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  					galleries[82798] = new gallery(82798,'2058452,2058348,2058180,1927645,1795655,1676395,1543715,1323926,1298499,1298469','Landscapes','gallery',[1179534,1298444,1298445,1298448,1298452,1298455,1298469,1298499,1323926,1543715,1676395,1795655,1927645,2058180,2058348,2058452],0, 0, '', 'gallery_82798.html',0,0);
				  					galleries[82818] = new gallery(82818,'2491011,1676881,1675256,1323664,1323660,1323657,1323656,1323653,1323649,1323647','Nature','gallery',[1298547,1323624,1323627,1323628,1323633,1323635,1323638,1323642,1323647,1323649,1323653,1323656,1323657,1323660,1323664,1675256,1676881,2491011],0, 0, '', 'gallery_82818.html',0,0);
				  					galleries[82800] = new gallery(82800,'1795453,1323735,1323729,1323721,1323714,1323678,1323675,1323670,1298616,1298603','Portraiture/Lifestyle','gallery',[1298603,1298616,1323670,1323675,1323678,1323714,1323721,1323729,1323735,1795453],0, 0, '', 'gallery_82800.html',0,0);
				  					galleries[129306] = new gallery(129306,'2491161,2491159,2491155,2491153,2491151,2491050,1927764,1856617,1856519,1835924','Sport and recreation','gallery',[1298506,1676683,1799715,1799720,1809967,1809969,1812043,1812168,1812169,1812602,1812743,1814506,1829221,1830904,1830905,1831184,1835924,1856519,1856617,1927764,2491050,2491151,2491153,2491155,2491159,2491161],0, 0, '', 'gallery_129306.html',0,0);
				  					galleries[82801] = new gallery(82801,'2072610,1298586,1298536,1298535,1298533,1298531,1298529,1298528,1298527,1298522','Transport and Engineering','gallery',[1298520,1298522,1298527,1298528,1298529,1298531,1298533,1298535,1298536,1298586,2072610],0, 0, '', 'gallery_82801.html',0,0);
/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = new Object();
imageSets[1] = '2491161,2491159,2491155,2491153,2491151,2491050,2491011,2072610,2058452,2058348,2058180,1927764,1927645,1856617,1856519,1835924,1831184,1830905,1830904,1829221,1814506,1812743,1812602,1812169,1812168,1812043,1809969,1809967,1799720,1799715,1795655,1795453,1676881,1676683,1676395,1675256,1543715,1323926,1323735,1323729,1323721,1323714,1323678,1323675,1323670,1323664,1323660,1323657,1323656,1323653';
imageSets[3] = '2491161,2491159,2491155,2491153,2491151,2491050,2491011,2072610,2058452,2058348,2058180,1927764,1927645,1856617,1856519,1835924,1831184,1830905,1830904,1829221,1814506,1812743,1812602,1812169,1812168,1812043,1809969,1809967,1799720,1799715,1795655,1795453,1676881,1676683,1676395,1675256,1543715,1323926,1323735,1323729,1323721,1323714,1323678,1323675,1323670,1323664,1323660,1323657,1323656,1323653';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/PeterJDavies/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/PeterJDavies/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/PeterJDavies/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/PeterJDavies/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/PeterJDavies/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/PeterJDavies/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/PeterJDavies/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/PeterJDavies/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/PeterJDavies/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/PeterJDavies/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/PeterJDavies/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/PeterJDavies/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/PeterJDavies/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/PeterJDavies/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/PeterJDavies/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://admin2.clikpic.com/PeterJDavies/images';
		break;
	}
		switch (server_id) {
		case 33:
		val = 'http://www8.clikpic.com/PeterJDavies/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/PeterJDavies/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/PeterJDavies/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/PeterJDavies/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/PeterJDavies/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/PeterJDavies/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));		  $('body').trigger('clikUpdate');		}, 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 = 'P  e  t  e  r   J   D  a  v  i  e  s Photography: ' + photoCaption;
			    }
        if (op.$detail.length > 0) {
      temp = op.nextPhoto.fnGetImageDetails();
	    op.$detail.fadeGalleryDetails(temp, op.speed, function(){
	    var options = {photoinfominwidth:200};	    		options.photoinfoadjacent = true;			      	      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));      $('body').trigger('clikUpdate');    }        
    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 == undefined) {
    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>';
	}
					
	temp = temp + this.fnGetPaymentInfo();
				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>Buy now using PayPal:</p>';
				temp = temp + '<p class="imageinfo" id="imagePrice"><strong>' + this.purchase_instruction + '</strong> &pound;' + (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 + '<form id="paymentForm" style="margin:0px;border:0px;" name="paymentForm" target="_blank" action="https://www.paypal.com/cgi-bin/webscr" method="post">';
	temp = temp + '<input type="hidden" name="item_name" value="'+item_name+'">';
								ref = '';
				if(this.photo_ref != ''){
					ref = this.photo_ref+' - '+this.caption;
				}
				else{
					ref = this.id+' - '+this.caption;
				}
				price = amount;					temp = temp + '<input type="hidden" name="cmd" value="_cart">';
	temp = temp + '<input type="hidden" name="business" value="peterdavies36@btinternet.com">';
	temp = temp + '<input type="hidden" name="currency_code" value="GBP">';
	temp = temp + '<input type="hidden" name="add" value="1">';
					temp = temp + '<input type="hidden" name="amount" value="'+amount+'">';
	temp = temp + '<input type="hidden" name="item_number" value="'+ref+'">';
					temp = temp + '<input type=\"Submit\" value=\"Add to cart\" id=\"paymentAddButton\" class=\"button\" onmouseover=\"this.className=\'buttonHi\';\" onmouseout=\"this.className=\'button\';\">';
									temp = temp + '</form>';
								temp = temp + '<form id="paymentCartForm" style="margin:0px;" name="paymentCartForm" target="_blank" action="https://www.paypal.com/cgi-bin/webscr" method="post">';
	temp = temp + '<input type="hidden" name="cmd" value="_cart">';
	temp = temp + '<input type="hidden" name="business" value="peterdavies36@btinternet.com">';
	temp = temp + '<input type="hidden" name="display" value="1">';
	temp = temp + '<input type=\"Submit\" value=\"View cart\" id=\"paymentViewButton\" class=\"button\" onmouseover=\"this.className=\'buttonHi\';\" onmouseout=\"this.className=\'button\';\">';
	temp = temp + '</form>';
							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;
	}
}

			

