window.thumbnails = new Object();
												thumbnails[763946] = new thumbnail(763946,'58961','','Yellow_crab_apples_thumb.jpg',130, 108,15,'photo_763946.html');
												thumbnails[763947] = new thumbnail(763947,'58964','','Lilac_thumb.jpg',130, 105,15,'photo_763947.html');
												thumbnails[763949] = new thumbnail(763949,'58948','','Heather_thumb.jpg',130, 177,15,'photo_763949.html');
												thumbnails[763951] = new thumbnail(763951,'58965','','Skimmia_thumb.jpg',130, 150,15,'photo_763951.html');
												thumbnails[763953] = new thumbnail(763953,'58960','','Red_autumn_leaves_thumb.jpg',130, 100,15,'photo_763953.html');
												thumbnails[763960] = new thumbnail(763960,'58962','','Purple_viola_thumb.jpg',130, 165,15,'photo_763960.html');
												thumbnails[764001] = new thumbnail(764001,'58967','','French_lavender1_thumb.jpg',130, 162,15,'photo_764001.html');
												thumbnails[766762] = new thumbnail(766762,'59264','','Heuchera_flower_thumb.jpg',130, 181,15,'photo_766762.html');
												thumbnails[763955] = new thumbnail(763955,'58962','','Arts_and_Crafts_thumb.jpg',130, 195,15,'photo_763955.html');
												thumbnails[763961] = new thumbnail(763961,'58948','','Contemporary_seaside_thumb.jpg',130, 176,15,'photo_763961.html');
												thumbnails[763963] = new thumbnail(763963,'58960','','Landscape_thumb.jpg',130, 96,15,'photo_763963.html');
												thumbnails[763970] = new thumbnail(763970,'58964','','North_facing_thumb.jpg',130, 139,15,'photo_763970.html');
												thumbnails[763974] = new thumbnail(763974,'58961','','Low_maintenance_thumb.jpg',130, 147,15,'photo_763974.html');
												thumbnails[763990] = new thumbnail(763990,'58967','','Portugal_B&B_thumb.jpg',130, 67,15,'photo_763990.html');
												thumbnails[766667] = new thumbnail(766667,'59264','','Town_terrace_thumb.jpg',130, 141,15,'photo_766667.html');
												thumbnails[768197] = new thumbnail(768197,'58965','','New_build1_thumb.jpg',130, 60,15,'photo_768197.html');
												thumbnails[763956] = new thumbnail(763956,'58962','','Broad_beans_thumb.jpg',130, 190,15,'photo_763956.html');
												thumbnails[763962] = new thumbnail(763962,'58948','','Yellow_ball_flowers_thumb.jpg',130, 131,15,'photo_763962.html');
												thumbnails[763968] = new thumbnail(763968,'58960','','Sunlit_beech_thumb.jpg',130, 92,15,'photo_763968.html');
												thumbnails[763973] = new thumbnail(763973,'58964','','Red-Crabapples_thumb.jpg',130, 191,15,'photo_763973.html');
												thumbnails[763983] = new thumbnail(763983,'58961','','Wisteria-macro_thumb.jpg',130, 128,15,'photo_763983.html');
												thumbnails[763989] = new thumbnail(763989,'58965','','Crabapple_blossom_thumb.jpg',130, 139,15,'photo_763989.html');
												thumbnails[763991] = new thumbnail(763991,'58967','','Foliage_and_urns_thumb.jpg',130, 115,15,'photo_763991.html');
												thumbnails[766676] = new thumbnail(766676,'59264','','Town_garden_after_thumb.jpg',130, 100,15,'photo_766676.html');
												thumbnails[763958] = new thumbnail(763958,'58962','','Arts_and_Crafts_detail_thumb.jpg',130, 119,15,'photo_763958.html');
												thumbnails[763966] = new thumbnail(763966,'58960','','Landscape_detail_2_thumb.jpg',130, 94,15,'photo_763966.html');
												thumbnails[763980] = new thumbnail(763980,'58961','','Low_maintenance_detail_thumb.jpg',130, 132,15,'photo_763980.html');
												thumbnails[766678] = new thumbnail(766678,'59264','','Town_garden_front_thumb.jpg',130, 162,15,'photo_766678.html');
												thumbnails[764080] = new thumbnail(764080,'58965','','New_build_detail_thumb.jpg',130, 164,15,'photo_764080.html');
												thumbnails[764081] = new thumbnail(764081,'58967','','Portugal_detail_thumb.jpg',130, 125,15,'photo_764081.html');

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  					galleries[58948] = new gallery(58948,'763949','Seaside ','gallery',[763949,763961,763962],0, 0, '', 'gallery_58948.html',0,0);
				  					galleries[58960] = new gallery(58960,'763953','Landscape ','gallery',[763953,763963,763968,763966],0, 0, '', 'gallery_58960.html',0,0);
				  					galleries[58961] = new gallery(58961,'763946','Low maintenance','gallery',[763946,763974,763983,763980],0, 0, '', 'gallery_58961.html',0,0);
				  					galleries[58962] = new gallery(58962,'763960','Arts & Crafts','gallery',[763960,763955,763956,763958],0, 0, '', 'gallery_58962.html',0,0);
				  					galleries[58964] = new gallery(58964,'763947','North facing','gallery',[763947,763970,763973],0, 0, '', 'gallery_58964.html',0,0);
				  					galleries[58965] = new gallery(58965,'763951','New Home','gallery',[763951,768197,763989,764080],0, 0, '', 'gallery_58965.html',0,0);
				  					galleries[58967] = new gallery(58967,'764001','European inn','gallery',[764001,763990,763991,764081],0, 0, '', 'gallery_58967.html',0,0);
				  					galleries[59264] = new gallery(59264,'766762','Town','gallery',[766762,766667,766676,766678],0, 0, '', 'gallery_59264.html',0,0);
/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = new Object();
imageSets[1] = '763989';
imageSets[2] = '766762,764001,763960,763953,763951,763949,763947,763946';
imageSets[3] = '768197,766762,766678,766676,766667,764081,764080,764001,763991,763990,763989,763983,763980,763974,763973,763970,763968,763966,763963,763962,763961,763960,763958,763956,763955,763953,763951,763949,763947,763946';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/carolinewalden/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/carolinewalden/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/carolinewalden/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/carolinewalden/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/carolinewalden/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/carolinewalden/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/carolinewalden/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/carolinewalden/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/carolinewalden/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/carolinewalden/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/carolinewalden/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/carolinewalden/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/carolinewalden/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/carolinewalden/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/carolinewalden/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://admin2.clikpic.com/carolinewalden/images';
		break;
	}
		switch (server_id) {
		case 33:
		val = 'http://www8.clikpic.com/carolinewalden/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/carolinewalden/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/carolinewalden/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/carolinewalden/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/carolinewalden/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/carolinewalden/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 = 'Caroline Walden Garden Design: ' + 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;
	}
}

			

