window.thumbnails = new Object();
												thumbnails[6840414] = new thumbnail(6840414,'357169','Common blues','common_blue_thumb.jpg',130, 180,32,'photo_6840414.html');
												thumbnails[6841322] = new thumbnail(6841322,'371532','Pulpit staircase','church_staircase_thumb.jpg',130, 130,32,'photo_6841322.html');
												thumbnails[6841330] = new thumbnail(6841330,'371532','Chinese Lantern','black__white_lantern_web_thumb.jpg',130, 173,32,'photo_6841330.html');
												thumbnails[6841337] = new thumbnail(6841337,'371532','Beetroot leaf','Black__White_Beetroot_leaf_web_thumb.jpg',130, 173,32,'photo_6841337.html');
												thumbnails[6841358] = new thumbnail(6841358,'371532','Hosta leaf 1','black_and_white_hosta_leaves_2_web_thumb.jpg',130, 173,32,'photo_6841358.html');
												thumbnails[6841372] = new thumbnail(6841372,'371532','Hosta leaves 1','black_and_white_hosta_leaves_web_thumb.jpg',130, 98,32,'photo_6841372.html');
												thumbnails[6841375] = new thumbnail(6841375,'371532','Lichen 1','bw_lichen_web_thumb.jpg',130, 172,32,'photo_6841375.html');
												thumbnails[6841384] = new thumbnail(6841384,'371532','Summer meadow','by_the_fence_black_and_white_web_thumb.jpg',130, 194,32,'photo_6841384.html');
												thumbnails[6841393] = new thumbnail(6841393,'371532','Seed heads ','cow_parsley_seed_heads_web_thumb.jpg',130, 87,32,'photo_6841393.html');
												thumbnails[6841401] = new thumbnail(6841401,'371532','Storm Clouds over Derwent Water','Derwent_Water_Black_and_White_web_thumb.jpg',130, 173,32,'photo_6841401.html');
												thumbnails[6841409] = new thumbnail(6841409,'371532','Fishermen 1','Fishing_Hornsea_2b_web_thumb.jpg',130, 76,32,'photo_6841409.html');
												thumbnails[6841497] = new thumbnail(6841497,'371532','Streaming Down','Early_morning_sunlight_Arkengarthdale_1_black_and_white_web_thumb.jpg',130, 173,32,'photo_6841497.html');
												thumbnails[6841518] = new thumbnail(6841518,'371532','Under the mushroom','mushroom_1_web_thumb.jpg',130, 173,32,'photo_6841518.html');
												thumbnails[6841522] = new thumbnail(6841522,'371532','Half mile walk','Half_Mile_Walk_black_and_white_web_thumb.jpg',130, 191,32,'photo_6841522.html');
												thumbnails[6841528] = new thumbnail(6841528,'371532','Hornsea Mere Boats','Mere_boats_1_black_and_white_web_thumb.jpg',130, 173,32,'photo_6841528.html');
												thumbnails[6841543] = new thumbnail(6841543,'371532','Chinese Lanterns','Lanterns_bw_2_web_thumb.jpg',130, 73,32,'photo_6841543.html');
												thumbnails[6841556] = new thumbnail(6841556,'371532','Under the Mushroom','mushroom_2_web_thumb.jpg',130, 173,32,'photo_6841556.html');
												thumbnails[6841565] = new thumbnail(6841565,'371532','Sheep shelter','Sheep_shelter_black_and_white_web_thumb.jpg',130, 164,32,'photo_6841565.html');
												thumbnails[6841644] = new thumbnail(6841644,'371532','Snow formations','snowdrift_forms_black_and_white_web_thumb.jpg',130, 173,32,'photo_6841644.html');
												thumbnails[6841659] = new thumbnail(6841659,'371532','Sunlight through the bridge','Sunlight_through_the_bridge_1black_and_white_web_thumb.jpg',130, 98,32,'photo_6841659.html');
												thumbnails[6841669] = new thumbnail(6841669,'371532','Snowy spruce','Snowy_spruce_web_thumb.jpg',130, 173,32,'photo_6841669.html');
												thumbnails[6841704] = new thumbnail(6841704,'371532','Church gate','Church_gate_3_web_thumb.jpg',130, 173,32,'photo_6841704.html');
												thumbnails[6841717] = new thumbnail(6841717,'357169','bolts and barnicles','Bolts_and_Barnicles_thumb.jpg',130, 87,32,'photo_6841717.html');
												thumbnails[6841771] = new thumbnail(6841771,'357169','Cobble Hall Poppies ','cobble_hall_lane_thumb.jpg',130, 173,32,'photo_6841771.html');
												thumbnails[6841784] = new thumbnail(6841784,'357169','Crummock Water ','Crummock_Water_1_thumb.jpg',130, 196,32,'photo_6841784.html');
												thumbnails[6842668] = new thumbnail(6842668,'357173','Gun Dog','P1010078LT_thumb.jpg',130, 173,32,'photo_6842668.html');
												thumbnails[6842716] = new thumbnail(6842716,'357173','Springer spaniels','P1010039LT_thumb.jpg',130, 98,32,'photo_6842716.html');
												thumbnails[6842948] = new thumbnail(6842948,'357170','Rachel','P1010076LT_thumb.jpg',130, 173,32,'photo_6842948.html');
												thumbnails[6842960] = new thumbnail(6842960,'357173','Sally','Paint_Sally_2LT_thumb.jpg',130, 173,32,'photo_6842960.html');
												thumbnails[6843104] = new thumbnail(6843104,'357173','Boris','Boris_2_thumb.jpg',130, 165,32,'photo_6843104.html');
												thumbnails[6843108] = new thumbnail(6843108,'357173','Dempsey','Painting_PonyLT_thumb.jpg',130, 173,32,'photo_6843108.html');
												thumbnails[6843112] = new thumbnail(6843112,'357173','Roger','Roger_2LT_thumb.jpg',130, 173,32,'photo_6843112.html');
												thumbnails[6843114] = new thumbnail(6843114,'357173','Bobby','BobbyLT_thumb.jpg',130, 173,32,'photo_6843114.html');
												thumbnails[6843416] = new thumbnail(6843416,'357169','Days end','Days_end_web_thumb.jpg',130, 98,32,'photo_6843416.html');
												thumbnails[6843529] = new thumbnail(6843529,'357169','Dawn','Dawn_1_Web_thumb.jpg',130, 67,32,'photo_6843529.html');
												thumbnails[6843558] = new thumbnail(6843558,'357169','Colour of rust 1','DSC07932_thumb.JPG',130, 98,32,'photo_6843558.html');
												thumbnails[6844024] = new thumbnail(6844024,'357173','Tabby & White Cat ','cat1LT_thumb.jpg',130, 198,32,'photo_6844024.html');
												thumbnails[6844036] = new thumbnail(6844036,'357173','Stalky','cat3LT_thumb.jpg',130, 183,32,'photo_6844036.html');
												thumbnails[6844105] = new thumbnail(6844105,'357173','Sumo','cat6LT_thumb.jpg',130, 185,32,'photo_6844105.html');
												thumbnails[6844156] = new thumbnail(6844156,'357173','Charlie','charlieLT_thumb.jpg',130, 181,32,'photo_6844156.html');
												thumbnails[6844175] = new thumbnail(6844175,'357173','','dog4LT_thumb.jpg',130, 184,32,'photo_6844175.html');
												thumbnails[6844235] = new thumbnail(6844235,'357173','Rusty','dog6LT_thumb.jpg',130, 192,32,'photo_6844235.html');
												thumbnails[6844242] = new thumbnail(6844242,'357173','Molly','dog10LT_thumb.jpg',130, 195,32,'photo_6844242.html');
												thumbnails[6844244] = new thumbnail(6844244,'357173','Two terriers','dogs8LT_thumb.jpg',130, 93,32,'photo_6844244.html');
												thumbnails[6844256] = new thumbnail(6844256,'357173','Ralph','DSC00509_thumb.JPG',130, 192,32,'photo_6844256.html');
												thumbnails[6844269] = new thumbnail(6844269,'357170','Garden flowers','DSC00755_thumb.JPG',130, 194,32,'photo_6844269.html');
												thumbnails[6844336] = new thumbnail(6844336,'357170','Cockerel and dove cote','DSC04968_thumb.JPG',130, 194,32,'photo_6844336.html');
												thumbnails[6844424] = new thumbnail(6844424,'357170','Wild flowers in Whins Lane','flowers_thumb.jpg',130, 86,32,'photo_6844424.html');
												thumbnails[6844429] = new thumbnail(6844429,'357170','After the storm','Paint-_SpurnLT_thumb.JPG',130, 173,32,'photo_6844429.html');
												thumbnails[6844437] = new thumbnail(6844437,'357170','Botanical study','Flowers2LT_thumb.jpg',130, 194,32,'photo_6844437.html');
												thumbnails[6844444] = new thumbnail(6844444,'357170','Garden Bouquet','flowersLT_thumb.jpg',130, 98,32,'photo_6844444.html');
												thumbnails[6844450] = new thumbnail(6844450,'357170','Collection of fruit','FruitLT_thumb.jpg',130, 97,32,'photo_6844450.html');
												thumbnails[6844455] = new thumbnail(6844455,'357170','Hare','Hare_thumb.jpg',130, 172,32,'photo_6844455.html');
												thumbnails[6844495] = new thumbnail(6844495,'357173','Horse','horse2LT_thumb.jpg',130, 184,32,'photo_6844495.html');
												thumbnails[6844568] = new thumbnail(6844568,'357170','Japanese Anemone','Purple_FlowerLT_thumb.jpg',130, 193,32,'photo_6844568.html');
												thumbnails[6844573] = new thumbnail(6844573,'357170','Rose','rose_the_cowLT_thumb.jpg',130, 191,32,'photo_6844573.html');
												thumbnails[6844576] = new thumbnail(6844576,'357173','Shiba Inu','Shiba_Inu_BlackLT_thumb.jpg',130, 184,32,'photo_6844576.html');
												thumbnails[6844581] = new thumbnail(6844581,'357170','Cottage in the snow','snow_sceneLT_thumb.jpg',130, 90,32,'photo_6844581.html');
												thumbnails[6844590] = new thumbnail(6844590,'357173','Rags','Rags-ponyLT_thumb.jpg',130, 173,32,'photo_6844590.html');
												thumbnails[6844591] = new thumbnail(6844591,'357169','','Fritillary_seedheads_2_thumb.jpg',130, 123,32,'photo_6844591.html');
												thumbnails[6844897] = new thumbnail(6844897,'357169','At the skate board park','skate_boarders_colour_thumb.jpg',130, 94,32,'photo_6844897.html');
												thumbnails[6844901] = new thumbnail(6844901,'357169','Dusk over the wolds','dusk_over_the_wolds_thumb.jpg',130, 87,32,'photo_6844901.html');
												thumbnails[6844907] = new thumbnail(6844907,'357169',' Spurn Point sunrise','Sunrise_over_Spurn_1_thumb.jpg',130, 185,32,'photo_6844907.html');
												thumbnails[6844908] = new thumbnail(6844908,'357169','Spurn Point sunrise 2','Sunrise_over_Spurn_2_thumb.jpg',130, 173,32,'photo_6844908.html');
												thumbnails[6844949] = new thumbnail(6844949,'357169','Pink poppies','DSC02633_thumb.JPG',130, 87,32,'photo_6844949.html');
												thumbnails[6844962] = new thumbnail(6844962,'357169','Harbour reflections 1','Hon_Fleur_harbour_reflections_thumb.jpg',130, 173,32,'photo_6844962.html');
												thumbnails[6844964] = new thumbnail(6844964,'357169','Monet\'s Water Lily','Monets_water_lily_thumb.jpg',130, 98,32,'photo_6844964.html');
												thumbnails[6844969] = new thumbnail(6844969,'357169','Through the cloisters','Through_the_Cloisters_thumb.jpg',130, 173,32,'photo_6844969.html');
												thumbnails[6846088] = new thumbnail(6846088,'357169','Sit!','Andrew_and_Paddy_web_thumb.jpg',130, 348,32,'photo_6846088.html');
												thumbnails[6846094] = new thumbnail(6846094,'357169','Ropes and Bolts','Bolt_and_Nets_web_thumb.jpg',130, 173,32,'photo_6846094.html');
												thumbnails[6846097] = new thumbnail(6846097,'357169','Givendale Church','church_view_web_thumb.jpg',130, 98,32,'photo_6846097.html');
												thumbnails[6846105] = new thumbnail(6846105,'357169','Dog Walking Fraisthorpe beach','Dog_walking_on_Fraisthorpe_beach_3_web_thumb.jpg',130, 45,32,'photo_6846105.html');
												thumbnails[6846118] = new thumbnail(6846118,'357169','Dog Walking Fraisthorpe Beach 4','Dog_walking_on_Fraisthorpe_beach_5_web_thumb.jpg',130, 45,32,'photo_6846118.html');
												thumbnails[6846124] = new thumbnail(6846124,'357169','Dog Walking on Fraisthorpe beach  5','Fraisthorpe_dog_walking_web_thumb.jpg',130, 45,32,'photo_6846124.html');
												thumbnails[6846130] = new thumbnail(6846130,'357169','Early morning surf','Early_morning_surf_web_thumb.jpg',130, 176,32,'photo_6846130.html');
												thumbnails[6846135] = new thumbnail(6846135,'357169','Evening Sailing','Evening_sailing_1_web_thumb.jpg',130, 98,32,'photo_6846135.html');
												thumbnails[6846141] = new thumbnail(6846141,'357169','Wold field patterns','field_patterns_2_web_thumb.jpg',130, 173,32,'photo_6846141.html');
												thumbnails[6846147] = new thumbnail(6846147,'357169','Hornsea Inshore rescue','Inshore_rescue_1_web_thumb.jpg',130, 86,32,'photo_6846147.html');
												thumbnails[6846155] = new thumbnail(6846155,'357169','Fireball','Fire_ball_1_web_thumb.jpg',130, 98,32,'photo_6846155.html');
												thumbnails[6846159] = new thumbnail(6846159,'357169','Golden Stones','Four_golden_stones_web_thumb.jpg',130, 68,32,'photo_6846159.html');
												thumbnails[6846163] = new thumbnail(6846163,'357169','Sand Surf Sky','Hornsea_Feb_10_No_2_web_thumb.jpg',130, 88,32,'photo_6846163.html');
												thumbnails[6846167] = new thumbnail(6846167,'357169','Autumn wood Givendale','in_the_wood_web_thumb.jpg',130, 173,32,'photo_6846167.html');
												thumbnails[6846179] = new thumbnail(6846179,'357169','Blue rust','Blue_rust_thumb.jpg',130, 173,32,'photo_6846179.html');
												thumbnails[6846184] = new thumbnail(6846184,'357169','Red rust','Red_rust_thumb.jpg',130, 173,32,'photo_6846184.html');
												thumbnails[6846190] = new thumbnail(6846190,'357169','Stones in Breakwater','Breaker_Pebbles_WEB_thumb.jpg',130, 50,32,'photo_6846190.html');
												thumbnails[6846199] = new thumbnail(6846199,'357169','Beach Stone 1','Beach_Stone_1_thumb.jpg',130, 194,32,'photo_6846199.html');
												thumbnails[6846204] = new thumbnail(6846204,'357169','Beach stones 2','Beach_Stone_2_thumb.jpg',130, 194,32,'photo_6846204.html');
												thumbnails[6846206] = new thumbnail(6846206,'357169','Hoverfly','Hoverfly_thumb.jpg',130, 87,32,'photo_6846206.html');
												thumbnails[6846212] = new thumbnail(6846212,'357169','Pink stocks','Pink_stocks_web_thumb.jpg',130, 173,32,'photo_6846212.html');
												thumbnails[6846221] = new thumbnail(6846221,'357169','River reflections','River_reflections_web_thumb.jpg',130, 133,32,'photo_6846221.html');
												thumbnails[6846225] = new thumbnail(6846225,'357169','Snaking wall','Snow_tree_and_wall_web_thumb.jpg',130, 98,32,'photo_6846225.html');
												thumbnails[6846236] = new thumbnail(6846236,'357169','Snow fall at sunset','snowfall_at_sunset_web_thumb.jpg',130, 54,32,'photo_6846236.html');
												thumbnails[6846246] = new thumbnail(6846246,'357169','Long shadows','Shadows_on_the_sand_web_thumb.jpg',130, 98,32,'photo_6846246.html');
												thumbnails[6846254] = new thumbnail(6846254,'357169','One man and his dog','One_man_and_his_dog_web_thumb.jpg',130, 350,32,'photo_6846254.html');
												thumbnails[6846262] = new thumbnail(6846262,'357169','Shoreline Textures','Shoreline_textures_1_web12_thumb.jpg',130, 98,32,'photo_6846262.html');
												thumbnails[6846268] = new thumbnail(6846268,'357169','Stone Creek dredger','Stone_Creek_Dredger_thumb.jpg',130, 173,32,'photo_6846268.html');
												thumbnails[6846283] = new thumbnail(6846283,'357169','Tree on the Wolds 2','Tree_on_the_Wolds_web1_thumb.jpg',130, 193,32,'photo_6846283.html');
												thumbnails[6665722] = new thumbnail(6665722,'357169','Autumn leaves 2','Autumn_leaves_3_thumb.jpg',130, 87,32,'photo_6665722.html');
												thumbnails[6842686] = new thumbnail(6842686,'357173','Cross collie','DSC00215LT_thumb.jpg',130, 98,32,'photo_6842686.html');
												thumbnails[6484445] = new thumbnail(6484445,'357173','Dash','DSC01794LT_thumb.jpg',130, 173,32,'photo_6484445.html');
												thumbnails[6665776] = new thumbnail(6665776,'357169','Beverley Minster from the Westwood','Beverley_Minster_from_the_Westwood_web_thumb.jpg',130, 86,32,'photo_6665776.html');
												thumbnails[6842971] = new thumbnail(6842971,'357173','The Family Group ','Painting_dogsLT_thumb.jpg',130, 98,32,'photo_6842971.html');
												thumbnails[6484438] = new thumbnail(6484438,'357173','','2005_0908Image0051LT_thumb.jpg',130, 98,32,'photo_6484438.html');
												thumbnails[6844251] = new thumbnail(6844251,'357173','Family pets','dogsbirdsLT_thumb.jpg',130, 89,32,'photo_6844251.html');
												thumbnails[6484454] = new thumbnail(6484454,'357173','','DSC00079LT_thumb.jpg',130, 231,32,'photo_6484454.html');
												thumbnails[6484451] = new thumbnail(6484451,'357173','','Cocker_spanielLT_thumb.jpg',130, 173,32,'photo_6484451.html');

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  					galleries[357169] = new gallery(357169,'6846283,6846268,6846262,6846254,6846246,6846236,6846225,6846221,6846212,6846206','Colour Photographs','gallery',[6840414,6841717,6841771,6841784,6843416,6843529,6843558,6844591,6844897,6844901,6844907,6844908,6844949,6844962,6844964,6844969,6846088,6846094,6846097,6846105,6846118,6846124,6846130,6846135,6846141,6846147,6846155,6846159,6846163,6846167,6846179,6846184,6846190,6846199,6846204,6846206,6846212,6846221,6846225,6846236,6846246,6846254,6846262,6846268,6846283,6665722,6665776],0, 0, '', 'gallery_357169.html',0,0);
				  					galleries[371532] = new gallery(371532,'6841704,6841669,6841659,6841644,6841565,6841556,6841543,6841528,6841522,6841518','Monochrome Photographs','gallery',[6841322,6841330,6841337,6841358,6841372,6841375,6841384,6841393,6841401,6841409,6841497,6841518,6841522,6841528,6841543,6841556,6841565,6841644,6841659,6841669,6841704],0, 0, '', 'gallery_371532.html',0,0);
				  					galleries[357170] = new gallery(357170,'6844581,6844573,6844568,6844455,6844450,6844444,6844437,6844429,6844424,6844336','Paintings','gallery',[6842948,6844269,6844336,6844424,6844429,6844437,6844444,6844450,6844455,6844568,6844573,6844581],0, 0, '', 'gallery_357170.html',0,0);
				  					galleries[357173] = new gallery(357173,'6484438','Pet portraits','gallery',[6842668,6842716,6842960,6843104,6843108,6843112,6843114,6844024,6844036,6844105,6844156,6844175,6844235,6844242,6844244,6844256,6844495,6844576,6844590,6842686,6484445,6842971,6484438,6844251,6484454,6484451],0, 0, '', 'gallery_357173.html',0,0);
/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = new Object();
imageSets[1] = '6846283,6846268,6846262,6846254,6846246,6846236,6846225,6846221,6846212,6846206,6846204,6846199,6846190,6846184,6846179,6846167,6846163,6846159,6846155,6846147,6846141,6846135,6846130,6846124,6846118,6846105,6846097,6846094,6846088,6844969,6844964,6844962,6844949,6844908,6844907,6844901,6844897,6844591,6844590,6844581,6844576,6844573,6844568,6844495,6844455,6844450,6844444,6844437,6844429,6844424';
imageSets[2] = '6484438';
imageSets[3] = '6846283,6846268,6846262,6846254,6846246,6846236,6846225,6846221,6846212,6846206,6846204,6846199,6846190,6846184,6846179,6846167,6846163,6846159,6846155,6846147,6846141,6846135,6846130,6846124,6846118,6846105,6846097,6846094,6846088,6844969,6844964,6844962,6844949,6844908,6844907,6844901,6844897,6844591,6844590,6844581,6844576,6844573,6844568,6844495,6844455,6844450,6844444,6844437,6844429,6844424';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/bjtopham/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/bjtopham/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/bjtopham/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/bjtopham/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/bjtopham/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/bjtopham/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/bjtopham/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/bjtopham/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/bjtopham/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/bjtopham/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/bjtopham/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/bjtopham/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/bjtopham/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/bjtopham/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/bjtopham/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://admin2.clikpic.com/bjtopham/images';
		break;
	}
		switch (server_id) {
		case 33:
		val = 'http://www8.clikpic.com/bjtopham/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/bjtopham/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/bjtopham/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/bjtopham/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/bjtopham/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/bjtopham/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 = 'topicart: ' + photoCaption;
			    }
        if (op.$detail.length > 0) {
      temp = op.nextPhoto.fnGetImageDetails();
	    op.$detail.fadeGalleryDetails(temp, op.speed, function(){
	    var options = {};	    	      	      resizePhotoInfo(options);
        if (typeof(backgrounds) != 'undefined' && op.nextPhoto == backgrounds[op.nextPhoto.id]) {
  	      toggleAddToCartConfirm(backgrounds);
  	    } else if (typeof(photos) != 'undefined' && op.nextPhoto == photos[op.nextPhoto.id]) {
  	      toggleAddToCartConfirm(photos);
  	    }
	    });
    }
        if (!op.speed) {      clik.doColumnResize(false, op.$photo.add(op.$detail).add(op.$title));      $('body').trigger('clikUpdate');    }        
    return html;			}
	else {
				
		window.location = 'photo_' + nextPhoto.id + '.html';
	}
		
}

/***************************************************************************
* Toggle add to cart confirmation element and set up the click event for   *
* the 'Add to cart' button.                                                *
***************************************************************************/
function toggleAddToCartConfirm(array){
  if (typeof(array) !== 'object' || array == undefined) {
    array = photos;
  }
	if($('#paymentConfirm').length > 0){
		$('#paymentConfirm').hide();
		$('#paymentAddButton')
		.unbind()
		.click(function(){
						form = document.getElementById('paymentForm');
			option_id = 0;
			if(form.item_option.value){
				option_id = form.item_option.value;
			}
			if(addItemToBasket(form.item_number.value,array,form.site.value,parseInt(form.quantity.value, 10),option_id)){
				if($.browser.msie){$('#paymentConfirm').text('Item added to cart').show();}
				else{
					$('#paymentConfirm').text('Item added to cart').fadeIn();
					dspOrderDetails(form.site.value);
				}
			}
			else{
				$('#paymentConfirm').text('Item not added - check cookies are enabled in your browser.').fadeIn();
			}
		});
	}
}
/***************************************************************************
* Get payment info for image - add as 'method' to photo object             *
***************************************************************************/
photo.prototype.fnGetImageDetails = function(){
	var temp = '';
	if (this.description != '') {
		temp = temp +  '<p id="imageDescription">' + this.description + '</p>';
	}
		if (this.photo_ref != '') {
		temp = temp + '<p class="imageinfo" id="imageRef"><strong>Ref: </strong>' + this.photo_ref + '</p>';
	}
		if (this.takendate != '') {
				
		temp = temp + '<p class="imageinfo" id="imageDate"><strong>Date: </strong>' + this.takendate + '</p>';
	}
	
	if (this.location != '') {
				
		temp = temp + '<p class="imageinfo" id="imageLocation"><strong>Location: </strong>' +  this.location + '</p>';
	}
	
	if (this.photographer != '') {
				
		temp = temp + '<p class="imageinfo" id="imagePhotographer"><strong>Artist/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;
	}
}

			

