window.thumbnails = {};
															thumbnails[7701726] = clik.newPhoto({"id":7701726,"src":"trees_footer_thumb.jpg","galleries_id":"","server_id":5,"link":"#","width":130,"caption":"","height":66});
															thumbnails[5076245] = clik.newPhoto({"id":5076245,"src":"misty_woods_thumb.jpg","galleries_id":287144,"server_id":5,"link":"photo_5076245.html","width":130,"caption":"Misty Woods","height":170});
															thumbnails[5253325] = clik.newPhoto({"id":5253325,"src":"Green-Forest-rough_thumb.jpg","galleries_id":287144,"server_id":5,"link":"photo_5253325.html","width":130,"caption":"Green Forest","height":173});
															thumbnails[5284564] = clik.newPhoto({"id":5284564,"src":"winter_woodland_thumb.jpg","galleries_id":287144,"server_id":5,"link":"photo_5284564.html","width":130,"caption":"Winter Woodland","height":163});
															thumbnails[6624078] = clik.newPhoto({"id":6624078,"src":"1_8D4D3788-24E8-5EC4-4F460C0329BE0814_thumb.jpg","galleries_id":287144,"server_id":5,"link":"photo_6624078.html","width":130,"caption":"Grove I","height":179});
															thumbnails[6624085] = clik.newPhoto({"id":6624085,"src":"4_8D4DFA0E-24E8-5EC4-4FD6B07833F27641_thumb.jpg","galleries_id":287144,"server_id":5,"link":"photo_6624085.html","width":130,"caption":"Grove II","height":177});
															thumbnails[6624148] = clik.newPhoto({"id":6624148,"src":"3_8D44A816-24E8-5EC4-4F2790A332E8D0AF_thumb.jpg","galleries_id":287144,"server_id":5,"link":"photo_6624148.html","width":130,"caption":"Birches","height":173});
															thumbnails[7121048] = clik.newPhoto({"id":7121048,"src":"Dont_Be_Scared1small_thumb.jpg","galleries_id":287144,"server_id":5,"link":"photo_7121048.html","width":130,"caption":"Don't Be Scared I","height":166});
															thumbnails[7121052] = clik.newPhoto({"id":7121052,"src":"Dont_Be_Scared2small_thumb.jpeg","galleries_id":287144,"server_id":5,"link":"photo_7121052.html","width":130,"caption":"Don't Be Scared II","height":167});
															thumbnails[7353348] = clik.newPhoto({"id":7353348,"src":"Ghosts_thumb.jpg","galleries_id":287144,"server_id":5,"link":"photo_7353348.html","width":130,"caption":"Ghosts","height":163});
															thumbnails[7646938] = clik.newPhoto({"id":7646938,"src":"Inflorescence_thumb.jpg","galleries_id":287144,"server_id":5,"link":"photo_7646938.html","width":130,"caption":"Inflorescence","height":172});
															thumbnails[7652580] = clik.newPhoto({"id":7652580,"src":"vihara-garden_thumb.jpg","galleries_id":287144,"server_id":5,"link":"photo_7652580.html","width":130,"caption":"Vihara Garden","height":172});
															thumbnails[7689442] = clik.newPhoto({"id":7689442,"src":"shadows2_thumb.jpg","galleries_id":287144,"server_id":5,"link":"photo_7689442.html","width":130,"caption":"In Transition","height":205});
															thumbnails[7834281] = clik.newPhoto({"id":7834281,"src":"1_125877E9-1EC9-D45B-1C9558DAFC240C6F_thumb.jpg","galleries_id":422762,"server_id":5,"link":"photo_7834281.html","width":130,"caption":"","height":90});
															thumbnails[7834293] = clik.newPhoto({"id":7834293,"src":"2_125F7BBC-1EC9-D45B-1C00A69CFACAA241_thumb.jpg","galleries_id":422762,"server_id":5,"link":"photo_7834293.html","width":130,"caption":"","height":89});
															thumbnails[7834294] = clik.newPhoto({"id":7834294,"src":"3_1261291E-1EC9-D45B-1C8D3F6FD0040D57_thumb.jpg","galleries_id":422762,"server_id":5,"link":"photo_7834294.html","width":130,"caption":"","height":89});
															thumbnails[7834301] = clik.newPhoto({"id":7834301,"src":"4_12676FFA-1EC9-D45B-1C7603A31865D18C_thumb.jpg","galleries_id":422762,"server_id":5,"link":"photo_7834301.html","width":130,"caption":"","height":89});
															thumbnails[7834306] = clik.newPhoto({"id":7834306,"src":"5_126AB7C1-1EC9-D45B-1C62C0D50D596E40_thumb.jpg","galleries_id":422762,"server_id":5,"link":"photo_7834306.html","width":130,"caption":"","height":190});
															thumbnails[7834327] = clik.newPhoto({"id":7834327,"src":"6_126C3BE0-1EC9-D45B-1C2CEFEEC8824B93_thumb.jpg","galleries_id":422762,"server_id":5,"link":"photo_7834327.html","width":130,"caption":"","height":191});
															thumbnails[7834333] = clik.newPhoto({"id":7834333,"src":"7_126DBBB9-1EC9-D45B-1C4BE2ECAAE201BE_thumb.jpg","galleries_id":422762,"server_id":5,"link":"photo_7834333.html","width":130,"caption":"","height":89});
															thumbnails[7834337] = clik.newPhoto({"id":7834337,"src":"8_126F2EFF-1EC9-D45B-1CE15CD4FC72E3FB_thumb.jpg","galleries_id":422762,"server_id":5,"link":"photo_7834337.html","width":130,"caption":"","height":89});
															thumbnails[7834345] = clik.newPhoto({"id":7834345,"src":"10_thumb.jpg","galleries_id":422762,"server_id":5,"link":"photo_7834345.html","width":130,"caption":"","height":90});
															thumbnails[8109642] = clik.newPhoto({"id":8109642,"src":"Green_Forest_thumb.jpg","galleries_id":434124,"server_id":5,"link":"photo_8109642.html","width":130,"caption":"Green Forest","height":173});
															thumbnails[8109681] = clik.newPhoto({"id":8109681,"src":"Dont_Be_Scared1small_107DD120-1EC9-D45B-1C2F47BC8A0A3C38_thumb.jpg","galleries_id":434124,"server_id":5,"link":"photo_8109681.html","width":130,"caption":"Don't Be Scared I","height":166});
															thumbnails[8109701] = clik.newPhoto({"id":8109701,"src":"Dont_Be_Scared2small_1081D4D4-1EC9-D45B-1CF1ED237F398317_thumb.jpeg","galleries_id":434124,"server_id":5,"link":"photo_8109701.html","width":130,"caption":"Don't Be Scared II","height":167});
															thumbnails[8109731] = clik.newPhoto({"id":8109731,"src":"Apple_Tree_thumb.jpg","galleries_id":434124,"server_id":5,"link":"photo_8109731.html","width":130,"caption":"Apple Tree","height":165});
															thumbnails[8109743] = clik.newPhoto({"id":8109743,"src":"Red_Hot_Pokers_thumb.jpg","galleries_id":434124,"server_id":5,"link":"photo_8109743.html","width":130,"caption":"Red Hot Pokers","height":97});
															thumbnails[8109747] = clik.newPhoto({"id":8109747,"src":"Midnight_Bay_thumb.jpg","galleries_id":434124,"server_id":5,"link":"photo_8109747.html","width":130,"caption":"Midnight Bay","height":108});
															thumbnails[5149444] = clik.newPhoto({"id":5149444,"src":"Cordillera-152cm-by180cm_thumb.jpg","galleries_id":287143,"server_id":5,"link":"photo_5149444.html","width":130,"caption":"Cordillera","height":106});
															thumbnails[7392383] = clik.newPhoto({"id":7392383,"src":"Universal_Truths_thumb.jpg","galleries_id":400274,"server_id":5,"link":"photo_7392383.html","width":130,"caption":"Universal Truths","height":130});
															thumbnails[5151645] = clik.newPhoto({"id":5151645,"src":"nocturnal_reflection_combined_thumb.jpg","galleries_id":287143,"server_id":5,"link":"photo_5151645.html","width":130,"caption":"Nocturnal Reflection","height":80});
															thumbnails[7589302] = clik.newPhoto({"id":7589302,"src":"Microcosmos_thumb.jpg","galleries_id":400274,"server_id":5,"link":"photo_7589302.html","width":130,"caption":"Microcosmos","height":130});
															thumbnails[5076362] = clik.newPhoto({"id":5076362,"src":"Forest_Border_-_Lisa_Denyer_thumb.jpg","galleries_id":287143,"server_id":5,"link":"photo_5076362.html","width":130,"caption":"Forest Border","height":166});
															thumbnails[7392392] = clik.newPhoto({"id":7392392,"src":"Crystal_Abstract_thumb.jpg","galleries_id":400274,"server_id":5,"link":"photo_7392392.html","width":130,"caption":"Crystal Abstract","height":130});
															thumbnails[5149899] = clik.newPhoto({"id":5149899,"src":"range_thumb.jpg","galleries_id":287143,"server_id":5,"link":"photo_5149899.html","width":130,"caption":"Range","height":93});
															thumbnails[7929103] = clik.newPhoto({"id":7929103,"src":"Untitled_Prisms_thumb.jpg","galleries_id":400274,"server_id":5,"link":"photo_7929103.html","width":130,"caption":"Untitled (Prisms)","height":120});
															thumbnails[5149907] = clik.newPhoto({"id":5149907,"src":"stack_thumb.jpg","galleries_id":287143,"server_id":5,"link":"photo_5149907.html","width":130,"caption":"Stack","height":93});
															thumbnails[8053701] = clik.newPhoto({"id":8053701,"src":"Untitled-shardsII_thumb.jpg","galleries_id":400274,"server_id":5,"link":"photo_8053701.html","width":130,"caption":"Untitled (Prisms II)","height":195});
															thumbnails[5149869] = clik.newPhoto({"id":5149869,"src":"eclat_thumb.jpg","galleries_id":287143,"server_id":5,"link":"photo_5149869.html","width":130,"caption":"Eclat","height":94});
															thumbnails[8053631] = clik.newPhoto({"id":8053631,"src":"Untitled-architecture_thumb.jpg","galleries_id":400274,"server_id":5,"link":"photo_8053631.html","width":130,"caption":"Untitled (Architecture)","height":240});
															thumbnails[6731236] = clik.newPhoto({"id":6731236,"src":"B-movie_thumb.jpg","galleries_id":287143,"server_id":5,"link":"photo_6731236.html","width":130,"caption":"B movie","height":91});
															thumbnails[8053716] = clik.newPhoto({"id":8053716,"src":"Piezoelectric_thumb.jpg","galleries_id":400274,"server_id":5,"link":"photo_8053716.html","width":130,"caption":"Piezoelectric ","height":119});
															thumbnails[5076371] = clik.newPhoto({"id":5076371,"src":"snow_peaked_thumb.jpg","galleries_id":287143,"server_id":5,"link":"photo_5076371.html","width":130,"caption":"Snow Peaked","height":95});
															thumbnails[8243686] = clik.newPhoto({"id":8243686,"src":"Test-Tubes1_thumb.jpg","galleries_id":400274,"server_id":5,"link":"photo_8243686.html","width":130,"caption":"Test Tubes","height":88});
															thumbnails[6624089] = clik.newPhoto({"id":6624089,"src":"2_BA63C951-1EC9-D45B-1CE7D409C38F0333_thumb.jpg","galleries_id":287143,"server_id":5,"link":"photo_6624089.html","width":130,"caption":"Whitecap","height":97});
															thumbnails[8089712] = clik.newPhoto({"id":8089712,"src":"Untitled-Light-Box_thumb.jpg","galleries_id":400274,"server_id":5,"link":"photo_8089712.html","width":130,"caption":"Untitled (Light Box)","height":195});
															thumbnails[5075158] = clik.newPhoto({"id":5075158,"src":"journey_thumb.jpg","galleries_id":287143,"server_id":5,"link":"photo_5075158.html","width":130,"caption":"Journey","height":103});
															thumbnails[5770449] = clik.newPhoto({"id":5770449,"src":"3_thumb.jpg","galleries_id":326824,"server_id":5,"link":"photo_5770449.html","width":130,"caption":"","height":87});
															thumbnails[8248661] = clik.newPhoto({"id":8248661,"src":"Grid_thumb.jpg","galleries_id":400274,"server_id":5,"link":"photo_8248661.html","width":130,"caption":"Grid","height":89});
															thumbnails[7254584] = clik.newPhoto({"id":7254584,"src":"Prisms_thumb.jpg","galleries_id":287143,"server_id":5,"link":"photo_7254584.html","width":130,"caption":"Prisms","height":99});
															thumbnails[8465348] = clik.newPhoto({"id":8465348,"src":"Lisa-Denyer---Samsara-I_thumb.jpg","galleries_id":400274,"server_id":5,"link":"photo_8465348.html","width":130,"caption":"Samsara I","height":174});
															thumbnails[8465630] = clik.newPhoto({"id":8465630,"src":"Lisa_Denyer_Samsara_II_thumb.jpg","galleries_id":400274,"server_id":5,"link":"photo_8465630.html","width":130,"caption":"Samsara II","height":174});
															thumbnails[8506584] = clik.newPhoto({"id":8506584,"src":"Lisa-Denyer---Samsara-joined_thumb.jpg","galleries_id":400274,"server_id":5,"link":"photo_8506584.html","width":130,"caption":"Samsara (Combined)","height":87});
															thumbnails[8746034] = clik.newPhoto({"id":8746034,"src":"Cause-and-Effect1_thumb.jpg","galleries_id":400274,"server_id":5,"link":"photo_8746034.html","width":130,"caption":"Cause\/Effect I","height":170});
															thumbnails[8746051] = clik.newPhoto({"id":8746051,"src":"Cause-and-Effect2_thumb.jpg","galleries_id":400274,"server_id":5,"link":"photo_8746051.html","width":130,"caption":"Cause\/Effect II","height":170});
															thumbnails[8746073] = clik.newPhoto({"id":8746073,"src":"Cause--Effect_thumb.jpg","galleries_id":400274,"server_id":5,"link":"photo_8746073.html","width":130,"caption":"Cause\/Effect (Combined)","height":85});
															thumbnails[5770452] = clik.newPhoto({"id":5770452,"src":"4_thumb.jpg","galleries_id":326824,"server_id":5,"link":"photo_5770452.html","width":130,"caption":"","height":86});
															thumbnails[9050030] = clik.newPhoto({"id":9050030,"src":"2_800DE7BD-24E8-5EC4-4FBC4E61B0F565FF_thumb.jpg","galleries_id":400274,"server_id":5,"link":"photo_9050030.html","width":130,"caption":"Hollow I","height":130});
															thumbnails[5771250] = clik.newPhoto({"id":5771250,"src":"7_thumb.jpg","galleries_id":326824,"server_id":5,"link":"photo_5771250.html","width":130,"caption":"","height":88});
															thumbnails[9050079] = clik.newPhoto({"id":9050079,"src":"1_8024B256-24E8-5EC4-4F44E7D4A1FDCDC5_thumb.jpg","galleries_id":400274,"server_id":5,"link":"photo_9050079.html","width":130,"caption":"Hollow II","height":130});
															thumbnails[5770445] = clik.newPhoto({"id":5770445,"src":"2_thumb.jpg","galleries_id":326824,"server_id":5,"link":"photo_5770445.html","width":130,"caption":"","height":87});
															thumbnails[9050112] = clik.newPhoto({"id":9050112,"src":"Lisa_Denyer_-_Hollow_I__II_thumb.jpg","galleries_id":400274,"server_id":5,"link":"photo_9050112.html","width":130,"caption":"Hollow (Combined)","height":66});
															thumbnails[5770465] = clik.newPhoto({"id":5770465,"src":"5_thumb.jpg","galleries_id":326824,"server_id":5,"link":"photo_5770465.html","width":130,"caption":"","height":88});
															thumbnails[5771257] = clik.newPhoto({"id":5771257,"src":"8_thumb.jpg","galleries_id":326824,"server_id":5,"link":"photo_5771257.html","width":130,"caption":"","height":83});
															thumbnails[5771258] = clik.newPhoto({"id":5771258,"src":"9_thumb.jpg","galleries_id":326824,"server_id":5,"link":"photo_5771258.html","width":130,"caption":"","height":88});
															thumbnails[5770470] = clik.newPhoto({"id":5770470,"src":"6_thumb.jpg","galleries_id":326824,"server_id":5,"link":"photo_5770470.html","width":130,"caption":"","height":88});
															thumbnails[5770444] = clik.newPhoto({"id":5770444,"src":"1_thumb.jpg","galleries_id":326824,"server_id":5,"link":"photo_5770444.html","width":130,"caption":"","height":89});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  						galleries[287144] = clik.newGallery({"parentGallery":"","usePopups":true,"title":"Forests","link":"gallery_287144.html","maxRecords":0.0,"photoIDs":[5076245.0,5253325.0,5284564.0,6624078.0,6624085.0,6624148.0,7121048.0,7121052.0,7353348.0,7646938.0,7652580.0,7689442.0],"skipIndex":0,"section_code":"gallery","featured_images":"7689442,7652580,7646938,7353348,7121052,7121048,6624148,6624085,6624078,5284564","id":287144,"singleSection":false});				  						galleries[287143] = clik.newGallery({"parentGallery":"","usePopups":true,"title":"Mountains","link":"gallery_287143.html","maxRecords":0.0,"photoIDs":[5149444.0,5151645.0,5076362.0,5149899.0,5149907.0,5149869.0,6731236.0,5076371.0,6624089.0,5075158.0,7254584.0],"skipIndex":0,"section_code":"gallery","featured_images":"7254584,6731236,6624089,5151645,5149907,5149899,5149869,5149444,5076371,5076362","id":287143,"singleSection":false});				  						galleries[400274] = clik.newGallery({"parentGallery":"","usePopups":true,"title":"Crystal Abstracts","link":"gallery_400274.html","maxRecords":0.0,"photoIDs":[7392383.0,7589302.0,7392392.0,7929103.0,8053701.0,8053631.0,8053716.0,8243686.0,8089712.0,8248661.0,8465348.0,8465630.0,8506584.0,8746034.0,8746051.0,8746073.0,9050030.0,9050079.0,9050112.0],"skipIndex":0,"section_code":"gallery","featured_images":"9050112,9050079,9050030,8746073,8746051,8746034,8506584,8465630,8465348,8248661","id":400274,"singleSection":false});				  						galleries[326824] = clik.newGallery({"parentGallery":"","usePopups":true,"title":"La Plagne 2010","link":"gallery_326824.html","maxRecords":0.0,"photoIDs":[5770449.0,5770452.0,5771250.0,5770445.0,5770465.0,5771257.0,5771258.0,5770470.0,5770444.0],"skipIndex":0,"section_code":"gallery","featured_images":"5771258,5771257,5771250,5770470,5770465,5770452,5770449,5770445,5770444","id":326824,"singleSection":false});				  						galleries[422762] = clik.newGallery({"parentGallery":"","usePopups":true,"title":"Usk Valley 2011","link":"gallery_422762.html","maxRecords":0.0,"photoIDs":[7834281.0,7834293.0,7834294.0,7834301.0,7834306.0,7834327.0,7834333.0,7834337.0,7834345.0],"skipIndex":0,"section_code":"gallery","featured_images":"7834345,7834337,7834333,7834327,7834306,7834301,7834294,7834293,7834281","id":422762,"singleSection":false});				  						galleries[434124] = clik.newGallery({"parentGallery":"","usePopups":true,"title":"Giclee Prints","link":"gallery_434124.html","maxRecords":0.0,"photoIDs":[8109642.0,8109681.0,8109701.0,8109731.0,8109743.0,8109747.0],"skipIndex":0,"section_code":"gallery","featured_images":"8109747,8109743,8109731,8109701,8109681,8109642","id":434124,"singleSection":false});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[1] = '5149444,7589302,5151645,7929103,8053631,8053716,8089712,8248661,8506584,8746073,9050079';
imageSets[3] = '9050112,9050079,9050030,8746073,8746051,8746034,8506584,8465630,8465348,8248661,8243686,8109747,8109743,8109731,8109701,8109681,8109642,8089712,8053716,8053701,8053631,7929103,7834345,7834337,7834333,7834327,7834306,7834301,7834294,7834293,7834281,7701726,7689442,7652580,7646938,7589302,7392392,7392383,7353348,7254584,7121052,7121048,6731236,6624148,6624089,6624085,6624078,5771258,5771257,5771250';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 51:
		val = 'http://www12.clikpic.com/DenyerL/images';
		break;
	}
		switch (server_id) {
		case 0:
		val = 'http://www.clikpic.com/DenyerL/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/DenyerL/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/DenyerL/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/DenyerL/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/DenyerL/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/DenyerL/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/DenyerL/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/DenyerL/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/DenyerL/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/DenyerL/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/DenyerL/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/DenyerL/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/DenyerL/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/DenyerL/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/DenyerL/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/DenyerL/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/DenyerL/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/DenyerL/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/DenyerL/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/DenyerL/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/DenyerL/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/DenyerL/images';
		break;
	}
		switch (server_id) {
		case 53:
		val = 'http://images.clikpic.com/DenyerL/images';
		break;
	}
		switch (server_id) {
		case 52:
		val = 'http://tpc22/clikpic/DenyerL/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/DenyerL/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/DenyerL/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 = 'Lisa Denyer - Contemporary Landscape Artist: ' + 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 PayPal:</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="updateItemValues($(this.form).next(\'#paymentForm\')[0],this.form.payment_options_id.options[this.form.payment_options_id.options.selectedIndex].value);">';
		
		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" target="_blank" action="https://www.paypal.com/cgi-bin/webscr" method="post">';
			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 += '<input type="hidden" name="cmd" value="_cart">';
					temp += '<input type="hidden" name="business" value="lisadenyer84@hotmail.com">';
					temp += '<input type="hidden" name="currency_code" value="GBP">';
					temp += '<input type="hidden" name="add" value="1">';
													temp += '<input type="hidden" name="amount" value="'+amount+'">';
					temp += '<input type="hidden" name="item_number" value="'+ref+'">';
													temp += '<input type=\"Submit\" value=\"Add to cart\" id=\"paymentAddButton\" class=\"button\" onmouseover=\"this.className=\'buttonHi\';\" onmouseout=\"this.className=\'button\';\">';
										temp += '</form>';
										temp += '<form id="paymentCartForm" style="margin:0px;" name="paymentCartForm" target="_blank" action="https://www.paypal.com/cgi-bin/webscr" method="post">';
				temp += '<input type="hidden" name="cmd" value="_cart">';
				temp += '<input type="hidden" name="business" value="lisadenyer84@hotmail.com">';
				temp += '<input type="hidden" name="display" value="1">';
				temp += '<input type=\"Submit\" value=\"View cart\" id=\"paymentViewButton\" class=\"button\" onmouseover=\"this.className=\'buttonHi\';\" onmouseout=\"this.className=\'button\';\">';
				temp += '</form>';
						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;
	}
}

			

