window.thumbnails = new Object();
												thumbnails[2548122] = new thumbnail(2548122,'158531','Burano Palette','Burano Palette_thumb.jpg',130, 87,32,'photo_2548122.html');
												thumbnails[2548124] = new thumbnail(2548124,'158531','Duomo, Firenze','Duomo, Firenze_thumb.jpg',130, 92,32,'photo_2548124.html');
												thumbnails[2548130] = new thumbnail(2548130,'158531','Escape to Selfridges','Escape to Selfridges _thumb.jpg',130, 87,32,'photo_2548130.html');
												thumbnails[2548132] = new thumbnail(2548132,'158531','Graffiti Lady','Spanish Grafitti_thumb.jpg',130, 87,32,'photo_2548132.html');
												thumbnails[2548134] = new thumbnail(2548134,'162872','One of Hers, One of Mine (in leather)','1_hers_1_mine_thumb.jpg',130, 126,32,'photo_2548134.html');
												thumbnails[2548135] = new thumbnail(2548135,'162872','The Builder and the Model ','Builder and the Model _thumb.jpg',130, 83,32,'photo_2548135.html');
												thumbnails[2548137] = new thumbnail(2548137,'162872','Foxy Lady','Foxy Lady_thumb.jpg',130, 163,32,'photo_2548137.html');
												thumbnails[2548143] = new thumbnail(2548143,'162872','Fur \'n\' Debs \'n\' Dog','Fur \'n\' Debs \'n\' Dog tif_thumb.jpg',130, 129,32,'photo_2548143.html');
												thumbnails[2548144] = new thumbnail(2548144,'162872','Lady of Southwark<br>\r\n','Lady of Southwark_thumb.jpg',130, 92,32,'photo_2548144.html');
												thumbnails[2548145] = new thumbnail(2548145,'162872','Recorded Vida','Recorded Vida_thumb.jpg',130, 130,32,'photo_2548145.html');
												thumbnails[2548146] = new thumbnail(2548146,'162872','True Grit Landscape','True Grit_thumb.jpg',130, 185,32,'photo_2548146.html');
												thumbnails[2548151] = new thumbnail(2548151,'158532','','5,12 copy_thumb.jpg',130, 130,32,'photo_2548151.html');
												thumbnails[2548153] = new thumbnail(2548153,'158532','','9-6ncrop_thumb.jpg',130, 130,32,'photo_2548153.html');
												thumbnails[2548155] = new thumbnail(2548155,'158532','','9-24ncrop_thumb.jpg',130, 130,32,'photo_2548155.html');
												thumbnails[2548156] = new thumbnail(2548156,'158532','','12-9ncrop2_thumb.jpg',130, 130,32,'photo_2548156.html');
												thumbnails[2548158] = new thumbnail(2548158,'158532','','12-16ncrop_thumb.jpg',130, 130,32,'photo_2548158.html');
												thumbnails[2548162] = new thumbnail(2548162,'158532','','19-35ncrop_thumb.jpg',130, 130,32,'photo_2548162.html');
												thumbnails[2548164] = new thumbnail(2548164,'158532','','23-17ncrop (1)_thumb.jpg',130, 130,32,'photo_2548164.html');
												thumbnails[2548168] = new thumbnail(2548168,'162873','Death at Bryce','Death @ Bryce _thumb.jpg',130, 83,32,'photo_2548168.html');
												thumbnails[2548169] = new thumbnail(2548169,'162873','Ebeneezer Geezer','Ebeneezer Geezer_thumb.jpg',130, 89,32,'photo_2548169.html');
												thumbnails[2548170] = new thumbnail(2548170,'162873','Empire State and Friends','Empire State & Friends _thumb.jpg',130, 81,32,'photo_2548170.html');
												thumbnails[2548173] = new thumbnail(2548173,'162873','Mixed Foliage, Kanab','Mixed Foliage, Kanab _thumb.jpg',130, 87,32,'photo_2548173.html');
												thumbnails[2548174] = new thumbnail(2548174,'162873','Relief at Page','Relief @ Page_thumb.jpg',130, 85,32,'photo_2548174.html');
												thumbnails[2548176] = new thumbnail(2548176,'162873','Texas Rocks','Texas Rocks_thumb.jpg',130, 84,32,'photo_2548176.html');
												thumbnails[2548178] = new thumbnail(2548178,'162873','We Remember','We Remember_thumb.jpg',130, 85,32,'photo_2548178.html');
												thumbnails[2548182] = new thumbnail(2548182,'162879','300 Miles Desert Ahead','4_thumb.300 Miles Desert Ahead .jpg',130, 82,32,'photo_2548182.html');
												thumbnails[2548184] = new thumbnail(2548184,'162879','Concorde, 18th October 2003','Concorde Landing at Heathrow_thumb.jpg',130, 92,32,'photo_2548184.html');
												thumbnails[2548192] = new thumbnail(2548192,'162879','QE2\'s Last Voyage','QE2\'s Last Voyage _thumb.jpg',130, 83,32,'photo_2548192.html');
												thumbnails[2548194] = new thumbnail(2548194,'162879','Texaco Gas Station','Texaco Rules_thumb.jpg',130, 86,32,'photo_2548194.html');
												thumbnails[2548287] = new thumbnail(2548287,'162874','Lady of the Lagoon','Lady of the Lagoon_thumb.jpg',130, 87,32,'photo_2548287.html');
												thumbnails[2548291] = new thumbnail(2548291,'162874','Masked Invite','Masked Invite_thumb.jpg',130, 85,32,'photo_2548291.html');
												thumbnails[2548294] = new thumbnail(2548294,'162874','Mirror, Mirror','Mirror, Mirror_thumb.jpg',130, 195,32,'photo_2548294.html');
												thumbnails[2548296] = new thumbnail(2548296,'162874','The Venice Five','Venetian Five_thumb.jpg',130, 195,32,'photo_2548296.html');
												thumbnails[3763691] = new thumbnail(3763691,'162872','Bert Hardy Remembered','Bert-Hardy-Remembered-copy_thumb.jpg',130, 195,32,'photo_3763691.html');
												thumbnails[3763731] = new thumbnail(3763731,'162873','Erosion at Bryce','Erosion--Bryce_thumb.jpg',130, 87,32,'photo_3763731.html');
												thumbnails[2548131] = new thumbnail(2548131,'158531','Selfridges Curves','Selfridges_thumb.jpg',130, 198,32,'photo_2548131.html');
												thumbnails[2548177] = new thumbnail(2548177,'162873','Turn Left at the Castle','Turn Left @ The Castle_thumb.jpg',130, 199,32,'photo_2548177.html');
												thumbnails[2548187] = new thumbnail(2548187,'162879','Flag at Grand Central','Flag @ Grand Central _thumb.jpg',130, 199,32,'photo_2548187.html');
												thumbnails[3763628] = new thumbnail(3763628,'158532','','Greenhouse-Gangster_thumb.jpg',130, 87,32,'photo_3763628.html');
												thumbnails[2548133] = new thumbnail(2548133,'158531','Spanish Turtle','Spanish Turtle_thumb.jpg',130, 199,32,'photo_2548133.html');
												thumbnails[2548165] = new thumbnail(2548165,'158532','','Mobil Gas Station_thumb.jpg',130, 83,32,'photo_2548165.html');
												thumbnails[2548175] = new thumbnail(2548175,'162873','Squaw, Professor and Taxi Driver','Squaw, Professor, Taxi Driver_thumb.jpg',130, 197,32,'photo_2548175.html');
												thumbnails[2548189] = new thumbnail(2548189,'162879','Phillips 66','Phillips 66_thumb.jpg',130, 195,32,'photo_2548189.html');
												thumbnails[2548123] = new thumbnail(2548123,'158531','Church at the UN','Church @ the UN_thumb.jpg',130, 195,32,'photo_2548123.html');
												thumbnails[2548160] = new thumbnail(2548160,'158532','','15-19ncrop_thumb.jpg',130, 87,32,'photo_2548160.html');
												thumbnails[2548171] = new thumbnail(2548171,'162873','Erosion, Slot Canyon','Erosion, Slot Canyon _thumb.jpg',130, 203,32,'photo_2548171.html');

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  					galleries[158531] = new gallery(158531,'2548133,2548132,2548131,2548130,2548124,2548123,2548122','Architectural Design','gallery',[2548122,2548124,2548130,2548132,2548131,2548133,2548123],0, 0, '', 'gallery_158531.html',0,0);
				  					galleries[162872] = new gallery(162872,'3763691,2548146,2548145,2548144,2548143,2548137,2548135,2548134','Monochrome','gallery',[2548134,2548135,2548137,2548143,2548144,2548145,2548146,3763691],0, 0, '', 'gallery_162872.html',0,0);
				  					galleries[158532] = new gallery(158532,'3763628,2548165,2548164,2548162,2548160,2548158,2548156,2548155,2548153,2548151','Route 66','gallery',[2548151,2548153,2548155,2548156,2548158,2548162,2548164,3763628,2548165,2548160],0, 0, '', 'gallery_158532.html',0,0);
				  					galleries[162879] = new gallery(162879,'2548194,2548192,2548189,2548187,2548184,2548182','Transport','gallery',[2548182,2548184,2548192,2548194,2548187,2548189],0, 0, '', 'gallery_162879.html',0,0);
				  					galleries[162873] = new gallery(162873,'3763731,2548178,2548177,2548176,2548175,2548174,2548173,2548171,2548170,2548169','USA','gallery',[2548168,2548169,2548170,2548173,2548174,2548176,2548178,3763731,2548177,2548175,2548171],0, 0, '', 'gallery_162873.html',0,0);
				  					galleries[162874] = new gallery(162874,'2548296,2548294,2548291,2548287','Venice Carnival','gallery',[2548287,2548291,2548294,2548296],0, 0, '', 'gallery_162874.html',0,0);
/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = new Object();
imageSets[1] = '3763731,3763691,3763628,2548296,2548294,2548291,2548287,2548194,2548192,2548189,2548187,2548184,2548182,2548178,2548177,2548176,2548175,2548174,2548173,2548171,2548170,2548169,2548168,2548165,2548164,2548162,2548160,2548158,2548156,2548155,2548153,2548151,2548146,2548145,2548144,2548143,2548137,2548135,2548134,2548133,2548132,2548131,2548130,2548124,2548123,2548122';
imageSets[3] = '3763731,3763691,3763628,2548296,2548294,2548291,2548287,2548194,2548192,2548189,2548187,2548184,2548182,2548178,2548177,2548176,2548175,2548174,2548173,2548171,2548170,2548169,2548168,2548165,2548164,2548162,2548160,2548158,2548156,2548155,2548153,2548151,2548146,2548145,2548144,2548143,2548137,2548135,2548134,2548133,2548132,2548131,2548130,2548124,2548123,2548122';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/gedmunds/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/gedmunds/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/gedmunds/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/gedmunds/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/gedmunds/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/gedmunds/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/gedmunds/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/gedmunds/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/gedmunds/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/gedmunds/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/gedmunds/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/gedmunds/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/gedmunds/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/gedmunds/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/gedmunds/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://admin2.clikpic.com/gedmunds/images';
		break;
	}
		switch (server_id) {
		case 33:
		val = 'http://www8.clikpic.com/gedmunds/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/gedmunds/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/gedmunds/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/gedmunds/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/gedmunds/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/gedmunds/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 = 'Glyn Edmunds 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));      $('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 = 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;
	}
}

			

