window.thumbnails = new Object();
												thumbnails[1527291] = new thumbnail(1527291,'','Castle Douglas','Castle Douglas_thumb.jpg',130, 166,18,'							photo_1527291.html');
												thumbnails[5308505] = new thumbnail(5308505,'104787','Balmaclellan Village','DSC_0049_thumb.jpg',130, 87,18,'							photo_5308505.html');
												thumbnails[5309051] = new thumbnail(5309051,'104787','Balmaclellan.','DSC_0051_thumb.jpg',130, 87,18,'							photo_5309051.html');
												thumbnails[5244492] = new thumbnail(5244492,'295536','Threave Castle 2009','DSC_0110_thumb.jpg',130, 87,18,'							photo_5244492.html');
												thumbnails[1714105] = new thumbnail(1714105,'115134','Stag cleaning ','stag cleaning-01JPG_thumb.jpg',130, 196,18,'							photo_1714105.html');
												thumbnails[1714106] = new thumbnail(1714106,'115134','Stag','DSC_0023-01JPG_thumb.jpg',130, 81,18,'							photo_1714106.html');
												thumbnails[1714107] = new thumbnail(1714107,'104789','Winter in Scotland','frost-01JPG_thumb.jpg',130, 86,18,'							photo_1714107.html');
												thumbnails[1714109] = new thumbnail(1714109,'104789','Kilchurn Castle','Kilchurn Castle-01JPG_thumb.jpg',130, 86,18,'							photo_1714109.html');
												thumbnails[1714112] = new thumbnail(1714112,'104789','Winter','Andys stone-01JPG_thumb.jpg',130, 86,18,'							photo_1714112.html');
												thumbnails[1714116] = new thumbnail(1714116,'104789','Cold Winter','winter scotland-01JPG_thumb.jpg',130, 213,18,'							photo_1714116.html');
												thumbnails[1714118] = new thumbnail(1714118,'104789','Scotland','DSC_0086-01JPG_thumb.jpg',130, 86,18,'							photo_1714118.html');
												thumbnails[1714133] = new thumbnail(1714133,'104789','Winter\'s Evening in Scotland','DSC_0122-01JPG_thumb.jpg',130, 86,18,'							photo_1714133.html');
												thumbnails[1525550] = new thumbnail(1525550,'115134','Barn Owl','Barn Owl_thumb.jpg',130, 86,18,'							photo_1525550.html');
												thumbnails[1527219] = new thumbnail(1527219,'104593','Bikes','Bikes_thumb.jpg',130, 97,18,'							photo_1527219.html');
												thumbnails[1527227] = new thumbnail(1527227,'104593','Bruges Canal','Bruges_thumb.jpg',130, 174,18,'							photo_1527227.html');
												thumbnails[1527230] = new thumbnail(1527230,'104593','Bruges Canal (2)','Bruges (2)_thumb.jpg',130, 97,18,'							photo_1527230.html');
												thumbnails[1527286] = new thumbnail(1527286,'104787','Carrick Beach','Carrick Beach_thumb.jpg',130, 196,18,'							photo_1527286.html');
												thumbnails[1527314] = new thumbnail(1527314,'104787','Douglas Hall Nets','Douglas Hall Nets_thumb.jpg',130, 86,18,'							photo_1527314.html');
												thumbnails[1527325] = new thumbnail(1527325,'104789','Glencoe','Glencoe_thumb.jpg',130, 86,18,'							photo_1527325.html');
												thumbnails[1527349] = new thumbnail(1527349,'104787','Heston Island','Heston Island_thumb.jpg',130, 203,18,'							photo_1527349.html');
												thumbnails[1527360] = new thumbnail(1527360,'104787','Kirkcudbright Harbour','Kirkudbright Harbour_thumb.jpg',130, 86,18,'							photo_1527360.html');
												thumbnails[1527378] = new thumbnail(1527378,'104787','Loch Ken,Galloway','Loch Ken_thumb.jpg',130, 184,18,'							photo_1527378.html');
												thumbnails[1527382] = new thumbnail(1527382,'104787','Moonlite Beach','Moonlite Beach_thumb.jpg',130, 196,18,'							photo_1527382.html');
												thumbnails[1527387] = new thumbnail(1527387,'104789','Ranoch Moore','Ranoch Moore_thumb.jpg',130, 86,18,'							photo_1527387.html');
												thumbnails[1527392] = new thumbnail(1527392,'104787','Southerness Lighthouse','Southerness Lighthouse_thumb.jpg',130, 196,18,'							photo_1527392.html');
												thumbnails[1527396] = new thumbnail(1527396,'104787','Sunset','Sunset_thumb.jpg',130, 196,18,'							photo_1527396.html');
												thumbnails[1527402] = new thumbnail(1527402,'104789','Thistle','Thistle_thumb.jpg',130, 150,18,'							photo_1527402.html');
												thumbnails[1527409] = new thumbnail(1527409,'295536','Threave Castle in Snow','Threave castle_thumb.jpg',130, 196,18,'							photo_1527409.html');
												thumbnails[1527415] = new thumbnail(1527415,'295536','Threave Castle At Sunset','Threave Castle Sunset_thumb.jpg',130, 86,18,'							photo_1527415.html');
												thumbnails[1527418] = new thumbnail(1527418,'295536','Threave Castle Snow','Threave In Snow_thumb.jpg',130, 86,18,'							photo_1527418.html');
												thumbnails[1532913] = new thumbnail(1532913,'104787','cairn Holy','carin holyJPG_thumb.jpg',130, 86,18,'							photo_1532913.html');
												thumbnails[1532916] = new thumbnail(1532916,'104787','Carrick Sunset','Carrick SunsetJPG_thumb.jpg',130, 196,18,'							photo_1532916.html');
												thumbnails[1532936] = new thumbnail(1532936,'104787','Gatehouse Of Fleet','Gatehouse Of FleetJPG_thumb.jpg',130, 86,18,'							photo_1532936.html');
												thumbnails[1532937] = new thumbnail(1532937,'104789','Glencoe','GlencoeJPG_thumb.jpg',130, 86,18,'							photo_1532937.html');
												thumbnails[1532938] = new thumbnail(1532938,'104787','overlooking Kirkcudbright','kirkcudbrightJPG_thumb.jpg',130, 86,18,'							photo_1532938.html');
												thumbnails[1532941] = new thumbnail(1532941,'104787','Orchardton Tower','DSC_0067JPG_thumb.jpg',130, 86,18,'							photo_1532941.html');
												thumbnails[1532961] = new thumbnail(1532961,'104787','Beach Scene','photographer on beachJPG_thumb.jpg',130, 86,18,'							photo_1532961.html');
												thumbnails[1532964] = new thumbnail(1532964,'104787','Sandyhills Beach','SandyhillsJPG_thumb.jpg',130, 86,18,'							photo_1532964.html');
												thumbnails[1532967] = new thumbnail(1532967,'115134','Stag in the mist','stagg in the mistJPG_thumb.jpg',130, 86,18,'							photo_1532967.html');
												thumbnails[1532973] = new thumbnail(1532973,'104787','Sunset Beach','sunset on the beachJPG_thumb.jpg',130, 196,18,'							photo_1532973.html');
												thumbnails[1532980] = new thumbnail(1532980,'295536','Threave Castle','threave castleJPG_thumb.jpg',130, 86,18,'							photo_1532980.html');
												thumbnails[1714092] = new thumbnail(1714092,'295536','Threave Castle ','threave castle sunset_1_thumb.jpg',130, 196,18,'							photo_1714092.html');
												thumbnails[1714126] = new thumbnail(1714126,'115134','Stag at sunset','DSC_0055-01JPG_thumb.jpg',130, 196,18,'							photo_1714126.html');
												thumbnails[1714135] = new thumbnail(1714135,'115134','Stag\'s Head','DSC_0048-02JPG_thumb.jpg',130, 196,18,'							photo_1714135.html');
												thumbnails[1714141] = new thumbnail(1714141,'104789','Winters Morning','DSC_0089-01JPG_thumb.jpg',130, 206,18,'							photo_1714141.html');
												thumbnails[3443480] = new thumbnail(3443480,'104789','Glen Coe','Ben_thumb.jpg',130, 39,18,'							photo_3443480.html');
												thumbnails[3443497] = new thumbnail(3443497,'115134','Robin in the snow','DSC_0080_thumb.jpg',130, 113,18,'							photo_3443497.html');
												thumbnails[3443507] = new thumbnail(3443507,'104789','Luss small town next to Loch Lomond','DSC_0100_thumb.jpg',130, 196,18,'							photo_3443507.html');
												thumbnails[3443513] = new thumbnail(3443513,'104789',' Glen Coe','S Tiff 3_thumb.jpg',130, 29,18,'							photo_3443513.html');
												thumbnails[3444050] = new thumbnail(3444050,'104789','Snow near Glen Coe','DSC_0102-21_thumb.jpg',130, 87,18,'							photo_3444050.html');
												thumbnails[3788092] = new thumbnail(3788092,'295536','Threave House','Threave_House_thumb.jpg',130, 95,18,'							photo_3788092.html');
												thumbnails[3788118] = new thumbnail(3788118,'295536','Threave House,Castle Douglas','Threave_House1_thumb.jpg',130, 196,18,'							photo_3788118.html');
												thumbnails[3826273] = new thumbnail(3826273,'104789','','DSC_0020_thumb.jpg',130, 86,18,'							photo_3826273.html');
												thumbnails[3826279] = new thumbnail(3826279,'104787','Sea Fishing in Galloway','man_fishing_thumb.jpg',130, 198,18,'							photo_3826279.html');
												thumbnails[3826282] = new thumbnail(3826282,'104789','Winter on Rannoch Moor.','Scotland_thumb.jpg',130, 86,18,'							photo_3826282.html');
												thumbnails[3826497] = new thumbnail(3826497,'104789','Luss','DSC_0022_thumb.jpg',130, 196,18,'							photo_3826497.html');
												thumbnails[3826506] = new thumbnail(3826506,'104789','Rannoch Moor','Copy_of_DSC_0091-2_thumb.jpg',130, 196,18,'							photo_3826506.html');
												thumbnails[3826530] = new thumbnail(3826530,'295536','Threave Cottage at Threave Gardens','DSC_0128_thumb.jpg',130, 86,18,'							photo_3826530.html');
												thumbnails[3826575] = new thumbnail(3826575,'104593','City of Bath early morning.','DSC_0023_thumb.jpg',130, 86,18,'							photo_3826575.html');
												thumbnails[3826620] = new thumbnail(3826620,'295536','Threave Castle','DSC_0078-01_thumb.jpg',130, 196,18,'							photo_3826620.html');
												thumbnails[3826647] = new thumbnail(3826647,'104593','Frost','Frost_thumb.jpg',130, 86,18,'							photo_3826647.html');
												thumbnails[5244499] = new thumbnail(5244499,'104787','Morning Mist','DSC_0034-Edit-2_thumb.jpg',130, 195,18,'							photo_5244499.html');
												thumbnails[5244503] = new thumbnail(5244503,'295536','Threave Castle','DSC_0109_thumb.jpg',130, 195,18,'							photo_5244503.html');
												thumbnails[5309054] = new thumbnail(5309054,'104593','Tree','DSC_0012_thumb.jpg',130, 179,18,'							photo_5309054.html');
												thumbnails[5311322] = new thumbnail(5311322,'295536','Threave Castle','DSC_0067_thumb.jpg',130, 195,18,'							photo_5311322.html');
												thumbnails[5313353] = new thumbnail(5313353,'115134','Red Squirrel','DSC_0033_thumb.jpg',130, 195,18,'							photo_5313353.html');
												thumbnails[5313356] = new thumbnail(5313356,'115134','Red Squirrel','DSC_0020-2_thumb.jpg',130, 87,18,'							photo_5313356.html');
												thumbnails[5313989] = new thumbnail(5313989,'295536','Threave House. Spring','DSC_0123_thumb.jpg',130, 87,18,'							photo_5313989.html');
												thumbnails[5345291] = new thumbnail(5345291,'295536','Threave Castle 2010 Winter','Threave_Castle_thumb.jpg',130, 87,18,'							photo_5345291.html');
												thumbnails[5345302] = new thumbnail(5345302,'295536','Threave Castle.','DSC_0047_thumb.jpg',130, 87,18,'							photo_5345302.html');
												thumbnails[5345306] = new thumbnail(5345306,'295536','Threave Castle.','DSC_0016_thumb.jpg',130, 195,18,'							photo_5345306.html');
												thumbnails[5603444] = new thumbnail(5603444,'115134','Stag at sunset.','DSC_0017-01_thumb.jpg',130, 201,18,'							photo_5603444.html');
												thumbnails[6316355] = new thumbnail(6316355,'295536','Threave Castle Summer 2010','099_010_thumb.jpg',130, 86,18,'							photo_6316355.html');
												thumbnails[7025119] = new thumbnail(7025119,'115134','B/W Stag.','DSC_0093_thumb.jpg',130, 107,18,'							photo_7025119.html');
												thumbnails[6908898] = new thumbnail(6908898,'115134','Stag in Scotland','DSC_0022_BAC1902D-1D09-001F-99443B0150D7D854_thumb.jpg',130, 86,18,'							photo_6908898.html');
												thumbnails[1713916] = new thumbnail(1713916,'115134','Stag','glen coe stag-01JPG_thumb.jpg',130, 86,18,'							photo_1713916.html');
												thumbnails[1713924] = new thumbnail(1713924,'104789','Loch Lomond','16 bit lomond-01JPG_thumb.jpg',130, 86,18,'							photo_1713924.html');
												thumbnails[1714049] = new thumbnail(1714049,'115134','The Stag','stag At Glencoe_thumb.jpg',130, 196,18,'							photo_1714049.html');
												thumbnails[1714009] = new thumbnail(1714009,'104789','Autumn trees on loch lomond','autum tree on lomond_thumb.jpg',130, 196,18,'							photo_1714009.html');
												thumbnails[1714012] = new thumbnail(1714012,'104789','Loch Lomond','bank of lomond-01JPG_thumb.jpg',130, 86,18,'							photo_1714012.html');
												thumbnails[1714018] = new thumbnail(1714018,'104789','Boat jetty on lomond sunset','jetty on lomond-01JPG_thumb.jpg',130, 86,18,'							photo_1714018.html');
												thumbnails[1714031] = new thumbnail(1714031,'104789','Loch Lomond','loch lomond_thumb.jpg',130, 196,18,'							photo_1714031.html');
												thumbnails[1714035] = new thumbnail(1714035,'104789','Sunset over Lomond','loch lomond-01JPG_thumb.jpg',130, 86,18,'							photo_1714035.html');
												thumbnails[1714036] = new thumbnail(1714036,'104789','Lomond','novmber lomond_thumb.jpg',130, 86,18,'							photo_1714036.html');
												thumbnails[1714043] = new thumbnail(1714043,'104593','','smoking fisherman_thumb.jpg',130, 196,18,'							photo_1714043.html');
												thumbnails[1714054] = new thumbnail(1714054,'115134','Posing Stag','stag 1JPG_thumb.jpg',130, 86,18,'							photo_1714054.html');
												thumbnails[1714062] = new thumbnail(1714062,'115134','Wagtail','pyed wagtailJPG_thumb.jpg',130, 86,18,'							photo_1714062.html');
												thumbnails[1714082] = new thumbnail(1714082,'104789','Hills over Glencoe','hills-01JPG_thumb.jpg',130, 86,18,'							photo_1714082.html');

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  					galleries[104787] = new gallery(104787,'5308505','Dumfries & Galloway','gallery',[5308505,5309051,1527286,1527314,1527349,1527360,1527378,1527382,1527392,1527396,1532913,1532916,1532936,1532938,1532941,1532961,1532964,1532973,3826279,5244499],0, 0, '', '																																																																																																							gallery_104787.html',0,0);
				  					galleries[104789] = new gallery(104789,'3826506,3826497,3826282,3826273,3444050,3443513,3443507,3443480,1714141,1714133','Scotland','gallery',[1714107,1714109,1714112,1714116,1714118,1714133,1527325,1527387,1527402,1532937,1714141,3443480,3443507,3443513,3444050,3826273,3826282,3826497,3826506,1713924,1714009,1714012,1714018,1714031,1714035,1714036,1714082],0, 0, '', '																																																																																																							gallery_104789.html',0,0);
				  					galleries[295536] = new gallery(295536,'6316355,5345306,5345302,5345291,5313989,5311322,5244503,5244492,3826620,3826530','Threave Castle','gallery',[5244492,1527409,1527415,1527418,1532980,1714092,3788092,3788118,3826530,3826620,5244503,5311322,5313989,5345291,5345302,5345306,6316355],0, 0, '', '																																																																																																							gallery_295536.html',0,0);
				  					galleries[115134] = new gallery(115134,'7025119,6908898,5603444,5313356,5313353,3443497,1714135,1714126,1714106,1714105','Wildlife in Scotland','gallery',[1714105,1714106,1525550,1532967,1714126,1714135,3443497,5313353,5313356,5603444,7025119,6908898,1713916,1714049,1714054,1714062],0, 0, '', '																																																																																																							gallery_115134.html',0,0);
				  					galleries[104593] = new gallery(104593,'5309054,3826647,3826575,1714043,1527230,1527227,1527219','Miscellaneous','gallery',[1527219,1527227,1527230,3826575,3826647,5309054,1714043],0, 0, '', '																																																																																																							gallery_104593.html',0,0);
/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = new Object();
imageSets[1] = '7025119,6316355,5345302,5311322,5309051,5308505,5244503,5244499,5244492,3826497,3443507,1714116,1714107,1714106,1713916,1532941';
imageSets[2] = '5308505,1527291';
imageSets[3] = '5244492,3826620,3788118,3788092,1532980';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/ramage/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/ramage/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/ramage/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/ramage/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/ramage/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/ramage/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/ramage/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/ramage/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/ramage/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/ramage/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/ramage/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/ramage/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/ramage/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/ramage/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/ramage/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://admin2.clikpic.com/ramage/images';
		break;
	}
		switch (server_id) {
		case 33:
		val = 'http://www8.clikpic.com/ramage/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/ramage/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/ramage/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/ramage/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/ramage/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/ramage/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 = 'Ramage Photo Scotland: ' + photoCaption;
			    }
        if (op.$detail.length > 0) {
      temp = op.nextPhoto.fnGetImageDetails();
	    op.$detail.fadeGalleryDetails(temp, op.speed, function(){
	    var options = {photoinfominwidth:200};	    		options.photoinfoadjacent = true;			      	      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> 				&pound;' + (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 + '<form id="paymentForm" style="margin:0px;border:0px;" name="paymentForm" target="_blank" action="https://www.paypal.com/cgi-bin/webscr" method="post">';
	temp = temp + '<input type="hidden" name="item_name" value="'+item_name+'">';
								ref = '';
				if(this.photo_ref != ''){
					ref = this.photo_ref+' - '+this.caption;
				}
				else{
					ref = this.id+' - '+this.caption;
				}
				price = amount;					temp = temp + '<input type="hidden" name="cmd" value="_cart">';
	temp = temp + '<input type="hidden" name="business" value="eeramage@btinternet.com">';
	temp = temp + '<input type="hidden" name="currency_code" value="GBP">';
	temp = temp + '<input type="hidden" name="add" value="1">';
					temp = temp + '<input type="hidden" name="amount" value="'+amount+'">';
	temp = temp + '<input type="hidden" name="item_number" value="'+ref+'">';
					temp = temp + '<input type=\"Submit\" value=\"Add to cart\" id=\"paymentAddButton\" class=\"button\" onmouseover=\"this.className=\'buttonHi\';\" onmouseout=\"this.className=\'button\';\">';
									temp = temp + '</form>';
								temp = temp + '<form id="paymentCartForm" style="margin:0px;" name="paymentCartForm" target="_blank" action="https://www.paypal.com/cgi-bin/webscr" method="post">';
	temp = temp + '<input type="hidden" name="cmd" value="_cart">';
	temp = temp + '<input type="hidden" name="business" value="eeramage@btinternet.com">';
	temp = temp + '<input type="hidden" name="display" value="1">';
	temp = temp + '<input type=\"Submit\" value=\"View cart\" id=\"paymentViewButton\" class=\"button\" onmouseover=\"this.className=\'buttonHi\';\" onmouseout=\"this.className=\'button\';\">';
	temp = temp + '</form>';
							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;
	}
}

		

