window.thumbnails = new Object();
												thumbnails[4138576] = new thumbnail(4138576,'','','mulberry--046_thumb.jpg',130, 130,1,'#');
												thumbnails[4139224] = new thumbnail(4139224,'','','mulberry--055_thumb.jpg',130, 130,1,'#');
												thumbnails[4139306] = new thumbnail(4139306,'247608','','mulberry--060_thumb.jpg',130, 130,1,'photo_4139306.html');
												thumbnails[3264984] = new thumbnail(3264984,'23508','','O_J-218_TIF_1401526402_thumb.jpg',130, 130,1,'photo_3264984.html');
												thumbnails[4136291] = new thumbnail(4136291,'23508','','mulberry--028_thumb.jpg',130, 130,1,'photo_4136291.html');
												thumbnails[4136287] = new thumbnail(4136287,'23508','','mulberry--026_thumb.jpg',130, 130,1,'photo_4136287.html');
												thumbnails[4136573] = new thumbnail(4136573,'23508','','mulberry--033_thumb.jpg',130, 130,1,'photo_4136573.html');
												thumbnails[4138691] = new thumbnail(4138691,'23508','','mulberry--0392_thumb.jpg',130, 130,1,'photo_4138691.html');
												thumbnails[4136574] = new thumbnail(4136574,'23508','','mulberry--034_thumb.jpg',130, 130,1,'photo_4136574.html');
												thumbnails[4136585] = new thumbnail(4136585,'23508','','mulberry--041_thumb.jpg',130, 130,1,'photo_4136585.html');
												thumbnails[4138405] = new thumbnail(4138405,'23508','','mulberry--042_thumb.jpg',130, 130,1,'photo_4138405.html');
												thumbnails[4138712] = new thumbnail(4138712,'23508','','O_J-220_TIF_1401527402_thumb.jpg',130, 130,1,'photo_4138712.html');
												thumbnails[4118620] = new thumbnail(4118620,'23508','','mulberry--025_thumb.jpg',130, 130,1,'photo_4118620.html');
												thumbnails[4138581] = new thumbnail(4138581,'23508','','mulberry--048_thumb.jpg',130, 130,1,'photo_4138581.html');
												thumbnails[4143320] = new thumbnail(4143320,'23508','','mulberry--068_thumb.jpg',130, 130,1,'photo_4143320.html');
												thumbnails[4143329] = new thumbnail(4143329,'23508','','mulberry--070_thumb.jpg',130, 130,1,'photo_4143329.html');
												thumbnails[3264945] = new thumbnail(3264945,'23508','','LGW112_thumb.jpg',130, 130,1,'photo_3264945.html');
												thumbnails[3264956] = new thumbnail(3264956,'23508','','LGW-1201_thumb.jpg',130, 130,1,'photo_3264956.html');
												thumbnails[3264950] = new thumbnail(3264950,'23508','','LGW113_thumb.jpg',130, 130,1,'photo_3264950.html');
												thumbnails[4136567] = new thumbnail(4136567,'23508','','mulberry--031_thumb.jpg',130, 130,1,'photo_4136567.html');
												thumbnails[4138574] = new thumbnail(4138574,'23508','','mulberry--043_thumb.jpg',130, 130,1,'photo_4138574.html');
												thumbnails[4143324] = new thumbnail(4143324,'23508','','mulberry--069_thumb.jpg',130, 130,1,'photo_4143324.html');
												thumbnails[4136580] = new thumbnail(4136580,'23508','','mulberry--037_thumb.jpg',130, 130,1,'photo_4136580.html');
												thumbnails[3264808] = new thumbnail(3264808,'247644','','cherry027_thumb.jpg',130, 130,1,'photo_3264808.html');
												thumbnails[3264813] = new thumbnail(3264813,'247644','','Lucy___Dan-006 [TIF 1438892002]_thumb.jpg',130, 130,1,'photo_3264813.html');
												thumbnails[3264952] = new thumbnail(3264952,'23511','','LGW108_thumb.jpg',130, 130,1,'photo_3264952.html');
												thumbnails[3264957] = new thumbnail(3264957,'23511','','LGW110_thumb.jpg',130, 130,1,'photo_3264957.html');
												thumbnails[3264973] = new thumbnail(3264973,'247644','','vintage-china-plates-wedding1_thumb.jpg',130, 130,1,'photo_3264973.html');
												thumbnails[3264975] = new thumbnail(3264975,'247644','','vintage-flower-decoration-wedding1_thumb.jpg',130, 130,1,'photo_3264975.html');
												thumbnails[3264977] = new thumbnail(3264977,'23511','','vintage-flower-jug1_thumb.jpg',130, 130,1,'photo_3264977.html');
												thumbnails[3264982] = new thumbnail(3264982,'247644','','vintage-prop-hire_thumb.jpg',130, 130,1,'photo_3264982.html');
												thumbnails[3264991] = new thumbnail(3264991,'247644','','vintage-wedding-marquee-styling1_thumb.jpg',130, 130,1,'photo_3264991.html');
												thumbnails[4138403] = new thumbnail(4138403,'247644','','1401501002_thumb.jpg',130, 130,1,'photo_4138403.html');
												thumbnails[4138584] = new thumbnail(4138584,'23511','','mulberry--051_thumb.jpg',130, 130,1,'photo_4138584.html');
												thumbnails[4138587] = new thumbnail(4138587,'23511','','mulberry--053_thumb.jpg',130, 130,1,'photo_4138587.html');
												thumbnails[4138596] = new thumbnail(4138596,'23511','','mulberry--054_thumb.jpg',130, 130,1,'photo_4138596.html');
												thumbnails[4139249] = new thumbnail(4139249,'247644','','mulberry--059_thumb.jpg',130, 130,1,'photo_4139249.html');
												thumbnails[4143286] = new thumbnail(4143286,'23511','','mulberry--0551_thumb.jpg',130, 130,1,'photo_4143286.html');
												thumbnails[4143313] = new thumbnail(4143313,'23511','','mulberry--067_thumb.jpg',130, 130,1,'photo_4143313.html');
												thumbnails[4143334] = new thumbnail(4143334,'23511','','mulberry--071_thumb.jpg',130, 130,1,'photo_4143334.html');
												thumbnails[4143336] = new thumbnail(4143336,'23511','','mulberry--076_thumb.jpg',130, 130,1,'photo_4143336.html');
												thumbnails[4143341] = new thumbnail(4143341,'23511','','mulberry--079_thumb.jpg',130, 130,1,'photo_4143341.html');
												thumbnails[4143454] = new thumbnail(4143454,'23511','','mulberry--081_thumb.jpg',130, 130,1,'photo_4143454.html');
												thumbnails[4143673] = new thumbnail(4143673,'247644','','O_J-158-TIF-1438896402_thumb.jpg',130, 130,1,'photo_4143673.html');
												thumbnails[4143683] = new thumbnail(4143683,'247644','','O_J-217-TIF-1438899202_thumb.jpg',130, 130,1,'photo_4143683.html');
												thumbnails[4143691] = new thumbnail(4143691,'247644','','O_J-269-TIF-1438906002_thumb.jpg',130, 130,1,'photo_4143691.html');
												thumbnails[4143767] = new thumbnail(4143767,'247644','','O_J-259_TIF_1401543602_thumb.jpg',130, 130,1,'photo_4143767.html');

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  					galleries[23508] = new gallery(23508,'3264984','CHINA','gallery',[3264984,4136291,4136287,4136573,4138691,4136574,4136585,4138405,4138712,4118620,4138581,4143320,4143329,3264945,3264956,3264950,4136567,4138574,4143324,4136580],0, 0, '', 'gallery_23508.html',0,0);
				  					galleries[247644] = new gallery(247644,'3264982','Ideas','section300183',[3264808,3264813,3264973,3264975,3264982,3264991,4138403,4139249,4143673,4143683,4143691,4143767],0, 0, '', 'section300183_247644.html',0,0);
				  					galleries[247608] = new gallery(247608,'4139306','GLASS','gallery',[4139306],0, 0, '', 'gallery_247608.html',0,0);
				  					galleries[23511] = new gallery(23511,'3264957','PROPS','section300183',[3264952,3264957,3264977,4138584,4138587,4138596,4143286,4143313,4143334,4143336,4143341,4143454],0, 0, '', 'section300183_23511.html',0,0);
/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = new Object();
imageSets[1] = '4143320,4138403,4136585,4136580,4136573,4136567,4136287,4118620,3264991,3264973,3264808';
imageSets[2] = '3264984,3264982,3264957';
imageSets[3] = '4143767,4143691,4143683,4143673,4143454,4143341,4143336,4143334,4143329,4143324,4143320,4143313,4143286,4139306,4139249,4139224,4138712,4138691,4138596,4138587,4138584,4138581,4138576,4138574,4138405,4138403,4136585,4136580,4136574,4136573,4136567,4136291,4136287,4118620,3264991,3264984,3264982,3264977,3264975,3264973,3264957,3264956,3264952,3264950,3264945,3264813,3264808';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/oliviabrabbs/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/oliviabrabbs/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/oliviabrabbs/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/oliviabrabbs/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/oliviabrabbs/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/oliviabrabbs/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/oliviabrabbs/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/oliviabrabbs/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/oliviabrabbs/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/oliviabrabbs/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/oliviabrabbs/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/oliviabrabbs/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/oliviabrabbs/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/oliviabrabbs/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/oliviabrabbs/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://admin2.clikpic.com/oliviabrabbs/images';
		break;
	}
		switch (server_id) {
		case 33:
		val = 'http://www8.clikpic.com/oliviabrabbs/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/oliviabrabbs/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/oliviabrabbs/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/oliviabrabbs/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/oliviabrabbs/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/oliviabrabbs/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 = 'The Vintage China Cupboard: ' + 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 == 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>Description:  </strong>' +  this.location + '</p>';
	}
	
	if (this.photographer != '') {
				
		temp = temp + '<p class="imageinfo" id="imagePhotographer"><strong>Hire Cost:  </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;
	}
}

			

