window.thumbnails = new Object();
												thumbnails[7063404] = new thumbnail(7063404,'89913','<strong>Calm</strong>','Calm_thumb.JPG',130, 87,18,'photo_7063404.html');
												thumbnails[5458339] = new thumbnail(5458339,'381593','<strong>Chalice Stream</strong>','166_Chalice_Stream_thumb.JPG',130, 87,18,'photo_5458339.html');
												thumbnails[2903624] = new thumbnail(2903624,'381594','<strong>Forgotten</strong>','108_thumb. Forgotten.JPG',130, 86,18,'photo_2903624.html');
												thumbnails[2045892] = new thumbnail(2045892,'381595','<strong>Houghton Bridge</strong>','50_thumb. Houghton Bridge.JPG',87, 130,18,'photo_2045892.html');
												thumbnails[7063407] = new thumbnail(7063407,'89913','<strong>Flag and Fog</strong>','Flag_and_Fog_thumb.JPG',130, 87,18,'photo_7063407.html');
												thumbnails[5458368] = new thumbnail(5458368,'381593','<strong>Looking Down</strong>','173_Looking_Down_thumb.jpg',130, 87,18,'photo_5458368.html');
												thumbnails[1839343] = new thumbnail(1839343,'381594','<strong>Cathedral View</strong>','29_thumb. Cathedral View.JPG',130, 88,18,'photo_1839343.html');
												thumbnails[1747089] = new thumbnail(1747089,'381595','<strong>Buoys (borrowed)</strong>','17 - Beach Image_thumb.JPG',88, 130,18,'photo_1747089.html');
												thumbnails[7055799] = new thumbnail(7055799,'89913','<strong>Eyes of Blue</strong>','Edwin_1_thumb.JPG',130, 87,18,'photo_7055799.html');
												thumbnails[5458375] = new thumbnail(5458375,'381593','<strong>Sagrada</strong>','174_Sagrada_thumb.jpg',130, 87,18,'photo_5458375.html');
												thumbnails[1086402] = new thumbnail(1086402,'381594','<strong>Boat and flags</strong>','SM214_thumb.jpg',87, 130,18,'photo_1086402.html');
												thumbnails[884454] = new thumbnail(884454,'381595','<strong>Tombstone, Offington Cemetery</strong> ','Angel_thumb.jpg',130, 98,18,'photo_884454.html');
												thumbnails[7063412] = new thumbnail(7063412,'89913','<strong>Flora and Sea</strong>','Flora_and_Sea_thumb.JPG',87, 130,18,'photo_7063412.html');
												thumbnails[5458391] = new thumbnail(5458391,'381593','<strong>Barca Sunset</strong>','178_Barca_Sunset_thumb.jpg',87, 130,18,'photo_5458391.html');
												thumbnails[1364164] = new thumbnail(1364164,'381594','<strong>A River Magnified</strong>','Magnified River_thumb.jpg',130, 87,18,'photo_1364164.html');
												thumbnails[1364169] = new thumbnail(1364169,'381595','<strong>Shoreham Sunset</strong>','Shoreham Sunset_thumb.jpg',87, 130,18,'photo_1364169.html');
												thumbnails[7063425] = new thumbnail(7063425,'89913','<strong>Kea Peaks</strong>','Kea_Peaks_thumb.JPG',130, 87,18,'photo_7063425.html');
												thumbnails[3402772] = new thumbnail(3402772,'381595','<strong>Pompeiian Reflections</strong>','126_thumb. Pompeiian Reflections.JPG',87, 130,18,'photo_3402772.html');
												thumbnails[3402764] = new thumbnail(3402764,'381594','<strong>Roman Glade</strong>','123_thumb. Roman Glade.JPG',87, 130,18,'photo_3402764.html');
												thumbnails[2368114] = new thumbnail(2368114,'381593','<strong>Rye Artist</strong>','85_thumb. Rye Artist 1.JPG',130, 88,18,'photo_2368114.html');
												thumbnails[7063422] = new thumbnail(7063422,'89913','<strong>Growing Above The Clouds</strong>','Growing_Above_The_Clouds_thumb.JPG',130, 87,18,'photo_7063422.html');
												thumbnails[7055800] = new thumbnail(7055800,'89913','<strong>Carry On Smiling</strong>','Smile_Again_thumb.JPG',130, 87,18,'photo_7055800.html');
												thumbnails[2903623] = new thumbnail(2903623,'381593','<strong>Cissbury Sunrise</strong>','107_thumb. Cussbury Sunrise.JPG',130, 66,18,'photo_2903623.html');
												thumbnails[1839332] = new thumbnail(1839332,'381594','<strong>A Winter’s Morning</strong>','26_thumb. A Winter\'s Morning.JPG',88, 130,18,'photo_1839332.html');
												thumbnails[1262840] = new thumbnail(1262840,'381595','<strong>Millennium Bridge</strong>','Millennium Bridge Two_thumb.jpg',87, 130,18,'photo_1262840.html');
												thumbnails[7063427] = new thumbnail(7063427,'89913','<strong>Kona Sunset</strong>','Kona_Sunset_thumb.JPG',87, 130,18,'photo_7063427.html');
												thumbnails[2181796] = new thumbnail(2181796,'381595','<strong>Brighton Panorama</strong>','74_thumb. Brighton Panorama.jpg',130, 43,18,'photo_2181796.html');
												thumbnails[1747047] = new thumbnail(1747047,'381593','<strong>Kenyan Track</strong>','01 - Kenya_thumb.JPG',87, 130,18,'photo_1747047.html');
												thumbnails[938201] = new thumbnail(938201,'381594','<strong>Bluebell copse near Ashurst</strong>','Bluebell Wood_thumb.jpg',97, 130,18,'photo_938201.html');
												thumbnails[7063456] = new thumbnail(7063456,'89913','<strong>Observing</strong>','Observing_thumb.JPG',87, 130,18,'photo_7063456.html');
												thumbnails[1747083] = new thumbnail(1747083,'381593','<strong>Worthing sunset</strong>','14 - Worthing_thumb.JPG',130, 87,18,'photo_1747083.html');
												thumbnails[1510043] = new thumbnail(1510043,'381595','<strong>Mombasa Sunrise</strong>','8_thumb. Mombasa Sunrise.jpg',87, 130,18,'photo_1510043.html');
												thumbnails[1086394] = new thumbnail(1086394,'381594','<strong>Pier Reflection</strong>','Pier Reflection_thumb.jpg',87, 130,18,'photo_1086394.html');
												thumbnails[7055801] = new thumbnail(7055801,'89913','<strong>Ta-Dah!!</Strong>','Ta_Dah_thumb.JPG',130, 122,18,'photo_7055801.html');
												thumbnails[2368065] = new thumbnail(2368065,'381594','<strong>Peach on Blue</strong>','76_thumb. Peach on Blue.JPG',130, 85,18,'photo_2368065.html');
												thumbnails[2180395] = new thumbnail(2180395,'381595','<strong>Exotic Flower</strong>','64_thumb. Exotic Flower.jpg',130, 87,18,'photo_2180395.html');
												thumbnails[985051] = new thumbnail(985051,'381593','<strong>Tunis Beach</strong>','Tunis Beach_thumb.jpg',130, 104,18,'photo_985051.html');
												thumbnails[7063418] = new thumbnail(7063418,'89913','<strong>Flora and Sea Too</strong>','Flora_and_Sea_Too_thumb.JPG',130, 87,18,'photo_7063418.html');
												thumbnails[8154459] = new thumbnail(8154459,'434874','<strong>Transamerica Pyramid</strong>','IMG_1517_thumb.JPG',87, 130,18,'photo_8154459.html');
												thumbnails[2181790] = new thumbnail(2181790,'381593','<strong>Graffiti & Nature</strong>','69_thumb. Graffiti and Nature.JPG',130, 87,18,'photo_2181790.html');
												thumbnails[1747064] = new thumbnail(1747064,'381595','<strong>Lunchtime</strong>','06 - Kenya_thumb.JPG',130, 87,18,'photo_1747064.html');
												thumbnails[1747062] = new thumbnail(1747062,'381594','<strong>Vervet Monkey</strong>','05 - Kenya_thumb.JPG',130, 87,18,'photo_1747062.html');
												thumbnails[7063457] = new thumbnail(7063457,'89913','<strong>Peeking Thru</strong>','Peeking_Thru_thumb.JPG',130, 87,18,'photo_7063457.html');
												thumbnails[3402780] = new thumbnail(3402780,'381595','<strong>Moment in Time</strong>','128_thumb. Moment In Time.JPG',130, 87,18,'photo_3402780.html');
												thumbnails[1510031] = new thumbnail(1510031,'381593','<strong>Mudbath</strong>','4_thumb. Mudbath.jpg',130, 87,18,'photo_1510031.html');
												thumbnails[1747066] = new thumbnail(1747066,'381594','<strong>Dusting down</strong>','07 - Kenya_thumb.JPG',130, 87,18,'photo_1747066.html');
												thumbnails[7055802] = new thumbnail(7055802,'89913','<strong>Tasty</strong>','Edwin_2_thumb.JPG',130, 93,18,'photo_7055802.html');
												thumbnails[3402788] = new thumbnail(3402788,'381593','<strong>Square Colosseum</strong>','131_thumb. Square Colosseum.JPG',130, 87,18,'photo_3402788.html');
												thumbnails[2574527] = new thumbnail(2574527,'381594','<strong>Industrial Battersea</strong>','102_thumb. Industrial Battersea.JPG',88, 130,18,'photo_2574527.html');
												thumbnails[1747078] = new thumbnail(1747078,'381595','<strong>Water Tower, Cardiff Bay</strong>','12 - Cardiff_thumb.JPG',87, 130,18,'photo_1747078.html');
												thumbnails[7063460] = new thumbnail(7063460,'89913','<strong>San Scraper</strong>','San_Scraper_thumb.jpg',130, 87,18,'photo_7063460.html');
												thumbnails[2903622] = new thumbnail(2903622,'381594','<strong>Bowsprit</strong>','106_thumb. Bowsprit.jpg',130, 86,18,'photo_2903622.html');
												thumbnails[2572457] = new thumbnail(2572457,'381595','<strong>Paperclips</strong>','91_thumb. Paperclips.JPG',130, 85,18,'photo_2572457.html');
												thumbnails[1747076] = new thumbnail(1747076,'381593','<strong>Water Tower reflected</strong>','11 - Cardiff_thumb.jpg',87, 130,18,'photo_1747076.html');
												thumbnails[7063461] = new thumbnail(7063461,'89913','<strong>Transamerica</strong>','Transamerica_thumb.JPG',87, 130,18,'photo_7063461.html');
												thumbnails[2574534] = new thumbnail(2574534,'381593','<strong>Athletic Expectation</strong>','104_thumb. Athletic Expectation.JPG',130, 88,18,'photo_2574534.html');
												thumbnails[2572531] = new thumbnail(2572531,'381594','<strong>LCDR Crest</strong>','99_thumb. LCDR Crest.jpg',130, 88,18,'photo_2572531.html');
												thumbnails[2045888] = new thumbnail(2045888,'381595','<strong>Light Reflected</strong>','47_thumb. Light reflected.jpg',130, 87,18,'photo_2045888.html');
												thumbnails[7055803] = new thumbnail(7055803,'89913','<strong>Start as you mean to continue...</Strong>','Start_As_You_Mean_To_Go_On_thumb.JPG',130, 87,18,'photo_7055803.html');
												thumbnails[3402783] = new thumbnail(3402783,'381595','<strong>Three Pillars of Rome</strong>','129_thumb. Three Pillars of Rome.JPG',130, 87,18,'photo_3402783.html');
												thumbnails[3402776] = new thumbnail(3402776,'381594','<strong>A Cry From History</strong>','127_thumb. A Cry from History.JPG',130, 87,18,'photo_3402776.html');
												thumbnails[1364170] = new thumbnail(1364170,'381593','<strong>Wood and Metal</strong>','Wood and Metal_thumb.jpg',130, 87,18,'photo_1364170.html');
												thumbnails[7063464] = new thumbnail(7063464,'89913','<strong>Walkway</strong>','Walkway_thumb.JPG',87, 130,18,'photo_7063464.html');
												thumbnails[4388965] = new thumbnail(4388965,'381595','<strong>Behind You</strong>','146_Behind_You_thumb.jpg',87, 130,18,'photo_4388965.html');
												thumbnails[2045881] = new thumbnail(2045881,'381594','<strong>Canal Afternoon</strong>','41_thumb. Canal Walk.JPG',130, 87,18,'photo_2045881.html');
												thumbnails[2045883] = new thumbnail(2045883,'381593','<strong>Romantic Amsterdam</strong>','42_thumb. Romantic Amsterdam.jpg',87, 130,18,'photo_2045883.html');
												thumbnails[7063467] = new thumbnail(7063467,'89913','<strong>Water Tower</strong>','Water_Tower_thumb.jpg',130, 87,18,'photo_7063467.html');
												thumbnails[4388972] = new thumbnail(4388972,'381595','<strong>Confetti</strong>','151_Confetti_thumb.jpg',130, 87,18,'photo_4388972.html');
												thumbnails[2045885] = new thumbnail(2045885,'381593','<strong>Zuiderkerk</strong>','44_thumb. Zuiderkerk.jpg',88, 130,18,'photo_2045885.html');
												thumbnails[3757173] = new thumbnail(3757173,'381594','<strong>Sophie</strong>','143_Sophie_2_thumb.jpg',87, 130,18,'photo_3757173.html');
												thumbnails[7055804] = new thumbnail(7055804,'89913','<strong>One, Two, Three...</strong>','One_Two_Three_thumb.JPG',87, 130,18,'photo_7055804.html');
												thumbnails[2574531] = new thumbnail(2574531,'381593','<strong>Athletic Power</strong>','103_thumb. Athletic Power.jpg',130, 87,18,'photo_2574531.html');
												thumbnails[3757177] = new thumbnail(3757177,'381594','<strong>Dennis Four</strong>','144_Dennis_3_thumb.jpg',87, 130,18,'photo_3757177.html');
												thumbnails[7048301] = new thumbnail(7048301,'381595','<strong>Keep Clear?</strong>','Keep_Clear_thumb.jpg',111, 130,18,'photo_7048301.html');
												thumbnails[4388969] = new thumbnail(4388969,'381594','<strong>Modern Technology</strong>','149_Modern_Technology_thumb.jpg',130, 87,18,'photo_4388969.html');
												thumbnails[2903625] = new thumbnail(2903625,'381593','<strong>A Joke Cracked</strong>','109_thumb. A Joke Cracked.JPG',130, 86,18,'photo_2903625.html');
												thumbnails[7048296] = new thumbnail(7048296,'381595','<strong>Horse & Rider</strong>','Horse_and_rider_thumb.jpg',87, 130,18,'photo_7048296.html');
												thumbnails[8154477] = new thumbnail(8154477,'434874','<strong>Alcatraz Water Tower</strong>','IMG_1609b_thumb.jpg',98, 130,18,'photo_8154477.html');
												thumbnails[4388976] = new thumbnail(4388976,'381594','<strong>Conducting</strong>','155_Conducting_thumb.JPG',130, 87,18,'photo_4388976.html');
												thumbnails[4388971] = new thumbnail(4388971,'381593','<strong>Retouch</strong>','150_Retouch_thumb.jpg',130, 87,18,'photo_4388971.html');
												thumbnails[7048340] = new thumbnail(7048340,'381595','<strong>Tyne Bridge</strong>','Tyne_Bridge_thumb.jpg',66, 130,18,'photo_7048340.html');
												thumbnails[7048285] = new thumbnail(7048285,'381593','<strong>Brighton Grafitti</strong>','Brighton_Graffiti_thumb.JPG',89, 130,18,'photo_7048285.html');
												thumbnails[7048310] = new thumbnail(7048310,'381593','<strong>Nile Morning</strong>','Nile_Morning_thumb.jpg',130, 98,18,'photo_7048310.html');
												thumbnails[7048314] = new thumbnail(7048314,'381593','<strong>Pier Amusements</strong>','Pier_Amusements_thumb.jpg',130, 87,18,'photo_7048314.html');
												thumbnails[7048321] = new thumbnail(7048321,'381593','<strong>Sage</strong>','Sage_thumb.jpg',130, 87,18,'photo_7048321.html');
												thumbnails[8154436] = new thumbnail(8154436,'434874','<strong>San Francisco Office Building</strong>','IMG_1447b_thumb.jpg',98, 130,18,'photo_8154436.html');
												thumbnails[8154489] = new thumbnail(8154489,'434874','<strong>Keymer Windmill</strong>','IMG_2346_thumb.JPG',87, 130,18,'photo_8154489.html');
												thumbnails[8154563] = new thumbnail(8154563,'434874','<strong>Keymer Blades</strong>','IMG_2347_thumb.JPG',130, 93,18,'photo_8154563.html');
												thumbnails[8154580] = new thumbnail(8154580,'434874','<strong>Holy Thorn</strong>','IMG_2524_thumb.JPG',130, 87,18,'photo_8154580.html');
												thumbnails[8154619] = new thumbnail(8154619,'434874','<strong>Tor Panorama</strong>','Tor_panorama_thumb.jpg',130, 87,18,'photo_8154619.html');
												thumbnails[8154622] = new thumbnail(8154622,'434874','<strong>Worthing Wording</strong>','Worthing_6x4_thumb.jpg',130, 87,18,'photo_8154622.html');

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  					galleries[434874] = new gallery(434874,'8154622,8154619,8154563,8154489,8154477,8154459,8154436','Worthing Open Houses 2011','gallery',[8154459,8154477,8154436,8154489,8154563,8154580,8154619,8154622],0, 0, '', 'gallery_434874.html',0,0);
				  					galleries[89913] = new gallery(89913,'7063467,7063464,7063461,7063460,7063457,7063456,7063427,7063425,7063422,7063418,7063412,7063407,7063404,7055804,7055803,7055802,7055801,7055800,7055799','New Images','gallery',[7063404,7063407,7055799,7063412,7063425,7063422,7055800,7063427,7063456,7055801,7063418,7063457,7055802,7063460,7063461,7055803,7063464,7063467,7055804],0, 0, '', 'gallery_89913.html',0,0);
				  					galleries[381593] = new gallery(381593,'7048321,7048314,7048285,5458375,5458368,5458339,3402788,2903625,2903623,2574534,2574531,2368114,2181790,2045885,2045883,1747083,1747076,1747047,1510031,1364170,985051','Gallery One','gallery',[5458339,5458368,5458375,5458391,2368114,2903623,1747047,1747083,985051,2181790,1510031,3402788,1747076,2574534,1364170,2045883,2045885,2574531,2903625,4388971,7048285,7048310,7048314,7048321],0, 0, '', 'gallery_381593.html',0,0);
				  					galleries[381594] = new gallery(381594,'3757177,3757173,3402776,3402764,2903624,2903622,2574527,2572531,2368065,2045881,1839332,1747066,1364164,1086402,1086394,938201','Gallery Two','gallery',[2903624,1839343,1086402,1364164,3402764,1839332,938201,1086394,2368065,1747062,1747066,2574527,2903622,2572531,3402776,2045881,3757173,3757177,4388969,4388976],0, 0, '', 'gallery_381594.html',0,0);
				  					galleries[381595] = new gallery(381595,'7048340,7048296,3402783,3402780,3402772,2572457,2181796,2180395,2045892,2045888,1747078,1747064,1510043,1364169,1262840','Gallery Three','gallery',[2045892,1747089,884454,1364169,3402772,1262840,2181796,1510043,2180395,1747064,3402780,1747078,2572457,2045888,3402783,4388965,4388972,7048301,7048296,7048340],0, 0, '', 'gallery_381595.html',0,0);
/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = new Object();
imageSets[1] = '8154622,8154619,8154580,8154563,8154489,8154477,8154459,8154436,7063467,7063464,7063461,7063460,7063457,7063456,7063427,7063425,7063422,7063418,7063412,7063407,7063404,7055804,7055803,7055802,7055801,7055800,7055799,7048340,7048321,7048314,7048301,7048296,7048285,5458391,5458375,5458368,5458339,1747083,1747078,1747076,1510031,1364170,1364169,1364164,1262840,1086394,938201,884454';
imageSets[2] = '8154622,8154619,8154563,8154489,8154477,8154459,8154436,7063467,7063464,7063461,7063460,7063457,7063456,7063427,7063425,7063422,7063418,7063412,7063407,7063404,7055804,7055803,7055802,7055801,7055800,7055799,7048340,7048321,7048314,7048296,7048285,5458375,5458368,5458339,3757177,3757173,3402788,3402783,3402780,3402776,3402772,3402764,2903625,2903624,2903623,2903622,2574534,2574531,2574527,2572531,2572457,2368114,2368065,2181796,2181790,2180395,2045892,2045888,2045885,2045883,2045881,1839332,1747083,1747078,1747076,1747066,1747064,1747047,1510043,1510031,1364170,1364169,1364164,1262840,1086402,1086394,985051,938201';
imageSets[3] = '8154622,8154619,8154580,8154563,8154489,8154477,8154459,8154436,7063467,7063464,7063461,7063460,7063457,7063456,7063427,7063425,7063422,7063418,7063412,7063407,7063404,7055804,7055803,7055802,7055801,7055800,7055799,7048340,7048321,7048314,7048310,7048301,7048296,7048285,5458391,5458375,5458368,5458339,4388976,4388972,4388971,4388969,4388965,3757177,3757173,3402788,3402783,3402780,3402776,3402772';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/RichardCK/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/RichardCK/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/RichardCK/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/RichardCK/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/RichardCK/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/RichardCK/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/RichardCK/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/RichardCK/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/RichardCK/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/RichardCK/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/RichardCK/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/RichardCK/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/RichardCK/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/RichardCK/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/RichardCK/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://admin2.clikpic.com/RichardCK/images';
		break;
	}
		switch (server_id) {
		case 33:
		val = 'http://www8.clikpic.com/RichardCK/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/RichardCK/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/RichardCK/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/RichardCK/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/RichardCK/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/RichardCK/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 = 'Cooper-Knight Photography: ' + photoCaption;
			    }
        if (op.$detail.length > 0) {
      temp = op.nextPhoto.fnGetImageDetails();
	    op.$detail.fadeGalleryDetails(temp, op.speed, function(){
	    var options = {photoinfominwidth:200};	    		options.photoinfoadjacent = true;			      	      resizePhotoInfo(options);
        if (typeof(backgrounds) != 'undefined' && op.nextPhoto == backgrounds[op.nextPhoto.id]) {
  	      toggleAddToCartConfirm(backgrounds);
  	    } else if (typeof(photos) != 'undefined' && op.nextPhoto == photos[op.nextPhoto.id]) {
  	      toggleAddToCartConfirm(photos);
  	    }
	    });
    }
        if (!op.speed) {      clik.doColumnResize(false, op.$photo.add(op.$detail).add(op.$title));      $('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>Photographer: </strong>' + this.photographer + '</p>';
	}
					
	temp = temp + this.fnGetPaymentInfo();
				if (temp != '') {
		temp = temp + '<div class="spacer"></div>';
	}
	return temp;
};

/***************************************************************************
* Get payment info for image - add as 'method' to photo object             *
***************************************************************************/
photo.prototype.fnGetPaymentInfo = function(){
	var temp = '';
	if (this.item_price !== '') {
																		temp = temp + '<p>Buy now using PayPal:</p>';
				temp = temp + '<p class="imageinfo" id="imagePrice"><strong>' + this.purchase_instruction + '</strong> &pound;' + (this.item_price).toFixed(2) + '</p>';
		var item_name  = this.purchase_instruction;
		var amount = (this.item_price).toFixed(2);
		var item_option  = 0;
	}
	else if (this.payment_groups_id !== '') {
		temp = temp + '<p>Buy this print online:</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="cooperknights@yahoo.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="cooperknights@yahoo.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;
	}
}

			

