window.thumbnails = new Object();
												thumbnails[1839557] = new thumbnail(1839557,'','Still life with fruit.','still_life_thumb.jpg',130, 68,15,'#');
												thumbnails[1840012] = new thumbnail(1840012,'','Kelvinhall.','kelvinhall_thumb.jpg',130, 99,15,'#');
												thumbnails[3260841] = new thumbnail(3260841,'','The Glasgow Arc','11_squinty-br-4501_thumb.jpg',130, 131,15,'#');
												thumbnails[1847971] = new thumbnail(1847971,'124031','','01white_orchids_thumb.jpg',130, 129,15,'photo_1847971.html');
												thumbnails[1847973] = new thumbnail(1847973,'124031','','02red_tulip_thumb.jpg',130, 184,15,'photo_1847973.html');
												thumbnails[1847975] = new thumbnail(1847975,'124031','','03orch_in_fl_thumb.jpg',130, 117,15,'photo_1847975.html');
												thumbnails[1847978] = new thumbnail(1847978,'124031','','06three_tulips_thumb.jpg',130, 110,15,'photo_1847978.html');
												thumbnails[1847985] = new thumbnail(1847985,'124031','','05orchid_vase1_thumb.jpg',130, 157,15,'photo_1847985.html');
												thumbnails[1847986] = new thumbnail(1847986,'124031','','04Magnolia1_thumb.jpg',130, 104,15,'photo_1847986.html');
												thumbnails[5262444] = new thumbnail(5262444,'296256','','01-Old_Kilpatrick_thumb.jpg',130, 73,15,'photo_5262444.html');
												thumbnails[5262459] = new thumbnail(5262459,'296256','','02-Old-K-to-East_thumb.jpg',130, 68,15,'photo_5262459.html');
												thumbnails[5262462] = new thumbnail(5262462,'296256','','03-Goldenhill-park-Duntoche_thumb.jpg',130, 68,15,'photo_5262462.html');
												thumbnails[5262466] = new thumbnail(5262466,'296256','','04-Castlehill_thumb.jpg',130, 72,15,'photo_5262466.html');
												thumbnails[5262477] = new thumbnail(5262477,'296256','','05-Roman-Field-Bearsden_thumb.jpg',130, 87,15,'photo_5262477.html');
												thumbnails[5262482] = new thumbnail(5262482,'296256','','07-Bearsden-Roman-Bathhouse_thumb.jpg',130, 87,15,'photo_5262482.html');
												thumbnails[5262483] = new thumbnail(5262483,'296256','','08-Bearsden-Roman-Bathhouse_thumb.jpg',130, 87,15,'photo_5262483.html');
												thumbnails[5262486] = new thumbnail(5262486,'296256','','09-New-Kilpatrick-Cemetery_thumb.jpg',130, 87,15,'photo_5262486.html');
												thumbnails[5262487] = new thumbnail(5262487,'296256','','10-New-K-_thumb.jpg',130, 84,15,'photo_5262487.html');
												thumbnails[5262492] = new thumbnail(5262492,'296256','','11-New-K_thumb.jpg',130, 87,15,'photo_5262492.html');
												thumbnails[5262493] = new thumbnail(5262493,'296256','','12-New-K_thumb.jpg',130, 83,15,'photo_5262493.html');
												thumbnails[5262495] = new thumbnail(5262495,'296256','','13-area-of-Cadder-fort_thumb.jpg',130, 64,15,'photo_5262495.html');
												thumbnails[5262497] = new thumbnail(5262497,'296256','','14-Cadder-1_thumb.jpg',130, 195,15,'photo_5262497.html');
												thumbnails[5262498] = new thumbnail(5262498,'296256','','15-East-from-Peel-Park-Kir_thumb.jpg',130, 87,15,'photo_5262498.html');
												thumbnails[5262499] = new thumbnail(5262499,'296256','','16-W-from-Peel-Park-Kirkin_thumb.jpg',130, 87,15,'photo_5262499.html');
												thumbnails[5262501] = new thumbnail(5262501,'296256','','17-Faustina-1_thumb.jpg',130, 195,15,'photo_5262501.html');
												thumbnails[5262503] = new thumbnail(5262503,'296256','','18-Faustina-2_thumb.jpg',130, 180,15,'photo_5262503.html');
												thumbnails[3260902] = new thumbnail(3260902,'198745','Bell\'s Bridge','20_Bells-Br1_thumb.jpg',130, 87,15,'photo_3260902.html');
												thumbnails[7251921] = new thumbnail(7251921,'297077','looking upriver from King\'s bridge.','0201_thumb.jpg',130, 87,15,'photo_7251921.html');
												thumbnails[7251861] = new thumbnail(7251861,'297077','Downriver from King\'s Bridge.','021_thumb.jpg',130, 97,15,'photo_7251861.html');
												thumbnails[7251862] = new thumbnail(7251862,'297077','St. Andrews Suspension Bridge.','022_thumb.jpg',130, 90,15,'photo_7251862.html');
												thumbnails[5262510] = new thumbnail(5262510,'296256','','23-Croy-hill-1_thumb.jpg',130, 53,15,'photo_5262510.html');
												thumbnails[7251906] = new thumbnail(7251906,'297077','Under George V Bridge.','023_thumb.jpg',130, 87,15,'photo_7251906.html');
												thumbnails[5262512] = new thumbnail(5262512,'296256','','24-near-Banknock-1_thumb.jpg',130, 64,15,'photo_5262512.html');
												thumbnails[3260904] = new thumbnail(3260904,'198745','Bell\'s Bridge','25_Bells-Br1_thumb.jpg',130, 195,15,'photo_3260904.html');
												thumbnails[5262513] = new thumbnail(5262513,'296256','','26-Dullatur_thumb.jpg',130, 184,15,'photo_5262513.html');
												thumbnails[7251910] = new thumbnail(7251910,'297077','Atlantic Quay on the North bank of the Clyde.','025_thumb.jpg',130, 87,15,'photo_7251910.html');
												thumbnails[7255437] = new thumbnail(7255437,'297077','The Tradeston Bridge (the Squiggly bridge) to the left.','026_thumb.jpg',130, 87,15,'photo_7255437.html');
												thumbnails[5262515] = new thumbnail(5262515,'296256','','27-Seabegs-wood_thumb.jpg',130, 87,15,'photo_5262515.html');
												thumbnails[7255438] = new thumbnail(7255438,'297077','Bell\'s Bridge.','027_thumb.jpg',130, 91,15,'photo_7255438.html');
												thumbnails[5262517] = new thumbnail(5262517,'296256','','28-Rough-Castle_thumb.jpg',130, 47,15,'photo_5262517.html');
												thumbnails[7255440] = new thumbnail(7255440,'297077','Bell\'s Bridge open to let the River Taxi pass.','028_thumb.jpg',130, 87,15,'photo_7255440.html');
												thumbnails[5262518] = new thumbnail(5262518,'296256','','29-Rough-Castle_thumb.jpg',130, 86,15,'photo_5262518.html');
												thumbnails[7255443] = new thumbnail(7255443,'297077','Glasgow Science Centre.','029_thumb.jpg',130, 87,15,'photo_7255443.html');
												thumbnails[3260907] = new thumbnail(3260907,'198745','View of the Squinty Bridge from Bell\'s Bridge','30_arc-view1_thumb.jpg',130, 87,15,'photo_3260907.html');
												thumbnails[7255446] = new thumbnail(7255446,'297077','Sea Plane arriving at the Science Centre pier.','031_thumb.jpg',130, 87,15,'photo_7255446.html');
												thumbnails[5262519] = new thumbnail(5262519,'296256','','31-Rough-Castle_thumb.jpg',130, 87,15,'photo_5262519.html');
												thumbnails[7255449] = new thumbnail(7255449,'297077','Glasgow\'s new Museum of Transport, which will open in 2011.','032_thumb.jpg',130, 87,15,'photo_7255449.html');
												thumbnails[5262520] = new thumbnail(5262520,'296256','','32-Watling-Lodge_thumb.jpg',130, 87,15,'photo_5262520.html');
												thumbnails[7255450] = new thumbnail(7255450,'297077','The Tall Ship, Glenlee.','033_thumb.jpg',130, 87,15,'photo_7255450.html');
												thumbnails[5262521] = new thumbnail(5262521,'296256','','33-Watling-Lodge_thumb.jpg',130, 87,15,'photo_5262521.html');
												thumbnails[7255452] = new thumbnail(7255452,'297077','PS Waverley passing the old Barclay Curle Yard.','034_thumb.jpg',130, 87,15,'photo_7255452.html');
												thumbnails[5262523] = new thumbnail(5262523,'296256','','34-Callendar-Park_thumb.jpg',130, 87,15,'photo_5262523.html');
												thumbnails[7255454] = new thumbnail(7255454,'297077','Reflections at high tide.','035_thumb.jpg',130, 91,15,'photo_7255454.html');
												thumbnails[3260911] = new thumbnail(3260911,'198745','Lights reflected in the River Clyde','35_crane1_thumb.jpg',130, 88,15,'photo_3260911.html');
												thumbnails[5262525] = new thumbnail(5262525,'296256','','35-Polmont-Woods_thumb.jpg',130, 87,15,'photo_5262525.html');
												thumbnails[7255456] = new thumbnail(7255456,'297077','View upriver at Clydebank.','036_thumb.jpg',130, 87,15,'photo_7255456.html');
												thumbnails[5262526] = new thumbnail(5262526,'296256','','36-Kinneil-House-grounds_thumb.jpg',130, 88,15,'photo_5262526.html');
												thumbnails[7255457] = new thumbnail(7255457,'297077','From up high on the Titan Crane at Clydebank.','037_thumb.jpg',130, 87,15,'photo_7255457.html');
												thumbnails[7255459] = new thumbnail(7255459,'297077','The Ferry Inn at the Renfrew Ferry Crossing.','040_thumb.jpg',130, 97,15,'photo_7255459.html');
												thumbnails[7255460] = new thumbnail(7255460,'297077','The Renfrew Rose, shortly before her last crossing over to Renfrew from Yoker.','041_thumb.jpg',130, 87,15,'photo_7255460.html');
												thumbnails[7255462] = new thumbnail(7255462,'297077','and her successor, heading over to Renfrew.','042_thumb.jpg',130, 90,15,'photo_7255462.html');
												thumbnails[3260912] = new thumbnail(3260912,'198745','Bell\'s Bridge','40_bells-br1_thumb.jpg',130, 87,15,'photo_3260912.html');
												thumbnails[7255464] = new thumbnail(7255464,'297077','PS Waverley heading downriver, viewed from Renfrew.','045_thumb.jpg',130, 87,15,'photo_7255464.html');
												thumbnails[7255467] = new thumbnail(7255467,'297077','and paddling down towards Erskine.','046_thumb.jpg',130, 87,15,'photo_7255467.html');
												thumbnails[7255469] = new thumbnail(7255469,'297077','Beside the Erskine Bridge are the remains of the old Erskine Ferry approaches.','047_thumb.jpg',130, 87,15,'photo_7255469.html');
												thumbnails[7255471] = new thumbnail(7255471,'297077','Under the Erskine Bridge, looking north to Old Kilpatrick.','048_thumb.jpg',130, 87,15,'photo_7255471.html');
												thumbnails[7255473] = new thumbnail(7255473,'297077','Looking downriver from near Bishopton.','050_thumb.jpg',130, 87,15,'photo_7255473.html');
												thumbnails[7255475] = new thumbnail(7255475,'297077','Newark Castle at Port Glasgow.','051_thumb.jpg',130, 87,15,'photo_7255475.html');
												thumbnails[3260913] = new thumbnail(3260913,'198745','Scottish Exhibition and Conference Centre -<br>\r\n            the Armadillo','50_armadillo1_thumb.jpg',130, 116,15,'photo_3260913.html');
												thumbnails[7255479] = new thumbnail(7255479,'297077','View from Gourock, looking over to Kilcreggan.','053_thumb.jpg',130, 87,15,'photo_7255479.html');
												thumbnails[7255480] = new thumbnail(7255480,'297077','Yachting on the Clyde, off Gourock.','055_thumb.jpg',130, 88,15,'photo_7255480.html');
												thumbnails[7255481] = new thumbnail(7255481,'297077','Gourock.','056_thumb.jpg',130, 87,15,'photo_7255481.html');
												thumbnails[7255485] = new thumbnail(7255485,'297077','At Lunderston Bay, beyond Gourock, looking towards the Inverkip Power Station.','057_thumb.jpg',130, 85,15,'photo_7255485.html');
												thumbnails[7255486] = new thumbnail(7255486,'297077','and ending the journey with a misty sunset.','058_thumb.jpg',130, 87,15,'photo_7255486.html');
												thumbnails[3260916] = new thumbnail(3260916,'198745','The Squinty Bridge and lights reflected in the River Clyde','60_sq-br1_thumb.jpg',130, 189,15,'photo_3260916.html');
												thumbnails[3260917] = new thumbnail(3260917,'198745','Darker sky and brighter reflections','65_dark-arc1_thumb.jpg',130, 195,15,'photo_3260917.html');
												thumbnails[3260919] = new thumbnail(3260919,'198745','BBC Scotland','70-BBC1_thumb.jpg',130, 89,15,'photo_3260919.html');
												thumbnails[3260921] = new thumbnail(3260921,'198745','Glasgow Cathedral','95_cath1_thumb.jpg',130, 83,15,'photo_3260921.html');
												thumbnails[3260923] = new thumbnail(3260923,'198745','Cathedral Square','100_cath1_thumb.jpg',130, 82,15,'photo_3260923.html');
												thumbnails[3260927] = new thumbnail(3260927,'198745','Looking toward the sunset from the Necropolis','110_necr1_thumb.jpg',130, 87,15,'photo_3260927.html');
												thumbnails[3260930] = new thumbnail(3260930,'198745','beside the bridge entrance to the Necropolis','105_necr1_thumb.jpg',130, 195,15,'photo_3260930.html');
												thumbnails[3260933] = new thumbnail(3260933,'198745','the same building against the sunset','115_necr1_thumb.jpg',130, 86,15,'photo_3260933.html');
												thumbnails[3260934] = new thumbnail(3260934,'198745','one of the memorial stones in the Necropolis','120_necr1_thumb.jpg',130, 195,15,'photo_3260934.html');
												thumbnails[3262158] = new thumbnail(3262158,'198745','The Mitchell Library','140_mitchell1_thumb.jpg',130, 85,15,'photo_3262158.html');
												thumbnails[3262168] = new thumbnail(3262168,'198745','The Mitchell Library','150_mitchell1_thumb.jpg',130, 195,15,'photo_3262168.html');
												thumbnails[3262224] = new thumbnail(3262224,'198745','The Mitchell Library','155_mitchell1_thumb.jpg',130, 187,15,'photo_3262224.html');
												thumbnails[3262226] = new thumbnail(3262226,'198745','Kelvingrove Museum and Art Gallery','160_kgrove1_thumb.jpg',130, 75,15,'photo_3262226.html');
												thumbnails[3262230] = new thumbnail(3262230,'198745','Kelvingrove Museum and Art Gallery','165_Kgrove1_thumb.jpg',130, 90,15,'photo_3262230.html');
												thumbnails[3262232] = new thumbnail(3262232,'198745','Kelvingrove Museum and Art Gallery','170_kgrove1_thumb.jpg',130, 182,15,'photo_3262232.html');
												thumbnails[3262157] = new thumbnail(3262157,'198745','The Winter Garden of the Peoples\' Palace Museum','130_p_palace1_thumb.jpg',130, 85,15,'photo_3262157.html');
												thumbnails[3262235] = new thumbnail(3262235,'198745','Glasgow University','180_g_univ1_thumb.jpg',130, 87,15,'photo_3262235.html');
												thumbnails[3262236] = new thumbnail(3262236,'198745','The Kibble Palace, Botanic Gardens','200_BotanicGdns1_thumb.jpg',130, 93,15,'photo_3262236.html');
												thumbnails[3262238] = new thumbnail(3262238,'198745','The Kibble Palace, Botanic Gardens','205_Botanic1_thumb.jpg',130, 118,15,'photo_3262238.html');
												thumbnails[3262241] = new thumbnail(3262241,'198745','The Kibble Palace, Botanic Gardens','210_BotanicGdns1_thumb.jpg',130, 86,15,'photo_3262241.html');
												thumbnails[3262243] = new thumbnail(3262243,'198745','The Kibble Palace, Botanic Gardens','220_Botanic_Kibble2_thumb.jpg',130, 199,15,'photo_3262243.html');
												thumbnails[3262245] = new thumbnail(3262245,'198745','Factory chimney','240_chimney2_thumb.jpg',130, 186,15,'photo_3262245.html');
												thumbnails[3262246] = new thumbnail(3262246,'198745','Sunrise over Maryhill','250_sunrise_11_thumb.jpg',130, 70,15,'photo_3262246.html');
												thumbnails[3262247] = new thumbnail(3262247,'198745','Sunrise over Maryhill','260_sunrise_21_thumb.jpg',130, 87,15,'photo_3262247.html');

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  					galleries[297077] = new gallery(297077,'7255486,7255485,7255481,7255480,7255479,7255475,7255473,7255471,7255469,7255467','River Clyde photos ','gallery',[7251921,7251861,7251862,7251906,7251910,7255437,7255438,7255440,7255443,7255446,7255449,7255450,7255452,7255454,7255456,7255457,7255459,7255460,7255462,7255464,7255467,7255469,7255471,7255473,7255475,7255479,7255480,7255481,7255485,7255486],0, 0, '', 'gallery_297077.html',0,0);
				  					galleries[198745] = new gallery(198745,'3262247,3262246,3262245,3262243,3262241,3262238,3262236,3262235,3262232,3262230','Glasgow Light','gallery',[3260902,3260904,3260907,3260911,3260912,3260913,3260916,3260917,3260919,3260921,3260923,3260927,3260930,3260933,3260934,3262158,3262168,3262224,3262226,3262230,3262232,3262157,3262235,3262236,3262238,3262241,3262243,3262245,3262246,3262247],0, 0, '', 'gallery_198745.html',0,0);
				  					galleries[124031] = new gallery(124031,'1847986,1847985,1847978,1847975,1847973,1847971','Mainly Black and Red ','gallery',[1847971,1847973,1847975,1847978,1847985,1847986],0, 0, '', 'gallery_124031.html',0,0);
				  					galleries[296256] = new gallery(296256,'5262526,5262525,5262523,5262521,5262520,5262519,5262518,5262517,5262515,5262513','Antonine Wall','gallery',[5262444,5262459,5262462,5262466,5262477,5262482,5262483,5262486,5262487,5262492,5262493,5262495,5262497,5262498,5262499,5262501,5262503,5262510,5262512,5262513,5262515,5262517,5262518,5262519,5262520,5262521,5262523,5262525,5262526],0, 0, '', 'gallery_296256.html',0,0);
/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = new Object();
imageSets[1] = '3260841,1840012,1839557';
imageSets[3] = '7255486,7255485,7255481,7255480,7255479,7255475,7255473,7255471,7255469,7255467,7255464,7255462,7255460,7255459,7255457,7255456,7255454,7255452,7255450,7255449,7255446,7255443,7255440,7255438,7255437,7251921,7251910,7251906,7251862,7251861,5262526,5262525,5262523,5262521,5262520,5262519,5262518,5262517,5262515,5262513,5262512,5262510,5262503,5262501,5262499,5262498,5262497,5262495,5262493,5262492';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/m_garscube/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/m_garscube/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/m_garscube/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/m_garscube/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/m_garscube/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/m_garscube/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/m_garscube/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/m_garscube/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/m_garscube/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/m_garscube/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/m_garscube/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/m_garscube/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/m_garscube/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/m_garscube/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/m_garscube/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://admin2.clikpic.com/m_garscube/images';
		break;
	}
		switch (server_id) {
		case 33:
		val = 'http://www8.clikpic.com/m_garscube/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/m_garscube/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/m_garscube/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/m_garscube/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/m_garscube/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/m_garscube/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 = 'Garscube Photography: ' + 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;
	}
}

			

