window.thumbnails = {};
															thumbnails[3407790] = clik.newPhoto({"id":3407790,"src":"Cuban_Cowboy_thumb.jpg","galleries_id":210159,"server_id":15,"link":"photo_3407790.html","width":98,"caption":"Cuban Cowboy","height":130});
															thumbnails[3437767] = clik.newPhoto({"id":3437767,"src":"Expired_Poppy_thumb.jpg","galleries_id":210163,"server_id":15,"link":"photo_3437767.html","width":130,"caption":"Expired Poppy","height":87});
															thumbnails[3437778] = clik.newPhoto({"id":3437778,"src":"Sea_Lion_Trio_thumb.jpg","galleries_id":210158,"server_id":15,"link":"photo_3437778.html","width":130,"caption":"Sea Lion Trio","height":98});
															thumbnails[3442305] = clik.newPhoto({"id":3442305,"src":"Hardwick_Hall_Sunset_thumb.jpg","galleries_id":210161,"server_id":15,"link":"photo_3442305.html","width":87,"caption":"Hardwick Hall Sunset","height":130});
															thumbnails[3457619] = clik.newPhoto({"id":3457619,"src":"Hardstoft_Panoramic_3_thumb.jpg","galleries_id":210161,"server_id":15,"link":"photo_3457619.html","width":130,"caption":"Hardstoft Panoramic Sunset","height":41});
															thumbnails[3471434] = clik.newPhoto({"id":3471434,"src":"Red_Dahlia_thumb.jpg","galleries_id":210158,"server_id":15,"link":"photo_3471434.html","width":130,"caption":"Red Dahlia","height":87});
															thumbnails[3473268] = clik.newPhoto({"id":3473268,"src":"Sail_Boat_Masts_thumb.jpg","galleries_id":210161,"server_id":15,"link":"photo_3473268.html","width":87,"caption":"Sail Boat Masts","height":130});
															thumbnails[3473306] = clik.newPhoto({"id":3473306,"src":"Portrait_thumb.jpg","galleries_id":210159,"server_id":15,"link":"photo_3473306.html","width":130,"caption":"","height":87});
															thumbnails[3507254] = clik.newPhoto({"id":3507254,"src":"Egyptian_Gecko_thumb.jpg","galleries_id":210158,"server_id":15,"link":"photo_3507254.html","width":130,"caption":"Egyptian Gecko","height":98});
															thumbnails[3560834] = clik.newPhoto({"id":3560834,"src":"Clearing_Storm_thumb.jpg","galleries_id":208158,"server_id":15,"link":"photo_3560834.html","width":130,"caption":"Clearing Storm","height":87});
															thumbnails[3561291] = clik.newPhoto({"id":3561291,"src":"Howden_Resevoir_thumb.jpg","galleries_id":226276,"server_id":15,"link":"photo_3561291.html","width":130,"caption":"Howden Reservoir","height":98});
															thumbnails[3561917] = clik.newPhoto({"id":3561917,"src":"Expired_Dandelion_thumb.jpg","galleries_id":210158,"server_id":15,"link":"photo_3561917.html","width":130,"caption":"Expired Dandelion","height":87});
															thumbnails[3573833] = clik.newPhoto({"id":3573833,"src":"Working_Bee_thumb.jpg","galleries_id":210158,"server_id":15,"link":"photo_3573833.html","width":130,"caption":"Bee at Work","height":87});
															thumbnails[3704382] = clik.newPhoto({"id":3704382,"src":"Whinstone_Lee_Tor__thumb.jpg","galleries_id":226276,"server_id":15,"link":"photo_3704382.html","width":130,"caption":"Whinstone Lee Tor","height":87});
															thumbnails[3711546] = clik.newPhoto({"id":3711546,"src":"Mam_Tor_thumb.jpg","galleries_id":226276,"server_id":15,"link":"photo_3711546.html","width":87,"caption":"Mam Tor","height":130});
															thumbnails[3773422] = clik.newPhoto({"id":3773422,"src":"Mayfly_thumb.jpg","galleries_id":210158,"server_id":15,"link":"photo_3773422.html","width":87,"caption":"Friendly Mayflies","height":130});
															thumbnails[3840777] = clik.newPhoto({"id":3840777,"src":"Beach_Drift_Wood_thumb.jpg","galleries_id":208158,"server_id":15,"link":"photo_3840777.html","width":130,"caption":"Beach Drift Wood","height":87});
															thumbnails[4670118] = clik.newPhoto({"id":4670118,"src":"KP1-14_thumb.jpg","galleries_id":269155,"server_id":15,"link":"photo_4670118.html","width":130,"caption":"","height":99});
															thumbnails[4670207] = clik.newPhoto({"id":4670207,"src":"KP1_thumb.jpg","galleries_id":269155,"server_id":15,"link":"photo_4670207.html","width":87,"caption":"","height":130});
															thumbnails[4670617] = clik.newPhoto({"id":4670617,"src":"KP1-7_thumb.jpg","galleries_id":269155,"server_id":15,"link":"photo_4670617.html","width":130,"caption":"","height":87});
															thumbnails[4670649] = clik.newPhoto({"id":4670649,"src":"KP1-8_thumb.jpg","galleries_id":269155,"server_id":15,"link":"photo_4670649.html","width":87,"caption":"","height":130});
															thumbnails[4670766] = clik.newPhoto({"id":4670766,"src":"KP1-9_thumb.jpg","galleries_id":269155,"server_id":15,"link":"photo_4670766.html","width":130,"caption":"","height":87});
															thumbnails[4670796] = clik.newPhoto({"id":4670796,"src":"KP1-10_thumb.jpg","galleries_id":269155,"server_id":15,"link":"photo_4670796.html","width":87,"caption":"","height":130});
															thumbnails[4670814] = clik.newPhoto({"id":4670814,"src":"KP1-11_thumb.jpg","galleries_id":269155,"server_id":15,"link":"photo_4670814.html","width":87,"caption":"","height":130});
															thumbnails[4670832] = clik.newPhoto({"id":4670832,"src":"KP1-12_thumb.jpg","galleries_id":269155,"server_id":15,"link":"photo_4670832.html","width":130,"caption":"","height":87});
															thumbnails[4671066] = clik.newPhoto({"id":4671066,"src":"KP1-20_thumb.jpg","galleries_id":269155,"server_id":15,"link":"photo_4671066.html","width":130,"caption":"","height":87});
															thumbnails[4671350] = clik.newPhoto({"id":4671350,"src":"KP1-22_thumb.jpg","galleries_id":269155,"server_id":15,"link":"photo_4671350.html","width":87,"caption":"","height":130});
															thumbnails[4671550] = clik.newPhoto({"id":4671550,"src":"KP1-26_thumb.jpg","galleries_id":269155,"server_id":15,"link":"photo_4671550.html","width":130,"caption":"","height":87});
															thumbnails[4671556] = clik.newPhoto({"id":4671556,"src":"KP1-27_thumb.jpg","galleries_id":269155,"server_id":15,"link":"photo_4671556.html","width":87,"caption":"","height":130});
															thumbnails[4671726] = clik.newPhoto({"id":4671726,"src":"KP1-28_thumb.jpg","galleries_id":269155,"server_id":15,"link":"photo_4671726.html","width":87,"caption":"","height":130});
															thumbnails[4825078] = clik.newPhoto({"id":4825078,"src":"KP112-17_thumb.jpg","galleries_id":269155,"server_id":15,"link":"photo_4825078.html","width":87,"caption":"","height":130});
															thumbnails[5384314] = clik.newPhoto({"id":5384314,"src":"Portugal_Trees_thumb.jpg","galleries_id":208157,"server_id":15,"link":"photo_5384314.html","width":87,"caption":"","height":130});
															thumbnails[5384466] = clik.newPhoto({"id":5384466,"src":"Fishing_Boats_Huts_thumb.jpg","galleries_id":210161,"server_id":15,"link":"photo_5384466.html","width":130,"caption":"Portuguese Fishing Boats","height":87});
															thumbnails[5455433] = clik.newPhoto({"id":5455433,"src":"Fisherman-3-25LR_thumb.jpg","galleries_id":208158,"server_id":15,"link":"photo_5455433.html","width":79,"caption":"Beach Fisherman","height":130});
															thumbnails[5455455] = clik.newPhoto({"id":5455455,"src":"Fishing_Harbour_Boats-LR25_thumb.jpg","galleries_id":208158,"server_id":15,"link":"photo_5455455.html","width":130,"caption":"","height":87});
															thumbnails[5455478] = clik.newPhoto({"id":5455478,"src":"WindermereLR_thumb.jpg","galleries_id":208158,"server_id":15,"link":"photo_5455478.html","width":130,"caption":"","height":87});
															thumbnails[5455686] = clik.newPhoto({"id":5455686,"src":"Seagull_New_York_thumb.jpg","galleries_id":210158,"server_id":15,"link":"photo_5455686.html","width":130,"caption":"","height":98});
															thumbnails[5457842] = clik.newPhoto({"id":5457842,"src":"Sri-Lanka-SunsetLR_thumb.jpg","galleries_id":208158,"server_id":15,"link":"photo_5457842.html","width":130,"caption":"Sunset Sri Lanka","height":79});
															thumbnails[5463598] = clik.newPhoto({"id":5463598,"src":"Elephant-WaterholeLR_thumb.jpg","galleries_id":210158,"server_id":15,"link":"photo_5463598.html","width":87,"caption":"","height":130});
															thumbnails[7025140] = clik.newPhoto({"id":7025140,"src":"Deer2-25LR_thumb.jpg","galleries_id":210158,"server_id":15,"link":"photo_7025140.html","width":87,"caption":"","height":130});
															thumbnails[7053115] = clik.newPhoto({"id":7053115,"src":"Chatsworth-Garden-LR_thumb.jpg","galleries_id":210161,"server_id":15,"link":"photo_7053115.html","width":130,"caption":"Chatsworth House Gardens","height":87});
															thumbnails[8283282] = clik.newPhoto({"id":8283282,"src":"Bon_Jovi_3-25_thumb.jpg","galleries_id":304983,"server_id":35,"link":"photo_8283282.html","width":98,"caption":"","height":130});
															thumbnails[7363501] = clik.newPhoto({"id":7363501,"src":"Watch-Tower-25LR_thumb.jpg","galleries_id":304983,"server_id":15,"link":"photo_7363501.html","width":87,"caption":"","height":130});
															thumbnails[5471243] = clik.newPhoto({"id":5471243,"src":"Rock_FishermanLR_thumb.jpg","galleries_id":208158,"server_id":15,"link":"photo_5471243.html","width":87,"caption":"","height":130});
															thumbnails[5403109] = clik.newPhoto({"id":5403109,"src":"Fisherman_thumb.jpg","galleries_id":210159,"server_id":15,"link":"photo_5403109.html","width":87,"caption":"Beach Net Fisherman","height":130});
															thumbnails[5390456] = clik.newPhoto({"id":5390456,"src":"Sri_Lanka_Sunset_thumb.jpg","galleries_id":208158,"server_id":15,"link":"photo_5390456.html","width":98,"caption":"Sri Lanken Sunset","height":130});
															thumbnails[5384534] = clik.newPhoto({"id":5384534,"src":"Beached_Boats_thumb.jpg","galleries_id":210161,"server_id":15,"link":"photo_5384534.html","width":87,"caption":"Beached Boats","height":130});
															thumbnails[4795443] = clik.newPhoto({"id":4795443,"src":"MURPH_thumb.jpg","galleries_id":210158,"server_id":15,"link":"photo_4795443.html","width":130,"caption":"","height":87});
															thumbnails[3893568] = clik.newPhoto({"id":3893568,"src":"Shed_Moth_thumb.jpg","galleries_id":210158,"server_id":15,"link":"photo_3893568.html","width":87,"caption":"","height":130});
															thumbnails[5403104] = clik.newPhoto({"id":5403104,"src":"Elephant_Relaxing_thumb.jpg","galleries_id":210158,"server_id":15,"link":"photo_5403104.html","width":130,"caption":"Relaxing Elephant","height":87});
															thumbnails[5455276] = clik.newPhoto({"id":5455276,"src":"Snow_Scene_thumb.jpg","galleries_id":208157,"server_id":15,"link":"photo_5455276.html","width":87,"caption":"","height":130});
															thumbnails[6354001] = clik.newPhoto({"id":6354001,"src":"Snow_Field_LR_thumb.jpg","galleries_id":208157,"server_id":15,"link":"photo_6354001.html","width":87,"caption":"","height":130});
															thumbnails[5403141] = clik.newPhoto({"id":5403141,"src":"Fishermen_thumb.jpg","galleries_id":210159,"server_id":15,"link":"photo_5403141.html","width":130,"caption":"Sri Lanken Net Fishermen","height":87});
															thumbnails[5401573] = clik.newPhoto({"id":5401573,"src":"River_Canoe_thumb.jpg","galleries_id":208158,"server_id":15,"link":"photo_5401573.html","width":98,"caption":"River Fishing Canoe","height":130});
															thumbnails[5390502] = clik.newPhoto({"id":5390502,"src":"Storm-25LR_thumb.jpg","galleries_id":210158,"server_id":15,"link":"photo_5390502.html","width":130,"caption":"Double Lightening Strike","height":50});
															thumbnails[5384589] = clik.newPhoto({"id":5384589,"src":"Truck_thumb.jpg","galleries_id":210161,"server_id":15,"link":"photo_5384589.html","width":130,"caption":"Backyard Truck","height":87});
															thumbnails[5384357] = clik.newPhoto({"id":5384357,"src":"Cliff_Top_Fishing_thumb.jpg","galleries_id":210159,"server_id":15,"link":"photo_5384357.html","width":130,"caption":"","height":85});
															thumbnails[4671080] = clik.newPhoto({"id":4671080,"src":"KP1-21_thumb.jpg","galleries_id":269155,"server_id":15,"link":"photo_4671080.html","width":130,"caption":"","height":87});
															thumbnails[4663519] = clik.newPhoto({"id":4663519,"src":"Balloon2LR_thumb.jpg","galleries_id":210161,"server_id":15,"link":"photo_4663519.html","width":87,"caption":"Dragon Balloon ","height":130});
															thumbnails[4326206] = clik.newPhoto({"id":4326206,"src":"Ring_Tailed_Lemur_thumb.jpg","galleries_id":210158,"server_id":15,"link":"photo_4326206.html","width":130,"caption":"Ring Tailed Lemur","height":87});
															thumbnails[3573188] = clik.newPhoto({"id":3573188,"src":"M1_North_Motorway_thumb.jpg","galleries_id":210161,"server_id":15,"link":"photo_3573188.html","width":130,"caption":"M1 North Motorway","height":87});
															thumbnails[3437740] = clik.newPhoto({"id":3437740,"src":"Field_of_View_thumb.jpg","galleries_id":208157,"server_id":15,"link":"photo_3437740.html","width":87,"caption":"Field of View","height":130});
															thumbnails[3407739] = clik.newPhoto({"id":3407739,"src":"Manhatten_thumb.jpg","galleries_id":210161,"server_id":15,"link":"photo_3407739.html","width":130,"caption":"New York Manhattan ","height":98});
															thumbnails[3495978] = clik.newPhoto({"id":3495978,"src":"Derwent_Dam_thumb.jpg","galleries_id":226276,"server_id":15,"link":"photo_3495978.html","width":87,"caption":"Derwent Dam","height":130});
															thumbnails[3411089] = clik.newPhoto({"id":3411089,"src":"Lake-Windermere_thumb.jpg","galleries_id":208158,"server_id":15,"link":"photo_3411089.html","width":87,"caption":"Lake Windermere Rowing Boat","height":130});
															thumbnails[3411118] = clik.newPhoto({"id":3411118,"src":"Cuban_Classic_American-Car_thumb.jpg","galleries_id":210161,"server_id":15,"link":"photo_3411118.html","width":130,"caption":"American Classic Car","height":99});
															thumbnails[3437806] = clik.newPhoto({"id":3437806,"src":"Reflecting_Beach_thumb.jpg","galleries_id":208158,"server_id":15,"link":"photo_3437806.html","width":87,"caption":"Reflecting Beach","height":130});
															thumbnails[3561078] = clik.newPhoto({"id":3561078,"src":"Aged_Tulip_thumb.jpg","galleries_id":210163,"server_id":15,"link":"photo_3561078.html","width":130,"caption":"Aged Tulip","height":87});
															thumbnails[4825021] = clik.newPhoto({"id":4825021,"src":"KP112-8_thumb.jpg","galleries_id":269155,"server_id":15,"link":"photo_4825021.html","width":87,"caption":"","height":130});
															thumbnails[3437825] = clik.newPhoto({"id":3437825,"src":"Cuba-Beach-Sunset_thumb.jpg","galleries_id":208158,"server_id":15,"link":"photo_3437825.html","width":87,"caption":"Setting Sun","height":130});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  						galleries[304983] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"New Images","link":"gallery_304983.html","maxRecords":0.0,"photoIDs":[8283282.0,7363501.0],"skipIndex":0,"section_code":"gallery","featured_images":7363501.0,"id":304983,"singleSection":false});				  						galleries[269155] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Weddings","link":"gallery_269155.html","maxRecords":0.0,"photoIDs":[4670118.0,4670207.0,4670617.0,4670649.0,4670766.0,4670796.0,4670814.0,4670832.0,4671066.0,4671350.0,4671550.0,4671556.0,4671726.0,4825078.0,4671080.0,4825021.0],"skipIndex":0,"section_code":"gallery","featured_images":4670118.0,"id":269155,"singleSection":false});				  						galleries[208157] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Urban & Country Landscapes","link":"gallery_208157.html","maxRecords":0.0,"photoIDs":[5384314.0,5455276.0,6354001.0,3437740.0],"skipIndex":0,"section_code":"gallery","featured_images":3437740.0,"id":208157,"singleSection":false});				  						galleries[208158] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Water & Seascapes","link":"gallery_208158.html","maxRecords":0.0,"photoIDs":[3560834.0,3840777.0,5455433.0,5455455.0,5455478.0,5457842.0,5471243.0,5390456.0,5401573.0,3411089.0,3437806.0,3437825.0],"skipIndex":0,"section_code":"gallery","featured_images":"3560834,3437806","id":208158,"singleSection":false});				  						galleries[210158] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Natural World","link":"gallery_210158.html","maxRecords":0.0,"photoIDs":[3437778.0,3471434.0,3507254.0,3561917.0,3573833.0,3773422.0,5455686.0,5463598.0,7025140.0,4795443.0,3893568.0,5403104.0,5390502.0,4326206.0],"skipIndex":0,"section_code":"gallery","featured_images":"7025140,4795443,4326206,3893568","id":210158,"singleSection":false});				  						galleries[210159] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Human Nature","link":"gallery_210159.html","maxRecords":0.0,"photoIDs":[3407790.0,3473306.0,5403109.0,5403141.0,5384357.0],"skipIndex":0,"section_code":"gallery","featured_images":3473306.0,"id":210159,"singleSection":false});				  						galleries[210161] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Man Made World","link":"gallery_210161.html","maxRecords":0.0,"photoIDs":[3442305.0,3457619.0,3473268.0,5384466.0,7053115.0,5384534.0,5384589.0,4663519.0,3573188.0,3407739.0,3411118.0],"skipIndex":0,"section_code":"gallery","featured_images":"4663519,3573188,3411118,3407739","id":210161,"singleSection":false});				  						galleries[210163] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Abstracts","link":"gallery_210163.html","maxRecords":0.0,"photoIDs":[3437767.0,3561078.0],"skipIndex":0,"section_code":"gallery","featured_images":3561078.0,"id":210163,"singleSection":false});				  						galleries[226276] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Derbyshire Peak District National Park","link":"gallery_226276.html","maxRecords":0.0,"photoIDs":[3561291.0,3704382.0,3711546.0,3495978.0],"skipIndex":0,"section_code":"gallery","featured_images":3495978.0,"id":226276,"singleSection":false});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[1] = '7363501,6354001,5471243,5455276,5403141,5403109,5403104,5401573,5390502,5390456,5384589,5384534,5384357,4825021,4795443,4671080,4663519,4326206,3893568,3573188,3561078,3495978,3437825,3437806,3437740,3411118,3411089,3407739';
imageSets[2] = '7363501,7025140,4795443,4670118,4663519,4326206,3893568,3573188,3561078,3560834,3495978,3473306,3437806,3437740,3411118,3407739';
imageSets[3] = '7053115,7025140,5403141,5403109,5384589,5384534,5384357';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/spanky/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/spanky/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/spanky/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/spanky/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/spanky/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/spanky/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/spanky/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/spanky/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/spanky/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/spanky/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/spanky/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/spanky/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/spanky/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/spanky/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/spanky/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/spanky/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://admin2.clikpic.com/spanky/images';
		break;
	}
		switch (server_id) {
		case 33:
		val = 'http://www8.clikpic.com/spanky/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/spanky/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/spanky/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/spanky/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/spanky/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/spanky/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/spanky/images';
		break;
	}
		return val;
}

/***************************************************************************
* img = reference to image object in which to show image                   *
***************************************************************************/
function showHomeImage(img) {
	imageID = randomListVal('');
	if (!basic) {
		img.src = photos[imageID].src;
		img.width = photos[imageID].width;
		img.height = photos[imageID].height;
		img.parentNode.title = img.alt = photos[imageID].caption;
	} else {
		newImage = new Image(photos[imageID].width,photos[imageID].height);
		newImage.src = photos[imageID].src;
		document.images[img.name] = newImage;
		
	}
}

function getHomeImageLink(imageID) {
  	var href='', photo = backgrounds && backgrounds[imageID];
	if(photo){
		if (photo && photo.galleries_id != '') {
  			href = photo.fnGalleryLink();
  		}
  		  		else {
  				href += 'gallery.html';
  	  		}
	}
    return href;
}

/***************************************************************************
* Show a random image on home page from featured images                    *
***************************************************************************/
function showHomeImageInline(el, image_sets_id, href) {
	
	var css = {}, imageID,
	    imageSetsId = 1;
	if(image_sets_id){
		imageSetsId = image_sets_id;
	}
	imageID = randomListVal(imageSets[imageSetsId]);
	if (href == null && 'gallery' != '') {
					href = getHomeImageLink(imageID);
	}
	
	updateImage({nextPhoto: backgrounds[imageID], img:el.find('img')[0],
                $photo:el, $title:$('#homeimageTitleContainer'), $detail:$('#homeimageDetailsContainer'),                speed:0, href:href, css:css, onAfter: function(){                  this.closest('.contentsection').doManualAlign({				    inner: 'img',				    crop: 'a'				  });                }              });
}

/***************************************************************************
* Set 'img' to be a new image given its photo() object                     *
***************************************************************************/
function updateImage (options) {
	var defaults = {nextPhoto:'',field:'',img:'',$photo:'',$title:'',$detail:'',$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 = 'Lee Hankins Photography: ' + 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="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="SPANKY">';
			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({					href: thumbnails[imageID].fnGalleryLink(gallery_id),					title: galleries[gallery_id].title				});
			}
		}
	}
}

/***************************************************************************
* If we have dynamic HTML, replace the galleries link with a list that     *
* doesn't include thecurrent gallery                                       *
***************************************************************************/
function showGalleries(gallery_id) {
		
	
	if (!basic) {
		temp = '';
		for (i = 0; i < galleries.length; i++) {
						
			
			if (galleries[i].id != gallery_id) {
								
				if (temp != '') {
					temp += ' | ';
				}
								temp += '<a href="' + galleries[i].section_code + '_' + galleries[i].id + '.html">' + galleries[i].title + '</a>';
							}
		}
		document.all.galleryLinks.innerHTML = 'Other galleries: ' + temp;
	}
}

			

