window.thumbnails = {};
															thumbnails[3113918] = clik.newPhoto({"id":3113918,"src":"pegs_1_thumb.jpg","galleries_id":191373,"server_id":35,"link":"photo_3113918.html","width":130,"caption":"Pegs","height":173});
															thumbnails[3113950] = clik.newPhoto({"id":3113950,"src":"madeiranladies_1_thumb.jpg","galleries_id":191350,"server_id":35,"link":"photo_3113950.html","width":130,"caption":"Sunbathers","height":87});
															thumbnails[3114462] = clik.newPhoto({"id":3114462,"src":"madeiranboats_1_thumb.jpg","galleries_id":191350,"server_id":35,"link":"photo_3114462.html","width":130,"caption":"Lone Sunbather","height":87});
															thumbnails[3114464] = clik.newPhoto({"id":3114464,"src":"boats_1_thumb.jpg","galleries_id":191373,"server_id":35,"link":"photo_3114464.html","width":130,"caption":"Maderian Boats, Funchal","height":194});
															thumbnails[3747564] = clik.newPhoto({"id":3747564,"src":"cow_1_thumb.jpg","galleries_id":191361,"server_id":35,"link":"photo_3747564.html","width":130,"caption":"Cow","height":194});
															thumbnails[3764783] = clik.newPhoto({"id":3764783,"src":"pig_1_thumb.jpg","galleries_id":191361,"server_id":35,"link":"photo_3764783.html","width":130,"caption":"Pig, Isle of Wight","height":194});
															thumbnails[4632099] = clik.newPhoto({"id":4632099,"src":"dog_1_thumb.jpg","galleries_id":191361,"server_id":35,"link":"photo_4632099.html","width":130,"caption":"Sleeping Dog","height":87});
															thumbnails[3114454] = clik.newPhoto({"id":3114454,"src":"edinburghpassageway_1_thumb.jpg","galleries_id":225263,"server_id":35,"link":"photo_3114454.html","width":130,"caption":"Edinburgh Passageway","height":173});
															thumbnails[3112391] = clik.newPhoto({"id":3112391,"src":"Dungeness_Lighthouse_thumb.jpg","galleries_id":191373,"server_id":5,"link":"photo_3112391.html","width":130,"caption":"Dungeness Lighthouse","height":200});
															thumbnails[3112473] = clik.newPhoto({"id":3112473,"src":"Brighton_Carousel_thumb.jpg","galleries_id":191368,"server_id":5,"link":"photo_3112473.html","width":130,"caption":"Seafront Carousel","height":194});
															thumbnails[3114457] = clik.newPhoto({"id":3114457,"src":"Highland_Cow_close_up_thumb.jpg","galleries_id":191361,"server_id":5,"link":"photo_3114457.html","width":130,"caption":"Highland Cattle","height":194});
															thumbnails[3119126] = clik.newPhoto({"id":3119126,"src":"Ram_close_up_thumb.jpg","galleries_id":191361,"server_id":5,"link":"photo_3119126.html","width":130,"caption":"Sussex Billy goat close up","height":87});
															thumbnails[3119261] = clik.newPhoto({"id":3119261,"src":"Power_Station_thumb.jpg","galleries_id":191373,"server_id":5,"link":"photo_3119261.html","width":130,"caption":"Dungeness Power Station","height":87});
															thumbnails[3119264] = clik.newPhoto({"id":3119264,"src":"West_Pier_Sunset_thumb.jpg","galleries_id":191368,"server_id":5,"link":"photo_3119264.html","width":130,"caption":"West Pier, Brighton","height":87});
															thumbnails[3764994] = clik.newPhoto({"id":3764994,"src":"Camber_Sands_beach_thumb.jpg","galleries_id":191373,"server_id":5,"link":"photo_3764994.html","width":130,"caption":"Camber Sands","height":86});
															thumbnails[3764739] = clik.newPhoto({"id":3764739,"src":"DSCF0335_thumb.JPG","galleries_id":191350,"server_id":5,"link":"photo_3764739.html","width":130,"caption":"Joseph","height":195});
															thumbnails[3764760] = clik.newPhoto({"id":3764760,"src":"malcolm_singing_thumb.jpg","galleries_id":191350,"server_id":5,"link":"photo_3764760.html","width":130,"caption":"Malcolm","height":87});
															thumbnails[3764778] = clik.newPhoto({"id":3764778,"src":"boat_dweller_2_thumb.jpg","galleries_id":191350,"server_id":5,"link":"photo_3764778.html","width":130,"caption":"Canal boat man","height":199});
															thumbnails[3742379] = clik.newPhoto({"id":3742379,"src":"IMG_1088_thumb.JPG","galleries_id":191361,"server_id":5,"link":"photo_3742379.html","width":130,"caption":"Pansy","height":98});
															thumbnails[3119194] = clik.newPhoto({"id":3119194,"src":"worthing sunset portrait_thumb.jpg","galleries_id":191373,"server_id":5,"link":"photo_3119194.html","width":130,"caption":"Winter Sunset Over Worthing Pier","height":173});
															thumbnails[3112230] = clik.newPhoto({"id":3112230,"src":"bw bexhill dome small_thumb.jpg","galleries_id":225263,"server_id":5,"link":"photo_3112230.html","width":130,"caption":"Bexhill seafront","height":87});
															thumbnails[3112233] = clik.newPhoto({"id":3112233,"src":"Worthing fishing boat and pier_thumb.jpg","galleries_id":191373,"server_id":5,"link":"photo_3112233.html","width":130,"caption":"Fishing boat and pier, Worthing, West Sussex","height":85});
															thumbnails[3112239] = clik.newPhoto({"id":3112239,"src":"Sunset West Pier Starlings (1 of 1)_thumb.jpg","galleries_id":191368,"server_id":5,"link":"photo_3112239.html","width":130,"caption":"West Pier Starlings","height":65});
															thumbnails[3112248] = clik.newPhoto({"id":3112248,"src":"West Pier Paramount Blue 4 portrait_thumb.jpg","galleries_id":191368,"server_id":5,"link":"photo_3112248.html","width":130,"caption":"West Pier in Paramount Blue, Brighton","height":173});
															thumbnails[3112288] = clik.newPhoto({"id":3112288,"src":"b-w grehound bexhill (1 of 1)_thumb.jpg","galleries_id":225263,"server_id":5,"link":"photo_3112288.html","width":130,"caption":"Greyhound in Bexhill","height":194});
															thumbnails[3112334] = clik.newPhoto({"id":3112334,"src":"Worthing fishing boat portrait_thumb.jpg","galleries_id":191373,"server_id":5,"link":"photo_3112334.html","width":130,"caption":"Worthing Fishing Boat","height":194});
															thumbnails[3112353] = clik.newPhoto({"id":3112353,"src":"Eiffel Tower_thumb.jpg","galleries_id":225263,"server_id":5,"link":"photo_3112353.html","width":130,"caption":"Eiffel Tower","height":173});
															thumbnails[3112375] = clik.newPhoto({"id":3112375,"src":"French Chocolate Sign_thumb.jpg","galleries_id":190976,"server_id":5,"link":"photo_3112375.html","width":130,"caption":"French Chocolate Sign","height":175});
															thumbnails[3112402] = clik.newPhoto({"id":3112402,"src":"suffolk 2_thumb.jpg","galleries_id":225263,"server_id":5,"link":"photo_3112402.html","width":130,"caption":"Suffolk Tree, Flixton 2008","height":195});
															thumbnails[3112427] = clik.newPhoto({"id":3112427,"src":"French ruin window_thumb.jpg","galleries_id":190976,"server_id":5,"link":"photo_3112427.html","width":130,"caption":"Window in French Ruin","height":173});
															thumbnails[3112441] = clik.newPhoto({"id":3112441,"src":"Carousel and Helter Skelter_thumb.jpg","galleries_id":191368,"server_id":5,"link":"photo_3112441.html","width":130,"caption":"Palace Pier, Brighton.","height":185});
															thumbnails[3112445] = clik.newPhoto({"id":3112445,"src":"Carousel 4_thumb.jpg","galleries_id":191368,"server_id":5,"link":"photo_3112445.html","width":130,"caption":"Palace Pier, Brighton","height":173});
															thumbnails[3112454] = clik.newPhoto({"id":3112454,"src":"Tree_on_Conic_Hill_thumb.jpg","galleries_id":225263,"server_id":5,"link":"photo_3112454.html","width":130,"caption":"Tree on Conic Hill, Balmaha","height":194});
															thumbnails[3112456] = clik.newPhoto({"id":3112456,"src":"Funchal flag display_thumb.jpg","galleries_id":190976,"server_id":5,"link":"photo_3112456.html","width":130,"caption":"Flag display, Funchal, Madeira","height":195});
															thumbnails[3112464] = clik.newPhoto({"id":3112464,"src":"Pavilion reflection2_thumb.jpg","galleries_id":191368,"server_id":5,"link":"photo_3112464.html","width":130,"caption":"Brighton Pavilion reflection","height":70});
															thumbnails[3112478] = clik.newPhoto({"id":3112478,"src":"Carrick_Castle_Loch_Goil_thumb.jpg","galleries_id":191373,"server_id":5,"link":"photo_3112478.html","width":130,"caption":"Carrick Castle, Loch Goil","height":199});
															thumbnails[3113942] = clik.newPhoto({"id":3113942,"src":"windmill_thumb.jpg","galleries_id":190976,"server_id":5,"link":"photo_3113942.html","width":130,"caption":"Jack and Jill Windmills","height":87});
															thumbnails[3113957] = clik.newPhoto({"id":3113957,"src":"gate_thumb.jpg","galleries_id":225263,"server_id":5,"link":"photo_3113957.html","width":130,"caption":"A farm gate on the Sussex Downs","height":87});
															thumbnails[3114446] = clik.newPhoto({"id":3114446,"src":"Beach Hut Panorama Titled_thumb.jpg","galleries_id":191368,"server_id":5,"link":"photo_3114446.html","width":130,"caption":"Brighton beach hut panorama","height":92});
															thumbnails[3114447] = clik.newPhoto({"id":3114447,"src":"Downland Grass_thumb.jpg","galleries_id":225263,"server_id":5,"link":"photo_3114447.html","width":130,"caption":"Downland grasses, Cornwall","height":173});
															thumbnails[3114453] = clik.newPhoto({"id":3114453,"src":"funchal market arial_thumb.jpg","galleries_id":190976,"server_id":5,"link":"photo_3114453.html","width":130,"caption":"Funchal market ","height":195});
															thumbnails[3114459] = clik.newPhoto({"id":3114459,"src":"selva pass_thumb.jpg","galleries_id":225263,"server_id":5,"link":"photo_3114459.html","width":130,"caption":"Pass above Selva, Italy","height":195});
															thumbnails[3114547] = clik.newPhoto({"id":3114547,"src":"Red Snapper_thumb.jpg","galleries_id":190976,"server_id":5,"link":"photo_3114547.html","width":130,"caption":"Red snapper, Sydney fish market","height":173});
															thumbnails[3114725] = clik.newPhoto({"id":3114725,"src":"Highland_Cattle_1_thumb.jpg","galleries_id":191361,"server_id":5,"link":"photo_3114725.html","width":130,"caption":"Highland Cows","height":195});
															thumbnails[3114728] = clik.newPhoto({"id":3114728,"src":"Akaroa moody lighting shot_thumb.jpg","galleries_id":190976,"server_id":5,"link":"photo_3114728.html","width":130,"caption":"Rainstorm in Akaroa, NZ","height":196});
															thumbnails[3119045] = clik.newPhoto({"id":3119045,"src":"Mel and ice cream in Worthing 2008_thumb.jpg","galleries_id":191350,"server_id":5,"link":"photo_3119045.html","width":130,"caption":"Mel and Ice Cream","height":87});
															thumbnails[3119050] = clik.newPhoto({"id":3119050,"src":"werewolf in woolies_thumb.jpg","galleries_id":191350,"server_id":5,"link":"photo_3119050.html","width":130,"caption":"Werewolf in Woolworths","height":195});
															thumbnails[3119055] = clik.newPhoto({"id":3119055,"src":"the bexhill posse (1 of 1)_thumb.jpg","galleries_id":191350,"server_id":5,"link":"photo_3119055.html","width":130,"caption":"The Bexhill Posse","height":87});
															thumbnails[3119068] = clik.newPhoto({"id":3119068,"src":"Sally Mcloy portrait_thumb.jpg","galleries_id":191350,"server_id":5,"link":"photo_3119068.html","width":130,"caption":"Portrait of Sally","height":124});
															thumbnails[3119076] = clik.newPhoto({"id":3119076,"src":"Bee in pollen_thumb.JPG","galleries_id":191361,"server_id":5,"link":"photo_3119076.html","width":130,"caption":"Bee in Pollen","height":173});
															thumbnails[3119097] = clik.newPhoto({"id":3119097,"src":"California Poppy_thumb.jpg","galleries_id":191361,"server_id":5,"link":"photo_3119097.html","width":130,"caption":"California Poppy","height":97});
															thumbnails[3119102] = clik.newPhoto({"id":3119102,"src":"Droplets on a leaf_thumb.JPG","galleries_id":191361,"server_id":5,"link":"photo_3119102.html","width":130,"caption":"Leaf Droplets","height":98});
															thumbnails[3119110] = clik.newPhoto({"id":3119110,"src":"Owl portrait_thumb.jpg","galleries_id":191361,"server_id":5,"link":"photo_3119110.html","width":130,"caption":"Owl portrait","height":122});
															thumbnails[3119111] = clik.newPhoto({"id":3119111,"src":"Loch Leven_thumb.jpg","galleries_id":191373,"server_id":5,"link":"photo_3119111.html","width":130,"caption":"Loch Leven, Scotland","height":194});
															thumbnails[3119113] = clik.newPhoto({"id":3119113,"src":"Fort William Tree_thumb.jpg","galleries_id":225263,"server_id":5,"link":"photo_3119113.html","width":130,"caption":"Fort William Tree","height":194});
															thumbnails[3119124] = clik.newPhoto({"id":3119124,"src":"Temple Tatu Brighton_thumb.jpg","galleries_id":191350,"server_id":5,"link":"photo_3119124.html","width":130,"caption":"Temple Tatu, Brighton","height":87});
															thumbnails[3119130] = clik.newPhoto({"id":3119130,"src":"Ventry_Harbour_Beach_thumb.jpg","galleries_id":191373,"server_id":5,"link":"photo_3119130.html","width":130,"caption":"Ventry Harbour Beach","height":194});
															thumbnails[3119180] = clik.newPhoto({"id":3119180,"src":"Tree Bark Mountfield_thumb.jpg","galleries_id":225263,"server_id":5,"link":"photo_3119180.html","width":130,"caption":"Tree Cross Section","height":173});
															thumbnails[3119259] = clik.newPhoto({"id":3119259,"src":"Path_to_Skye_thumb.jpg","galleries_id":191373,"server_id":5,"link":"photo_3119259.html","width":130,"caption":"The path to Skye","height":173});
															thumbnails[3119278] = clik.newPhoto({"id":3119278,"src":"Eilean_Donan_Castle_thumb.jpg","galleries_id":191373,"server_id":5,"link":"photo_3119278.html","width":130,"caption":"Eilean Donan Castle","height":173});
															thumbnails[3119772] = clik.newPhoto({"id":3119772,"src":"Pompidou Centre_thumb.jpg","galleries_id":190976,"server_id":5,"link":"photo_3119772.html","width":130,"caption":"Pompidou Centre, Paris","height":173});
															thumbnails[3747581] = clik.newPhoto({"id":3747581,"src":"road_to_Glenelg_thumb.jpg","galleries_id":191373,"server_id":5,"link":"photo_3747581.html","width":130,"caption":"The road to Glenelg","height":173});
															thumbnails[3751729] = clik.newPhoto({"id":3751729,"src":"Mel_port_BW_thumb.jpg","galleries_id":191350,"server_id":5,"link":"photo_3751729.html","width":130,"caption":"Mel","height":194});
															thumbnails[5789228] = clik.newPhoto({"id":5789228,"src":"Sunset_over_the_Strait_of_Sleat_thumb.jpg","galleries_id":191373,"server_id":5,"link":"photo_5789228.html","width":130,"caption":"The Strait of Sleat at sunset","height":97});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  						galleries[225263] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Black and White","link":"gallery_225263.html","maxRecords":0.0,"photoIDs":[3114454.0,3112230.0,3112288.0,3112353.0,3112402.0,3112454.0,3113957.0,3114447.0,3114459.0,3119113.0,3119180.0],"skipIndex":0,"section_code":"gallery","featured_images":"3119180,3119113,3114459,3114454,3114447,3113957,3112454,3112402,3112353,3112288","id":225263,"singleSection":false});				  						galleries[191373] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Colour ","link":"gallery_191373.html","maxRecords":0.0,"photoIDs":[3113918.0,3114464.0,3112391.0,3119261.0,3764994.0,3119194.0,3112233.0,3112334.0,3112478.0,3119111.0,3119130.0,3119259.0,3119278.0,3747581.0,5789228.0],"skipIndex":0,"section_code":"gallery","featured_images":"5789228,3764994,3747581,3119278,3119261,3119259,3119194,3119130,3119111,3114464","id":191373,"singleSection":false});				  						galleries[191368] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"In Brighton","link":"gallery_191368.html","maxRecords":0.0,"photoIDs":[3112473.0,3119264.0,3112239.0,3112248.0,3112441.0,3112445.0,3112464.0,3114446.0],"skipIndex":0,"section_code":"gallery","featured_images":"3119264,3114446,3112473,3112464,3112445,3112441,3112248,3112239","id":191368,"singleSection":false});				  						galleries[191361] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Nature","link":"gallery_191361.html","maxRecords":0.0,"photoIDs":[3747564.0,3764783.0,4632099.0,3114457.0,3119126.0,3742379.0,3114725.0,3119076.0,3119097.0,3119102.0,3119110.0],"skipIndex":0,"section_code":"gallery","featured_images":"4632099,3764783,3747564,3742379,3119126,3119110,3119102,3119097,3119076,3114725","id":191361,"singleSection":false});				  						galleries[191350] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"People","link":"gallery_191350.html","maxRecords":0.0,"photoIDs":[3113950.0,3114462.0,3764739.0,3764760.0,3764778.0,3119045.0,3119050.0,3119055.0,3119068.0,3119124.0,3751729.0],"skipIndex":0,"section_code":"gallery","featured_images":"3764778,3764760,3764739,3751729,3119124,3119068,3119055,3119050,3119045,3114462","id":191350,"singleSection":false});				  						galleries[190976] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Travel","link":"gallery_190976.html","maxRecords":0.0,"photoIDs":[3112375.0,3112427.0,3112456.0,3113942.0,3114453.0,3114547.0,3114728.0,3119772.0],"skipIndex":0,"section_code":"gallery","featured_images":"3119772,3114728,3114547,3114453,3113942,3112456,3112427,3112375","id":190976,"singleSection":false});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[1] = '3119126,3119097,3114725,3113942,3112478,3112239';
imageSets[3] = '5789228,4632099,3764994,3764783,3764778,3764760,3764739,3751729,3747581,3747564,3742379,3119772,3119278,3119264,3119261,3119259,3119194,3119180,3119130,3119126,3119124,3119113,3119111,3119110,3119102,3119097,3119076,3119068,3119055,3119050,3119045,3114728,3114725,3114547,3114464,3114462,3114459,3114457,3114454,3114453,3114447,3114446,3113957,3113950,3113942,3113918,3112478,3112473,3112464,3112456';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 51:
		val = 'http://www12.clikpic.com/GaryDP/images';
		break;
	}
		switch (server_id) {
		case 0:
		val = 'http://www.clikpic.com/GaryDP/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/GaryDP/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/GaryDP/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/GaryDP/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/GaryDP/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/GaryDP/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/GaryDP/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/GaryDP/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/GaryDP/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/GaryDP/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/GaryDP/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/GaryDP/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/GaryDP/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/GaryDP/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/GaryDP/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/GaryDP/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/GaryDP/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/GaryDP/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/GaryDP/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/GaryDP/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/GaryDP/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/GaryDP/images';
		break;
	}
		switch (server_id) {
		case 53:
		val = 'http://images.clikpic.com/GaryDP/images';
		break;
	}
		switch (server_id) {
		case 52:
		val = 'http://tpc22/clikpic/GaryDP/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/GaryDP/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/GaryDP/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 Penalver 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.item_price !== '') {
																		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="garypenalver@yahoo.co.uk">';
					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="garypenalver@yahoo.co.uk">';
				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;
	}
}

			

