window.thumbnails = new Object();
												thumbnails[1655576] = new thumbnail(1655576,'111843','Just Ali','IMG_6168_thumb.jpg',130, 182,1,'photo_1655576.html');
												thumbnails[1655774] = new thumbnail(1655774,'111843','Hate to see you go ...','IMG_6102_thumb.jpg',130, 87,1,'photo_1655774.html');
												thumbnails[1655926] = new thumbnail(1655926,'111855','Banking Left','IMG_0554_thumb.jpg',130, 87,1,'photo_1655926.html');
												thumbnails[1655995] = new thumbnail(1655995,'111855','Muddy Flier','IMG_5115_thumb.jpg',130, 111,1,'photo_1655995.html');
												thumbnails[1656005] = new thumbnail(1656005,'111844','The Plains?','EPV0072_thumb.jpg',130, 182,1,'photo_1656005.html');
												thumbnails[1656010] = new thumbnail(1656010,'111845','Road To Shoshone','IMG_6438_thumb.jpg',130, 52,1,'photo_1656010.html');
												thumbnails[1656018] = new thumbnail(1656018,'111845','PT Cruiser Convertible','IMG_6462_thumb.jpg',130, 87,1,'photo_1656018.html');
												thumbnails[1656059] = new thumbnail(1656059,'111843','Vulnerable','IMG_2962_thumb.jpg',130, 87,1,'photo_1656059.html');
												thumbnails[1656074] = new thumbnail(1656074,'111843','A Lost Soul II','IMG_2946-Colour_thumb.jpg',130, 87,1,'photo_1656074.html');
												thumbnails[1656396] = new thumbnail(1656396,'111845','Inlet','WexfordBeachInlet1_thumb.jpg',130, 87,1,'photo_1656396.html');
												thumbnails[1670858] = new thumbnail(1670858,'112741','Ulster Bank','IMG_1044_thumb.jpg',130, 195,1,'photo_1670858.html');
												thumbnails[1670860] = new thumbnail(1670860,'112741','Docklands','IMG_1054_thumb.jpg',130, 157,1,'photo_1670860.html');
												thumbnails[1670867] = new thumbnail(1670867,'111855','Tandem Jump','IMG_0442_thumb.jpg',130, 195,1,'photo_1670867.html');
												thumbnails[1670905] = new thumbnail(1670905,'111844','Redshank','IMG_7878_thumb.jpg',130, 87,1,'photo_1670905.html');
												thumbnails[1670955] = new thumbnail(1670955,'111844','Heron','EPV0242_thumb.jpg',130, 195,1,'photo_1670955.html');
												thumbnails[1671047] = new thumbnail(1671047,'112741','Radisson','Radisson-Belfast-1_thumb.jpg',130, 98,1,'photo_1671047.html');
												thumbnails[1671067] = new thumbnail(1671067,'111845','Ngoronoro','NgorongoroSunsetThumb_thumb.jpg',130, 28,1,'photo_1671067.html');
												thumbnails[1671074] = new thumbnail(1671074,'111845','Wrecked Boat','DuncannonWreckedBoat_thumb.jpg',130, 195,1,'photo_1671074.html');
												thumbnails[1671080] = new thumbnail(1671080,'111845','The Strip','Stitch-Small_thumb.jpg',130, 20,1,'photo_1671080.html');
												thumbnails[1671181] = new thumbnail(1671181,'111855','Polo','IMG_2499_thumb.jpg',130, 87,1,'photo_1671181.html');
												thumbnails[1671203] = new thumbnail(1671203,'111844','Elephant Herd','ElephantLandscape_thumb.jpg',130, 52,1,'photo_1671203.html');
												thumbnails[1722974] = new thumbnail(1722974,'111843','In The Frame','IMG_7457-No-Feet_thumb.jpg',130, 195,1,'photo_1722974.html');
												thumbnails[1728416] = new thumbnail(1728416,'111843','Frozen in the Sun','IMG_7524_thumb.jpg',130, 87,1,'photo_1728416.html');
												thumbnails[1746764] = new thumbnail(1746764,'111843','Give Me Coffee','GiveMeCoffee_thumb.jpg',130, 99,1,'photo_1746764.html');
												thumbnails[1873917] = new thumbnail(1873917,'111844','Rabbit','IMG_2267_thumb.jpg',130, 87,1,'photo_1873917.html');
												thumbnails[2004392] = new thumbnail(2004392,'111855','Into The Blue','IMG_9443_thumb.jpg',130, 87,1,'photo_2004392.html');
												thumbnails[2004433] = new thumbnail(2004433,'111855','','IMG_9788_thumb.jpg',130, 195,1,'photo_2004433.html');
												thumbnails[2057179] = new thumbnail(2057179,'111843','Blue II','IMG_0079_thumb.jpg',130, 195,1,'photo_2057179.html');
												thumbnails[2112913] = new thumbnail(2112913,'111844','Great Egret in Flight','IMG_1369_thumb.jpg',130, 87,1,'photo_2112913.html');
												thumbnails[2148778] = new thumbnail(2148778,'111855','Sideways','IMG_1646_thumb.jpg',130, 195,1,'photo_2148778.html');
												thumbnails[2468689] = new thumbnail(2468689,'111844','Gannet Couple','IMG_6033_thumb.jpg',130, 86,1,'photo_2468689.html');
												thumbnails[2849055] = new thumbnail(2849055,'111844','Blue Tit','IMG_8575_thumb.jpg',130, 87,1,'photo_2849055.html');
												thumbnails[2849060] = new thumbnail(2849060,'111844','Coal Tit','IMG_8628_thumb.jpg',130, 87,1,'photo_2849060.html');
												thumbnails[2857274] = new thumbnail(2857274,'111844','Greenfinch','IMG_0400_thumb.jpg',130, 87,1,'photo_2857274.html');
												thumbnails[2903841] = new thumbnail(2903841,'111845','','IMG_9113_thumb.jpg',130, 86,1,'photo_2903841.html');
												thumbnails[2998620] = new thumbnail(2998620,'111845','Hook Head','IMG_0189_thumb.jpg',130, 87,1,'photo_2998620.html');
												thumbnails[2998631] = new thumbnail(2998631,'111845','St. Helens Bay','IMG_0176_thumb.jpg',130, 87,1,'photo_2998631.html');
												thumbnails[3021783] = new thumbnail(3021783,'111845','Liffey Falls','IMG_0195_thumb.jpg',130, 195,1,'photo_3021783.html');
												thumbnails[3259245] = new thumbnail(3259245,'111844','Stonechat','IMG_0850_thumb.jpg',130, 87,1,'photo_3259245.html');
												thumbnails[3424207] = new thumbnail(3424207,'111845','Curragh Graveyard In Snow','IMG_1095_thumb.jpg',130, 87,1,'photo_3424207.html');
												thumbnails[3424216] = new thumbnail(3424216,'111845','Splendid Frozen Isolation','IMG_1125_thumb.jpg',130, 87,1,'photo_3424216.html');
												thumbnails[3601932] = new thumbnail(3601932,'111843','Swept Off Her Feet','IMG_7423_thumb.jpg',130, 84,1,'photo_3601932.html');
												thumbnails[3733982] = new thumbnail(3733982,'111845','Bodie Island Lighthouse','IMG_6925_thumb.jpg',130, 87,1,'photo_3733982.html');
												thumbnails[3757707] = new thumbnail(3757707,'111844','White Tailed Sea Eagle & Fish','WhiteTailedSeaEagleAndFish_thumb.jpg',130, 87,1,'photo_3757707.html');
												thumbnails[3865477] = new thumbnail(3865477,'111843','Nikki','IMG_7931_Web_thumb.jpg',130, 148,1,'photo_3865477.html');
												thumbnails[3865490] = new thumbnail(3865490,'111843','Nikki Crying','IMG_7955_Web_thumb.jpg',130, 96,1,'photo_3865490.html');
												thumbnails[3900591] = new thumbnail(3900591,'111844','Red Kite','IMG_8189_thumb.jpg',130, 87,1,'photo_3900591.html');
												thumbnails[3992528] = new thumbnail(3992528,'111844','Shag','Saltee_Islands_199_thumb.jpg',130, 87,1,'photo_3992528.html');
												thumbnails[3992623] = new thumbnail(3992623,'111844','Puffin','Saltee_Islands_040_thumb.jpg',130, 87,1,'photo_3992623.html');
												thumbnails[3992626] = new thumbnail(3992626,'111844','Puffins','Saltee_Islands_077_thumb.jpg',130, 87,1,'photo_3992626.html');
												thumbnails[3992642] = new thumbnail(3992642,'111844','Shag','Saltee_Islands_1861_thumb.jpg',130, 87,1,'photo_3992642.html');
												thumbnails[3992659] = new thumbnail(3992659,'111844','Gannets','Saltee_Islands_207_thumb.jpg',130, 87,1,'photo_3992659.html');
												thumbnails[3993612] = new thumbnail(3993612,'111844','Great Grey Owl','Owl_Centre_221_thumb.jpg',130, 193,1,'photo_3993612.html');
												thumbnails[3993700] = new thumbnail(3993700,'111845','Sgwd Ddwli Isaf','IMG_8027_thumb.jpg',130, 87,1,'photo_3993700.html');
												thumbnails[3993726] = new thumbnail(3993726,'111844','White-Tailed Sea Eagle','IMG_7700_thumb.jpg',130, 130,1,'photo_3993726.html');
												thumbnails[4130884] = new thumbnail(4130884,'111844','Northern Gannet','Saltee_Islands_184_thumb.jpg',130, 87,1,'photo_4130884.html');
												thumbnails[4130901] = new thumbnail(4130901,'111844','Northern Gannet','Saltee_Islands_202_thumb.jpg',130, 87,1,'photo_4130901.html');
												thumbnails[4130919] = new thumbnail(4130919,'111844','Shags','Saltee_Islands_347_thumb.jpg',130, 87,1,'photo_4130919.html');
												thumbnails[5328421] = new thumbnail(5328421,'111844','Male Redpoll','Kildare_Redpolls_013_thumb.jpg',130, 87,1,'photo_5328421.html');
												thumbnails[5348185] = new thumbnail(5348185,'111845','Curragh on Ice','Curragh_Fox_016_thumb.jpg',130, 130,1,'photo_5348185.html');
												thumbnails[5473308] = new thumbnail(5473308,'111844','Falcon Feathers','Woodlands_Falconry_177_thumb.jpg',130, 87,1,'photo_5473308.html');
												thumbnails[5541070] = new thumbnail(5541070,'111844','Bald Eagle','North_West_Trek_307_thumb.jpg',130, 195,1,'photo_5541070.html');
												thumbnails[5544566] = new thumbnail(5544566,'111844','Coyote','North_West_Trek_416_thumb.jpg',130, 195,1,'photo_5544566.html');
												thumbnails[5673969] = new thumbnail(5673969,'111844','Barn Owl','Northshots_Raptor_Weekend_681_thumb.jpg',130, 89,1,'photo_5673969.html');
												thumbnails[5673972] = new thumbnail(5673972,'111844','Merlin','Northshots_Raptor_Weekend_541_thumb.jpg',130, 87,1,'photo_5673972.html');
												thumbnails[5679345] = new thumbnail(5679345,'111844','Eagle Owl','Northshots_Raptor_Weekend_517_thumb.jpg',130, 87,1,'photo_5679345.html');
												thumbnails[5679394] = new thumbnail(5679394,'111844','Golden Eagle, on a Mountain Hare','Northshots_Raptor_Weekend_438_thumb.jpg',130, 87,1,'photo_5679394.html');
												thumbnails[5928250] = new thumbnail(5928250,'111845','Manassas','Virginia_582_thumb.jpg',130, 87,1,'photo_5928250.html');
												thumbnails[5935333] = new thumbnail(5935333,'111844','Great Blue Heron','Virginia_463_thumb.jpg',130, 87,1,'photo_5935333.html');
												thumbnails[6146813] = new thumbnail(6146813,'111844','Incoming Razorbill with Sandeels','Saltees_154_thumb.jpg',130, 87,1,'photo_6146813.html');
												thumbnails[6234592] = new thumbnail(6234592,'111844','Osprey','Rothiemurchus_223_thumb.jpg',130, 87,1,'photo_6234592.html');
												thumbnails[6252840] = new thumbnail(6252840,'111844','Red Squirrel','Rothiemurchus_192_thumb.jpg',130, 130,1,'photo_6252840.html');
												thumbnails[6283413] = new thumbnail(6283413,'111844','Martial Eagle','Wild_Arena_Birds_of_Prey_442_thumb.jpg',130, 87,1,'photo_6283413.html');
												thumbnails[6644716] = new thumbnail(6644716,'111844','The Getaway','Rothiemurchus_039_thumb.jpg',130, 87,1,'photo_6644716.html');
												thumbnails[6726934] = new thumbnail(6726934,'111845','Lough Leane','Killarney_125_thumb.jpg',130, 75,1,'photo_6726934.html');
												thumbnails[6726941] = new thumbnail(6726941,'111845','Torc Waterfall','Killarney_008_thumb.jpg',130, 195,1,'photo_6726941.html');
												thumbnails[6803604] = new thumbnail(6803604,'111844','Red Kite','Woodlands_Falconry_0991_thumb.jpg',130, 130,1,'photo_6803604.html');
												thumbnails[6844697] = new thumbnail(6844697,'111844','Goshawk','Woodlands_Falconry_221_thumb.jpg',130, 87,1,'photo_6844697.html');
												thumbnails[6844702] = new thumbnail(6844702,'111844','Lanner Falcon','Woodlands_Falconry_235_thumb.jpg',130, 87,1,'photo_6844702.html');
												thumbnails[7413547] = new thumbnail(7413547,'111844','No Poison Required','Norway_382_thumb.jpg',130, 130,1,'photo_7413547.html');
												thumbnails[7413552] = new thumbnail(7413552,'111844','Golden Eagle','Norway_119_thumb.jpg',130, 94,1,'photo_7413552.html');
												thumbnails[7413559] = new thumbnail(7413559,'111844','Red Kite','Gigrin_Farm_525_thumb.jpg',130, 93,1,'photo_7413559.html');
												thumbnails[7413561] = new thumbnail(7413561,'111844','Kestrel','Woodlands_Falconry_038_thumb.jpg',130, 184,1,'photo_7413561.html');
												thumbnails[7413562] = new thumbnail(7413562,'111844','Sparrowhawk','Woodlands_Falconry_109_thumb.jpg',130, 93,1,'photo_7413562.html');
												thumbnails[7413568] = new thumbnail(7413568,'111844','Long-Eared Owl','Woodlands_Falconry_106_thumb.jpg',130, 183,1,'photo_7413568.html');
												thumbnails[7413569] = new thumbnail(7413569,'111844','Barn Owl','Woodlands_Falconry_244_thumb.jpg',130, 195,1,'photo_7413569.html');
												thumbnails[7413574] = new thumbnail(7413574,'112741','Independence Day','3X4R5520_thumb.jpg',130, 195,1,'photo_7413574.html');
												thumbnails[7413576] = new thumbnail(7413576,'112741','Bundestag','3X4R5542_thumb.jpg',130, 195,1,'photo_7413576.html');
												thumbnails[7413579] = new thumbnail(7413579,'112741','Juvenile Bald Eagle','Wild_Arena_Birds_of_Prey_305_thumb.jpg',130, 87,1,'photo_7413579.html');
												thumbnails[7413636] = new thumbnail(7413636,'111844','Grey Heron','Dublin_Zoo_172_thumb.jpg',130, 94,1,'photo_7413636.html');
												thumbnails[7413637] = new thumbnail(7413637,'111844','Asian Elephant','Dublin_Zoo_315_thumb.jpg',130, 195,1,'photo_7413637.html');
												thumbnails[1873913] = new thumbnail(1873913,'111844','Pheasant','IMG_2223_thumb.jpg',130, 91,1,'photo_1873913.html');
												thumbnails[1931203] = new thumbnail(1931203,'111844','Full of the Joys of Spring','IMG_8856_thumb.jpg',130, 87,1,'photo_1931203.html');
												thumbnails[1931208] = new thumbnail(1931208,'111845','Victorian Glasshouse','IMG_8948_thumb.jpg',130, 87,1,'photo_1931208.html');
												thumbnails[1972250] = new thumbnail(1972250,'111843','Raven at Sunrise','IMG_9008_thumb.jpg',130, 195,1,'photo_1972250.html');
												thumbnails[1656350] = new thumbnail(1656350,'111844','Grey Heron','Heron2_thumb.jpg',130, 195,1,'photo_1656350.html');

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  					galleries[111843] = new gallery(111843,'1728416','People','gallery',[1655576,1655774,1656059,1656074,1722974,1728416,1746764,2057179,3601932,3865477,3865490,1972250],0, 0, '', 'gallery_111843.html',0,0);
				  					galleries[111844] = new gallery(111844,'5673969','Natural','gallery',[1656005,1670905,1670955,1671203,1873917,2112913,2468689,2849055,2849060,2857274,3259245,3757707,3900591,3992528,3992623,3992626,3992642,3992659,3993612,3993726,4130884,4130901,4130919,5328421,5473308,5541070,5544566,5673969,5673972,5679345,5679394,5935333,6146813,6234592,6252840,6283413,6644716,6803604,6844697,6844702,7413547,7413552,7413559,7413561,7413562,7413568,7413569,7413636,7413637,1873913,1931203,1656350],0, 0, '', 'gallery_111844.html',0,0);
				  					galleries[111845] = new gallery(111845,'2998620','Landscape','gallery',[1656010,1656018,1656396,1671067,1671074,1671080,2903841,2998620,2998631,3021783,3424207,3424216,3733982,3993700,5348185,5928250,6726934,6726941,1931208],0, 0, '', 'gallery_111845.html',0,0);
				  					galleries[111855] = new gallery(111855,'2004392','Sports','gallery',[1655926,1655995,1670867,1671181,2004392,2004433,2148778],0, 0, '', 'gallery_111855.html',0,0);
				  					galleries[112741] = new gallery(112741,'1671047','Urban','gallery',[1670858,1670860,1671047,7413574,7413576,7413579],0, 0, '', 'gallery_112741.html',0,0);
/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = new Object();
imageSets[1] = '6234592';
imageSets[2] = '5673969,2998620,2004392,1728416,1671047';
imageSets[3] = '7413637,7413636,7413579,7413576,7413574,7413569,7413568,7413562,7413561,7413559,7413552,7413547,6844702,6844697,6803604,6726941,6726934,6644716,6283413,6252840,6234592,6146813,5935333,5928250,5679394,5679345,5673972,5673969,5544566,5541070,5473308,5348185,5328421,4130919,4130901,4130884,3993726,3993700,3993612,3992659,3992642,3992626,3992623,3992528,3900591,3865490,3865477,3757707,3733982,3601932';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/aidan_finn/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/aidan_finn/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/aidan_finn/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/aidan_finn/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/aidan_finn/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/aidan_finn/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/aidan_finn/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/aidan_finn/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/aidan_finn/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/aidan_finn/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/aidan_finn/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/aidan_finn/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/aidan_finn/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/aidan_finn/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/aidan_finn/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://admin2.clikpic.com/aidan_finn/images';
		break;
	}
		switch (server_id) {
		case 33:
		val = 'http://www8.clikpic.com/aidan_finn/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/aidan_finn/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/aidan_finn/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/aidan_finn/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/aidan_finn/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/aidan_finn/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 = 'Aidan Finn 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> &euro;' + (this.item_price).toFixed(2) + '</p>';
		var item_name  = this.purchase_instruction;
		var amount = (this.item_price).toFixed(2);
		var item_option  = 0;
	}
	else if (this.payment_groups_id !== '') {
		temp = temp + '<p>Buy this print online:</p>';
				temp = temp + '<form id="paymentOptions" style="margin:0px;border:0px;" name="paymentOptions">';
											temp = temp + '<select class="paymentlink" name="payment_options_id" onchange="updateItemValues(document.forms.paymentForm,this.form.payment_options_id.options[this.form.payment_options_id.options.selectedIndex].value);">';
				
		temp = temp + getPaymentOptions(this.payment_groups_id);
		temp = temp + '</select>';
		temp = temp + '</form>';
				var item_option  = paymentGroups[this.payment_groups_id].options[0];
		if(paymentOptions[item_option]){
			var item_name  = paymentOptions[item_option].payment_option;
			var amount =  paymentOptions[item_option].price;
		}
			}
	else {
				
	}
	if (this.item_price !== '' || this.payment_groups_id !== '') {
																				temp = temp + '<form id="paymentForm" style="margin:0px;border:0px;" name="paymentForm" target="_blank" action="https://www.paypal.com/cgi-bin/webscr" method="post">';
	temp = temp + '<input type="hidden" name="item_name" value="'+item_name+'">';
								ref = '';
				if(this.photo_ref != ''){
					ref = this.photo_ref+' - '+this.caption;
				}
				else{
					ref = this.id+' - '+this.caption;
				}
				price = amount;					temp = temp + '<input type="hidden" name="cmd" value="_cart">';
	temp = temp + '<input type="hidden" name="business" value="aidan.finn@gmail.com">';
	temp = temp + '<input type="hidden" name="currency_code" value="EUR">';
	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="aidan.finn@gmail.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;
	}
}

			

