window.thumbnails = new Object();
thumbnails[7211865] = new thumbnail(7211865,'','IntroImage','IntroImage_thumb.jpg',130, 86,21,' photo_7211865.html');
thumbnails[7222445] = new thumbnail(7222445,'','','Published_thumb.jpg',130, 57,21,' photo_7222445.html');
thumbnails[7227443] = new thumbnail(7227443,'','','WelshPhotosLogo2_thumb.jpg',130, 13,21,' photo_7227443.html');
thumbnails[7211316] = new thumbnail(7211316,'389538','Swallow Falls','SwallowFalls_thumb.jpg',130, 87,21,' photo_7211316.html');
thumbnails[7211391] = new thumbnail(7211391,'389709','Sunset Ponies','WildPoniesGower_thumb.JPG',130, 87,21,' photo_7211391.html');
thumbnails[7211456] = new thumbnail(7211456,'389708','Caswell Bay','Caswell_thumb.jpg',130, 87,21,' photo_7211456.html');
thumbnails[7211751] = new thumbnail(7211751,'389744','Evening at Eilean Donan Castle','EileanDonanCastle_thumb.jpg',130, 87,21,' photo_7211751.html');
thumbnails[7212272] = new thumbnail(7212272,'389707','Dragonfly 1','Img_3812_thumb.jpg',130, 87,21,' photo_7212272.html');
thumbnails[7212276] = new thumbnail(7212276,'389744','View from the Storr','Stor2_thumb.jpg',130, 87,21,' photo_7212276.html');
thumbnails[7212330] = new thumbnail(7212330,'389751','The Dog','Dog1_thumb.jpg',130, 87,21,' photo_7212330.html');
thumbnails[7212335] = new thumbnail(7212335,'389772','West Shore View Llandudno','LlandudnoAndConwy_thumb.JPG',130, 87,21,' photo_7212335.html');
thumbnails[7212343] = new thumbnail(7212343,'389767','Whitby','Whitby3_thumb.jpg',130, 87,21,' photo_7212343.html');
thumbnails[7212349] = new thumbnail(7212349,'389770','The Green Bridge','GreenBridgeWales_thumb.jpg',130, 87,21,' photo_7212349.html');
thumbnails[7212355] = new thumbnail(7212355,'389769','Dunraven Bay','8873s_thumb.jpg',130, 130,21,' photo_7212355.html');
thumbnails[7212405] = new thumbnail(7212405,'389708','Rhossili Trig Point','Img6919_thumb.jpg',130, 87,21,' photo_7212405.html');
thumbnails[7212423] = new thumbnail(7212423,'389708','The Wreck of the Helvetia','WreckHelvetiaRhosilli_Dali_thumb.jpg',130, 87,21,' photo_7212423.html');
thumbnails[7213467] = new thumbnail(7213467,'389847','Ferryside','Ferryside1_thumb.jpg',130, 87,21,' photo_7213467.html');
thumbnails[7213986] = new thumbnail(7213986,'389708','Snow on the Three Cliffs','Img_6697_thumb.jpg',130, 87,21,' photo_7213986.html');
thumbnails[7214011] = new thumbnail(7214011,'389709','Two Ponies','Img_2423_thumb.jpg',130, 87,21,' photo_7214011.html');
thumbnails[7215816] = new thumbnail(7215816,'389709','Little Pony','img_2460s_thumb.jpg',130, 87,21,' photo_7215816.html');
thumbnails[7215882] = new thumbnail(7215882,'389708','Pennard Castle','Img_6184_thumb.jpg',130, 87,21,' photo_7215882.html');
thumbnails[7215888] = new thumbnail(7215888,'389772','Puffin Island and Lighthouse','Img_7373s_thumb.jpg',130, 87,21,' photo_7215888.html');
thumbnails[7215975] = new thumbnail(7215975,'389709','BW Horse (1)','img-2464_bw_thumb.jpg',130, 87,21,' photo_7215975.html');
thumbnails[7216364] = new thumbnail(7216364,'389945','Dripping Duck','Img_2824s_thumb.jpg',130, 87,21,' photo_7216364.html');
thumbnails[7216371] = new thumbnail(7216371,'389945','Swan Neck','Img_3206_thumb.jpg',130, 87,21,' photo_7216371.html');
thumbnails[7216602] = new thumbnail(7216602,'389708','An Evening at Rhossili','RhosilliBay_thumb.JPG',130, 87,21,' photo_7216602.html');
thumbnails[7216785] = new thumbnail(7216785,'389744','Callander Kayaks ','Callander_Canoe_thumb.jpg',130, 57,21,' photo_7216785.html');
thumbnails[7217836] = new thumbnail(7217836,'389847','Reflections of Ferryside','Img_9694_thumb.jpg',130, 87,21,' photo_7217836.html');
thumbnails[7217844] = new thumbnail(7217844,'389708','Pennard Castle Path','Penard_thumb.jpg',130, 87,21,' photo_7217844.html');
thumbnails[7218015] = new thumbnail(7218015,'389719','Mitchell\'s Fold Stone','Mitchells_Fold_Stone_thumb.jpg',130, 89,21,' photo_7218015.html');
thumbnails[7218655] = new thumbnail(7218655,'389751','Grey Squirrel','Squirrel_thumb.jpg',130, 87,21,' photo_7218655.html');
thumbnails[7218663] = new thumbnail(7218663,'389538','Pontneddfechan (3)','Img_5696_thumb.jpg',130, 87,21,' photo_7218663.html');
thumbnails[7218672] = new thumbnail(7218672,'389538','Pontneddfechan (4)','Img_5709_thumb.jpg',130, 87,21,' photo_7218672.html');
thumbnails[7218676] = new thumbnail(7218676,'389847','Picnic at Burry Port','BurryPort3_thumb.jpg',130, 86,21,' photo_7218676.html');
thumbnails[7218680] = new thumbnail(7218680,'389770','Strumble Head, Lighthouse','Fishguard_thumb.jpg',130, 86,21,' photo_7218680.html');
thumbnails[7218694] = new thumbnail(7218694,'390029','Pen Y Fan Climber','Climber_thumb.jpg',130, 87,21,' photo_7218694.html');
thumbnails[7218698] = new thumbnail(7218698,'390028','Borrowdale from Castle Crag','Img_2066_thumb.jpg',130, 87,21,' photo_7218698.html');
thumbnails[7218699] = new thumbnail(7218699,'389708','Mumbles Lighthouse','MumblesLighthouse_thumb.jpg',130, 87,21,' photo_7218699.html');
thumbnails[7218709] = new thumbnail(7218709,'390028','Catbells','Img_2227_thumb.jpg',130, 87,21,' photo_7218709.html');
thumbnails[7218711] = new thumbnail(7218711,'389751','Giraffe Head','GiraffeHead1_thumb.jpg',130, 84,21,' photo_7218711.html');
thumbnails[7218719] = new thumbnail(7218719,'389945','Puffin Talk','PuffinsSkomerIsland_thumb.jpg',130, 87,21,' photo_7218719.html');
thumbnails[7218721] = new thumbnail(7218721,'389945','Puffin in a Flap','Puffins1_thumb.jpg',130, 87,21,' photo_7218721.html');
thumbnails[7218722] = new thumbnail(7218722,'389709','4 Horses','Img_2407_thumb.jpg',130, 87,21,' photo_7218722.html');
thumbnails[7218745] = new thumbnail(7218745,'389708','Gower Downs','Img_6745_thumb.jpg',130, 87,21,' photo_7218745.html');
thumbnails[7218758] = new thumbnail(7218758,'389770','Tenby Harbour Dive','Tenby_Harbour_Dive_thumb.JPG',130, 87,21,' photo_7218758.html');
thumbnails[7218763] = new thumbnail(7218763,'389708','Rhossili Path','Rhossilli_Path2_thumb.jpg',130, 87,21,' photo_7218763.html');
thumbnails[7218765] = new thumbnail(7218765,'390029','The Lone Walker','Img_0362_thumb.jpg',130, 87,21,' photo_7218765.html');
thumbnails[7218766] = new thumbnail(7218766,'389945','Duck (2)','Img_2604_thumb.jpg',130, 87,21,' photo_7218766.html');
thumbnails[7218767] = new thumbnail(7218767,'389719','Stonehenge','SH2_thumb.jpg',130, 88,21,' photo_7218767.html');
thumbnails[7218768] = new thumbnail(7218768,'389707','Dragonfly 2','Img_3819_thumb.jpg',130, 87,21,' photo_7218768.html');
thumbnails[7218769] = new thumbnail(7218769,'389847','Encounter at Ferryside!','Ferryside_3_thumb.jpg',130, 87,21,' photo_7218769.html');
thumbnails[7218773] = new thumbnail(7218773,'389719','Thames at Night','Img_1363_thumb.jpg',130, 87,21,' photo_7218773.html');
thumbnails[7218776] = new thumbnail(7218776,'389769','The Road to Wales','IMG_0905_thumb.jpg',130, 87,21,' photo_7218776.html');
thumbnails[7218777] = new thumbnail(7218777,'389707','Dragonfly 3','Img_3978_thumb.jpg',130, 87,21,' photo_7218777.html');
thumbnails[7219324] = new thumbnail(7219324,'389538','Cascades','Cascades_thumb.JPG',130, 87,21,' photo_7219324.html');
thumbnails[7219326] = new thumbnail(7219326,'389719','St Michaels Mount','St_Michaels_Mount_thumb.jpg',130, 87,21,' photo_7219326.html');
thumbnails[7219332] = new thumbnail(7219332,'389707','Orb Spider','Img_3646_thumb.jpg',130, 87,21,' photo_7219332.html');
thumbnails[7219368] = new thumbnail(7219368,'389772','Well Earned Rest','Img_0395_thumb.jpg',130, 87,21,' photo_7219368.html');
thumbnails[7219376] = new thumbnail(7219376,'389744','The Bridge at Sligachan','Img_2995_thumb.jpg',130, 87,21,' photo_7219376.html');
thumbnails[7219388] = new thumbnail(7219388,'390028','Two Graves','Lake_District_Graves_thumb.jpg',130, 87,21,' photo_7219388.html');
thumbnails[7219398] = new thumbnail(7219398,'389772','The West Shore','Img_1444_thumb.jpg',130, 85,21,' photo_7219398.html');
thumbnails[7219409] = new thumbnail(7219409,'389772','Point of Ayr Lighthouse','Img_7222_thumb.jpg',130, 87,21,' photo_7219409.html');
thumbnails[7219411] = new thumbnail(7219411,'389772','Point of Ayr Lighthouse (2)','Img_7246_thumb.jpg',130, 87,21,' photo_7219411.html');
thumbnails[7219412] = new thumbnail(7219412,'389767','The Gathering Storm','Img_5590_thumb.jpg',130, 87,21,' photo_7219412.html');
thumbnails[7222226] = new thumbnail(7222226,'389708','Flower Fantasy','Flower_Fantasy_thumb.jpg',130, 87,21,' photo_7222226.html');
thumbnails[7222770] = new thumbnail(7222770,'389772','Ogwen Valley','Llyn_Ogwen_thumb.jpg',130, 87,21,' photo_7222770.html');
thumbnails[7222784] = new thumbnail(7222784,'389707','Damsel Fly','Chaser_thumb.jpg',130, 87,21,' photo_7222784.html');
thumbnails[7222787] = new thumbnail(7222787,'389708','Rhossili Dreamscape','Img_5587_thumb.jpg',130, 85,21,' photo_7222787.html');
thumbnails[7223149] = new thumbnail(7223149,'389707','The Web','Web_thumb.jpg',130, 87,21,' photo_7223149.html');
thumbnails[7223150] = new thumbnail(7223150,'389719','Lands End','Lands_End_thumb.jpg',130, 87,21,' photo_7223150.html');
thumbnails[7223152] = new thumbnail(7223152,'389538','Sgwd Gwladys/Lady Falls','Img_9873_thumb.jpg',130, 87,21,' photo_7223152.html');
thumbnails[7223207] = new thumbnail(7223207,'389945','Duck (3)','Img_2602_thumb.jpg',130, 87,21,' photo_7223207.html');
thumbnails[7223210] = new thumbnail(7223210,'389708','Broad Pool (2)','Broad_Pool_3_thumb.jpg',130, 87,21,' photo_7223210.html');
thumbnails[7211311] = new thumbnail(7211311,'389538','Pontneddfechan','Img_9857_thumb.jpg',130, 195,21,' photo_7211311.html');
thumbnails[7211759] = new thumbnail(7211759,'389719','A Portrait of Beachy Head','Beachy_Head_thumb.jpg',130, 195,21,' photo_7211759.html');
thumbnails[7213959] = new thumbnail(7213959,'389847','Burry Port Lighthouse','BurryPort1_thumb.jpg',130, 195,21,' photo_7213959.html');
thumbnails[7215821] = new thumbnail(7215821,'389538','Melincourt','Img_5527_thumb.jpg',130, 195,21,' photo_7215821.html');
thumbnails[7218710] = new thumbnail(7218710,'389751','Giraffe in Hand','Giraffe1_thumb.jpg',130, 195,21,' photo_7218710.html');
thumbnails[7218723] = new thumbnail(7218723,'389767','Warkworth Castle','Img_4786_thumb.jpg',130, 195,21,' photo_7218723.html');
thumbnails[7219372] = new thumbnail(7219372,'389744','Edinburgh Heights ','Img_6944_thumb.jpg',130, 195,21,' photo_7219372.html');
thumbnails[7213962] = new thumbnail(7213962,'389847','Llanelli Evening','Llanelli_thumb.JPG',130, 195,21,' photo_7213962.html');
thumbnails[7218743] = new thumbnail(7218743,'389767','Warkworth Castle (2)','Img4831_thumb.jpg',130, 195,21,' photo_7218743.html');
thumbnails[7218764] = new thumbnail(7218764,'389708','Path to Worms Head','Rhossili_Path_Portrait_thumb.jpg',130, 171,21,' photo_7218764.html');
thumbnails[7211680] = new thumbnail(7211680,'389708','Evening at Broad Pool','Broad_Pool_2_2_thumb.JPG',130, 195,21,' photo_7211680.html');
thumbnails[7213965] = new thumbnail(7213965,'389847','Sunset over Burry Port','Llanelli3_thumb.JPG',130, 195,21,' photo_7213965.html');
thumbnails[7218668] = new thumbnail(7218668,'389538','Pontneddfechan (2)','Img_55931_thumb.jpg',130, 195,21,' photo_7218668.html');
thumbnails[7212340] = new thumbnail(7212340,'389767','Beyond Here Lies Nothing','Whitby1_thumb.jpg',130, 195,21,' photo_7212340.html');
thumbnails[7213977] = new thumbnail(7213977,'389847','Sunset over Burry Port (2)','Llanelli21_thumb.JPG',130, 195,21,' photo_7213977.html');
thumbnails[7217855] = new thumbnail(7217855,'389708','Mill Wood Tree','IMG_2558_thumb.jpg',130, 195,21,' photo_7217855.html');
thumbnails[7218696] = new thumbnail(7218696,'389751','Friendly Sheep','Curious_Sheep1_thumb.jpg',130, 195,21,' photo_7218696.html');
thumbnails[7218770] = new thumbnail(7218770,'389708','A Stream through Mill Wood','Img_9978_thumb.jpg',130, 195,21,' photo_7218770.html');
thumbnails[7218707] = new thumbnail(7218707,'389538','Fall Strip','Fall_Strip_thumb.jpg',130, 320,21,' photo_7218707.html');

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
galleries[389751] = new gallery(389751,'7218711,7218710,7218696,7218655,7212330','Animals','gallery',[7212330,7218655,7218711,7218710,7218696],0, 0, '389749', ' gallery_389751.html',0,0);
galleries[389945] = new gallery(389945,'7223207,7218766,7218721,7218719,7216371,7216364','Birds','gallery',[7216364,7216371,7218719,7218721,7218766,7223207],0, 0, '389749', ' gallery_389945.html',0,0);
galleries[390029] = new gallery(390029,'7218765,7218694','Brecon Beacons/Black Mountains','gallery',[7218694,7218765],0, 0, '389766', ' gallery_390029.html',0,0);
galleries[389847] = new gallery(389847,'7218769,7218676,7217836,7213977,7213965,7213962,7213959,7213467','Carmarthenshire','gallery',[7213467,7217836,7218676,7218769,7213959,7213962,7213965,7213977],0, 0, '389766', ' gallery_389847.html',0,0);
galleries[389719] = new gallery(389719,'7223150,7219326,7218773,7218767,7218015,7211759','English Excursions','gallery',[7218015,7218767,7218773,7219326,7223150,7211759],0, 0, '389771', ' gallery_389719.html',0,0);
galleries[389767] = new gallery(389767,'7219412,7218743,7218723,7212343,7212340','North East England','gallery',[7212343,7219412,7218723,7218743,7212340],0, 0, '389771', ' gallery_389767.html',0,0);
galleries[389772] = new gallery(389772,'7222770,7219411,7219409,7219398,7219368,7215888,7212335','North Wales','gallery',[7212335,7215888,7219368,7219398,7219409,7219411,7222770],0, 0, '389766', ' gallery_389772.html',0,0);
galleries[389769] = new gallery(389769,'7218776,7212355','South East Wales','gallery',[7212355,7218776],0, 0, '389766', ' gallery_389769.html',0,0);
galleries[389708] = new gallery(389708,'7223210,7222787,7222226,7218770,7218764,7218763,7218745,7218699,7217855,7217844','The Gower','gallery',[7211456,7212405,7212423,7213986,7215882,7216602,7217844,7218699,7218745,7218763,7222226,7222787,7223210,7218764,7211680,7217855,7218770],0, 0, '389766', ' gallery_389708.html',0,0);
galleries[390028] = new gallery(390028,'7219388,7218709,7218698','The Lake District','gallery',[7218698,7218709,7219388],0, 0, '389771', ' gallery_390028.html',0,0);
galleries[389707] = new gallery(389707,'7223149,7222784,7219332,7218777,7218768,7212272','The Macroverse','gallery',[7212272,7218768,7218777,7219332,7222784,7223149],0, 0, '389749', ' gallery_389707.html',0,0);
galleries[389770] = new gallery(389770,'7218758,7218680,7212349','West Wales','gallery',[7212349,7218680,7218758],0, 0, '389766', ' gallery_389770.html',0,0);
galleries[389709] = new gallery(389709,'7218722,7215975,7215816,7214011,7211391','Wild Ponies','gallery',[7211391,7214011,7215816,7215975,7218722],0, 0, '389749', ' gallery_389709.html',0,0);
galleries[389766] = new gallery(389766,'7223210,7223152,7222787,7222770,7222226,7219411,7219409,7219398,7219368,7219324','Wales','gallery',[],0, 0, '', ' gallery_389766.html',0,0);
galleries[389538] = new gallery(389538,'7223152,7219324,7218707,7218672,7218668,7218663,7215821,7211316,7211311','Waterfall Country','gallery',[7211316,7218663,7218672,7219324,7223152,7211311,7215821,7218668,7218707],0, 0, '389766', ' gallery_389538.html',0,0);
galleries[389771] = new gallery(389771,'7223150,7219412,7219388,7219326,7218773,7218767,7218743,7218723,7218709,7218698','England','gallery',[],0, 0, '', ' gallery_389771.html',0,0);
galleries[389744] = new gallery(389744,'7219376,7219372,7216785,7212276,7211751','Scotland','gallery',[7211751,7212276,7216785,7219376,7219372],0, 0, '', ' gallery_389744.html',0,0);
galleries[389749] = new gallery(389749,'7223207,7223149,7222784,7219332,7218777,7218768,7218766,7218722,7218721,7218719','Wildlife/Nature','gallery',[],0, 0, '', ' gallery_389749.html',0,0);
/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = new Object();
imageSets[3] = '7227443,7223210,7223207,7223152,7223150,7223149,7222787,7222784,7222770,7222445,7222226,7219412,7219411,7219409,7219398,7219388,7219376,7219372,7219368,7219332,7219326,7219324,7218777,7218776,7218773,7218770,7218769,7218768,7218767,7218766,7218765,7218764,7218763,7218758,7218745,7218743,7218723,7218722,7218721,7218719,7218711,7218710,7218709,7218707,7218699,7218698,7218696,7218694,7218680,7218676';
imageSets[2] = '7227443';
imageSets[1] = '7218765,7218719,7218694,7216371,7216364,7215888,7214011,7213467,7212423,7212272,7211865,7211456';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/AtekMan/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/AtekMan/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/AtekMan/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/AtekMan/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/AtekMan/images';
		break;
	}
		switch (server_id) {
		case 33:
		val = 'http://www8.clikpic.com/AtekMan/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/AtekMan/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/AtekMan/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/AtekMan/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/AtekMan/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/AtekMan/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/AtekMan/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/AtekMan/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/AtekMan/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/AtekMan/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/AtekMan/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/AtekMan/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://admin2.clikpic.com/AtekMan/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/AtekMan/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/AtekMan/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://www.clikchurch.com/AtekMan/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/AtekMan/images';
		break;
	}
		return val;
}

/***************************************************************************
* img = reference to image object in which to show image                   *
***************************************************************************/
function showHomeImage(img) {

	imageID = randomListVal('');
		if (!basic) {
	img.src = photos[imageID].src;
	img.width = photos[imageID].width;
	img.height = photos[imageID].height;
  img.parentNode.title = img.alt = photos[imageID].caption;
	}
	else {
		newImage = new Image(photos[imageID].width,photos[imageID].height);
		newImage.src = photos[imageID].src;
		document.images[img.name] = newImage;
				
	}
			}

function getHomeImageLink(imageID) {
  	var href='', photo = backgrounds && backgrounds[imageID];
	if(photo){
		if (photo && photo.galleries_id != '') {
  			href = photo.fnGalleryLink();
  		}
  		  		else {
  				href += 'gallery.html';
  	  		}
	}
    return href;
}
/***************************************************************************
* Show a random image on home page from featured images                    *
***************************************************************************/
function showHomeImageInline(el, image_sets_id, href) {
	
  var css = {}, imageID,
	    imageSetsId = 1;
	if(image_sets_id){
		imageSetsId = image_sets_id;
	}
	imageID = randomListVal(imageSets[imageSetsId]);
		if (href == null && 'gallery' != '') {
					href = getHomeImageLink(imageID);
	}
    
  updateImage({nextPhoto: backgrounds[imageID], img:el.find('img')[0],
                $photo:el, $title:$('#homeimageTitleContainer'), $detail:$('#homeimageDetailsContainer'),                speed:0, href:href, css:css, onAfter: function(){                  this.closest('.contentsection').doManualAlign({				    inner: 'img',				    crop: 'a'				  });                }              });
}

/***************************************************************************
* Set 'img' to be a new image given its photo() object                     *
***************************************************************************/
function updateImage (options) {
  var defaults = {nextPhoto:'',field:'',img:'',$photo:'',$title:'',$detail:'',
                    updateDocumentTitle:false,speed:0,href:false,css:false,updateHash:false,onAfter:null,onBefore:null},
      op = $.extend({},defaults,options),
      html = '', temp = '',
      photoId = op.nextPhoto.id,
      photoCaption = op.nextPhoto.caption,
      photoSrc = op.nextPhoto.src;
		
		if (!basic) {
    if (op.updateHash && clik.getIDInUrl(location.href,'photo') != op.nextPhoto.id) {
		clik.changeHash('photos_id=' + op.nextPhoto.id, true);
    }
				
    if (op.$photo.length > 0) {
      html = $('<img/>',{
        'class': 'mainphoto photo',
        src: photoSrc,
        id: 'mainPic',
        name: 'mainPic',
        width: op.nextPhoto.width,
        height: op.nextPhoto.height,
        alt: photoCaption,
        css: op.css || {}
      });
      if (op.href) {
      	if (op.href.match(/<a/)) {
      	  html = $(op.href).append(html);
      	} else {
		  html = $('<a/>', {
			href: op.href,
			title: photoCaption
		  }).append(html);
	    }
      } else {
      	html = $('<a/>', {
			title: photoCaption
		  }).append(html);
      }
      if (op.speed == 0) {        op.$photo.html(html);        if (op.onBefore) {          op.onBefore.apply(op.$photo);        }        if (op.onAfter) {          op.onAfter.apply(op.$photo);        }      } else {        op.$photo.stop(true,true).fadeReplaceWith(html,op.speed,'',function(){            if (op.onAfter) {		    op.onAfter.apply(this);          }		  clik.doColumnResize(false, $(this).add(op.$detail).add(op.$title));		}, op.onBefore);
      }    }
    	if (op.field) {
		op.field.value = photoId;
	} else {
		op.$photo.data('image_id', photoId);
    }
	    if (op.$title.length > 0) {
  		op.$title.fadeGalleryDetails(photoCaption, op.speed);
    }
        if (op.updateDocumentTitle) {
				  document.title = 'Welsh Photos: ' + photoCaption;
			    }
        if (op.$detail.length > 0) {
      temp = op.nextPhoto.fnGetImageDetails();
	    op.$detail.fadeGalleryDetails(temp, op.speed, function(){
	    var options = {photoinfominwidth:200};	    		options.photoinfoadjacent = true;			      resizePhotoInfo(options);
        if (typeof(backgrounds) != 'undefined' && op.nextPhoto == backgrounds[op.nextPhoto.id]) {
  	      toggleAddToCartConfirm(backgrounds);
  	    } else if (typeof(photos) != 'undefined' && op.nextPhoto == photos[op.nextPhoto.id]) {
  	      toggleAddToCartConfirm(photos);
  	    }
	    });
    }
        if (!op.speed) {      clik.doColumnResize(false, op.$photo.add(op.$detail).add(op.$title));    }        
    return html;			}
	else {
				
		window.location = 'photo_' + nextPhoto.id + '.html';
	}
		
}

/***************************************************************************
* Toggle add to cart confirmation element and set up the click event for   *
* the 'Add to cart' button.                                                *
***************************************************************************/
function toggleAddToCartConfirm(array){
  if (typeof(array) !== 'object') {
    array = photos;
  }
	if($('#paymentConfirm').length > 0){
		$('#paymentConfirm').hide();
		$('#paymentAddButton')
		.unbind()
		.click(function(){
						form = document.getElementById('paymentForm');
			option_id = 0;
			if(form.item_option.value){
				option_id = form.item_option.value;
			}
			if(addItemToBasket(form.item_number.value,array,form.site.value,parseInt(form.quantity.value, 10),option_id)){
				if($.browser.msie){$('#paymentConfirm').text('Item added to cart').show();}
				else{
					$('#paymentConfirm').text('Item added to cart').fadeIn();
					dspOrderDetails(form.site.value);
				}
			}
			else{
				$('#paymentConfirm').text('Item not added - check cookies are enabled in your browser.').fadeIn();
			}
		});
	}
}
/***************************************************************************
* Get payment info for image - add as 'method' to photo object             *
***************************************************************************/
photo.prototype.fnGetImageDetails = function(){
	var temp = '';
	if (this.description != '') {
		temp = temp +  '<p id="imageDescription">' + this.description + '</p>';
	}
		if (this.photo_ref != '') {
		temp = temp + '<p class="imageinfo" id="imageRef"><strong>Ref: </strong>' + this.photo_ref + '</p>';
	}
		if (this.takendate != '') {
				
		temp = temp + '<p class="imageinfo" id="imageDate"><strong>Date: </strong>' + this.takendate + '</p>';
	}
	
	if (this.location != '') {
				
		temp = temp + '<p class="imageinfo" id="imageLocation"><strong>Location: </strong>' +  this.location + '</p>';
	}
	
	if (this.photographer != '') {
				
		temp = temp + '<p class="imageinfo" id="imagePhotographer"><strong>Photographer: </strong>' + this.photographer + '</p>';
	}
			
				if (temp != '') {
		temp = temp + '<div class="spacer"></div>';
	}
	return temp;
};

/***************************************************************************
* Get payment info for image - add as 'method' to photo object             *
***************************************************************************/
photo.prototype.fnGetPaymentInfo = function(){
	var temp = '';
	if (this.item_price !== '') {
				temp = temp + '<p>Order this print:</p>';
				temp = temp + '<p class="imageinfo" id="imagePrice"><strong>' + this.purchase_instruction + '</strong> ' + (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;
	}
}

		

