window.thumbnails = new Object();
												thumbnails[239189] = new thumbnail(239189,'21627','St. David\'s Peninsula','ST_thumb. David\'s Peninsula.jpg',130, 86,15,'photo_239189.html');
												thumbnails[239268] = new thumbnail(239268,'21627','Ebbing Tide Ricketts Head','EbbingtideRicket\'shead_thumb.jpg',130, 183,15,'photo_239268.html');
												thumbnails[243091] = new thumbnail(243091,'21630','Abereiddy Evening','Abereiddi EveningJPG_thumb.jpg',130, 86,15,'photo_243091.html');
												thumbnails[243093] = new thumbnail(243093,'21630','Dropping Tide, Newgale','Dropping Tide, newgale CorrectionJPG_thumb.jpg',130, 85,15,'photo_243093.html');
												thumbnails[243096] = new thumbnail(243096,'21630','Evening Light, Rickets Head','Evening reflection, Ricket\'s HeadJPG_thumb.jpg',130, 196,15,'photo_243096.html');
												thumbnails[243097] = new thumbnail(243097,'21627','High Tide Abermawr','Evening Tide Abermawr (new one)JPG_thumb.jpg',130, 85,15,'photo_243097.html');
												thumbnails[243098] = new thumbnail(243098,'21627','Evening Tide, Newgale','evening tide thisoneJPG_thumb.jpg',130, 86,15,'photo_243098.html');
												thumbnails[243102] = new thumbnail(243102,'21627','High Tide, Newgale','High Tide, NewgaleJPG_thumb.jpg',130, 196,15,'photo_243102.html');
												thumbnails[243105] = new thumbnail(243105,'21627','Late Fishing, Nolton Haven','nolton eve (this one)JPG_thumb.jpg',130, 85,15,'photo_243105.html');
												thumbnails[243109] = new thumbnail(243109,'21630','Pushing Tide, Druidston','Pushing Tide, DruidstonJPG_thumb.jpg',130, 86,15,'photo_243109.html');
												thumbnails[243113] = new thumbnail(243113,'64116','St. Govans','st _thumb.Govans re sizeJPG.jpg',130, 92,15,'photo_243113.html');
												thumbnails[243114] = new thumbnail(243114,'21627','Sunset Reflections, Ricketts Head','Sunset Reflections, rickets headJPG_thumb.jpg',130, 86,15,'photo_243114.html');
												thumbnails[243117] = new thumbnail(243117,'21630','Sunset, Freshwater West','Sunset, freshwater WestJPG_thumb.jpg',130, 84,15,'photo_243117.html');
												thumbnails[243122] = new thumbnail(243122,'21630','Whitesands Sunset','WHITESANDS evening CorrectionJPG_thumb.jpg',130, 86,15,'photo_243122.html');
												thumbnails[243174] = new thumbnail(243174,'21630','Abereiddy Flowers','ABEREIDDI FLOWERSJPG_thumb.jpg',130, 86,15,'photo_243174.html');
												thumbnails[249282] = new thumbnail(249282,'64116','The wedge.','Broadhaven SouthJPG_thumb.jpg',130, 86,15,'photo_249282.html');
												thumbnails[5805238] = new thumbnail(5805238,'21632','High tide at Porth Clais Harbour, pembrokeshire','Porthclaisharbour_thumb.jpg',130, 187,15,'photo_5805238.html');
												thumbnails[6912970] = new thumbnail(6912970,'21632','Sunshafts create a dramatic scene, looking south towards St David\'s Head and Ramsay Island.','needs_more_worlk_thumb.jpg',130, 87,15,'photo_6912970.html');
												thumbnails[6913092] = new thumbnail(6913092,'21632','Penycwm Reflections','penycwm_reflections_thumb.jpg',130, 185,15,'photo_6913092.html');
												thumbnails[6913106] = new thumbnail(6913106,'21632','Porthgain Harbour','Porth_gain_harbour-1_thumb.jpg',130, 183,15,'photo_6913106.html');
												thumbnails[6913136] = new thumbnail(6913136,'21632','','newgale_thumb.jpg',130, 88,15,'photo_6913136.html');
												thumbnails[6913138] = new thumbnail(6913138,'21652','Low Tide Porthgain','low_tide_porthegain_thumb.jpg',130, 130,15,'photo_6913138.html');
												thumbnails[6913148] = new thumbnail(6913148,'21632','','solva_2_thumb.jpg',130, 182,15,'photo_6913148.html');
												thumbnails[7037174] = new thumbnail(7037174,'22188','Storm Spindle, Whitesands','storm_spindle_whitesands_2_thumb.jpg',130, 47,15,'photo_7037174.html');
												thumbnails[7037176] = new thumbnail(7037176,'21631','Low Tide, Solva','this_one_2_thumb.jpg',130, 56,15,'photo_7037176.html');
												thumbnails[7037177] = new thumbnail(7037177,'22188','View from Pencarnum','View_from_Pencarnum_thumb.jpg',130, 132,15,'photo_7037177.html');
												thumbnails[7037179] = new thumbnail(7037179,'22188','Winter Strolling, Whitesands','Winter_Stroll_Whitesands_thumb.jpg',130, 131,15,'photo_7037179.html');
												thumbnails[7037180] = new thumbnail(7037180,'21631','Sunset Reflections, Penycwm','sunset_reflections_penycwm_thumb.jpg',130, 58,15,'photo_7037180.html');
												thumbnails[7037181] = new thumbnail(7037181,'21631','Penycwm','maybe_more_sat_unsharpened_thumb.jpg',130, 58,15,'photo_7037181.html');
												thumbnails[7312614] = new thumbnail(7312614,'21627','Fiery Sky, Pointz Castle','firy_sky_pointzcastle_thumb.jpg',130, 84,15,'photo_7312614.html');
												thumbnails[6960716] = new thumbnail(6960716,'21631','Sunset Sky Penycwm','sunset_sky_pencwm_thumb.jpg',130, 297,15,'photo_6960716.html');
												thumbnails[6960735] = new thumbnail(6960735,'21631','Sunset Idyll, Pointz Castle','sunset_idyll_pointz_castle_thumb.jpg',130, 262,15,'photo_6960735.html');
												thumbnails[6960748] = new thumbnail(6960748,'21631','Winter Walk Newgale','newgale_2_thumb.jpg',130, 318,15,'photo_6960748.html');
												thumbnails[829476] = new thumbnail(829476,'21627','Sunset Sky West Dale','snset sky west dale_thumb.jpg',130, 195,15,'photo_829476.html');
												thumbnails[829446] = new thumbnail(829446,'21631','Broahaven South','boroahaven south_thumb.jpg',130, 54,15,'photo_829446.html');
												thumbnails[829456] = new thumbnail(829456,'21627','After Glow, Newgale','after glow more contrast_thumb.jpg',130, 86,15,'photo_829456.html');
												thumbnails[1936994] = new thumbnail(1936994,'21652','Marloes Evening','hghhg_thumb.jpg',130, 125,15,'photo_1936994.html');
												thumbnails[1937005] = new thumbnail(1937005,'21630','Haroldston Chins ','aroldston chins no ships_thumb.jpg',130, 195,15,'photo_1937005.html');
												thumbnails[1937024] = new thumbnail(1937024,'21630','Firey Sunset, Marloes','Firey sunset, marloes_thumb.jpg',130, 87,15,'photo_1937024.html');
												thumbnails[1937042] = new thumbnail(1937042,'21631','Offshore Wave','offshore wave_thumb.jpg',130, 69,15,'photo_1937042.html');
												thumbnails[1937049] = new thumbnail(1937049,'21631','Pembrokeshire Skies II Skomer','something over skomer1_thumb.jpg',130, 59,15,'photo_1937049.html');
												thumbnails[1937082] = new thumbnail(1937082,'21652','Cloud Shadows Whitesands','cloud shadows whitesands_thumb.jpg',130, 136,15,'photo_1937082.html');
												thumbnails[1937104] = new thumbnail(1937104,'21630','Late Evening, Driudston ','Late Evening, Driudston Correction_thumb.jpg',130, 86,15,'photo_1937104.html');
												thumbnails[2349220] = new thumbnail(2349220,'21631','Storm Clouds Broadhaven','Storm Clouds Broadhaven_thumb.jpg',130, 57,15,'photo_2349220.html');
												thumbnails[2349339] = new thumbnail(2349339,'21630','Sunset Glow Broadhaven','sunset glow broadhaven_thumb.jpg',130, 87,15,'photo_2349339.html');
												thumbnails[6960719] = new thumbnail(6960719,'21631','Whitesands View','whitesands_view2-1_thumb.jpg',130, 40,15,'photo_6960719.html');
												thumbnails[363984] = new thumbnail(363984,'21630','The Blue Lagoon','The Blue Lagoon_thumb.jpg',130, 85,15,'photo_363984.html');
												thumbnails[829447] = new thumbnail(829447,'21631','Reflections, Broadhaven South','broad south2_thumb.jpg',130, 56,15,'photo_829447.html');
												thumbnails[1936957] = new thumbnail(1936957,'21631','barafundle wave','barafundle wave_thumb.jpg',130, 72,15,'photo_1936957.html');
												thumbnails[1937006] = new thumbnail(1937006,'21630','Amroth Beach','groin 2_thumb.jpg',130, 201,15,'photo_1937006.html');
												thumbnails[1937025] = new thumbnail(1937025,'21630','Ram\'s Nose, Whitesands','IMG_0082-01b_thumb.jpg',130, 195,15,'photo_1937025.html');
												thumbnails[1937083] = new thumbnail(1937083,'21631','Druidston Haven Beach','druidston_thumb.jpg',130, 70,15,'photo_1937083.html');
												thumbnails[829458] = new thumbnail(829458,'64116','Crashing Wave, Pembrokeshire','crashing wave 2_thumb.jpg',130, 89,15,'photo_829458.html');
												thumbnails[1937007] = new thumbnail(1937007,'21630','Sea Groin, Amroth','groin_thumb.jpg',130, 84,15,'photo_1937007.html');
												thumbnails[1937026] = new thumbnail(1937026,'21652','Storm Clouds Newgale','storm clouds newgale_thumb.jpg',130, 125,15,'photo_1937026.html');
												thumbnails[1937084] = new thumbnail(1937084,'21630','Marloes Twilight','effort ish_thumb.jpg',130, 85,15,'photo_1937084.html');
												thumbnails[829449] = new thumbnail(829449,'21631','Stormy Sunset, Newgale','pointzcastle_thumb.jpg',130, 50,15,'photo_829449.html');
												thumbnails[1937027] = new thumbnail(1937027,'21630','Sunset Glow, West Dale','sunset glow, west dale_thumb.jpg',130, 186,15,'photo_1937027.html');
												thumbnails[1937085] = new thumbnail(1937085,'21630','Sunset Glow, Newgale','find original again_thumb.jpg',130, 87,15,'photo_1937085.html');
												thumbnails[1937108] = new thumbnail(1937108,'21630','Ramsay Island Sunset','Ramsay island sunset_thumb.jpg',130, 85,15,'photo_1937108.html');
												thumbnails[1936960] = new thumbnail(1936960,'21631','sunset halo, newgale','sunset halo, newgale_thumb.jpg',130, 68,15,'photo_1936960.html');
												thumbnails[1936998] = new thumbnail(1936998,'21652','Sunshafts over Skomer','sunshafts over skomer_thumb.jpg',130, 127,15,'photo_1936998.html');
												thumbnails[1937086] = new thumbnail(1937086,'21630','Storm Clouds, Porth Melgan','PM NEW ONE_thumb.jpg',130, 192,15,'photo_1937086.html');
												thumbnails[1937111] = new thumbnail(1937111,'21631','Sun Shower, Ramsey Island','sun shower, ramsey island_thumb.jpg',130, 54,15,'photo_1937111.html');
												thumbnails[2609645] = new thumbnail(2609645,'21630','After Glow, Newgale','After Glow, Newgale_thumb.jpg',130, 86,15,'photo_2609645.html');
												thumbnails[243199] = new thumbnail(243199,'21631','','Surfing Pembrokeshire (234)1_thumb.jpg',130, 64,15,'photo_243199.html');
												thumbnails[1937113] = new thumbnail(1937113,'64116','Winter Storm Whitesands','winter storm white_thumb.jpg',130, 85,15,'photo_1937113.html');
												thumbnails[829465] = new thumbnail(829465,'21627','Moody sunset, Newgale','newgale to name_thumb.jpg',130, 197,15,'photo_829465.html');
												thumbnails[829466] = new thumbnail(829466,'21627','Twilight Red, Newgale','newgale to tp b named_thumb.jpg',130, 195,15,'photo_829466.html');
												thumbnails[829467] = new thumbnail(829467,'21627','Nolton Haven Stream','nolton haven stream_thumb.jpg',130, 195,15,'photo_829467.html');
												thumbnails[829468] = new thumbnail(829468,'21627','Sun Shafts Penbwchdy','PBD_thumb.jpg',130, 86,15,'photo_829468.html');
												thumbnails[829471] = new thumbnail(829471,'21627','Pointz Castle Sunset','pointz castle sunset_thumb.jpg',130, 85,15,'photo_829471.html');
												thumbnails[829474] = new thumbnail(829474,'21627','Red Sky over Ponitz Castle','Red Sky over ponita castle_thumb.jpg',130, 85,15,'photo_829474.html');
												thumbnails[829477] = new thumbnail(829477,'21627','Storm Front Porth Melgan','Storm Front Porth Melgan_thumb.jpg',130, 193,15,'photo_829477.html');
												thumbnails[455193] = new thumbnail(455193,'21630','Snowy Pebbles, Newgale','Snowy Pebbles, NewgaleJPG_thumb.jpg',130, 200,15,'photo_455193.html');
												thumbnails[829479] = new thumbnail(829479,'64116','Storm Swell, Broad Haven South','Storm Swell, Broad Haven South_thumb.jpg',130, 82,15,'photo_829479.html');
												thumbnails[829481] = new thumbnail(829481,'64116','Stormy Seas near St. Nons','Stormy seas_thumb. St. non\'s.jpg',130, 87,15,'photo_829481.html');
												thumbnails[245489] = new thumbnail(245489,'64116','Crashing Wave, Pembrokeshire','Autum SwellJPG_thumb.jpg',130, 86,15,'photo_245489.html');
												thumbnails[829483] = new thumbnail(829483,'21627','Sun Shafts Newgale','Sun Shafts Newgale_thumb.jpg',130, 86,15,'photo_829483.html');
												thumbnails[829487] = new thumbnail(829487,'21627','Storm Swell, Marloes','west dale_thumb.jpg',130, 195,15,'photo_829487.html');
												thumbnails[255974] = new thumbnail(255974,'64116','Surfing Pembrokeshire (36)JPG','Surfing Pembrokeshire (36)JPG_thumb.jpg',130, 86,15,'photo_255974.html');

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  					galleries[22188] = new gallery(22188,'7037179,7037177,7037174','New Images. Limited Editions','gallery',[7037174,7037177,7037179],0, 0, '', 'gallery_22188.html',0,0);
				  					galleries[21627] = new gallery(21627,'243114,243105,243098,243097','Fine Art 1','gallery',[239189,239268,243097,243098,243102,243105,243114,7312614,829476,829456,829465,829466,829467,829468,829471,829474,829477,829483,829487],0, 0, '', 'gallery_21627.html',0,0);
				  					galleries[21630] = new gallery(21630,'1937024,1937006,243174,243122,243117,243109,243093,243091','Fine Art 2','gallery',[243091,243093,243096,243109,243117,243122,243174,1937005,1937024,1937104,2349339,363984,1937006,1937025,1937007,1937084,1937027,1937085,1937108,1937086,2609645,455193],0, 0, '', 'gallery_21630.html',0,0);
				  					galleries[21631] = new gallery(21631,'1937111,243199','Panoramics','gallery',[7037176,7037180,7037181,6960716,6960735,6960748,829446,1937042,1937049,2349220,6960719,829447,1936957,1937083,829449,1936960,1937111,243199],0, 0, '', 'gallery_21631.html',0,0);
				  					galleries[64116] = new gallery(64116,'249282,243113','Storm Scenes','gallery',[243113,249282,829458,1937113,829479,829481,245489,255974],0, 0, '', 'gallery_64116.html',0,0);
				  					galleries[21652] = new gallery(21652,'6913138,1936998,1936994','Squares','gallery',[6913138,1936994,1937082,1937026,1936998],0, 0, '', 'gallery_21652.html',0,0);
				  					galleries[21651] = new gallery(21651,'','Weddings','section92932',[],0, 0, '', 'section92932.html',0,1);
				  					galleries[21632] = new gallery(21632,'6913106,6913092,6912970','Black and White','gallery',[5805238,6912970,6913092,6913106,6913136,6913148],0, 0, '', 'gallery_21632.html',0,0);
				  					galleries[28816] = new gallery(28816,'','Surfing Pembrokeshire','section49252',[],0, 0, '', 'section49252_28816.html',0,0);
				  					galleries[25756] = new gallery(25756,'','Coasteer TYF 14.7.06','section39358',[],0, 0, '', 'section39358_25756.html',0,0);
				  					galleries[29964] = new gallery(29964,'','Action and Sports','section49252',[],0, 0, '', 'section49252_29964.html',0,0);
				  					galleries[28296] = new gallery(28296,'','Walking','section49252',[],0, 0, '', 'section49252_28296.html',0,0);
				  					galleries[28298] = new gallery(28298,'','Dogs and Owners','section49252',[],0, 0, '', 'section49252_28298.html',0,0);
				  					galleries[28297] = new gallery(28297,'','General Scenes Pembrokeshire','section49252',[],0, 0, '', 'section49252_28297.html',0,0);
				  					galleries[28300] = new gallery(28300,'','Animals and Wildlife','section49252',[],0, 0, '', 'section49252_28300.html',0,0);
/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = new Object();
imageSets[1] = '6913138,6913106,6913092,6912970,1937111,1937024,1937006,1936998,1936994,249282,243199,243174,243122,243117,243114,243113,243109,243105,243098,243097,243093,243091,239189';
imageSets[2] = '6913138,6913106,6913092,6912970,1937111,1937024,1937006,1936998,1936994,249282,243199,243174,243122,243117,243114,243113,243109,243105,243098,243097,243093,243091';
imageSets[3] = '6913138,6913106,6913092,6912970';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/adyhaw/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/adyhaw/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/adyhaw/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/adyhaw/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/adyhaw/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/adyhaw/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/adyhaw/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/adyhaw/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/adyhaw/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/adyhaw/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/adyhaw/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/adyhaw/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/adyhaw/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/adyhaw/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/adyhaw/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://admin2.clikpic.com/adyhaw/images';
		break;
	}
		switch (server_id) {
		case 33:
		val = 'http://www8.clikpic.com/adyhaw/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/adyhaw/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/adyhaw/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/adyhaw/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/adyhaw/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/adyhaw/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 = 'Adrian Hawke 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 = 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>';
	}
					
	temp = temp + this.fnGetPaymentInfo();
				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>Buy now using PayPal:</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 using Paypal</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="Adyhawke@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="Adyhawke@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;
	}
}

			

