window.thumbnails = new Object();
												thumbnails[7490627] = new thumbnail(7490627,'71164','Rock Pool','0253web_thumb.jpg',130, 182,18,'photo_7490627.html');
												thumbnails[7490773] = new thumbnail(7490773,'406165','Tin Mine Ruin','0051bweb1_thumb.jpg',130, 182,18,'photo_7490773.html');
												thumbnails[7490774] = new thumbnail(7490774,'406165','Tin Mine Ruin','0058bweb1_thumb.jpg',130, 163,18,'photo_7490774.html');
												thumbnails[7490780] = new thumbnail(7490780,'406165','Tin Mine ruin','0067web1_thumb.jpg',130, 182,18,'photo_7490780.html');
												thumbnails[7490789] = new thumbnail(7490789,'406164','Moss','0302web1_thumb.jpg',130, 182,18,'photo_7490789.html');
												thumbnails[7490868] = new thumbnail(7490868,'406161','Michelangelo\'s David','0421web_thumb.jpg',130, 163,18,'photo_7490868.html');
												thumbnails[7490873] = new thumbnail(7490873,'406161','Michelangelo\'s David','0416web_thumb.jpg',130, 182,18,'photo_7490873.html');
												thumbnails[7490877] = new thumbnail(7490877,'406161','Statue','0413web_thumb.jpg',130, 182,18,'photo_7490877.html');
												thumbnails[7490892] = new thumbnail(7490892,'406161','Medieval bridge over the Arno River.','0394web_thumb.jpg',130, 163,18,'photo_7490892.html');
												thumbnails[7490905] = new thumbnail(7490905,'406161','Chiesa di San Frediano in Castello','0342web_thumb.jpg',130, 163,18,'photo_7490905.html');
												thumbnails[7492029] = new thumbnail(7492029,'406165','Church Ruin','0079sweb_thumb.jpg',130, 182,18,'photo_7492029.html');
												thumbnails[7492102] = new thumbnail(7492102,'406165','Church Ruin','00031bweb_thumb.jpg',130, 93,18,'photo_7492102.html');
												thumbnails[7492114] = new thumbnail(7492114,'71164','Kynance Cove','0371webb_thumb.jpg',130, 163,18,'photo_7492114.html');
												thumbnails[7492125] = new thumbnail(7492125,'406165','Church Ruin','0087bweb_thumb.jpg',130, 182,18,'photo_7492125.html');
												thumbnails[7492138] = new thumbnail(7492138,'406164','Stanton Moor','0066web_thumb.jpg',130, 182,18,'photo_7492138.html');
												thumbnails[7492168] = new thumbnail(7492168,'406164','Stanton Moor','0038web_thumb.jpg',130, 182,18,'photo_7492168.html');
												thumbnails[7492254] = new thumbnail(7492254,'406165','Church Ruin','0087web_thumb.jpg',130, 182,18,'photo_7492254.html');
												thumbnails[7492270] = new thumbnail(7492270,'406164','Stanton Moor','0012web_thumb.jpg',130, 182,18,'photo_7492270.html');
												thumbnails[7492404] = new thumbnail(7492404,'406164','Stanton Moor','0078_thumb.jpg',130, 93,18,'photo_7492404.html');
												thumbnails[7492428] = new thumbnail(7492428,'88883','','0431web_thumb.jpg',130, 163,18,'photo_7492428.html');
												thumbnails[7492432] = new thumbnail(7492432,'88883','','0343web_thumb.jpg',130, 163,18,'photo_7492432.html');
												thumbnails[7492437] = new thumbnail(7492437,'88883','','0313web_thumb.jpg',130, 104,18,'photo_7492437.html');
												thumbnails[7492438] = new thumbnail(7492438,'88883','','0346web_thumb.jpg',130, 163,18,'photo_7492438.html');
												thumbnails[7492484] = new thumbnail(7492484,'88883','','Mollyweb_thumb.jpg',130, 163,18,'photo_7492484.html');
												thumbnails[7492486] = new thumbnail(7492486,'88883','','Molly1web_thumb.jpg',130, 130,18,'photo_7492486.html');
												thumbnails[7492488] = new thumbnail(7492488,'406164','Stanton Moor','0020web_thumb.jpg',130, 182,18,'photo_7492488.html');
												thumbnails[7492489] = new thumbnail(7492489,'88883','','0073web_thumb.jpg',130, 182,18,'photo_7492489.html');
												thumbnails[7492491] = new thumbnail(7492491,'88883','','0074web_thumb.jpg',130, 182,18,'photo_7492491.html');
												thumbnails[7492493] = new thumbnail(7492493,'88883','','0037web_thumb.jpg',130, 182,18,'photo_7492493.html');
												thumbnails[7492497] = new thumbnail(7492497,'88883','','0127web_thumb.jpg',130, 182,18,'photo_7492497.html');
												thumbnails[7492499] = new thumbnail(7492499,'88883','','032web_thumb.jpg',130, 87,18,'photo_7492499.html');
												thumbnails[7498726] = new thumbnail(7498726,'406165','Ruins of St John\'s Church','060web_thumb.jpg',130, 196,18,'photo_7498726.html');
												thumbnails[7498727] = new thumbnail(7498727,'406165','Ruin of St John\'s Church','062web_thumb.jpg',130, 196,18,'photo_7498727.html');
												thumbnails[7498729] = new thumbnail(7498729,'406165','Ruin of St John\'s Church','063web_thumb.jpg',130, 196,18,'photo_7498729.html');
												thumbnails[7498738] = new thumbnail(7498738,'406164','Purple Crocus','CROCUS2web_thumb.jpg',130, 184,18,'photo_7498738.html');
												thumbnails[7498739] = new thumbnail(7498739,'406164','Crocus Yellow','CROCUS1web_thumb.jpg',130, 92,18,'photo_7498739.html');
												thumbnails[7498811] = new thumbnail(7498811,'406166','Prarie Dog','125web_thumb.jpg',130, 196,18,'photo_7498811.html');
												thumbnails[7498835] = new thumbnail(7498835,'406166','Meerkat','153aweb_thumb.jpg',130, 182,18,'photo_7498835.html');
												thumbnails[7498855] = new thumbnail(7498855,'406166','Meerkat','159aweb_thumb.jpg',130, 182,18,'photo_7498855.html');
												thumbnails[7498865] = new thumbnail(7498865,'406166','Lion tailed macaque','173aweb_thumb.jpg',130, 182,18,'photo_7498865.html');
												thumbnails[7498866] = new thumbnail(7498866,'406166','Bear','141web_thumb.jpg',130, 87,18,'photo_7498866.html');
												thumbnails[7498867] = new thumbnail(7498867,'406166','Bear','132web_thumb.jpg',130, 87,18,'photo_7498867.html');
												thumbnails[7498868] = new thumbnail(7498868,'406166','Jaguar','Cat_2web_thumb.jpg',130, 104,18,'photo_7498868.html');
												thumbnails[7498870] = new thumbnail(7498870,'406166','Jaguar','Cat_3web_thumb.jpg',130, 93,18,'photo_7498870.html');
												thumbnails[7498884] = new thumbnail(7498884,'406166','Common Marmosets','056aweb_thumb.jpg',130, 93,18,'photo_7498884.html');
												thumbnails[7498905] = new thumbnail(7498905,'88883','','0090bweb_thumb.jpg',130, 163,18,'photo_7498905.html');
												thumbnails[7498906] = new thumbnail(7498906,'88883','','0014web_thumb.jpg',130, 163,18,'photo_7498906.html');
												thumbnails[7498908] = new thumbnail(7498908,'88883','','0082web_thumb.jpg',130, 87,18,'photo_7498908.html');
												thumbnails[7498923] = new thumbnail(7498923,'88883','','0284web_thumb.jpg',130, 163,18,'photo_7498923.html');
												thumbnails[7498925] = new thumbnail(7498925,'88883','','0163web_thumb.jpg',130, 182,18,'photo_7498925.html');
												thumbnails[7498932] = new thumbnail(7498932,'88883','','Buzz_1_thumb.jpg',130, 93,18,'photo_7498932.html');
												thumbnails[7490499] = new thumbnail(7490499,'71164','Light House','0047web_thumb.jpg',130, 182,18,'photo_7490499.html');
												thumbnails[7490507] = new thumbnail(7490507,'71164','Sea View','0049web_thumb.jpg',130, 182,18,'photo_7490507.html');
												thumbnails[7490511] = new thumbnail(7490511,'71164','Light House','0063web_thumb.jpg',130, 182,18,'photo_7490511.html');
												thumbnails[7490857] = new thumbnail(7490857,'406161','Basilica di Santa Maria del Fiore','0455web1_thumb.jpg',130, 182,18,'photo_7490857.html');
												thumbnails[7490859] = new thumbnail(7490859,'406161','Basilica di Santa Maria del Fiore','0439web_thumb.jpg',130, 104,18,'photo_7490859.html');
												thumbnails[7492099] = new thumbnail(7492099,'406162','Palais de Chaillot','fromeiffeltowerweb_thumb.jpg',130, 92,18,'photo_7492099.html');
												thumbnails[7498764] = new thumbnail(7498764,'406161','Basilica di Santa Maria del Fiore','0450web_thumb.jpg',130, 163,18,'photo_7498764.html');
												thumbnails[7490523] = new thumbnail(7490523,'71164','From St Michael\'s Mount Causeway','0086web_thumb.jpg',130, 93,18,'photo_7490523.html');
												thumbnails[7490541] = new thumbnail(7490541,'71164','St Michael\'s Mount','0114web_thumb.jpg',130, 182,18,'photo_7490541.html');
												thumbnails[7491024] = new thumbnail(7491024,'406161','Fountain','0112bweb_thumb.jpg',130, 182,18,'photo_7491024.html');
												thumbnails[7492160] = new thumbnail(7492160,'406162','Eiffel Tower','eiffeltowerweb_thumb.jpg',130, 196,18,'photo_7492160.html');
												thumbnails[7498731] = new thumbnail(7498731,'71164','Penzance','0069web_thumb.jpg',130, 182,18,'photo_7498731.html');
												thumbnails[7498732] = new thumbnail(7498732,'71164','Marazion','0088web_thumb.jpg',130, 182,18,'photo_7498732.html');
												thumbnails[7498735] = new thumbnail(7498735,'71164','St Michael\'s Mount','0138web_thumb.jpg',130, 182,18,'photo_7498735.html');
												thumbnails[7490564] = new thumbnail(7490564,'71164','Lifeboat launch','0171web_thumb.jpg',130, 182,18,'photo_7490564.html');
												thumbnails[7490610] = new thumbnail(7490610,'71164','The Lizard','0197web_thumb.jpg',130, 93,18,'photo_7490610.html');
												thumbnails[7490758] = new thumbnail(7490758,'71164','Blue boat','0287webb_thumb.jpg',130, 104,18,'photo_7490758.html');
												thumbnails[7490927] = new thumbnail(7490927,'406161','Colosseum ','0245aweb_thumb.jpg',130, 195,18,'photo_7490927.html');
												thumbnails[7492249] = new thumbnail(7492249,'406162','French barn window','thebarn1web_thumb.jpg',130, 92,18,'photo_7492249.html');
												thumbnails[7498756] = new thumbnail(7498756,'406161','Colosseum','0246web_thumb.jpg',130, 93,18,'photo_7498756.html');
												thumbnails[7498760] = new thumbnail(7498760,'406161','Colosseum','0252web_thumb.jpg',130, 182,18,'photo_7498760.html');
												thumbnails[7491039] = new thumbnail(7491039,'406161','Statue outside the Vatican','0060web_thumb.jpg',130, 93,18,'photo_7491039.html');
												thumbnails[7492121] = new thumbnail(7492121,'71164','Portland Bill Lighthouse','portlandweb_thumb.jpg',130, 182,18,'photo_7492121.html');
												thumbnails[7492222] = new thumbnail(7492222,'406162','French barn','thebarnweb_thumb.jpg',130, 184,18,'photo_7492222.html');
												thumbnails[7498752] = new thumbnail(7498752,'406161','Neptune Statue at the Trevi Fountain','0152bweb_thumb.jpg',130, 182,18,'photo_7498752.html');
												thumbnails[7498753] = new thumbnail(7498753,'406161','Statue at the Trevi Fountain','0132bweb_thumb.jpg',130, 182,18,'photo_7498753.html');
												thumbnails[7498802] = new thumbnail(7498802,'406161','Tevi Fountain','0113_thumb.jpg',130, 182,18,'photo_7498802.html');
												thumbnails[7498803] = new thumbnail(7498803,'406161','Trevi Fountain','0119_thumb.jpg',130, 182,18,'photo_7498803.html');
												thumbnails[7498805] = new thumbnail(7498805,'406161','Trevi Fountain','0157web_thumb.jpg',130, 182,18,'photo_7498805.html');
												thumbnails[7492210] = new thumbnail(7492210,'406162','View of Saumour','saumureweb_thumb.jpg',130, 92,18,'photo_7492210.html');
												thumbnails[7498736] = new thumbnail(7498736,'71164','Beach Breaker','0340web_thumb.jpg',130, 196,18,'photo_7498736.html');
												thumbnails[7498755] = new thumbnail(7498755,'406161','Statues, Piazza del Popolo','0182bweb_thumb.jpg',130, 93,18,'photo_7498755.html');
												thumbnails[7492191] = new thumbnail(7492191,'406162','French House','angersweb_thumb.jpg',130, 184,18,'photo_7492191.html');
												thumbnails[7492071] = new thumbnail(7492071,'406162','Arc de Triomphe','arcdetriompheweb_thumb.jpg',130, 93,18,'photo_7492071.html');
												thumbnails[7490824] = new thumbnail(7490824,'406161','Pisa Tower','0047web1_thumb.jpg',130, 91,18,'photo_7490824.html');
												thumbnails[7490832] = new thumbnail(7490832,'406161','Campo dei Miracoli','0049web1_thumb.jpg',130, 91,18,'photo_7490832.html');
												thumbnails[7490934] = new thumbnail(7490934,'406161','Pisa Tower','0062web_thumb.jpg',130, 104,18,'photo_7490934.html');
												thumbnails[7492076] = new thumbnail(7492076,'406162','Arc de Triomphe','arcdetriompheweb3_thumb.jpg',130, 182,18,'photo_7492076.html');
												thumbnails[7492001] = new thumbnail(7492001,'406162','Notre Dame','notredameweb_thumb.jpg',130, 182,18,'photo_7492001.html');
												thumbnails[7492025] = new thumbnail(7492025,'406162','Louvre Pyramid','louvrepyramidweb_thumb.jpg',130, 182,18,'photo_7492025.html');
												thumbnails[7492026] = new thumbnail(7492026,'406162','Louvre Pyramid','louvrepyramidweb1_thumb.jpg',130, 182,18,'photo_7492026.html');

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  					galleries[406166] = new gallery(406166,'7498884,7498870,7498868,7498867,7498866,7498865,7498855,7498835,7498811','Animals','gallery',[7498811,7498835,7498855,7498865,7498866,7498867,7498868,7498870,7498884],0, 1, '154502', 'gallery_406166.html',0,0);
				  					galleries[406162] = new gallery(406162,'7492249,7492222,7492210,7492191,7492160,7492099,7492076,7492071,7492026,7492025','France & Paris','gallery',[7492099,7492160,7492249,7492222,7492210,7492191,7492071,7492076,7492001,7492025,7492026],0, 1, '264843', 'gallery_406162.html',0,0);
				  					galleries[406161] = new gallery(406161,'7498805,7498803,7498802,7498764,7498760,7498756,7498755,7498753,7498752,7491039','Italy','gallery',[7490868,7490873,7490877,7490892,7490905,7490857,7490859,7498764,7491024,7490927,7498756,7498760,7491039,7498752,7498753,7498802,7498803,7498805,7498755,7490824,7490832,7490934],0, 1, '264843', 'gallery_406161.html',0,0);
				  					galleries[406164] = new gallery(406164,'7498739,7498738,7492488,7492404,7492270,7492168,7492138,7490789','Nature','gallery',[7490789,7492138,7492168,7492270,7492404,7492488,7498738,7498739],0, 1, '71343', 'gallery_406164.html',0,0);
				  					galleries[406167] = new gallery(406167,'','Portraits','gallery',[],0, 1, '154502', 'gallery_406167.html',0,0);
				  					galleries[406165] = new gallery(406165,'7498729,7498727,7498726,7492254,7492125,7492102,7492029,7490780,7490774,7490773','Time','gallery',[7490773,7490774,7490780,7492029,7492102,7492125,7492254,7498726,7498727,7498729],0, 1, '71343', 'gallery_406165.html',0,0);
				  					galleries[264843] = new gallery(264843,'7498805,7498803,7498802,7498764,7498760,7498756,7498755,7498753,7498752,7492249','Travel','gallery',[],0, 1, '', 'gallery_264843.html',0,0);
				  					galleries[71164] = new gallery(71164,'7498736,7498735,7498732,7498731,7492121,7492114,7490758,7490627,7490610,7490564','Coastal','gallery',[7490627,7492114,7490499,7490507,7490511,7490523,7490541,7498731,7498732,7498735,7490564,7490610,7490758,7492121,7498736],0, 1, '', 'gallery_71164.html',0,0);
				  					galleries[71343] = new gallery(71343,'7498739,7498738,7498729,7498727,7498726,7492488,7492404,7492270,7492254,7492168','Nature and Time','gallery',[],0, 1, '', 'gallery_71343.html',0,0);
				  					galleries[154502] = new gallery(154502,'7498884,7498870,7498868,7498867,7498866,7498865,7498855,7498835,7498811','Animals & Portraits','gallery',[],0, 1, '', 'gallery_154502.html',0,0);
				  					galleries[88883] = new gallery(88883,'7498932,7498925,7498923,7498908,7498906,7498905,7492499,7492497,7492493,7492491','Commissioned work','gallery',[7492428,7492432,7492437,7492438,7492484,7492486,7492489,7492491,7492493,7492497,7492499,7498905,7498906,7498908,7498923,7498925,7498932],0, 1, '', 'gallery_88883.html',0,0);
/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = new Object();
imageSets[1] = '7498932,7498925,7498923,7498908,7498906,7498905,7498884,7498870,7498868,7498867,7498866,7498865,7498855,7498835,7498811,7498805,7498803,7498802,7498764,7498760,7498756,7498755,7498753,7498752,7498739,7498738,7498736,7498735,7498732,7498731,7498729,7498727,7498726,7492499,7492497,7492493,7492491,7492489,7492488,7492486,7492484,7492438,7492437,7492432,7492428,7492404,7492270,7492254,7492249,7492222';
imageSets[3] = '7498932,7498925,7498923,7498908,7498906,7498905,7498884,7498870,7498868,7498867,7498866,7498865,7498855,7498835,7498811,7498805,7498803,7498802,7498764,7498760,7498756,7498755,7498753,7498752,7498739,7498738,7498736,7498735,7498732,7498731,7498729,7498727,7498726,7492499,7492497,7492493,7492491,7492489,7492488,7492486,7492484,7492438,7492437,7492432,7492428,7492404,7492270,7492254,7492249,7492222';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/abbyalden/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/abbyalden/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/abbyalden/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/abbyalden/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/abbyalden/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/abbyalden/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/abbyalden/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/abbyalden/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/abbyalden/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/abbyalden/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/abbyalden/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/abbyalden/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/abbyalden/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/abbyalden/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/abbyalden/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://admin2.clikpic.com/abbyalden/images';
		break;
	}
		switch (server_id) {
		case 33:
		val = 'http://www8.clikpic.com/abbyalden/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/abbyalden/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/abbyalden/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/abbyalden/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/abbyalden/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/abbyalden/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 = 'amaphotography: ' + 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>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;
	}
}

			

