window.thumbnails = {};
thumbnails[8288929] = clik.newPhoto({"link":"photo_8288929.html","caption":"Summer in the Peak","height":87,"id":8288929,"server_id":21,"src":"aDPP_0372_3_6_4_tonemappeda_thumb.jpg","galleries_id":441070,"width":130});
thumbnails[8288934] = clik.newPhoto({"link":"photo_8288934.html","caption":"Buxton Beams","height":87,"id":8288934,"server_id":21,"src":"aIMG_5093_thumb.JPG","galleries_id":441070,"width":130});
thumbnails[8288938] = clik.newPhoto({"link":"photo_8288938.html","caption":"","height":195,"id":8288938,"server_id":21,"src":"aIMG_5097_thumb.JPG","galleries_id":441070,"width":130});
thumbnails[8288940] = clik.newPhoto({"link":"photo_8288940.html","caption":"","height":87,"id":8288940,"server_id":21,"src":"aIMG_5081_thumb.JPG","galleries_id":441070,"width":130});
thumbnails[8288941] = clik.newPhoto({"link":"photo_8288941.html","caption":"","height":195,"id":8288941,"server_id":21,"src":"aIMG_5079_thumb.JPG","galleries_id":441070,"width":130});
thumbnails[8289313] = clik.newPhoto({"link":"photo_8289313.html","caption":"Woodland Sunbeams","height":107,"id":8289313,"server_id":21,"src":"aIMG_4665_thumb.JPG","galleries_id":441071,"width":160});
thumbnails[8310209] = clik.newPhoto({"link":"photo_8310209.html","caption":"","height":240,"id":8310209,"server_id":21,"src":"59655_thumb.jpg","galleries_id":441070,"width":160});
thumbnails[8310211] = clik.newPhoto({"link":"photo_8310211.html","caption":"","height":107,"id":8310211,"server_id":21,"src":"IMG_2727a_thumb.JPG","galleries_id":441071,"width":160});
thumbnails[8340246] = clik.newPhoto({"link":"photo_8340246.html","caption":"","height":107,"id":8340246,"server_id":21,"src":"Copy_of_Picture_055_thumb.jpg","galleries_id":443266,"width":160});
thumbnails[8340248] = clik.newPhoto({"link":"photo_8340248.html","caption":"","height":107,"id":8340248,"server_id":21,"src":"Picture_041a_thumb.jpg","galleries_id":443266,"width":160});
thumbnails[8340272] = clik.newPhoto({"link":"photo_8340272.html","caption":"","height":107,"id":8340272,"server_id":21,"src":"d-1bfc1b1622-4a46f64cb3de8-68cc2_thumb.jpg","galleries_id":443266,"width":160});
thumbnails[8340275] = clik.newPhoto({"link":"photo_8340275.html","caption":"","height":107,"id":8340275,"server_id":21,"src":"d-1bfc1b1622-4a46f64e75d20-68cc2_thumb.jpg","galleries_id":443267,"width":160});
thumbnails[8340276] = clik.newPhoto({"link":"photo_8340276.html","caption":"Sheep silhouette ","height":107,"id":8340276,"server_id":21,"src":"d-1bfc1b1622-4a46f6554c108-68cc2_thumb.jpg","galleries_id":443267,"width":160});
thumbnails[8340278] = clik.newPhoto({"link":"photo_8340278.html","caption":"","height":240,"id":8340278,"server_id":21,"src":"d-1bfc1b1622-4a46f65286d60-68cc2_thumb.jpg","galleries_id":441071,"width":160});
thumbnails[8340281] = clik.newPhoto({"link":"photo_8340281.html","caption":"","height":107,"id":8340281,"server_id":21,"src":"d-1bfc1b1622-4a46f65030340-68cc2_thumb.jpg","galleries_id":441071,"width":160});
thumbnails[8340283] = clik.newPhoto({"link":"photo_8340283.html","caption":"","height":120,"id":8340283,"server_id":21,"src":"d-1bfc1b1622-48e64d6071200-1b584a_thumb.jpg","galleries_id":441070,"width":160});
thumbnails[8340285] = clik.newPhoto({"link":"photo_8340285.html","caption":"","height":120,"id":8340285,"server_id":21,"src":"d-1bfc1b1622-48e6451eb8d20-1b584a_thumb.jpg","galleries_id":441070,"width":160});
thumbnails[8340286] = clik.newPhoto({"link":"photo_8340286.html","caption":"","height":77,"id":8340286,"server_id":21,"src":"d-1bfc1b1622-48e6523f7f380-1b584a_thumb.jpg","galleries_id":441070,"width":160});
thumbnails[8340287] = clik.newPhoto({"link":"photo_8340287.html","caption":"","height":91,"id":8340287,"server_id":21,"src":"d-1bfc1b1622-48e65792d4288-1b584a_thumb.jpg","galleries_id":441070,"width":160});
thumbnails[8340288] = clik.newPhoto({"link":"photo_8340288.html","caption":"","height":94,"id":8340288,"server_id":21,"src":"d-1bfc1b1622-48e64315776a0-1b584a_thumb.jpg","galleries_id":441070,"width":160});
thumbnails[8340289] = clik.newPhoto({"link":"photo_8340289.html","caption":"","height":240,"id":8340289,"server_id":21,"src":"d-1bfc1b1622-493ac9cecbc48-656f8_thumb.jpg","galleries_id":441070,"width":160});
thumbnails[8340291] = clik.newPhoto({"link":"photo_8340291.html","caption":"","height":107,"id":8340291,"server_id":21,"src":"d-1bfc1b1622-4970d9b928350-1bacbb_thumb.jpg","galleries_id":441070,"width":160});
thumbnails[8340292] = clik.newPhoto({"link":"photo_8340292.html","caption":"","height":240,"id":8340292,"server_id":21,"src":"d-1bfc1b1644-4a87a69a10398-1bbdae_thumb.jpg","galleries_id":443267,"width":160});
thumbnails[8340293] = clik.newPhoto({"link":"photo_8340293.html","caption":"","height":120,"id":8340293,"server_id":21,"src":"d-1bfc1b1644-48ce8ed2d1e48-189bf1_thumb.jpg","galleries_id":441070,"width":160});
thumbnails[8340295] = clik.newPhoto({"link":"photo_8340295.html","caption":"","height":120,"id":8340295,"server_id":21,"src":"d-1bfc1b1644-48db3e5f30cc0-d3e11_thumb.jpg","galleries_id":443266,"width":160});
thumbnails[8340297] = clik.newPhoto({"link":"photo_8340297.html","caption":"","height":107,"id":8340297,"server_id":21,"src":"d-1bfc1b1644-48f935ed1e8b0-1d6194_thumb.jpg","galleries_id":471422,"width":160});
thumbnails[8340298] = clik.newPhoto({"link":"photo_8340298.html","caption":"","height":107,"id":8340298,"server_id":21,"src":"d-1bfc1b1644-49d993d522b78-1f5b6f_thumb.jpg","galleries_id":441070,"width":160});
thumbnails[8340300] = clik.newPhoto({"link":"photo_8340300.html","caption":"","height":100,"id":8340300,"server_id":21,"src":"d-1bfc1b1644-497d47d6ddec0-fac9a_thumb.jpg","galleries_id":443266,"width":160});
thumbnails[8340301] = clik.newPhoto({"link":"photo_8340301.html","caption":"","height":107,"id":8340301,"server_id":21,"src":"d-1bfc1b1644-4970a0dfac8e8-1f2ef6_thumb.jpg","galleries_id":443266,"width":160});
thumbnails[8340303] = clik.newPhoto({"link":"photo_8340303.html","caption":"","height":240,"id":8340303,"server_id":21,"src":"d-1bfc1b1644-4970a0ed96918-1f2ef6_thumb.jpg","galleries_id":443266,"width":160});
thumbnails[8392124] = clik.newPhoto({"link":"photo_8392124.html","caption":"Monsal Waterfall","height":107,"id":8392124,"server_id":21,"src":"aIMG_5799_thumb.JPG","galleries_id":441070,"width":160});
thumbnails[8415537] = clik.newPhoto({"link":"photo_8415537.html","caption":"","height":118,"id":8415537,"server_id":21,"src":"IMG_2855ab_thumb.jpg","galleries_id":443267,"width":160});
thumbnails[8415539] = clik.newPhoto({"link":"photo_8415539.html","caption":"","height":107,"id":8415539,"server_id":21,"src":"IMG_9340_2_3_4_tonemapped_thumb.jpg","galleries_id":441070,"width":160});
thumbnails[8415544] = clik.newPhoto({"link":"photo_8415544.html","caption":"","height":62,"id":8415544,"server_id":21,"src":"IMG_5470ab_-_Copy_thumb.jpg","galleries_id":441070,"width":160});
thumbnails[8507630] = clik.newPhoto({"link":"photo_8507630.html","caption":"BUXTON 2012 CALENDAR","height":226,"id":8507630,"server_id":21,"src":"Picture_003_thumb.jpg","galleries_id":449666,"width":160});
thumbnails[8696165] = clik.newPhoto({"link":"photo_8696165.html","caption":"SOLOMONS TEMPLE WALK","height":107,"id":8696165,"server_id":21,"src":"aIMG_6758_-_Copy_thumb.jpg","galleries_id":441070,"width":160});
thumbnails[8696299] = clik.newPhoto({"link":"photo_8696299.html","caption":"DUKES DRIVE VIADUCT B\/W","height":107,"id":8696299,"server_id":21,"src":"DUKES_DRIVE_VIADUCT_OCTOBER_-_Copy_-_Copy_thumb.jpg","galleries_id":441070,"width":160});
thumbnails[8696381] = clik.newPhoto({"link":"photo_8696381.html","caption":"MULTI DEER","height":226,"id":8696381,"server_id":21,"src":"MULTI_DEER_-_Copy_thumb.jpg","galleries_id":443267,"width":160});
thumbnails[8878645] = clik.newPhoto({"link":"photo_8878645.html","caption":"Buxton Snow","height":106,"id":8878645,"server_id":21,"src":"swan_snow_thumb.jpg","galleries_id":443266,"width":160});
thumbnails[8878647] = clik.newPhoto({"link":"photo_8878647.html","caption":"Sunrise Hills","height":107,"id":8878647,"server_id":21,"src":"sunrise_hills_thumb.jpg","galleries_id":441070,"width":160});
thumbnails[8900235] = clik.newPhoto({"link":"photo_8900235.html","caption":"Solomon's Sunrise","height":107,"id":8900235,"server_id":21,"src":"Copy_of_SOLOMONS_TEMPLE_SEPTEMBER_thumb.jpg","galleries_id":441070,"width":160});
thumbnails[8912360] = clik.newPhoto({"link":"photo_8912360.html","caption":"Buxton Bandstand","height":105,"id":8912360,"server_id":21,"src":"bandstand_thumb.jpg","galleries_id":443266,"width":160});
thumbnails[8912371] = clik.newPhoto({"link":"photo_8912371.html","caption":"Grinlow","height":107,"id":8912371,"server_id":21,"src":"grinlow_sun__snow_thumb.jpg","galleries_id":441070,"width":160});
thumbnails[8912375] = clik.newPhoto({"link":"photo_8912375.html","caption":"Ray of Light","height":107,"id":8912375,"server_id":21,"src":"ray_of_light_thumb.jpg","galleries_id":441070,"width":160});
thumbnails[8912379] = clik.newPhoto({"link":"photo_8912379.html","caption":"Solomon's Temple Snow","height":240,"id":8912379,"server_id":21,"src":"sol_temple_snow_thumb.jpg","galleries_id":441070,"width":160});
thumbnails[8957253] = clik.newPhoto({"link":"photo_8957253.html","caption":"Bubbles","height":107,"id":8957253,"server_id":21,"src":"394550_349098811782178_100000461868363_1475955_1510262846_n_thumb.jpg","galleries_id":471422,"width":160});
thumbnails[8957255] = clik.newPhoto({"link":"photo_8957255.html","caption":"Bubbles 2","height":107,"id":8957255,"server_id":21,"src":"405056_349098538448872_100000461868363_1475954_1472621414_n_thumb.jpg","galleries_id":471422,"width":160});
thumbnails[8960290] = clik.newPhoto({"link":"photo_8960290.html","caption":"Media City","height":107,"id":8960290,"server_id":21,"src":"salford_quays211_thumb.jpg","galleries_id":443266,"width":160});
thumbnails[8992603] = clik.newPhoto({"link":"photo_8992603.html","caption":"Purple Leaf","height":107,"id":8992603,"server_id":21,"src":"374272_355494827809243_100000461868363_1503603_1041405864_n_thumb.jpg","galleries_id":443267,"width":160});
thumbnails[8992607] = clik.newPhoto({"link":"photo_8992607.html","caption":"Spider Plant","height":107,"id":8992607,"server_id":21,"src":"375204_355494594475933_100000461868363_1503600_139832898_n_thumb.jpg","galleries_id":443267,"width":160});
thumbnails[8992611] = clik.newPhoto({"link":"photo_8992611.html","caption":"Macro Mushrooms","height":107,"id":8992611,"server_id":21,"src":"393886_355494211142638_100000461868363_1503596_1390547315_n_thumb.jpg","galleries_id":443267,"width":160});
thumbnails[8992615] = clik.newPhoto({"link":"photo_8992615.html","caption":"x1 ","height":107,"id":8992615,"server_id":21,"src":"403629_355494134475979_100000461868363_1503594_19463801_n_thumb.jpg","galleries_id":443267,"width":160});
thumbnails[8992617] = clik.newPhoto({"link":"photo_8992617.html","caption":"Macro Shell","height":107,"id":8992617,"server_id":21,"src":"405867_355494917809234_100000461868363_1503604_608478994_n_thumb.jpg","galleries_id":443267,"width":160});
thumbnails[8992618] = clik.newPhoto({"link":"photo_8992618.html","caption":"Grass Lands","height":107,"id":8992618,"server_id":21,"src":"408246_355494687809257_100000461868363_1503601_305227022_n_thumb.jpg","galleries_id":443267,"width":160});
thumbnails[9040140] = clik.newPhoto({"link":"photo_9040140.html","caption":"Rose","height":107,"id":9040140,"server_id":21,"src":"Rose_pic_thumb.jpg","galleries_id":443267,"width":160});
thumbnails[9040174] = clik.newPhoto({"link":"photo_9040174.html","caption":"Sunset Tree","height":107,"id":9040174,"server_id":21,"src":"405853_361795100512549_100000461868363_1521785_978121376_n_thumb.jpg","galleries_id":441070,"width":160});
thumbnails[9040176] = clik.newPhoto({"link":"photo_9040176.html","caption":"Shell Rock","height":107,"id":9040176,"server_id":21,"src":"399865_361839837174742_100000461868363_1521885_1871261757_n_thumb.jpg","galleries_id":443267,"width":160});
thumbnails[9040181] = clik.newPhoto({"link":"photo_9040181.html","caption":"Shell Moss","height":107,"id":9040181,"server_id":21,"src":"392165_361839640508095_100000461868363_1521884_1485666204_n_thumb.jpg","galleries_id":443267,"width":160});
thumbnails[9040183] = clik.newPhoto({"link":"photo_9040183.html","caption":"Dew Drops","height":107,"id":9040183,"server_id":21,"src":"402581_361839290508130_100000461868363_1521880_1475961507_n_thumb.jpg","galleries_id":443267,"width":160});
thumbnails[9040188] = clik.newPhoto({"link":"photo_9040188.html","caption":"Horse silhouette","height":107,"id":9040188,"server_id":21,"src":"379909_361832310508828_100000461868363_1521850_1952870322_n_thumb.jpg","galleries_id":443267,"width":160});
thumbnails[9136269] = clik.newPhoto({"link":"photo_9136269.html","caption":"Snowman & Robin","height":113,"id":9136269,"server_id":21,"src":"DPP_1332_thumb.JPG","galleries_id":443267,"width":160});
thumbnails[9136272] = clik.newPhoto({"link":"photo_9136272.html","caption":"Ripple SunSet","height":240,"id":9136272,"server_id":21,"src":"DPP_1318_thumb.JPG","galleries_id":441070,"width":160});
thumbnails[9136280] = clik.newPhoto({"link":"photo_9136280.html","caption":"Reeds SunSet P","height":240,"id":9136280,"server_id":21,"src":"DPP_1305_thumb.JPG","galleries_id":441070,"width":160});
thumbnails[9136331] = clik.newPhoto({"link":"photo_9136331.html","caption":"Reeds SunSet L","height":107,"id":9136331,"server_id":21,"src":"DPP_1304_thumb.JPG","galleries_id":441070,"width":160});
thumbnails[9136366] = clik.newPhoto({"link":"photo_9136366.html","caption":"Goyt SunSet","height":240,"id":9136366,"server_id":21,"src":"aIMG_305_thumb.JPG","galleries_id":441070,"width":160});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
galleries[471422] = clik.newGallery({"photoIDs":[8340297,8957253,8957255],"link":"gallery_471422.html","skipIndex":0,"section_code":"gallery","id":471422,"parentGallery":"","featured_images":"8957255,8957253,8340297","maxRecords":0,"usePopups":false,"singleSection":false,"title":"Abstract"});galleries[449666] = clik.newGallery({"photoIDs":[8507630],"link":"gallery_449666.html","skipIndex":0,"section_code":"gallery","id":449666,"parentGallery":"","featured_images":8507630,"maxRecords":0,"usePopups":false,"singleSection":false,"title":"BUXTON 2012 CALENDAR"});galleries[443266] = clik.newGallery({"photoIDs":[8340246,8340248,8340272,8340295,8340300,8340301,8340303,8878645,8912360,8960290],"link":"gallery_443266.html","skipIndex":0,"section_code":"gallery","id":443266,"parentGallery":"","featured_images":"8960290,8912360,8878645,8340303,8340301,8340300,8340295,8340272,8340248,8340246","maxRecords":0,"usePopups":false,"singleSection":false,"title":"Cityscapes"});galleries[443267] = clik.newGallery({"photoIDs":[8340275,8340276,8340292,8415537,8696381,8992603,8992607,8992611,8992615,8992617,8992618,9040140,9040176,9040181,9040183,9040188,9136269],"link":"gallery_443267.html","skipIndex":0,"section_code":"gallery","id":443267,"parentGallery":"","featured_images":"9136269,9040188,9040183,9040181,9040176,9040140,8992618,8992617,8992615,8992611","maxRecords":0,"usePopups":false,"singleSection":false,"title":"Nature"});galleries[441070] = clik.newGallery({"photoIDs":[8288929,8288934,8288938,8288940,8288941,8310209,8340283,8340285,8340286,8340287,8340288,8340289,8340291,8340293,8340298,8392124,8415539,8415544,8696165,8696299,8878647,8900235,8912371,8912375,8912379,9040174,9136272,9136280,9136331,9136366],"link":"gallery_441070.html","skipIndex":0,"section_code":"gallery","id":441070,"parentGallery":"","featured_images":"9136366,9136331,9136280,9136272,9040174,8912379,8912375,8912371,8900235,8878647","maxRecords":0,"usePopups":false,"singleSection":false,"title":"landscapes"});galleries[441071] = clik.newGallery({"photoIDs":[8289313,8310211,8340278,8340281],"link":"gallery_441071.html","skipIndex":0,"section_code":"gallery","id":441071,"parentGallery":"","featured_images":"8340281,8340278,8310211,8289313","maxRecords":0,"usePopups":false,"singleSection":false,"title":"Woodland"});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[3] = '9136366,9136331,9136280,9136272,9136269,9040188,9040183,9040181,9040176,9040174,9040140,8992618,8992617,8992615,8992611,8992607,8992603,8960290,8957255,8957253,8912379,8912375,8912371,8912360,8900235,8878647,8878645,8696381,8696299,8696165,8507630,8415544,8415539,8415537,8392124,8340303,8340301,8340300,8340298,8340297,8340295,8340293,8340292,8340291,8340289,8340288,8340287,8340286,8340285,8340283';
imageSets[1] = '9040140,8960290,8912360,8900235,8340276,8289313';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/kevniro/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/kevniro/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/kevniro/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/kevniro/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/kevniro/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/kevniro/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/kevniro/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/kevniro/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/kevniro/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/kevniro/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/kevniro/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/kevniro/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/kevniro/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/kevniro/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/kevniro/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/kevniro/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/kevniro/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/kevniro/images';
		break;
	}
		switch (server_id) {
		case 0:
		val = 'http://www.clikpic.com/kevniro/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/kevniro/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/kevniro/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/kevniro/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/kevniro/images';
		break;
	}
		switch (server_id) {
		case 51:
		val = 'http://www12.clikpic.com/kevniro/images';
		break;
	}
		switch (server_id) {
		case 52:
		val = 'http://tpc22/clikpic/kevniro/images';
		break;
	}
		switch (server_id) {
		case 53:
		val = 'http://images.clikpic.com/kevniro/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/kevniro/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 = 'www.gbphoto.co.uk: ' + 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>';
	}
			
	temp += this.fnGetPaymentInfo();
				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>Buy now using Google Checkout:</p>';
				temp += '<div class="imageinfo" id="imagePrice"><strong>' + this.purchase_instruction + '</strong> &pound;' + (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.payment_groups_id !== '') {
		temp += '<p>Buy this print online:</p>';
				temp += '<form id="paymentOptions" style="margin:0px;border:0px;" name="paymentOptions">';
						temp += '<select class="paymentlink" name="payment_options_id" onchange="updateCartValue($(this.form).next(\'#paymentForm\')[0],this.form.payment_options_id.options[this.form.payment_options_id.options.selectedIndex].value); if(divShowing(\'paymentConfirm\')){fadeOut(\'paymentConfirm\', 3)};">';
		
		temp += getPaymentOptions(this.payment_groups_id);
		temp += '</select>';
		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 += '<form id="paymentForm" style="margin:0px;border:0px;" name="paymentForm">';
			temp += '	<input type="hidden" name="item_option" value="' + item_option + '">';
			temp += '	<input type="hidden" name="site" value="KEVNIRO">';
			temp += '	<input type="hidden" name="item_number" value="'+ this.id +'">';
			temp += '	<input type="hidden" name="quantity" value="1">';
						temp += '	<input value="Add to cart" id="paymentAddButton" class="button" onmouseover="this.className=\'buttonHi\'\;" onmouseout="this.className=\'button\'\;" type="Button">';
							temp += '	<input value="View cart" id="paymentViewButton" class="button" onmouseover="this.className=\'buttonHi\';" onmouseout="this.className=\'button\';" type="Button" onclick="javascript:window.location=\'cart.html\'">';
			temp += '</form>';
						temp += '<div class="clearing">&nbsp;</div>';
			temp += '<div id="confirmContainer">';
			temp += '<div id="paymentConfirm">Item added to cart</div>';
			temp += '</div>';
			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;
	}
}

		

