window.thumbnails = {};
															thumbnails[8616367] = clik.newPhoto({"id":8616367,"src":"1021_thumb.jpg","galleries_id":"","server_id":15,"link":"#","width":130,"caption":"","height":98});
															thumbnails[3824463] = clik.newPhoto({"id":3824463,"src":"100_0601_thumb.jpg","galleries_id":232389,"server_id":15,"link":"photo_3824463.html","width":130,"caption":"Sunrise","height":98});
															thumbnails[3824472] = clik.newPhoto({"id":3824472,"src":"100_0638_thumb.jpg","galleries_id":232389,"server_id":15,"link":"photo_3824472.html","width":130,"caption":"Boat on the Beach","height":98});
															thumbnails[3824474] = clik.newPhoto({"id":3824474,"src":"100_0852_thumb.jpg","galleries_id":232389,"server_id":15,"link":"photo_3824474.html","width":130,"caption":"Sunrise","height":98});
															thumbnails[3824484] = clik.newPhoto({"id":3824484,"src":"100_0854_thumb.jpg","galleries_id":232389,"server_id":15,"link":"photo_3824484.html","width":130,"caption":"The Sunrise","height":98});
															thumbnails[3824490] = clik.newPhoto({"id":3824490,"src":"100_0856_thumb.jpg","galleries_id":232389,"server_id":15,"link":"photo_3824490.html","width":130,"caption":"Sunrise","height":98});
															thumbnails[3824492] = clik.newPhoto({"id":3824492,"src":"100_0883_thumb.jpg","galleries_id":232389,"server_id":15,"link":"photo_3824492.html","width":130,"caption":"Sunrise","height":98});
															thumbnails[3824499] = clik.newPhoto({"id":3824499,"src":"0162a_thumb.jpg","galleries_id":232389,"server_id":15,"link":"photo_3824499.html","width":130,"caption":"Sunset","height":87});
															thumbnails[3824521] = clik.newPhoto({"id":3824521,"src":"8394a_thumb.jpg","galleries_id":232389,"server_id":15,"link":"photo_3824521.html","width":130,"caption":"Sunrise","height":87});
															thumbnails[6967106] = clik.newPhoto({"id":6967106,"src":"3515_thumb.jpg","galleries_id":232383,"server_id":15,"link":"photo_6967106.html","width":130,"caption":"Malham","height":98});
															thumbnails[6967118] = clik.newPhoto({"id":6967118,"src":"3625_thumb.jpg","galleries_id":232383,"server_id":15,"link":"photo_6967118.html","width":130,"caption":"Malham Cove","height":98});
															thumbnails[6971524] = clik.newPhoto({"id":6971524,"src":"3576_thumb.jpg","galleries_id":232383,"server_id":15,"link":"photo_6971524.html","width":130,"caption":"Malhamdale","height":98});
															thumbnails[6987299] = clik.newPhoto({"id":6987299,"src":"7597_thumb.jpg","galleries_id":232383,"server_id":15,"link":"photo_6987299.html","width":130,"caption":"The Crag","height":98});
															thumbnails[7007312] = clik.newPhoto({"id":7007312,"src":"8127_thumb.jpg","galleries_id":232388,"server_id":15,"link":"photo_7007312.html","width":130,"caption":"Tornado 60163","height":98});
															thumbnails[7007645] = clik.newPhoto({"id":7007645,"src":"100_0638_1D54B977-24E8-5EC4-4FADDEA07EBBDFC0_thumb.jpg","galleries_id":379702,"server_id":15,"link":"photo_7007645.html","width":130,"caption":"The Boat","height":98});
															thumbnails[7040275] = clik.newPhoto({"id":7040275,"src":"8876_thumb.jpg","galleries_id":232388,"server_id":15,"link":"photo_7040275.html","width":130,"caption":"Secial Effect","height":98});
															thumbnails[7085727] = clik.newPhoto({"id":7085727,"src":"6922_thumb.jpg","galleries_id":232384,"server_id":15,"link":"photo_7085727.html","width":130,"caption":"Goitstock Falls","height":98});
															thumbnails[7085887] = clik.newPhoto({"id":7085887,"src":"0638_thumb.jpg","galleries_id":232601,"server_id":15,"link":"photo_7085887.html","width":130,"caption":"Malham The Ford","height":98});
															thumbnails[7085932] = clik.newPhoto({"id":7085932,"src":"0644_thumb.jpg","galleries_id":232601,"server_id":15,"link":"photo_7085932.html","width":130,"caption":"The River Aire","height":98});
															thumbnails[7085938] = clik.newPhoto({"id":7085938,"src":"0796_thumb.jpg","galleries_id":232601,"server_id":15,"link":"photo_7085938.html","width":130,"caption":"Lower Laithe Reservoir","height":98});
															thumbnails[7086126] = clik.newPhoto({"id":7086126,"src":"7147_thumb.jpg","galleries_id":232600,"server_id":15,"link":"photo_7086126.html","width":130,"caption":"Whitby","height":98});
															thumbnails[8596197] = clik.newPhoto({"id":8596197,"src":"0048_thumb.jpg","galleries_id":232601,"server_id":15,"link":"photo_8596197.html","width":130,"caption":"Under the Arch","height":98});
															thumbnails[8596236] = clik.newPhoto({"id":8596236,"src":"100_thumb.jpg","galleries_id":232391,"server_id":15,"link":"photo_8596236.html","width":130,"caption":"Clouds-1","height":98});
															thumbnails[8596251] = clik.newPhoto({"id":8596251,"src":"102_thumb.jpg","galleries_id":232391,"server_id":15,"link":"photo_8596251.html","width":130,"caption":"Clouds-2","height":98});
															thumbnails[8596279] = clik.newPhoto({"id":8596279,"src":"119_thumb.jpg","galleries_id":232391,"server_id":15,"link":"photo_8596279.html","width":130,"caption":"Clouds-3","height":98});
															thumbnails[8596294] = clik.newPhoto({"id":8596294,"src":"0223_thumb.jpg","galleries_id":232600,"server_id":15,"link":"photo_8596294.html","width":130,"caption":"Half Moon Cafe","height":98});
															thumbnails[8596376] = clik.newPhoto({"id":8596376,"src":"0236_thumb.jpg","galleries_id":232383,"server_id":15,"link":"photo_8596376.html","width":130,"caption":"Shipley Glen, West Yorkshire","height":98});
															thumbnails[8607813] = clik.newPhoto({"id":8607813,"src":"0300_thumb.jpg","galleries_id":232391,"server_id":15,"link":"photo_8607813.html","width":130,"caption":"Early Morning Feed","height":98});
															thumbnails[8607841] = clik.newPhoto({"id":8607841,"src":"0329_thumb.jpg","galleries_id":232384,"server_id":15,"link":"photo_8607841.html","width":130,"caption":"Goitstock Falls","height":98});
															thumbnails[8607910] = clik.newPhoto({"id":8607910,"src":"1297_thumb.jpg","galleries_id":232384,"server_id":15,"link":"photo_8607910.html","width":130,"caption":"River Aire","height":98});
															thumbnails[8607919] = clik.newPhoto({"id":8607919,"src":"1772_thumb.jpg","galleries_id":232391,"server_id":15,"link":"photo_8607919.html","width":130,"caption":"Old Wreck","height":98});
															thumbnails[8607941] = clik.newPhoto({"id":8607941,"src":"1738_thumb.jpg","galleries_id":232388,"server_id":15,"link":"photo_8607941.html","width":130,"caption":"BR Ivatt No 41241","height":98});
															thumbnails[8607963] = clik.newPhoto({"id":8607963,"src":"2297_thumb.jpg","galleries_id":232388,"server_id":15,"link":"photo_8607963.html","width":130,"caption":"No 60007 Sir Nigel Gresley","height":98});
															thumbnails[8607999] = clik.newPhoto({"id":8607999,"src":"3640_thumb.jpg","galleries_id":232383,"server_id":15,"link":"photo_8607999.html","width":130,"caption":"Early Morning Sun","height":98});
															thumbnails[8608023] = clik.newPhoto({"id":8608023,"src":"4106_thumb.jpg","galleries_id":232600,"server_id":15,"link":"photo_8608023.html","width":130,"caption":"","height":98});
															thumbnails[8608054] = clik.newPhoto({"id":8608054,"src":"4819_thumb.jpg","galleries_id":232383,"server_id":15,"link":"photo_8608054.html","width":130,"caption":"Tree on a Hill","height":98});
															thumbnails[8608073] = clik.newPhoto({"id":8608073,"src":"4781_thumb.jpg","galleries_id":232383,"server_id":15,"link":"photo_8608073.html","width":130,"caption":"Leeming Reservoir","height":98});
															thumbnails[8608136] = clik.newPhoto({"id":8608136,"src":"4823_thumb.jpg","galleries_id":232383,"server_id":15,"link":"photo_8608136.html","width":130,"caption":"Hill and Sky","height":98});
															thumbnails[8608154] = clik.newPhoto({"id":8608154,"src":"4837_thumb.jpg","galleries_id":232383,"server_id":15,"link":"photo_8608154.html","width":130,"caption":"Stanbury","height":98});
															thumbnails[8608213] = clik.newPhoto({"id":8608213,"src":"4839_thumb.jpg","galleries_id":232383,"server_id":15,"link":"photo_8608213.html","width":130,"caption":"Lower Laithe Reservoir","height":98});
															thumbnails[8608230] = clik.newPhoto({"id":8608230,"src":"6610_thumb.jpg","galleries_id":232391,"server_id":15,"link":"photo_8608230.html","width":130,"caption":"Dramatic Sky","height":98});
															thumbnails[8608250] = clik.newPhoto({"id":8608250,"src":"6827_thumb.jpg","galleries_id":232384,"server_id":15,"link":"photo_8608250.html","width":130,"caption":"River Aire","height":98});
															thumbnails[8608301] = clik.newPhoto({"id":8608301,"src":"6875_thumb.jpg","galleries_id":232384,"server_id":15,"link":"photo_8608301.html","width":130,"caption":"River Aire","height":98});
															thumbnails[8608324] = clik.newPhoto({"id":8608324,"src":"8878_thumb.jpg","galleries_id":232383,"server_id":15,"link":"photo_8608324.html","width":130,"caption":"Oxenhope","height":98});
															thumbnails[8611849] = clik.newPhoto({"id":8611849,"src":"6940_thumb.jpg","galleries_id":232384,"server_id":15,"link":"photo_8611849.html","width":130,"caption":"Goitstock Falls","height":98});
															thumbnails[8611855] = clik.newPhoto({"id":8611855,"src":"7013_thumb.jpg","galleries_id":232384,"server_id":15,"link":"photo_8611855.html","width":130,"caption":"Pecca Falls (first)","height":98});
															thumbnails[8611884] = clik.newPhoto({"id":8611884,"src":"7085_thumb.jpg","galleries_id":232384,"server_id":15,"link":"photo_8611884.html","width":130,"caption":"Beezing Falls","height":98});
															thumbnails[8611894] = clik.newPhoto({"id":8611894,"src":"7099_thumb.jpg","galleries_id":232384,"server_id":15,"link":"photo_8611894.html","width":130,"caption":"Triple  Spout","height":98});
															thumbnails[8611897] = clik.newPhoto({"id":8611897,"src":"8184_thumb.jpg","galleries_id":232383,"server_id":15,"link":"photo_8611897.html","width":130,"caption":"Farm Track","height":98});
															thumbnails[8611901] = clik.newPhoto({"id":8611901,"src":"8193_thumb.jpg","galleries_id":232383,"server_id":15,"link":"photo_8611901.html","width":130,"caption":"Lower Laithe Reservoir","height":98});
															thumbnails[8611903] = clik.newPhoto({"id":8611903,"src":"8931_thumb.jpg","galleries_id":232383,"server_id":15,"link":"photo_8611903.html","width":130,"caption":"Haworth West Yorkshire","height":98});
															thumbnails[8611929] = clik.newPhoto({"id":8611929,"src":"8993_thumb.jpg","galleries_id":232600,"server_id":15,"link":"photo_8611929.html","width":130,"caption":"Salts Mill","height":98});
															thumbnails[8611931] = clik.newPhoto({"id":8611931,"src":"8998_thumb.jpg","galleries_id":232600,"server_id":15,"link":"photo_8611931.html","width":130,"caption":"Victoria Hall","height":98});
															thumbnails[8611934] = clik.newPhoto({"id":8611934,"src":"9079_thumb.jpg","galleries_id":232600,"server_id":15,"link":"photo_8611934.html","width":130,"caption":"Old Mill","height":98});
															thumbnails[8611940] = clik.newPhoto({"id":8611940,"src":"9132_thumb.jpg","galleries_id":232384,"server_id":15,"link":"photo_8611940.html","width":130,"caption":"Lumb Bridge","height":98});
															thumbnails[8611947] = clik.newPhoto({"id":8611947,"src":"9367_thumb.jpg","galleries_id":232383,"server_id":15,"link":"photo_8611947.html","width":130,"caption":"Red Hill","height":98});
															thumbnails[8611964] = clik.newPhoto({"id":8611964,"src":"9584_thumb.jpg","galleries_id":232601,"server_id":15,"link":"photo_8611964.html","width":130,"caption":"Winter Fields","height":98});
															thumbnails[8611966] = clik.newPhoto({"id":8611966,"src":"9755_thumb.jpg","galleries_id":232601,"server_id":15,"link":"photo_8611966.html","width":130,"caption":"United Reformed Church","height":98});
															thumbnails[8611974] = clik.newPhoto({"id":8611974,"src":"9765_thumb.jpg","galleries_id":232601,"server_id":15,"link":"photo_8611974.html","width":130,"caption":"Half Moon Cafe","height":98});
															thumbnails[8614942] = clik.newPhoto({"id":8614942,"src":"9902_thumb.jpg","galleries_id":232601,"server_id":15,"link":"photo_8614942.html","width":130,"caption":"Ice Falls","height":98});
															thumbnails[8614959] = clik.newPhoto({"id":8614959,"src":"056_thumb.jpg","galleries_id":232388,"server_id":15,"link":"photo_8614959.html","width":130,"caption":"L & Y 2F Locomotive","height":98});
															thumbnails[8614993] = clik.newPhoto({"id":8614993,"src":"2766_thumb.jpg","galleries_id":232388,"server_id":15,"link":"photo_8614993.html","width":130,"caption":"Class 47 715  K.W.V.R.","height":98});
															thumbnails[8615016] = clik.newPhoto({"id":8615016,"src":"2774_thumb.jpg","galleries_id":232388,"server_id":15,"link":"photo_8615016.html","width":130,"caption":"Deltic No55 019 Royal Highland Fusilier","height":98});
															thumbnails[8615024] = clik.newPhoto({"id":8615024,"src":"2786_thumb.jpg","galleries_id":232388,"server_id":15,"link":"photo_8615024.html","width":130,"caption":"Class 56 311","height":98});
															thumbnails[8615031] = clik.newPhoto({"id":8615031,"src":"3312_thumb.jpg","galleries_id":232388,"server_id":15,"link":"photo_8615031.html","width":130,"caption":"Class 20 031","height":98});
															thumbnails[8615052] = clik.newPhoto({"id":8615052,"src":"3525_thumb.jpg","galleries_id":232388,"server_id":15,"link":"photo_8615052.html","width":130,"caption":"Black Five No 45305","height":98});
															thumbnails[8664990] = clik.newPhoto({"id":8664990,"src":"3406_pencil_thumb.jpg","galleries_id":232387,"server_id":15,"link":"photo_8664990.html","width":130,"caption":"Keighley Departure","height":98});
															thumbnails[9045560] = clik.newPhoto({"id":9045560,"src":"0855A1_thumb.jpg","galleries_id":232388,"server_id":15,"link":"photo_9045560.html","width":130,"caption":"Out of the Steam","height":98});
															thumbnails[9045597] = clik.newPhoto({"id":9045597,"src":"1037_thumb.jpg","galleries_id":232391,"server_id":15,"link":"photo_9045597.html","width":130,"caption":"Tha Band Stand","height":173});
															thumbnails[9045625] = clik.newPhoto({"id":9045625,"src":"9892_thumb.jpg","galleries_id":232601,"server_id":15,"link":"photo_9045625.html","width":130,"caption":"Frozen Falls","height":98});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  						galleries[232383] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Landscapes","link":"gallery_232383.html","maxRecords":0.0,"photoIDs":[6967106.0,6967118.0,6971524.0,6987299.0,8596376.0,8607999.0,8608054.0,8608073.0,8608136.0,8608154.0,8608213.0,8608324.0,8611897.0,8611901.0,8611903.0,8611947.0],"skipIndex":0,"section_code":"gallery","featured_images":"8611947,8611903,8611901,8611897,8608324,8608213,8608154,8608136,8608073,8608054","id":232383,"singleSection":false});				  						galleries[232384] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Water","link":"gallery_232384.html","maxRecords":0.0,"photoIDs":[7085727.0,8607841.0,8607910.0,8608250.0,8608301.0,8611849.0,8611855.0,8611884.0,8611894.0,8611940.0],"skipIndex":0,"section_code":"gallery","featured_images":"8611940,8611894,8611884,8611855,8611849,8608301,8608250,8607910,8607841,7085727","id":232384,"singleSection":false});				  						galleries[232387] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Black & White","link":"gallery_232387.html","maxRecords":0.0,"photoIDs":[8664990.0],"skipIndex":0,"section_code":"gallery","featured_images":8664990.0,"id":232387,"singleSection":false});				  						galleries[232388] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Transport","link":"gallery_232388.html","maxRecords":0.0,"photoIDs":[7007312.0,7040275.0,8607941.0,8607963.0,8614959.0,8614993.0,8615016.0,8615024.0,8615031.0,8615052.0,9045560.0],"skipIndex":0,"section_code":"gallery","featured_images":"9045560,8615052,8615031,8615024,8615016,8614993,8614959,8607963,8607941,7040275","id":232388,"singleSection":false});				  						galleries[232389] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Sunset & Sunrise","link":"gallery_232389.html","maxRecords":0.0,"photoIDs":[3824463.0,3824472.0,3824474.0,3824484.0,3824490.0,3824492.0,3824499.0,3824521.0],"skipIndex":0,"section_code":"gallery","featured_images":3824484.0,"id":232389,"singleSection":false});				  						galleries[232391] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Miscellaneous","link":"gallery_232391.html","maxRecords":0.0,"photoIDs":[8596236.0,8596251.0,8596279.0,8607813.0,8607919.0,8608230.0,9045597.0],"skipIndex":0,"section_code":"gallery","featured_images":8608230.0,"id":232391,"singleSection":false});				  						galleries[232600] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Urban","link":"gallery_232600.html","maxRecords":0.0,"photoIDs":[7086126.0,8596294.0,8608023.0,8611929.0,8611931.0,8611934.0],"skipIndex":0,"section_code":"gallery","featured_images":"8611934,8611931,8611929,8608023,8596294,7086126","id":232600,"singleSection":false});				  						galleries[232601] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Winter Scenes","link":"gallery_232601.html","maxRecords":0.0,"photoIDs":[7085887.0,7085932.0,7085938.0,8596197.0,8611964.0,8611966.0,8611974.0,8614942.0,9045625.0],"skipIndex":0,"section_code":"gallery","featured_images":9045625.0,"id":232601,"singleSection":false});				  						galleries[379702] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Special Size","link":"gallery_379702.html","maxRecords":0.0,"photoIDs":[7007645.0],"skipIndex":0,"section_code":"gallery","featured_images":7007645.0,"id":379702,"singleSection":false});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[1] = '9045597,8615052,8614993,8614942,8611974,8611966,8611849,8608023,8607963,8607841,8596294,8596279,8596251,8596236,8596197,3824484,3824472';
imageSets[2] = '9045625,8608230,3824484';
imageSets[3] = '9045560,8664990,8615052,8615016,8614959,8614942,8611974,8611966,8611849,8608136,8608073,8608054,8608023,8607963,8607941,8607919,8607841,8596376,8596294,8596279,8596251,8596236,8596197,6967118,6967106';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 51:
		val = 'http://www12.clikpic.com/gholmes/images';
		break;
	}
		switch (server_id) {
		case 0:
		val = 'http://www.clikpic.com/gholmes/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/gholmes/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/gholmes/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/gholmes/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/gholmes/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/gholmes/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/gholmes/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/gholmes/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/gholmes/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/gholmes/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/gholmes/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/gholmes/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/gholmes/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/gholmes/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/gholmes/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/gholmes/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/gholmes/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/gholmes/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/gholmes/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/gholmes/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/gholmes/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/gholmes/images';
		break;
	}
		switch (server_id) {
		case 53:
		val = 'http://images.clikpic.com/gholmes/images';
		break;
	}
		switch (server_id) {
		case 52:
		val = 'http://tpc22/clikpic/gholmes/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/gholmes/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/gholmes/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 = 'Gary Holmes Foto Shop: ' + 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.item_price !== '') {
											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="GHOLMES">';
			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;
	}
}

			

