window.thumbnails = {};
thumbnails[9140895] = clik.newPhoto({"link":"#","caption":"","height":114,"id":9140895,"server_id":31,"src":"cLong_Tailed_Tits_in_the_Rain_1_thumb.jpg","galleries_id":"","width":160});
thumbnails[9140896] = clik.newPhoto({"link":"#","caption":"","height":116,"id":9140896,"server_id":31,"src":"Curves_Peter_Young_CPAGB_APAGB_1_thumb.jpg","galleries_id":"","width":160});
thumbnails[9140897] = clik.newPhoto({"link":"#","caption":"","height":119,"id":9140897,"server_id":31,"src":"Edinburgh_on_a_Winters_Evening_Ted_Sturgeon_LRPS_1_thumb.jpg","galleries_id":"","width":160});
thumbnails[9140898] = clik.newPhoto({"link":"#","caption":"","height":104,"id":9140898,"server_id":31,"src":"Eilean_Donan_Castle_1_thumb.jpg","galleries_id":"","width":160});
thumbnails[9140899] = clik.newPhoto({"link":"#","caption":"","height":129,"id":9140899,"server_id":31,"src":"Harley_Man_-_John_Long_ARPS_DPAGB_Hon_APAGB_1_thumb.jpg","galleries_id":"","width":160});
thumbnails[8503032] = clik.newPhoto({"link":"photo_8503032.html","caption":"","height":116,"id":8503032,"server_id":31,"src":"c29_06_Grandmothers_Kiss_Ann_McDonald_ARPS_DPAGB_thumb.jpg","galleries_id":422738,"width":160});
thumbnails[8503038] = clik.newPhoto({"link":"photo_8503038.html","caption":"","height":116,"id":8503038,"server_id":31,"src":"c29_09_Bonding_Gannets_Martin_Stephenson_thumb.jpg","galleries_id":422738,"width":160});
thumbnails[8503042] = clik.newPhoto({"link":"photo_8503042.html","caption":"","height":116,"id":8503042,"server_id":31,"src":"c45_11_Stoat_Steve_Chadd_thumb.jpg","galleries_id":422738,"width":160});
thumbnails[8503043] = clik.newPhoto({"link":"photo_8503043.html","caption":"","height":116,"id":8503043,"server_id":31,"src":"c46_05_Black_Tailed_Godwit_Philip_Mugridge_ARPS_thumb.jpg","galleries_id":422738,"width":160});
thumbnails[8503046] = clik.newPhoto({"link":"photo_8503046.html","caption":"","height":116,"id":8503046,"server_id":31,"src":"c71_07_Tulip_Starlight_Impression_Brian_Barkley_thumb.jpg","galleries_id":422738,"width":160});
thumbnails[8503048] = clik.newPhoto({"link":"photo_8503048.html","caption":"","height":116,"id":8503048,"server_id":31,"src":"c73_06_Christine_Langford_LRPS_CPAGB_APAGB_Gap_in_the_Clouds_thumb.jpg","galleries_id":422738,"width":160});
thumbnails[8503050] = clik.newPhoto({"link":"photo_8503050.html","caption":"","height":116,"id":8503050,"server_id":31,"src":"c74_02_David_Brian_John_McCarthy_thumb.jpg","galleries_id":422738,"width":160});
thumbnails[8503057] = clik.newPhoto({"link":"photo_8503057.html","caption":"Circle Certificate - Lisianthus #2","height":294,"id":8503057,"server_id":31,"src":"c2.25_Cert__Lisianthus_2-Phil_Smith_thumb.jpg","galleries_id":449436,"width":160});
thumbnails[8503069] = clik.newPhoto({"link":"photo_8503069.html","caption":"Circle Certificate - Lost","height":100,"id":8503069,"server_id":31,"src":"c3_Cert_Lost_Howard_Fisher_LRPS_CPAGB_thumb.jpg","galleries_id":449436,"width":160});
thumbnails[8503075] = clik.newPhoto({"link":"photo_8503075.html","caption":"Circle Certificate - Reed Warbler Singing","height":224,"id":8503075,"server_id":31,"src":"c4_Cert_Reed_Warbler_Singing_David_Venables_DPAGB_APAGB_BPE3_thumb.jpg","galleries_id":449436,"width":160});
thumbnails[8503078] = clik.newPhoto({"link":"photo_8503078.html","caption":"Circle Certificate - Fagin Hiding in the Shadows","height":233,"id":8503078,"server_id":31,"src":"c5_Cert_Fagin_Hiding_in_the_Shadows_-_Nick_Bodle_thumb.jpg","galleries_id":449436,"width":160});
thumbnails[8503081] = clik.newPhoto({"link":"photo_8503081.html","caption":"Circle Certificate - Shafts of Light","height":212,"id":8503081,"server_id":31,"src":"c7_Cert_Shafts_of_Light_Fay_Palmer_thumb.jpg","galleries_id":449436,"width":160});
thumbnails[8503083] = clik.newPhoto({"link":"photo_8503083.html","caption":"Circle Certificate - Long-tailed Tits in the Rain","height":114,"id":8503083,"server_id":31,"src":"c9_Cert_Long_Tailed_Tits_in_the_Rain_Ken_Dickenson_DPAGB_BPE2_thumb.jpg","galleries_id":449436,"width":160});
thumbnails[8503086] = clik.newPhoto({"link":"photo_8503086.html","caption":"Circle Certificate - Curves","height":116,"id":8503086,"server_id":31,"src":"c10_Cert_Curves_Peter_Young_CPAGB_APAGB_thumb.jpg","galleries_id":449436,"width":160});
thumbnails[8503088] = clik.newPhoto({"link":"photo_8503088.html","caption":"Circle Certificate - Therfield in Winter","height":109,"id":8503088,"server_id":31,"src":"c11_Cert_Therfield_in_Winter_Bob_Norris_thumb.jpg","galleries_id":449436,"width":160});
thumbnails[8503092] = clik.newPhoto({"link":"photo_8503092.html","caption":"Circle Certificate - The Old Printing Shop","height":123,"id":8503092,"server_id":31,"src":"c12_Cert_The_Old_Printing_Shop_Gordon_Dunford_thumb.jpg","galleries_id":449436,"width":160});
thumbnails[8503093] = clik.newPhoto({"link":"photo_8503093.html","caption":"Circle Certificate - Safety First","height":246,"id":8503093,"server_id":31,"src":"c14_Cert_Safety_First_Roy_Jones_thumb.jpg","galleries_id":449436,"width":160});
thumbnails[8503128] = clik.newPhoto({"link":"photo_8503128.html","caption":"Circle Certificate - Harley Man","height":129,"id":8503128,"server_id":31,"src":"c17.21_Cert_Harley_Man_-_John_Long_ARPS_DPAGB_Hon.PAGB_thumb.jpg","galleries_id":449436,"width":160});
thumbnails[8503131] = clik.newPhoto({"link":"photo_8503131.html","caption":"Circle Certificate - A Splash of Light","height":108,"id":8503131,"server_id":31,"src":"c19_Cert_A_Splash_of_Light_Ray_Grace_ARPS_DPAGB_thumb.jpg","galleries_id":449436,"width":160});
thumbnails[8503133] = clik.newPhoto({"link":"photo_8503133.html","caption":"Circle Certificate - Wood Mouse","height":105,"id":8503133,"server_id":31,"src":"c23.34_Cert_Wood_Mouse_Derek_Larkin_EFIAP_BPE4_thumb.jpg","galleries_id":449436,"width":160});
thumbnails[8503136] = clik.newPhoto({"link":"photo_8503136.html","caption":"Circle Certificate - Peace","height":109,"id":8503136,"server_id":31,"src":"c26_Cert_Peace_Gayle_Kirton_thumb.jpg","galleries_id":449436,"width":160});
thumbnails[8503164] = clik.newPhoto({"link":"photo_8503164.html","caption":"Circle Certificate - York Minster","height":250,"id":8503164,"server_id":31,"src":"c28_Cert_York_Minster_Roy_Jamieson_LRPS_CPAGB_thumb.jpg","galleries_id":449436,"width":160});
thumbnails[8503221] = clik.newPhoto({"link":"photo_8503221.html","caption":"Highly Commended - Dawn Blakey Ridge","height":120,"id":8503221,"server_id":31,"src":"c29_HC_Dawn_Blakey_Ridge_Chris_Aldred_ARPS_CPAGB_thumb.jpg","galleries_id":449436,"width":160});
thumbnails[8503234] = clik.newPhoto({"link":"photo_8503234.html","caption":"Highly Commended - Nuthatch","height":105,"id":8503234,"server_id":31,"src":"c29_HC_Nuthatch_John_Bulpitt_FRPS_thumb.jpg","galleries_id":449436,"width":160});
thumbnails[8503239] = clik.newPhoto({"link":"photo_8503239.html","caption":"Highly Commended - Winter Waves","height":82,"id":8503239,"server_id":31,"src":"c29_HC_Winter_Waves_Barbara_Myers_LRPS_CPAGB_thumb.jpg","galleries_id":449436,"width":160});
thumbnails[8503241] = clik.newPhoto({"link":"photo_8503241.html","caption":"Circle Certificate - Close encounters","height":105,"id":8503241,"server_id":31,"src":"c31_Cert_Close_Encounters_-_Ken_Dickenson_DPAGB_BPE3_thumb.jpg","galleries_id":449436,"width":160});
thumbnails[8503244] = clik.newPhoto({"link":"photo_8503244.html","caption":"Circle Certificate - In Bluebell Wood","height":108,"id":8503244,"server_id":31,"src":"c32_Cert_In_Bluebell_Wood_Neil_Humphries_thumb.jpg","galleries_id":449436,"width":160});
thumbnails[8503247] = clik.newPhoto({"link":"photo_8503247.html","caption":"Circle Certificate - Nature's Colours, White Pocket","height":105,"id":8503247,"server_id":31,"src":"c36_Cert_Natures_Colours_White_Pocket_Dave_Coats_ARPS_EFIAPg_MPAGB_APAGB_thumb.jpg","galleries_id":449436,"width":160});
thumbnails[8503248] = clik.newPhoto({"link":"photo_8503248.html","caption":"Circle Certificate - Australian Darter","height":94,"id":8503248,"server_id":31,"src":"c41_Cert_Australian_Darter_Keith_Seidel_thumb.jpg","galleries_id":449436,"width":160});
thumbnails[8503253] = clik.newPhoto({"link":"photo_8503253.html","caption":"Highly Commended - Hovering Barn Owl","height":118,"id":8503253,"server_id":31,"src":"c41_HC_Hovering_Barn_Owl_Steve_Weideger_thumb.jpg","galleries_id":449436,"width":160});
thumbnails[8503256] = clik.newPhoto({"link":"photo_8503256.html","caption":"Highly Commended - Seal in Sandstorm","height":106,"id":8503256,"server_id":31,"src":"c45_HC_Seal_in_Sandstorm_Miles_Langthorne_LRPS__DPAGB_thumb.jpg","galleries_id":449436,"width":160});
thumbnails[8503271] = clik.newPhoto({"link":"photo_8503271.html","caption":"Highly Commended - Tern Flight","height":90,"id":8503271,"server_id":31,"src":"c45_HC_Tern_Flight_Chris_Morton_DPAGB_thumb.jpg","galleries_id":449436,"width":160});
thumbnails[8503329] = clik.newPhoto({"link":"photo_8503329.html","caption":"Highly Commended - Red-necked Phalaropes Mating","height":108,"id":8503329,"server_id":31,"src":"c46_HC_Red-necked_Phalaropes_Mating_Philip_Mugridge_ARPS_thumb.jpg","galleries_id":449436,"width":160});
thumbnails[8503332] = clik.newPhoto({"link":"photo_8503332.html","caption":"Circle Certificate - Greater Kestrel (falco rupicoloides) Lifting Off","height":120,"id":8503332,"server_id":31,"src":"c60_Cert_Greater_Kestrel_falco_rupicoloides_Lifting_Off_Peter_Tulloch_ARPS_DPAGB_thumb.jpg","galleries_id":449436,"width":160});
thumbnails[8503335] = clik.newPhoto({"link":"photo_8503335.html","caption":"Circle Certificate - Swan Lake","height":106,"id":8503335,"server_id":31,"src":"c62_Cert_John_Butler_ARPS_DPAGB_APAGB_Swan_Lake_thumb.jpg","galleries_id":449436,"width":160});
thumbnails[8503336] = clik.newPhoto({"link":"photo_8503336.html","caption":"Highly Commended - The Lake District","height":104,"id":8503336,"server_id":31,"src":"c62_HC_Ken_Payne_The_Lake_District_thumb.jpg","galleries_id":449436,"width":160});
thumbnails[8503339] = clik.newPhoto({"link":"photo_8503339.html","caption":"Circle Certificate - Red Kite","height":114,"id":8503339,"server_id":31,"src":"c63_Cert_Andrew_Shorey_Red_Kite_thumb.jpg","galleries_id":449436,"width":160});
thumbnails[8503343] = clik.newPhoto({"link":"photo_8503343.html","caption":"Circle Certificate - Big Eyes","height":252,"id":8503343,"server_id":31,"src":"c72_Cert_Big_Eyes_Brian_Davis_thumb.jpg","galleries_id":449436,"width":160});
thumbnails[8503349] = clik.newPhoto({"link":"photo_8503349.html","caption":"Circle Certificate - Red Droplet","height":244,"id":8503349,"server_id":31,"src":"c74_Cert_Red_Droplet_Chris_Stobbs_CPAGB_thumb.jpg","galleries_id":449436,"width":160});
thumbnails[8503353] = clik.newPhoto({"link":"photo_8503353.html","caption":"Circle Certificate - Koln Cathedral","height":233,"id":8503353,"server_id":31,"src":"c75_Cert_Koln_Cathedral_John_Wigley_thumb.jpg","galleries_id":449436,"width":160});
thumbnails[9140793] = clik.newPhoto({"link":"photo_9140793.html","caption":"Great Black-backed Gull Takong Flight","height":120,"id":9140793,"server_id":31,"src":"c46_01_Great_Black-backed_Gull_taking_flight_John_Cucksey_ARPS_1_thumb.jpg","galleries_id":432227,"width":160});
thumbnails[9140795] = clik.newPhoto({"link":"photo_9140795.html","caption":"Ischnura elegans Paired","height":227,"id":9140795,"server_id":31,"src":"c46_02_Ischnura_elegans_Paired_Douglas_Hands_ARPS_1_thumb.jpg","galleries_id":432227,"width":160});
thumbnails[9140797] = clik.newPhoto({"link":"photo_9140797.html","caption":"Auriscalpum vulgara","height":116,"id":9140797,"server_id":31,"src":"c46_03_Auriscalpum_vulgare_Pamela_Jackson_ARPS_1_thumb.jpg","galleries_id":432227,"width":160});
thumbnails[9140799] = clik.newPhoto({"link":"photo_9140799.html","caption":"Xerocomus parasiticus","height":127,"id":9140799,"server_id":31,"src":"c46_04_Xerocomus_parasiticus_Pamela_Jackson_ARPS_1_thumb.jpg","galleries_id":432227,"width":160});
thumbnails[9140800] = clik.newPhoto({"link":"photo_9140800.html","caption":"Black-tailed Godwit","height":107,"id":9140800,"server_id":31,"src":"c46_05_Black-tailed_Godwit_Philip_Mugridge_ARPS_1_thumb.jpg","galleries_id":432227,"width":160});
thumbnails[9140802] = clik.newPhoto({"link":"photo_9140802.html","caption":"Early Thorn Moth","height":240,"id":9140802,"server_id":31,"src":"c46_06_Early_Thorn_Moth_Terry_Ridgely_ARPS_CPAGB_1_thumb.jpg","galleries_id":432227,"width":160});
thumbnails[9140805] = clik.newPhoto({"link":"photo_9140805.html","caption":"Great Blue Heron with Fish","height":120,"id":9140805,"server_id":31,"src":"c46_07_Great_Blue_Heron_with_fish_John_Bebbington_FRPS_1_thumb.jpg","galleries_id":432227,"width":160});
thumbnails[9140806] = clik.newPhoto({"link":"photo_9140806.html","caption":"Helophilus sp paired","height":120,"id":9140806,"server_id":31,"src":"c46_08_Helophilus_sp_paired__J_Bebbington_FRPS_1_thumb.jpg","galleries_id":432227,"width":160});
thumbnails[9140807] = clik.newPhoto({"link":"photo_9140807.html","caption":"Horned Poppy","height":116,"id":9140807,"server_id":31,"src":"c46_09_Horned_Poppy_Deryck_Ford_LRPS_1_thumb.jpg","galleries_id":432227,"width":160});
thumbnails[9140809] = clik.newPhoto({"link":"photo_9140809.html","caption":"Impala with Calves","height":107,"id":9140809,"server_id":31,"src":"c46_10_Impala_and_Calves_John_Cucksey_ARPS_1_thumb.jpg","galleries_id":432227,"width":160});
thumbnails[9140811] = clik.newPhoto({"link":"photo_9140811.html","caption":"Red-necked Phalaropes Mating","height":108,"id":9140811,"server_id":31,"src":"c46_11_Red-necked_Phalaropes_Mating_Philip_Mugridge_ARPS_1_thumb.jpg","galleries_id":432227,"width":160});
thumbnails[9140812] = clik.newPhoto({"link":"photo_9140812.html","caption":"Spider with Prey","height":117,"id":9140812,"server_id":31,"src":"c46_12_Spider_with_Prey_Douglas_Hands_ARPS_1_thumb.jpg","galleries_id":432227,"width":160});
thumbnails[9140814] = clik.newPhoto({"link":"photo_9140814.html","caption":"Female Orange Tip Butterfly","height":120,"id":9140814,"server_id":31,"src":"c46_13_Female_Orange_Tip_Butterfly_Euan_Wallace_1_thumb.jpg","galleries_id":432227,"width":160});
thumbnails[9140815] = clik.newPhoto({"link":"photo_9140815.html","caption":"Early Purple Orchid","height":258,"id":9140815,"server_id":31,"src":"c46_14_Early_Purple_Orchid_Jonathan_Ratnage_1_thumb.jpg","galleries_id":432227,"width":160});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
galleries[422738] = clik.newGallery({"photoIDs":[8503032,8503038,8503042,8503043,8503046,8503048,8503050],"link":"gallery_422738.html","skipIndex":0,"section_code":"gallery","id":422738,"parentGallery":"","featured_images":"8503050,8503048,8503046,8503043,8503042,8503038,8503032","maxRecords":0,"usePopups":false,"singleSection":false,"title":"Trophy Winners"});galleries[449436] = clik.newGallery({"photoIDs":[8503057,8503069,8503075,8503078,8503081,8503083,8503086,8503088,8503092,8503093,8503128,8503131,8503133,8503136,8503164,8503221,8503234,8503239,8503241,8503244,8503247,8503248,8503253,8503256,8503271,8503329,8503332,8503335,8503336,8503339,8503343,8503349,8503353],"link":"gallery_449436.html","skipIndex":0,"section_code":"gallery","id":449436,"parentGallery":"","featured_images":"8503353,8503349,8503343,8503339,8503336,8503335,8503332,8503329,8503271,8503256","maxRecords":0,"usePopups":false,"singleSection":false,"title":"Circle Certificate & Highly Commended"});galleries[432227] = clik.newGallery({"photoIDs":[9140793,9140795,9140797,9140799,9140800,9140802,9140805,9140806,9140807,9140809,9140811,9140812,9140814,9140815],"link":"gallery_432227.html","skipIndex":0,"section_code":"gallery","id":432227,"parentGallery":"","featured_images":"9140815,9140814,9140812,9140811,9140809,9140807,9140806,9140805,9140802,9140800","maxRecords":0,"usePopups":false,"singleSection":false,"title":"Featured Circle"});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[3] = '9140899,9140898,9140897,9140896,9140895,9140815,9140814,9140812,9140811,9140809,9140807,9140806,9140805,9140802,9140800,9140799,9140797,9140795,9140793,8503353,8503349,8503343,8503339,8503336,8503335,8503332,8503329,8503271,8503256,8503253,8503248,8503247,8503244,8503241,8503239,8503234,8503221,8503164,8503136,8503133,8503131,8503128,8503093,8503092,8503088,8503086,8503083,8503081,8503078,8503075';
imageSets[1] = '9140899,9140898,9140897,9140896,9140895';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/uppofgb/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/uppofgb/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/uppofgb/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/uppofgb/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/uppofgb/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/uppofgb/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/uppofgb/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/uppofgb/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/uppofgb/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/uppofgb/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/uppofgb/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/uppofgb/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/uppofgb/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/uppofgb/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/uppofgb/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/uppofgb/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/uppofgb/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/uppofgb/images';
		break;
	}
		switch (server_id) {
		case 0:
		val = 'http://www.clikpic.com/uppofgb/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/uppofgb/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/uppofgb/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/uppofgb/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/uppofgb/images';
		break;
	}
		switch (server_id) {
		case 51:
		val = 'http://www12.clikpic.com/uppofgb/images';
		break;
	}
		switch (server_id) {
		case 52:
		val = 'http://tpc22/clikpic/uppofgb/images';
		break;
	}
		switch (server_id) {
		case 53:
		val = 'http://images.clikpic.com/uppofgb/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/uppofgb/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 || photos || {})[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:'',$detailContainer:'',
                    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 (op.updateHash && clik.getIDInUrl(location.href,'photo') != op.nextPhoto.id) {
		clik.changeHash('photos_id=' + op.nextPhoto.id, true);
	}
		
	    if (op.$title.length > 0) {
  		op.$title.fadeGalleryDetails(photoCaption, op.speed);
    }
        if (op.updateDocumentTitle) {
				  document.title = 'United Photographic Postfolios: ' + photoCaption;
			    }
        if (op.$detail.length > 0) {
      	temp = op.nextPhoto.fnGetImageDetails();
	    op.$detail.fadeGalleryDetails(temp, op.speed, function(){
			if (typeof(backgrounds) != 'undefined' && op.nextPhoto == backgrounds[op.nextPhoto.id]) {
				toggleAddToCartConfirm(backgrounds, op.$detail);
			} else if (typeof(photos) != 'undefined' && op.nextPhoto == photos[op.nextPhoto.id]) {
				toggleAddToCartConfirm(photos, op.$detail);
			}
			$('body').trigger('clikUpdate.popup');
	    });
    }
        $(op.$detailContainer).find('.replaceable[class*=replaceable_photo-]').each(function(){
    	var field = clik.getPrefixedClass(this.className, 'replaceable_photo-');
    	if (field in op.nextPhoto) {
    		$(this).fadeGalleryDetails(op.nextPhoto[field], op.speed);
    	}
    }).end().find('.replaceable.photoPayment').fadeGalleryDetails(op.nextPhoto.fnGetPaymentInfo(), op.speed, function(){
		if (typeof(backgrounds) != 'undefined' && op.nextPhoto == backgrounds[op.nextPhoto.id]) {
			toggleAddToCartConfirm(backgrounds, op.$detailContainer);
		} else if (typeof(photos) != 'undefined' && op.nextPhoto == photos[op.nextPhoto.id]) {
			toggleAddToCartConfirm(photos, op.$detailContainer);
		}
		$('body').trigger('clikUpdate.popup');
	});
		if (op.$photo.length > 0) {
		html = $('<img/>',{
			'class': 'mainphoto photo',
			src: photoSrc,
			id: 'mainPic',
			name: 'mainPic',
			width: op.nextPhoto.width,
			height: op.nextPhoto.height,
			alt: photoCaption,
			css: op.css || {}
		});
		if (op.href) {
			if (op.href.match(/<a/)) {
				html = $(op.href).append(html);
			} else {
				html = $('<a/>', {
					href: op.href,
					title: photoCaption
				}).append(html);
			}
		} else {
			html = $('<a/>', {
				title: photoCaption
			}).append(html);
		}
		if (op.speed == 0) {			op.$photo.html(html);			if (op.onBefore) {			  	op.onBefore.apply(op.$photo);			}			if (op.onAfter) {			  	op.onAfter.apply(op.$photo);			}		} else {			op.$photo.stop(true,true).fadeReplaceWith(html,op.speed,'',function(){  				if (op.onAfter) {				  	op.onAfter.apply(this);				}				clik.doColumnResize(false, $(this).add(op.$detail).add(op.$title));			}, op.onBefore);
		}	}
    if (op.field) {
		op.field.value = photoId;
	} else {
		op.$photo.data('image_id', photoId);
    }
        if (!op.speed) {
      	clik.doColumnResize(false, op.$photo.add(op.$detail).add(op.$title));
    }
        
    return html;
	}

/***************************************************************************
* Toggle add to cart confirmation element and set up the click event for   *
* the 'Add to cart' button.                                                *
***************************************************************************/
function toggleAddToCartConfirm(array, root){
	if (typeof(array) !== 'object' || array === null) {
	  	array = photos;
	}
	if (!$(root).length) {		root = $('body');	}	if($('#paymentConfirm', root).length > 0){
		$('#paymentConfirm', root).hide();
		$('#paymentAddButton', root)
		.unbind()
		.click(function(){
						form = $('#paymentForm', root)[0];
			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', root).text('Item added to cart').show();}
				else{
					$('#paymentConfirm', root).text('Item added to cart').fadeIn();
					dspOrderDetails(form.site.value);
				}
			}
			else{
				$('#paymentConfirm', root).text('Item not added - check cookies are enabled in your browser.').fadeIn();
			}
		});
	}
}

/***************************************************************************
* Get payment info for image - add as 'method' to photo object             *
***************************************************************************/
clik.photo.fnGetImageDetails = function(){
	var temp = '';
	if (this.description != '') {
		temp +=  '<div id="imageDescription">' + this.description + '</div>';
	}
		if (this.photo_ref != '') {
		temp += '<div class="imageinfo" id="imageRef"><strong>Ref: </strong>' + this.photo_ref + '</div>';
	}
		if (this.takendate != '') {
		
		temp += '<div class="imageinfo" id="imageDate"><strong>Date: </strong>' + this.takendate + '</div>';
	}
	
	if (this.location != '') {
		
		temp += '<div class="imageinfo" id="imageLocation"><strong>Location: </strong>' +  this.location + '</div>';
	}
	
	if (this.photographer != '') {
		
		temp += '<div class="imageinfo" id="imagePhotographer"><strong>Photographer: </strong>' + this.photographer + '</div>';
	}
			
				if (temp != '') {
		temp += '<div class="spacer"></div>';
	}
	return temp;
};

/***************************************************************************
* Get payment info for image - add as 'method' to photo object             *
***************************************************************************/
clik.photo.fnGetPaymentInfo = function(){
	var temp = '';
	if (this.item_price !== '') {
				temp += '<p>Order this print:</p>';
				temp += '<div class="imageinfo" id="imagePrice"><strong>' + this.purchase_instruction + '</strong> ' + (this.item_price).toFixed(2) + '</div>';
		var item_name  = this.purchase_instruction;
		var amount = (this.item_price).toFixed(2);
		var item_option  = 0;
	}
		else {
		
	}
	if (this.item_price !== '') {
			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({					title: galleries[gallery_id].title				}).filter(function(){return this.href;}).attr({					href: thumbnails[imageID].fnGalleryLink(gallery_id)				});
			}
		}
	}
}

/***************************************************************************
* 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 += '<a href="' + galleries[i].section_code + '_' + galleries[i].id + '.html">' + galleries[i].title + '</a>';
							}
		}
		document.all.galleryLinks.innerHTML = 'Other galleries: ' + temp;
	}
}

		

