window.thumbnails = new Object();
												thumbnails[2682510] = new thumbnail(2682510,'','','me_thumb.jpg',109, 130,5,'#');
												thumbnails[2674984] = new thumbnail(2674984,'168975','','050507_droplet_thumb.jpg',89, 130,5,'photo_2674984.html');
												thumbnails[2675407] = new thumbnail(2675407,'168975','','040902_droplet_red_thumb.jpg',130, 104,5,'photo_2675407.html');
												thumbnails[2676475] = new thumbnail(2676475,'168975','','041014_pola_drops_thumb.jpg',130, 86,5,'photo_2676475.html');
												thumbnails[2680175] = new thumbnail(2680175,'168976','','080421_temple_thumb.jpg',130, 129,5,'photo_2680175.html');
												thumbnails[2680187] = new thumbnail(2680187,'168976','','080496_fish_market_thumb.jpg',130, 122,5,'photo_2680187.html');
												thumbnails[2680198] = new thumbnail(2680198,'168976','','080440_cobbled_street_erice_thumb.jpg',130, 105,5,'photo_2680198.html');
												thumbnails[2680207] = new thumbnail(2680207,'168976','','040805_dunes_thumb.jpg',130, 112,5,'photo_2680207.html');
												thumbnails[2680541] = new thumbnail(2680541,'168975','','050701_Drosanthemum_Hispidum_thumb.jpg',94, 130,5,'photo_2680541.html');
												thumbnails[2680574] = new thumbnail(2680574,'168975','','050640_Goats_beard _thumb.jpg',130, 86,5,'photo_2680574.html');
												thumbnails[2681061] = new thumbnail(2681061,'168976','','021101b_a7spain_thumb.jpg',130, 91,5,'photo_2681061.html');
												thumbnails[2681121] = new thumbnail(2681121,'168976','','021107_javea_windmill_thumb.jpg',99, 130,5,'photo_2681121.html');
												thumbnails[2681198] = new thumbnail(2681198,'168976','','040401c_boat_thumb.jpg',130, 105,5,'photo_2681198.html');
												thumbnails[2681545] = new thumbnail(2681545,'168975','','061002_fly_agaric_thumb.jpg',130, 89,5,'photo_2681545.html');
												thumbnails[2681569] = new thumbnail(2681569,'168975','','070501_allium_flower_thumb.jpg',130, 92,5,'photo_2681569.html');
												thumbnails[2715866] = new thumbnail(2715866,'168976','','080475 window mozia Sicily_thumb.jpg',130, 105,5,'photo_2715866.html');
												thumbnails[2715989] = new thumbnail(2715989,'168976','','080458 cefalu fisherman_thumb.jpg',130, 115,5,'photo_2715989.html');
												thumbnails[2739522] = new thumbnail(2739522,'168976','','080401_sicilian_grocer_thumb.jpg',130, 111,5,'photo_2739522.html');
												thumbnails[2739547] = new thumbnail(2739547,'168976','','080421_erice_cobbled_street_thumb.jpg',130, 104,5,'photo_2739547.html');
												thumbnails[2739636] = new thumbnail(2739636,'168976','','040821_fuerteventura_thumb.jpg',130, 111,5,'photo_2739636.html');
												thumbnails[2739839] = new thumbnail(2739839,'168975','','040502_mexican_potato_plant_thumb.jpg',130, 118,5,'photo_2739839.html');
												thumbnails[2739976] = new thumbnail(2739976,'168975','','040512_Alpine_Saxifraga_thumb.jpg',130, 86,5,'photo_2739976.html');
												thumbnails[2740775] = new thumbnail(2740775,'168975','','071017_coprinus_lagopus_fungi _thumb.jpg',97, 130,5,'photo_2740775.html');
												thumbnails[2989262] = new thumbnail(2989262,'168975','','051009 passion flower _thumb.jpg',130, 95,5,'photo_2989262.html');
												thumbnails[2992220] = new thumbnail(2992220,'168976','','080429a agrigento columns_thumb.jpg',106, 130,5,'photo_2992220.html');
												thumbnails[2992221] = new thumbnail(2992221,'168976','','080454 Temple of Concord_thumb.jpg',130, 99,5,'photo_2992221.html');
												thumbnails[2670740] = new thumbnail(2670740,'168923','','080208_croydon_architecture_thumb.jpg',130, 89,5,'photo_2670740.html');
												thumbnails[2674599] = new thumbnail(2674599,'168975','','071018_sycamore_seed_thumb.jpg',130, 97,5,'photo_2674599.html');
												thumbnails[2675385] = new thumbnail(2675385,'169114','','040603_tree_thumb.jpg',130, 104,5,'photo_2675385.html');
												thumbnails[2680246] = new thumbnail(2680246,'168922','','030501_black_face_thumb.jpg',98, 130,5,'photo_2680246.html');
												thumbnails[2983126] = new thumbnail(2983126,'168983','','081006 dragonfly_thumb.jpg',130, 110,5,'photo_2983126.html');
												thumbnails[2671295] = new thumbnail(2671295,'169114','','080740_lavender3_thumb.jpg',130, 124,5,'photo_2671295.html');
												thumbnails[2741212] = new thumbnail(2741212,'169105','','061106_fireworks_thumb.jpg',130, 118,5,'photo_2741212.html');
												thumbnails[2681375] = new thumbnail(2681375,'169114','','050203_snowy lane_thumb.jpg',130, 104,5,'photo_2681375.html');
												thumbnails[2670935] = new thumbnail(2670935,'168923','','080807_southbank_thumb.jpg',130, 106,5,'photo_2670935.html');
												thumbnails[2671171] = new thumbnail(2671171,'168922','','071275_sparklers_thumb.jpg',109, 130,5,'photo_2671171.html');
												thumbnails[2671316] = new thumbnail(2671316,'168983','','080817_cardoon_Cynara_cardunculus_thumb.jpg',103, 130,5,'photo_2671316.html');
												thumbnails[2741086] = new thumbnail(2741086,'169114','','050610_poppies_in_flax_thumb.jpg',130, 106,5,'photo_2741086.html');
												thumbnails[2985731] = new thumbnail(2985731,'168983','','061008 witches butter fungi_thumb.jpg',90, 130,5,'photo_2985731.html');
												thumbnails[2671010] = new thumbnail(2671010,'168923','','080731b_qe2_bridge1_thumb.jpg',130, 85,5,'photo_2671010.html');
												thumbnails[2677685] = new thumbnail(2677685,'169105','','00790000_firework1_thumb.jpg',85, 130,5,'photo_2677685.html');
												thumbnails[2681155] = new thumbnail(2681155,'168922','','00970803_fisheye_thumb.jpg',125, 130,5,'photo_2681155.html');
												thumbnails[2983375] = new thumbnail(2983375,'168983','','081009 fly agaric_thumb.jpg',113, 130,5,'photo_2983375.html');
												thumbnails[2674940] = new thumbnail(2674940,'168922','','050409_Muddy_sam_thumb.jpg',125, 130,5,'photo_2674940.html');
												thumbnails[2680490] = new thumbnail(2680490,'169105','','080730_lavender_harvest_thumb.jpg',127, 130,5,'photo_2680490.html');
												thumbnails[2680495] = new thumbnail(2680495,'168923','','080632_oracle_car_park_thumb.jpg',94, 130,5,'photo_2680495.html');
												thumbnails[2739477] = new thumbnail(2739477,'169114','','080259_cuckmere_river_thumb.jpg',130, 93,5,'photo_2739477.html');
												thumbnails[2983370] = new thumbnail(2983370,'168983','','081011 fungi_thumb.jpg',106, 130,5,'photo_2983370.html');
												thumbnails[2680298] = new thumbnail(2680298,'168923','','080121_worthing_pier_thumb.jpg',130, 106,5,'photo_2680298.html');
												thumbnails[2681165] = new thumbnail(2681165,'168922','','00980801b_jouster_thumb.jpg',90, 130,5,'photo_2681165.html');
												thumbnails[2681215] = new thumbnail(2681215,'169114','','040901_Canary_Wharf_thumb.jpg',130, 102,5,'photo_2681215.html');
												thumbnails[2681415] = new thumbnail(2681415,'169105','','050613_broken_shed _thumb.jpg',130, 105,5,'photo_2681415.html');
												thumbnails[2985690] = new thumbnail(2985690,'168983','','080920 spider and ladybird_thumb.jpg',98, 130,5,'photo_2985690.html');
												thumbnails[2675110] = new thumbnail(2675110,'169114','','050618_pink_poppy _thumb.jpg',130, 117,5,'photo_2675110.html');
												thumbnails[2680250] = new thumbnail(2680250,'168922','','071009_michael_thumb.jpg',130, 129,5,'photo_2680250.html');
												thumbnails[2680503] = new thumbnail(2680503,'169105','','080625_yellow_bin_thumb.jpg',98, 130,5,'photo_2680503.html');
												thumbnails[2739302] = new thumbnail(2739302,'168923','','080209_croydon_architecture_thumb.jpg',130, 104,5,'photo_2739302.html');
												thumbnails[2741010] = new thumbnail(2741010,'168983','','071122_russula_fungi_thumb.jpg',130, 110,5,'photo_2741010.html');
												thumbnails[2680147] = new thumbnail(2680147,'169114','','031002_cobbled_jetty_thumb.jpg',108, 130,5,'photo_2680147.html');
												thumbnails[2680498] = new thumbnail(2680498,'169105','','080629_walkway_thumb.jpg',120, 130,5,'photo_2680498.html');
												thumbnails[2681142] = new thumbnail(2681142,'168922','','00930601_baby_beer_thumb.jpg',100, 130,5,'photo_2681142.html');
												thumbnails[2739357] = new thumbnail(2739357,'168923','','080829_stansted_airport_thumb.jpg',112, 130,5,'photo_2739357.html');
												thumbnails[2983367] = new thumbnail(2983367,'168983','','081001 dragonfly_thumb.jpg',96, 130,5,'photo_2983367.html');
												thumbnails[2680241] = new thumbnail(2680241,'169114','','041102_dymchurch_thumb.jpg',130, 113,5,'photo_2680241.html');
												thumbnails[2680261] = new thumbnail(2680261,'168922','','071206_gravedigger_thumb.jpg',122, 130,5,'photo_2680261.html');
												thumbnails[2681499] = new thumbnail(2681499,'169105','','051107_the_leas_thumb.jpg',130, 109,5,'photo_2681499.html');
												thumbnails[2740273] = new thumbnail(2740273,'168923','','070722_Cardinal_House_thumb.jpg',100, 130,5,'photo_2740273.html');
												thumbnails[2741113] = new thumbnail(2741113,'168983','','050935_rocks_thumb.jpg',130, 106,5,'photo_2741113.html');
												thumbnails[2987912] = new thumbnail(2987912,'169114','','050202b snowy lane_thumb.jpg',130, 117,5,'photo_2987912.html');
												thumbnails[2675037] = new thumbnail(2675037,'169114','','050606_poppy_flax_thumb.jpg',130, 127,5,'photo_2675037.html');
												thumbnails[2680264] = new thumbnail(2680264,'168922','','080117_worthing_ladies_thumb.jpg',130, 119,5,'photo_2680264.html');
												thumbnails[2681560] = new thumbnail(2681560,'169105','','070311_tom_thumb.jpg',130, 89,5,'photo_2681560.html');
												thumbnails[2740626] = new thumbnail(2740626,'168923','','070776_hammersmith_bridge_thumb.jpg',130, 129,5,'photo_2740626.html');
												thumbnails[2741067] = new thumbnail(2741067,'168983','','050509_grass_thumb.jpg',130, 91,5,'photo_2741067.html');
												thumbnails[2739376] = new thumbnail(2739376,'168923','','080830_stansted_airport_abstract_thumb.jpg',130, 123,5,'photo_2739376.html');
												thumbnails[2739499] = new thumbnail(2739499,'169105','','080302_traffic_cone_thumb.jpg',130, 115,5,'photo_2739499.html');
												thumbnails[2740705] = new thumbnail(2740705,'168922','','071005_croydon_man_thumb.jpg',130, 106,5,'photo_2740705.html');
												thumbnails[2674786] = new thumbnail(2674786,'169114','','071255_cudham_sunrise_thumb.jpg',130, 104,5,'photo_2674786.html');
												thumbnails[2715799] = new thumbnail(2715799,'168983','','070936 badger meles meles_thumb.jpg',130, 113,5,'photo_2715799.html');
												thumbnails[2739406] = new thumbnail(2739406,'168923','','080122_worthing_pier_thumb.jpg',130, 114,5,'photo_2739406.html');
												thumbnails[2985702] = new thumbnail(2985702,'169105','','00980902b dragsters_thumb.jpg',130, 79,5,'photo_2985702.html');
												thumbnails[2681484] = new thumbnail(2681484,'169114','','051105_wooden_path_thumb.jpg',130, 113,5,'photo_2681484.html');
												thumbnails[2681537] = new thumbnail(2681537,'168983','','060905_inonotus_dryadeus_fungi_thumb.jpg',130, 89,5,'photo_2681537.html');
												thumbnails[2740690] = new thumbnail(2740690,'168922','','070935b_spitfire_pilot_thumb.jpg',130, 90,5,'photo_2740690.html');
												thumbnails[2740744] = new thumbnail(2740744,'168923','','071209_orange_building_thumb.jpg',130, 94,5,'photo_2740744.html');
												thumbnails[2992213] = new thumbnail(2992213,'169105','','070815 hastings fishing boat _thumb.jpg',130, 113,5,'photo_2992213.html');
												thumbnails[2680505] = new thumbnail(2680505,'169114','','080611_teddington_footbridge_thumb.JPG',130, 106,5,'photo_2680505.html');
												thumbnails[2715659] = new thumbnail(2715659,'168983','','080824 Common Frog, Rana temporaria 1_thumb.jpg',130, 124,5,'photo_2715659.html');
												thumbnails[2740464] = new thumbnail(2740464,'168922','','070745b_skim_board_thumb.jpg',130, 106,5,'photo_2740464.html');
												thumbnails[2992215] = new thumbnail(2992215,'169105','','070917 tilford cricket_thumb.jpg',130, 98,5,'photo_2992215.html');
												thumbnails[2680587] = new thumbnail(2680587,'169114','','080145_worthing_driftwood_thumb.jpg',130, 104,5,'photo_2680587.html');
												thumbnails[2681527] = new thumbnail(2681527,'168983','','060802_thursley_fire_thumb.jpg',113, 130,5,'photo_2681527.html');
												thumbnails[2992216] = new thumbnail(2992216,'169105','','071027 croydon sliproad_thumb.jpg',130, 126,5,'photo_2992216.html');
												thumbnails[2680634] = new thumbnail(2680634,'169114','','080507_bluebells_thumb.jpg',130, 89,5,'photo_2680634.html');
												thumbnails[2740050] = new thumbnail(2740050,'168983','','041206_shield_bug_thumb.jpg',130, 90,5,'photo_2740050.html');
												thumbnails[2992217] = new thumbnail(2992217,'169105','','071128 fireworks_thumb.jpg',112, 130,5,'photo_2992217.html');
												thumbnails[2677554] = new thumbnail(2677554,'168983','','031008_rainbow_thumb.jpg',130, 87,5,'photo_2677554.html');
												thumbnails[2992218] = new thumbnail(2992218,'169105','','080222 thames gate_thumb.jpg',130, 111,5,'photo_2992218.html');
												thumbnails[2992236] = new thumbnail(2992236,'169105','','080499n cefalu steps_thumb.jpg',130, 108,5,'photo_2992236.html');
												thumbnails[2987152] = new thumbnail(2987152,'169114','','070799e devon crow point_thumb.jpg',130, 108,5,'photo_2987152.html');
												thumbnails[2987808] = new thumbnail(2987808,'169114','','050206b tree in snow_thumb.jpg',130, 130,5,'photo_2987808.html');
												thumbnails[2987933] = new thumbnail(2987933,'169114','','050601 camber sands_thumb.jpg',130, 106,5,'photo_2987933.html');
												thumbnails[2988008] = new thumbnail(2988008,'169114','','030304 tatsfield tree_thumb.jpg',96, 130,5,'photo_2988008.html');
												thumbnails[2989272] = new thumbnail(2989272,'169114','','041023 sunset rays_thumb.jpg',130, 100,5,'photo_2989272.html');
												thumbnails[2989280] = new thumbnail(2989280,'169114','','050925 hasting flats_thumb.jpg',130, 109,5,'photo_2989280.html');
												thumbnails[2675310] = new thumbnail(2675310,'169114','','040401b_door_thumb.jpg',130, 106,5,'photo_2675310.html');
												thumbnails[2675149] = new thumbnail(2675149,'169114','','050811b_wind_turbines_thumb.jpg',130, 120,5,'photo_2675149.html');

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  					galleries[169114] = new gallery(169114,'2675385,2675310','Landscapes','gallery',[2675385,2671295,2681375,2741086,2739477,2681215,2675110,2680147,2680241,2987912,2675037,2674786,2681484,2680505,2680587,2680634,2987152,2987808,2987933,2988008,2989272,2989280,2675310,2675149],0, 0, '', 'gallery_169114.html',0,0);
				  					galleries[168983] = new gallery(168983,'2983126','Natural History & Nature','gallery',[2983126,2671316,2985731,2983375,2983370,2985690,2741010,2983367,2741113,2741067,2715799,2681537,2715659,2681527,2740050,2677554],0, 0, '', 'gallery_168983.html',0,0);
				  					galleries[168976] = new gallery(168976,'2680175','Travel','gallery',[2680175,2680187,2680198,2680207,2681061,2681121,2681198,2715866,2715989,2739522,2739547,2739636,2992220,2992221],0, 0, '', 'gallery_168976.html',0,0);
				  					galleries[168975] = new gallery(168975,'2674984','Hidden worlds','gallery',[2674984,2675407,2676475,2680541,2680574,2681545,2681569,2739839,2739976,2740775,2989262,2674599],0, 0, '', 'gallery_168975.html',0,0);
				  					galleries[168923] = new gallery(168923,'2670740','Architecture','gallery',[2670740,2670935,2671010,2680495,2680298,2739302,2739357,2740273,2740626,2739376,2739406,2740744],0, 0, '', 'gallery_168923.html',0,0);
				  					galleries[168922] = new gallery(168922,'2680246','People','gallery',[2680246,2671171,2681155,2674940,2681165,2680250,2681142,2680261,2680264,2740705,2740690,2740464],0, 0, '', 'gallery_168922.html',0,0);
				  					galleries[169105] = new gallery(169105,'2992236,2992218,2992217,2992216,2992215,2992213,2985702,2741212,2739499,2681560','Miscellaneous','gallery',[2741212,2677685,2680490,2681415,2680503,2680498,2681499,2681560,2739499,2985702,2992213,2992215,2992216,2992217,2992218,2992236],0, 0, '', 'gallery_169105.html',0,0);
/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = new Object();
imageSets[1] = '2681375';
imageSets[2] = '2983126,2680246,2680175,2675385,2675310,2674984,2670740';
imageSets[3] = '2992236,2992221,2992220,2992218,2992217,2992216,2992215,2992213,2989280,2989272,2989262,2988008,2987933,2987912,2987808,2987152,2985731,2985702,2985690,2983375,2983370,2983367,2983126,2741212,2741113,2741086,2741067,2741010,2740775,2740744,2740705,2740690,2740626,2740464,2740273,2740050,2739976,2739839,2739636,2739547,2739522,2739499,2739477,2739406,2739376,2739357,2739302,2715989,2715866,2715799';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/fungilad/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/fungilad/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/fungilad/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/fungilad/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/fungilad/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/fungilad/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/fungilad/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/fungilad/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/fungilad/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/fungilad/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/fungilad/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/fungilad/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/fungilad/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/fungilad/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/fungilad/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://admin2.clikpic.com/fungilad/images';
		break;
	}
		switch (server_id) {
		case 33:
		val = 'http://www8.clikpic.com/fungilad/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/fungilad/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/fungilad/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/fungilad/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/fungilad/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/fungilad/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 = 'Tony Watson 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>';
	}
					
				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> &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:</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="tony@tonywatson.co.uk">';
	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="tony@tonywatson.co.uk">';
	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;
	}
}

			

