window.thumbnails = new Object();
												thumbnails[2193451] = new thumbnail(2193451,'','Art on the Railings Logo 2008 <br>\r\nCopyright Ian Gorton 2008','w_AoR_Logo-ho-ho_thumb.jpg',130, 98,1,'#');
												thumbnails[1913192] = new thumbnail(1913192,'','Art on the Railings 2007','ArtonRails-Aug07_thumb.jpg',130, 194,1,'#');
												thumbnails[1903896] = new thumbnail(1903896,'','Vals Walk','CP_artonRails2008LOGO_thumb.jpg',130, 122,1,'#');
												thumbnails[1955703] = new thumbnail(1955703,'130177','Ken Hugill - Photo of Event 2007','IMG_3207_thumb.jpg',130, 97,1,'photo_1955703.html');
												thumbnails[1903899] = new thumbnail(1903899,'127677','Pam Banks working on a competition piece in the Church Grounds','MVC-087S_thumb.JPG',130, 98,1,'photo_1903899.html');
												thumbnails[2304219] = new thumbnail(2304219,'129249','Minal badekar<br>\r\n<br>\r\nUnamed','mb_4060_thumb.jpg',130, 98,1,'photo_2304219.html');
												thumbnails[2411896] = new thumbnail(2411896,'129249','','refittingtheoldgirl_thumb.gif',130, 86,1,'photo_2411896.html');
												thumbnails[2411991] = new thumbnail(2411991,'129249','','eightbysix Masculinity_thumb.jpg',130, 199,1,'photo_2411991.html');
												thumbnails[5980093] = new thumbnail(5980093,'337134','1st Prize Winner<br>\r\nInto the Future<br>\r\nArtist Ian Gorton','We_FoD_Into_the_Future_thumb.jpg',130, 195,1,'photo_5980093.html');
												thumbnails[3350991] = new thumbnail(3350991,'204503','First Prize Winner - Ambush','Exhi-first_2161_thumb.jpg',130, 107,1,'photo_3350991.html');
												thumbnails[5981962] = new thumbnail(5981962,'337134','2nd Prize Winner:<br>\r\nTawny Owl<br>\r\nArtist Geoff Jennings','Geoff-DSCF3936_thumb.jpg',130, 176,1,'photo_5981962.html');
												thumbnails[3350993] = new thumbnail(3350993,'204503','Ian Gorton - Sunset Fired 2nd Place','Exhi-Second_2164_thumb.jpg',130, 181,1,'photo_3350993.html');
												thumbnails[5980156] = new thumbnail(5980156,'337134','3rd Prize Winner:<br>\r\nThe Dean Heritage Centre; <br>\r\nDanny Marriott','100506_220207_thumb.jpg',130, 98,1,'photo_5980156.html');
												thumbnails[3350996] = new thumbnail(3350996,'204503','D R Marriott - Son of Mary 3rd Place<br>\r\n','Exhi-third_2165_thumb.jpg',130, 158,1,'photo_3350996.html');
												thumbnails[1939994] = new thumbnail(1939994,'129249','Mike O\'Neill - Light Sleepers Deep Dreamers','cp-light-sleepers-deep-drea_thumb.jpg',130, 174,1,'photo_1939994.html');
												thumbnails[1934365] = new thumbnail(1934365,'129249','Peter Day - Sailing Ship','cpPeterDay_thumb.jpg',130, 189,1,'photo_1934365.html');
												thumbnails[1928889] = new thumbnail(1928889,'129249','Jill Greenhalgh - Irises and Lindas','cpirises-&-lindas-0021_thumb.jpg',130, 173,1,'photo_1928889.html');
												thumbnails[1903852] = new thumbnail(1903852,'126948','Ian Gorton - House on the River','CP_6077-2a-watercol_NH_thumb.jpg',130, 173,1,'photo_1903852.html');
												thumbnails[1944551] = new thumbnail(1944551,'130177','Jill Greenhalgh - photo','AOR PHOTOS1_600x400_thumb.jpg',130, 98,1,'photo_1944551.html');
												thumbnails[3350984] = new thumbnail(3350984,'204503','Exhibition on Chairs in Church','Exhi_2157_thumb.jpg',130, 173,1,'photo_3350984.html');
												thumbnails[3350987] = new thumbnail(3350987,'204503','Exhibition in Church November 2008','Exhi_2158_thumb.jpg',130, 173,1,'photo_3350987.html');
												thumbnails[1939990] = new thumbnail(1939990,'129249','Ken Davis - Watercolour Pure and Simple','cp-kend_boats_600x400_thumb.jpg',130, 107,1,'photo_1939990.html');
												thumbnails[1903892] = new thumbnail(1903892,'126948','Ian Gorton - Sunflowers','W_S_Living_Sunshine_thumb.jpg',130, 194,1,'photo_1903892.html');
												thumbnails[1913157] = new thumbnail(1913157,'126948','Jill Greenhalgh - Poppies','cpPAINTINGS-020_thumb.jpg',130, 173,1,'photo_1913157.html');
												thumbnails[1913148] = new thumbnail(1913148,'129249','Jill Greenhalgh - Chepstow Castle','cpPAINTINGS-004_thumb.jpg',130, 98,1,'photo_1913148.html');
												thumbnails[1903864] = new thumbnail(1903864,'129249','Ian Gorton - Lava','CP_Cannop-Lava_thumb.jpg',130, 87,1,'photo_1903864.html');
												thumbnails[1944552] = new thumbnail(1944552,'130177','Jill Greenhalgh - Photo','AOR PHOTOS3_600x400_thumb.jpg',130, 173,1,'photo_1944552.html');
												thumbnails[1994159] = new thumbnail(1994159,'129249','Kay Leverton Incense Bowl','incense-bowl-web-copy_thumb.jpg',130, 168,1,'photo_1994159.html');
												thumbnails[1944555] = new thumbnail(1944555,'130177','Jill Greenhalgh -Photo','AOR PHOTOS5_600x400_thumb.jpg',130, 173,1,'photo_1944555.html');
												thumbnails[1913154] = new thumbnail(1913154,'126948','Jill Greenhalgh - Daisies','cpPAINTINGS-015_thumb.jpg',130, 87,1,'photo_1913154.html');
												thumbnails[1903867] = new thumbnail(1903867,'129249','IG - Forest Spell','CP_forest-for-a-spell_thumb.jpg',130, 194,1,'photo_1903867.html');
												thumbnails[1926891] = new thumbnail(1926891,'129249','Val Brown - Hocker Hill ','cpHocker-Hill-Chepstow1_thumb.jpg',130, 166,1,'photo_1926891.html');
												thumbnails[1908525] = new thumbnail(1908525,'126948','Val Brown - Yachts in Harbour','cp_Yachts-in-Harbour_thumb.jpg',130, 135,1,'photo_1908525.html');
												thumbnails[1926860] = new thumbnail(1926860,'126948','Val Brown - The Boat House','cpThe-Boat-House_thumb.jpg',130, 99,1,'photo_1926860.html');
												thumbnails[1928941] = new thumbnail(1928941,'126948','Frances Meredith - Chepstow Sign','cs-P095-Cropped_thumb.jpg',130, 94,1,'photo_1928941.html');
												thumbnails[1929165] = new thumbnail(1929165,'126948','Frances Meredith - Meadow Flowers','cp-P0104-Cropped_thumb.jpg',130, 93,1,'photo_1929165.html');
												thumbnails[1955698] = new thumbnail(1955698,'126948','Ken Hugill - Flowers','CNV00027rev copy_thumb.jpg',130, 133,1,'photo_1955698.html');

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  					galleries[337134] = new gallery(337134,'5981962,5980156,5980093','May 2010 Competition Winners','gallery',[5980093,5981962,5980156],0, 0, '', 'gallery_337134.html',0,0);
				  					galleries[204503] = new gallery(204503,'3350996,3350993,3350991,3350987,3350984','November 2008 Competition/Sale','gallery',[3350991,3350993,3350996,3350984,3350987],0, 0, '', 'gallery_204503.html',0,0);
				  					galleries[127677] = new gallery(127677,'1903899','History','gallery',[1903899],0, 0, '', 'gallery_127677.html',0,0);
				  					galleries[130177] = new gallery(130177,'1955703,1944555,1944552','Event Photos','gallery',[1955703,1944551,1944552,1944555],0, 0, '', 'gallery_130177.html',0,0);
				  					galleries[126948] = new gallery(126948,'1955698,1928941,1926860,1913157,1913154,1908525,1903892','Gallery 1 - Artists Exhibiting','gallery',[1903852,1903892,1913157,1913154,1908525,1926860,1928941,1929165,1955698],0, 0, '', 'gallery_126948.html',0,0);
				  					galleries[129249] = new gallery(129249,'1994159,1939994,1939990,1928889','Gallery 2 - Artists Exhibiting','gallery',[2304219,2411896,2411991,1939994,1934365,1928889,1939990,1913148,1903864,1994159,1903867,1926891],0, 0, '', 'gallery_129249.html',0,0);
/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = new Object();
imageSets[1] = '2193451,1913192';
imageSets[2] = '1994159,1955703,1955698,1944555,1944552,1939994,1939990,1928941,1928889,1926860,1913157,1913154,1908525,1903892';
imageSets[3] = '5981962,5980156,5980093,3350996,3350993,3350991,3350987,3350984,2411991,2411896,2304219,2193451,1994159,1955703,1955698,1944555,1944552,1944551,1939994,1939990,1934365,1929165,1928941,1928889,1926891,1926860,1913192,1913157,1913154,1913148,1908525,1903899,1903896,1903892,1903867,1903864,1903852';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/artontherailings/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/artontherailings/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/artontherailings/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/artontherailings/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/artontherailings/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/artontherailings/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/artontherailings/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/artontherailings/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/artontherailings/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/artontherailings/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/artontherailings/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/artontherailings/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/artontherailings/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/artontherailings/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/artontherailings/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://admin2.clikpic.com/artontherailings/images';
		break;
	}
		switch (server_id) {
		case 33:
		val = 'http://www8.clikpic.com/artontherailings/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/artontherailings/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/artontherailings/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/artontherailings/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/artontherailings/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/artontherailings/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 = 'Art on the Railings -  Chepstow: ' + 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>Email Address </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>Artist </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;
	}
}

			

