window.thumbnails = new Object();
												thumbnails[3405374] = new thumbnail(3405374,'208057','bald eagle I','DSC_0484_thumb.JPG',130, 118,15,'																			photo_3405374.html');
												thumbnails[3405446] = new thumbnail(3405446,'208057','Kingfisher','DSC_0069_thumb.JPG',130, 95,15,'																			photo_3405446.html');
												thumbnails[3405492] = new thumbnail(3405492,'208057','Reindeer I','DSC_0278_thumb.JPG',130, 130,15,'																			photo_3405492.html');
												thumbnails[3405547] = new thumbnail(3405547,'208057','Reindeer II','DSC_0310_thumb.JPG',130, 88,15,'																			photo_3405547.html');
												thumbnails[3406091] = new thumbnail(3406091,'208057','Banff I','DSC_0178_thumb.JPG',130, 76,15,'																			photo_3406091.html');
												thumbnails[3406094] = new thumbnail(3406094,'208057','Banff I (B&W)','DSC_0178BW_thumb.JPG',130, 76,15,'																			photo_3406094.html');
												thumbnails[3406100] = new thumbnail(3406100,'208057','How to travel in Banff','DSC_0194_thumb.JPG',130, 91,15,'																			photo_3406100.html');
												thumbnails[3406107] = new thumbnail(3406107,'208057','Chipmunk I','DSC_0237_thumb.JPG',130, 174,15,'																			photo_3406107.html');
												thumbnails[3406114] = new thumbnail(3406114,'208057','Banff II','DSC_0274_thumb.JPG',130, 192,15,'																			photo_3406114.html');
												thumbnails[3406121] = new thumbnail(3406121,'208057','Chipmunk II','DSC_0280_thumb.JPG',130, 88,15,'																			photo_3406121.html');
												thumbnails[3406126] = new thumbnail(3406126,'208057','Banff III','DSC_0314_thumb.JPG',130, 70,15,'																			photo_3406126.html');
												thumbnails[1691854] = new thumbnail(1691854,'60945','Time for Yoga','LondonZoo(1) 039_thumb.jpg',130, 105,15,'																			photo_1691854.html');
												thumbnails[1691897] = new thumbnail(1691897,'60945','Vulture I','LondonZoo(1) 024_thumb.jpg',130, 118,15,'																			photo_1691897.html');
												thumbnails[1691912] = new thumbnail(1691912,'60945','Vulture II','LondonZoo(1) 025_thumb.jpg',130, 138,15,'																			photo_1691912.html');
												thumbnails[3405482] = new thumbnail(3405482,'60945','Monkey I','LondonZoo(2) 050_thumb.jpg',130, 88,15,'																			photo_3405482.html');
												thumbnails[785257] = new thumbnail(785257,'60932','Seasons change','Snow_thumb.jpg',130, 86,15,'																			photo_785257.html');
												thumbnails[785325] = new thumbnail(785325,'60950','Sweets','Sweets_thumb.jpg',130, 98,15,'																			photo_785325.html');
												thumbnails[785332] = new thumbnail(785332,'60952','Sunset in Sepia','Sunset_thumb.jpg',130, 66,15,'																			photo_785332.html');
												thumbnails[785334] = new thumbnail(785334,'60952','Sunset I','Sunset_2_thumb.jpg',130, 72,15,'																			photo_785334.html');
												thumbnails[785336] = new thumbnail(785336,'60952','Sunset II','Sunset_3_thumb.jpg',130, 66,15,'																			photo_785336.html');
												thumbnails[785342] = new thumbnail(785342,'60945','Buzz I','Buzz_1_thumb.jpg',130, 123,15,'																			photo_785342.html');
												thumbnails[785346] = new thumbnail(785346,'60945','Buzz II','Buzz_2_thumb.jpg',130, 118,15,'																			photo_785346.html');
												thumbnails[785347] = new thumbnail(785347,'60952','Green Green Grass','Grass_thumb.jpg',130, 98,15,'																			photo_785347.html');
												thumbnails[785349] = new thumbnail(785349,'60945','Camouflage ','Butterfly_thumb.jpg',130, 101,15,'																			photo_785349.html');
												thumbnails[785351] = new thumbnail(785351,'60932','Purple Shine','Flower_1_thumb.jpg',130, 161,15,'																			photo_785351.html');
												thumbnails[785352] = new thumbnail(785352,'60932','Natural Fire','Flower_2_thumb.jpg',130, 117,15,'																			photo_785352.html');
												thumbnails[785355] = new thumbnail(785355,'60945','Little and Large','Meerkats_1_thumb.jpg',130, 205,15,'																			photo_785355.html');
												thumbnails[785358] = new thumbnail(785358,'60945','Meerkats','Meerkats_2_thumb.jpg',130, 112,15,'																			photo_785358.html');
												thumbnails[785368] = new thumbnail(785368,'60950','Flying Colours','Flying_Colours_thumb.jpg',130, 101,15,'																			photo_785368.html');
												thumbnails[785380] = new thumbnail(785380,'60952','Inside the Cove','Weymouth_1_thumb.jpg',130, 81,15,'																			photo_785380.html');
												thumbnails[785385] = new thumbnail(785385,'60952','Out To Sea','Weymouth_2_thumb.jpg',130, 83,15,'																			photo_785385.html');
												thumbnails[785389] = new thumbnail(785389,'60952','Durdle Door II','Weymouth_3_thumb.jpg',130, 78,15,'																			photo_785389.html');
												thumbnails[785392] = new thumbnail(785392,'60952','Durdle Door I','Weymouth_4_thumb.jpg',130, 102,15,'																			photo_785392.html');
												thumbnails[785401] = new thumbnail(785401,'60945','Penguins','Penguins_thumb.jpg',130, 155,15,'																			photo_785401.html');
												thumbnails[785393] = new thumbnail(785393,'60945','Look Around You','birdonbush_thumb.jpg',130, 102,15,'																			photo_785393.html');
												thumbnails[785395] = new thumbnail(785395,'60945','Bird on the Bush','birdonbush_2_thumb.jpg',130, 102,15,'																			photo_785395.html');
												thumbnails[785418] = new thumbnail(785418,'60952','Sepia Landscape','sepia_thumb.jpg',130, 102,15,'																			photo_785418.html');
												thumbnails[785397] = new thumbnail(785397,'60950','Electric Silhouette','Silhouette_1_thumb.jpg',130, 178,15,'																			photo_785397.html');
												thumbnails[785405] = new thumbnail(785405,'60950','Horror Silhouette','Silhouette_2_thumb.jpg',130, 174,15,'																			photo_785405.html');
												thumbnails[785407] = new thumbnail(785407,'60950','Silhouette','Silhouette_3_thumb.jpg',130, 174,15,'																			photo_785407.html');
												thumbnails[785408] = new thumbnail(785408,'60954','Gateway','church_thumb.jpg',130, 98,15,'																			photo_785408.html');
												thumbnails[785409] = new thumbnail(785409,'60954','Church View','church_2_thumb.jpg',130, 102,15,'																			photo_785409.html');
												thumbnails[785410] = new thumbnail(785410,'60932','Shing Through the Trees','Trees_thumb.jpg',130, 102,15,'																			photo_785410.html');
												thumbnails[785411] = new thumbnail(785411,'60950','Yellow Flower I','yellowflower_thumb.jpg',130, 102,15,'																			photo_785411.html');
												thumbnails[785412] = new thumbnail(785412,'60950','Yellow Flower','yellowflower_2_thumb.jpg',130, 133,15,'																			photo_785412.html');
												thumbnails[785416] = new thumbnail(785416,'60932','Sepia Weeping Willow','weeping_thumb.jpg',130, 102,15,'																			photo_785416.html');
												thumbnails[801623] = new thumbnail(801623,'62188','Lunar Eclipse I','LunarI_thumb.jpg',130, 107,15,'																			photo_801623.html');
												thumbnails[801626] = new thumbnail(801626,'62188','Lunar Eclipse II','LunarII_thumb.jpg',130, 113,15,'																			photo_801626.html');
												thumbnails[801630] = new thumbnail(801630,'62188','Lunar Eclipse III','LunarIII_thumb.jpg',130, 98,15,'																			photo_801630.html');
												thumbnails[801688] = new thumbnail(801688,'62188','Lunar Eclipse IV','LunarIV_thumb.jpg',130, 92,15,'																			photo_801688.html');
												thumbnails[801743] = new thumbnail(801743,'62188','Lunar Eclipse V','LunarV_thumb.jpg',130, 102,15,'																			photo_801743.html');
												thumbnails[801745] = new thumbnail(801745,'62188','Lunar Eclipse VI','LunarVI_thumb.jpg',130, 108,15,'																			photo_801745.html');
												thumbnails[801746] = new thumbnail(801746,'62188','Lunar Eclipse VII','LunarVII_thumb.jpg',130, 102,15,'																			photo_801746.html');
												thumbnails[801748] = new thumbnail(801748,'62188','Lunar Eclipse VIII','LunarVIII_thumb.jpg',130, 111,15,'																			photo_801748.html');
												thumbnails[801750] = new thumbnail(801750,'62188','Lunar Eclipse IX','LunarIX_thumb.jpg',130, 114,15,'																			photo_801750.html');
												thumbnails[801752] = new thumbnail(801752,'62188','Lunar Eclipse X','LunarX_thumb.jpg',130, 116,15,'																			photo_801752.html');

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  					galleries[208057] = new gallery(208057,'3405374','Canada & Alaska','gallery',[3405374,3405446,3405492,3405547,3406091,3406094,3406100,3406107,3406114,3406121,3406126],0, 0, '', '																																																																																																							gallery_208057.html',0,0);
				  					galleries[60932] = new gallery(60932,'785416,785410,785352,785351,785257','Plants & Flowers','gallery',[785257,785351,785352,785410,785416],0, 0, '', '																																																																																																							gallery_60932.html',0,0);
				  					galleries[60945] = new gallery(60945,'3405482,1691912,1691897,1691854,785401,785395,785393,785358,785355,785349','Animals','gallery',[1691854,1691897,1691912,3405482,785342,785346,785349,785355,785358,785401,785393,785395],0, 0, '', '																																																																																																							gallery_60945.html',0,0);
				  					galleries[62188] = new gallery(62188,'801752,801750,801748,801746,801745,801743,801688,801630,801626,801623','Lunar Eclipse','gallery',[801623,801626,801630,801688,801743,801745,801746,801748,801750,801752],0, 0, '', '																																																																																																							gallery_62188.html',0,0);
				  					galleries[60950] = new gallery(60950,'785325','Abstract','gallery',[785325,785368,785397,785405,785407,785411,785412],0, 0, '', '																																																																																																							gallery_60950.html',0,0);
				  					galleries[60952] = new gallery(60952,'785418,785392,785389,785385,785380,785347,785336,785334,785332','Landscapes & Waterscapes','gallery',[785332,785334,785336,785347,785380,785385,785389,785392,785418],0, 0, '', '																																																																																																							gallery_60952.html',0,0);
				  					galleries[60954] = new gallery(60954,'785409,785408','Other','gallery',[785408,785409],0, 0, '', '																																																																																																							gallery_60954.html',0,0);
/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = new Object();
imageSets[1] = '3406126,3406121,3406114,3406107,3406100,3406094,3406091,3405547,3405492,3405482,3405446,3405374,1691912,1691897,1691854,801752,801750,801748,801746,801745,801743,801688,801630,801626,801623,785418,785416,785412,785411,785410,785409,785408,785407,785405,785401,785397,785395,785393,785392,785389,785385,785380,785368,785358,785355,785352,785351,785349,785347,785346';
imageSets[2] = '3405374,785325';
imageSets[3] = '3406126,3406121,3406114,3406107,3406100,3406094,3406091,3405547,3405492,3405482,3405446,3405374,1691912,1691897,1691854,801752,801750,801748,801746,801745,801743,801688,801630,801626,801623,785418,785416,785412,785411,785410,785409,785408,785407,785405,785401,785397,785395,785393,785392,785389,785385,785380,785368,785358,785355,785352,785351,785349,785347,785346';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/DavidKelly/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/DavidKelly/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/DavidKelly/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/DavidKelly/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/DavidKelly/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/DavidKelly/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/DavidKelly/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/DavidKelly/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/DavidKelly/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/DavidKelly/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/DavidKelly/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/DavidKelly/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/DavidKelly/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/DavidKelly/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/DavidKelly/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://admin2.clikpic.com/DavidKelly/images';
		break;
	}
		switch (server_id) {
		case 33:
		val = 'http://www8.clikpic.com/DavidKelly/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/DavidKelly/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/DavidKelly/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/DavidKelly/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/DavidKelly/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/DavidKelly/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 = 'David Kelly 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;
	}
}

		

