window.thumbnails = {};
															thumbnails[1302285] = clik.newPhoto({"id":1302285,"src":"IMG_3034t.jpg","galleries_id":92311,"server_id":18,"link":"photo_1302285.html","width":130,"caption":"","height":87});
															thumbnails[1300145] = clik.newPhoto({"id":1300145,"src":"IMG3538t.jpg","galleries_id":92313,"server_id":18,"link":"photo_1300145.html","width":81,"caption":"","height":130});
															thumbnails[1302541] = clik.newPhoto({"id":1302541,"src":"JC170207103T.jpg","galleries_id":92327,"server_id":18,"link":"photo_1302541.html","width":87,"caption":"","height":130});
															thumbnails[4470636] = clik.newPhoto({"id":4470636,"src":"SA2_thumb.jpg","galleries_id":228568,"server_id":18,"link":"photo_4470636.html","width":92,"caption":"Almost ready!","height":130});
															thumbnails[1303570] = clik.newPhoto({"id":1303570,"src":"JC170207135T.jpg","galleries_id":92327,"server_id":18,"link":"photo_1303570.html","width":86,"caption":"","height":130});
															thumbnails[4470642] = clik.newPhoto({"id":4470642,"src":"SA8_thumb.jpg","galleries_id":228568,"server_id":18,"link":"photo_4470642.html","width":130,"caption":"Arriving","height":87});
															thumbnails[1303572] = clik.newPhoto({"id":1303572,"src":"JC170207147T.jpg","galleries_id":92327,"server_id":18,"link":"photo_1303572.html","width":87,"caption":"","height":130});
															thumbnails[4470641] = clik.newPhoto({"id":4470641,"src":"SA7_thumb.jpg","galleries_id":228568,"server_id":18,"link":"photo_4470641.html","width":130,"caption":"Nervously waiting!","height":72});
															thumbnails[1303574] = clik.newPhoto({"id":1303574,"src":"JC170207161T.jpg","galleries_id":92327,"server_id":18,"link":"photo_1303574.html","width":87,"caption":"","height":130});
															thumbnails[4470637] = clik.newPhoto({"id":4470637,"src":"SA3_thumb.jpg","galleries_id":228568,"server_id":18,"link":"photo_4470637.html","width":130,"caption":"The ceremony begins!","height":87});
															thumbnails[1303577] = clik.newPhoto({"id":1303577,"src":"JC170207185T.jpg","galleries_id":92327,"server_id":18,"link":"photo_1303577.html","width":130,"caption":"","height":87});
															thumbnails[4470634] = clik.newPhoto({"id":4470634,"src":"SA10_thumb.jpg","galleries_id":228568,"server_id":18,"link":"photo_4470634.html","width":130,"caption":"Ceremony almost over!","height":87});
															thumbnails[1303576] = clik.newPhoto({"id":1303576,"src":"JC170207184T.jpg","galleries_id":92327,"server_id":18,"link":"photo_1303576.html","width":130,"caption":"","height":87});
															thumbnails[4470640] = clik.newPhoto({"id":4470640,"src":"SA6_thumb.jpg","galleries_id":228568,"server_id":18,"link":"photo_4470640.html","width":101,"caption":"Ceremony over!","height":130});
															thumbnails[1303578] = clik.newPhoto({"id":1303578,"src":"JC170207189T.jpg","galleries_id":92327,"server_id":18,"link":"photo_1303578.html","width":87,"caption":"","height":130});
															thumbnails[4470639] = clik.newPhoto({"id":4470639,"src":"SA5_thumb.jpg","galleries_id":228568,"server_id":18,"link":"photo_4470639.html","width":130,"caption":"Sisters together!","height":87});
															thumbnails[1303579] = clik.newPhoto({"id":1303579,"src":"JC170207201T.jpg","galleries_id":92327,"server_id":18,"link":"photo_1303579.html","width":87,"caption":"","height":130});
															thumbnails[4470643] = clik.newPhoto({"id":4470643,"src":"SA9_thumb.jpg","galleries_id":228568,"server_id":18,"link":"photo_4470643.html","width":130,"caption":"Formal","height":110});
															thumbnails[1303580] = clik.newPhoto({"id":1303580,"src":"JC170207265T.jpg","galleries_id":92327,"server_id":18,"link":"photo_1303580.html","width":130,"caption":"","height":87});
															thumbnails[4470638] = clik.newPhoto({"id":4470638,"src":"SA4_thumb.jpg","galleries_id":228568,"server_id":18,"link":"photo_4470638.html","width":130,"caption":"Enjoying the grounds of Hardwick Hall","height":87});
															thumbnails[1303582] = clik.newPhoto({"id":1303582,"src":"JC170207029T.jpg","galleries_id":92327,"server_id":18,"link":"photo_1303582.html","width":89,"caption":"","height":130});
															thumbnails[4470633] = clik.newPhoto({"id":4470633,"src":"SA1_thumb.jpg","galleries_id":228568,"server_id":18,"link":"photo_4470633.html","width":120,"caption":"First Dance","height":130});
															thumbnails[1330801] = clik.newPhoto({"id":1330801,"src":"J&D120807856T.jpg","galleries_id":93721,"server_id":18,"link":"photo_1330801.html","width":119,"caption":"","height":130});
															thumbnails[4470635] = clik.newPhoto({"id":4470635,"src":"SA11_thumb.jpg","galleries_id":228568,"server_id":18,"link":"photo_4470635.html","width":103,"caption":"First Dance","height":130});
															thumbnails[1413058] = clik.newPhoto({"id":1413058,"src":"J&D120807_968T.jpg","galleries_id":93721,"server_id":18,"link":"photo_1413058.html","width":130,"caption":"","height":79});
															thumbnails[1399115] = clik.newPhoto({"id":1399115,"src":"J&D120807_962T.jpg","galleries_id":93721,"server_id":18,"link":"photo_1399115.html","width":87,"caption":"","height":130});
															thumbnails[1413315] = clik.newPhoto({"id":1413315,"src":"J&D120807_982T.jpg","galleries_id":93721,"server_id":18,"link":"photo_1413315.html","width":102,"caption":"","height":130});
															thumbnails[5084283] = clik.newPhoto({"id":5084283,"src":"7x5-0897_thumb.jpg","galleries_id":272167,"server_id":18,"link":"photo_5084283.html","width":130,"caption":"","height":87});
															thumbnails[6520097] = clik.newPhoto({"id":6520097,"src":"Alex-sample-2_thumb.jpg","galleries_id":358656,"server_id":18,"link":"photo_6520097.html","width":130,"caption":"","height":87});
															thumbnails[5084284] = clik.newPhoto({"id":5084284,"src":"7x5-0916_thumb.jpg","galleries_id":272167,"server_id":18,"link":"photo_5084284.html","width":115,"caption":"","height":130});
															thumbnails[5084285] = clik.newPhoto({"id":5084285,"src":"7x5-0927_thumb.jpg","galleries_id":272167,"server_id":18,"link":"photo_5084285.html","width":87,"caption":"","height":130});
															thumbnails[5084286] = clik.newPhoto({"id":5084286,"src":"7x5-0929_thumb.jpg","galleries_id":272167,"server_id":18,"link":"photo_5084286.html","width":87,"caption":"","height":130});
															thumbnails[5084287] = clik.newPhoto({"id":5084287,"src":"7x5-0977_thumb.jpg","galleries_id":272167,"server_id":18,"link":"photo_5084287.html","width":107,"caption":"","height":130});
															thumbnails[5084288] = clik.newPhoto({"id":5084288,"src":"7x5-0978_thumb.jpg","galleries_id":272167,"server_id":18,"link":"photo_5084288.html","width":130,"caption":"","height":87});
															thumbnails[5084289] = clik.newPhoto({"id":5084289,"src":"7x5-0983_thumb.jpg","galleries_id":272167,"server_id":18,"link":"photo_5084289.html","width":130,"caption":"","height":91});
															thumbnails[5084290] = clik.newPhoto({"id":5084290,"src":"7x5-0988_thumb.jpg","galleries_id":272167,"server_id":18,"link":"photo_5084290.html","width":130,"caption":"","height":98});
															thumbnails[5084291] = clik.newPhoto({"id":5084291,"src":"7x5-0990_thumb.jpg","galleries_id":272167,"server_id":18,"link":"photo_5084291.html","width":130,"caption":"","height":91});
															thumbnails[5084292] = clik.newPhoto({"id":5084292,"src":"7x5-0991_thumb.jpg","galleries_id":272167,"server_id":18,"link":"photo_5084292.html","width":130,"caption":"","height":87});
															thumbnails[5084293] = clik.newPhoto({"id":5084293,"src":"7x5-1071_thumb.jpg","galleries_id":272167,"server_id":18,"link":"photo_5084293.html","width":130,"caption":"","height":90});
															thumbnails[5084294] = clik.newPhoto({"id":5084294,"src":"7x5-1129_thumb.jpg","galleries_id":272167,"server_id":18,"link":"photo_5084294.html","width":130,"caption":"","height":87});
															thumbnails[5084295] = clik.newPhoto({"id":5084295,"src":"7x5-1134_thumb.jpg","galleries_id":272167,"server_id":18,"link":"photo_5084295.html","width":130,"caption":"7x5-1134","height":97});
															thumbnails[5084297] = clik.newPhoto({"id":5084297,"src":"7x5-1136_thumb.jpg","galleries_id":272167,"server_id":18,"link":"photo_5084297.html","width":130,"caption":"","height":93});
															thumbnails[5084298] = clik.newPhoto({"id":5084298,"src":"7x5-1140_thumb.jpg","galleries_id":272167,"server_id":18,"link":"photo_5084298.html","width":130,"caption":"7x5-1140","height":87});
															thumbnails[4743531] = clik.newPhoto({"id":4743531,"src":"IMG_0401_thumb.jpg","galleries_id":272167,"server_id":18,"link":"photo_4743531.html","width":130,"caption":"","height":87});
															thumbnails[5084299] = clik.newPhoto({"id":5084299,"src":"7x5-1143_thumb.jpg","galleries_id":272167,"server_id":18,"link":"photo_5084299.html","width":130,"caption":"7x5-1143","height":87});
															thumbnails[4743532] = clik.newPhoto({"id":4743532,"src":"IMG_0403_thumb.jpg","galleries_id":272167,"server_id":18,"link":"photo_4743532.html","width":130,"caption":"IMG 0403","height":87});
															thumbnails[5084300] = clik.newPhoto({"id":5084300,"src":"7x5-1147_thumb.jpg","galleries_id":272167,"server_id":18,"link":"photo_5084300.html","width":130,"caption":"7x5-1147","height":103});
															thumbnails[4743533] = clik.newPhoto({"id":4743533,"src":"IMG_0407_thumb.jpg","galleries_id":272167,"server_id":18,"link":"photo_4743533.html","width":130,"caption":"IMG 0407","height":87});
															thumbnails[4743534] = clik.newPhoto({"id":4743534,"src":"IMG_0408_thumb.jpg","galleries_id":272167,"server_id":18,"link":"photo_4743534.html","width":87,"caption":"IMG 0408","height":130});
															thumbnails[4743535] = clik.newPhoto({"id":4743535,"src":"IMG_04081_thumb.jpg","galleries_id":272167,"server_id":18,"link":"photo_4743535.html","width":87,"caption":"IMG 04081","height":130});
															thumbnails[4743536] = clik.newPhoto({"id":4743536,"src":"IMG_0409_thumb.jpg","galleries_id":272167,"server_id":18,"link":"photo_4743536.html","width":87,"caption":"IMG 0409","height":130});
															thumbnails[4743537] = clik.newPhoto({"id":4743537,"src":"IMG_0410_thumb.jpg","galleries_id":272167,"server_id":18,"link":"photo_4743537.html","width":87,"caption":"IMG 0410","height":130});
															thumbnails[4743516] = clik.newPhoto({"id":4743516,"src":"IMG_0356_thumb.jpg","galleries_id":287618,"server_id":18,"link":"photo_4743516.html","width":89,"caption":"","height":130});
															thumbnails[4743517] = clik.newPhoto({"id":4743517,"src":"IMG_0357_thumb.jpg","galleries_id":287618,"server_id":18,"link":"photo_4743517.html","width":87,"caption":"","height":130});
															thumbnails[4743518] = clik.newPhoto({"id":4743518,"src":"IMG_0358_thumb.jpg","galleries_id":287618,"server_id":18,"link":"photo_4743518.html","width":87,"caption":"","height":130});
															thumbnails[4743519] = clik.newPhoto({"id":4743519,"src":"IMG_0359_thumb.jpg","galleries_id":287618,"server_id":18,"link":"photo_4743519.html","width":87,"caption":"","height":130});
															thumbnails[4743520] = clik.newPhoto({"id":4743520,"src":"IMG_0360_thumb.jpg","galleries_id":287618,"server_id":18,"link":"photo_4743520.html","width":87,"caption":"","height":130});
															thumbnails[4743524] = clik.newPhoto({"id":4743524,"src":"IMG_0364_thumb.jpg","galleries_id":287618,"server_id":18,"link":"photo_4743524.html","width":93,"caption":"","height":130});
															thumbnails[1577133] = clik.newPhoto({"id":1577133,"src":"Youdell-tarn-t.jpg","galleries_id":107808,"server_id":18,"link":"photo_1577133.html","width":130,"caption":"Youdell Tarn ","height":65});
															thumbnails[1577205] = clik.newPhoto({"id":1577205,"src":"Millenium-BridgeT.jpg","galleries_id":107808,"server_id":18,"link":"photo_1577205.html","width":130,"caption":"","height":80});
															thumbnails[5104161] = clik.newPhoto({"id":5104161,"src":"20091113-IMG_1298_thumb.jpg","galleries_id":107808,"server_id":18,"link":"photo_5104161.html","width":130,"caption":"","height":87});
															thumbnails[5104162] = clik.newPhoto({"id":5104162,"src":"20091113-IMG_1299_thumb.jpg","galleries_id":107808,"server_id":18,"link":"photo_5104162.html","width":130,"caption":"","height":87});
															thumbnails[5104163] = clik.newPhoto({"id":5104163,"src":"20091113-IMG_1300_thumb.jpg","galleries_id":107808,"server_id":18,"link":"photo_5104163.html","width":130,"caption":"","height":87});
															thumbnails[5104164] = clik.newPhoto({"id":5104164,"src":"20091113-IMG_1302_thumb.jpg","galleries_id":107808,"server_id":18,"link":"photo_5104164.html","width":130,"caption":"","height":87});
															thumbnails[5104165] = clik.newPhoto({"id":5104165,"src":"20091113-IMG_1303_thumb.jpg","galleries_id":107808,"server_id":18,"link":"photo_5104165.html","width":130,"caption":"","height":87});
															thumbnails[5104166] = clik.newPhoto({"id":5104166,"src":"20091113-IMG_1304_thumb.jpg","galleries_id":107808,"server_id":18,"link":"photo_5104166.html","width":130,"caption":"","height":87});
															thumbnails[5104167] = clik.newPhoto({"id":5104167,"src":"20091113-IMG_1305_thumb.jpg","galleries_id":107808,"server_id":18,"link":"photo_5104167.html","width":130,"caption":"","height":87});
															thumbnails[5104168] = clik.newPhoto({"id":5104168,"src":"20091113-IMG_1306_thumb.jpg","galleries_id":107808,"server_id":18,"link":"photo_5104168.html","width":130,"caption":"","height":87});
															thumbnails[5104169] = clik.newPhoto({"id":5104169,"src":"20091113-IMG_1307_thumb.jpg","galleries_id":107808,"server_id":18,"link":"photo_5104169.html","width":130,"caption":"","height":87});
															thumbnails[5104170] = clik.newPhoto({"id":5104170,"src":"20091113-IMG_1308_thumb.jpg","galleries_id":107808,"server_id":18,"link":"photo_5104170.html","width":130,"caption":"","height":87});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  						galleries[287618] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Fashion ","link":"section345058.html","maxRecords":0.0,"photoIDs":[4743516.0,4743517.0,4743518.0,4743519.0,4743520.0,4743524.0],"skipIndex":0,"section_code":"section345058","featured_images":4743517.0,"id":287618,"singleSection":true});				  						galleries[358656] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Kids","link":"section327126_358656.html","maxRecords":0.0,"photoIDs":[6520097.0],"skipIndex":0,"section_code":"section327126","featured_images":6520097.0,"id":358656,"singleSection":false});				  						galleries[272167] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Portraits ","link":"section327126_272167.html","maxRecords":0.0,"photoIDs":[5084283.0,5084284.0,5084285.0,5084286.0,5084287.0,5084288.0,5084289.0,5084290.0,5084291.0,5084292.0,5084293.0,5084294.0,5084295.0,5084297.0,5084298.0,4743531.0,5084299.0,4743532.0,5084300.0,4743533.0,4743534.0,4743535.0,4743536.0,4743537.0],"skipIndex":0,"section_code":"section327126","featured_images":5084299.0,"id":272167,"singleSection":false});				  						galleries[228568] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Sarah and Andrew","link":"gallery_228568.html","maxRecords":0.0,"photoIDs":[4470636.0,4470642.0,4470641.0,4470637.0,4470634.0,4470640.0,4470639.0,4470643.0,4470638.0,4470633.0,4470635.0],"skipIndex":0,"section_code":"gallery","featured_images":4470638.0,"id":228568,"singleSection":false});				  						galleries[107808] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Travel","link":"section125218.html","maxRecords":0.0,"photoIDs":[1577133.0,1577205.0,5104161.0,5104162.0,5104163.0,5104164.0,5104165.0,5104166.0,5104167.0,5104168.0,5104169.0,5104170.0],"skipIndex":0,"section_code":"section125218","featured_images":"1577205,1577133","id":107808,"singleSection":true});				  						galleries[92311] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Jackie and Robbie","link":"gallery_92311.html","maxRecords":0.0,"photoIDs":[1302285.0],"skipIndex":0,"section_code":"gallery","featured_images":1302285.0,"id":92311,"singleSection":false});				  						galleries[92313] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Debbie and Shaun","link":"gallery_92313.html","maxRecords":0.0,"photoIDs":[1300145.0],"skipIndex":0,"section_code":"gallery","featured_images":1300145.0,"id":92313,"singleSection":false});				  						galleries[92327] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Jenny and Chris","link":"gallery_92327.html","maxRecords":0.0,"photoIDs":[1302541.0,1303570.0,1303572.0,1303574.0,1303577.0,1303576.0,1303578.0,1303579.0,1303580.0,1303582.0],"skipIndex":0,"section_code":"gallery","featured_images":"1303582,1303580,1303579,1303578,1303577,1303576,1303574,1303572,1303570,1302541","id":92327,"singleSection":false});				  						galleries[93721] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Jane and Derek","link":"gallery_93721.html","maxRecords":0.0,"photoIDs":[1330801.0,1413058.0,1399115.0,1413315.0],"skipIndex":0,"section_code":"gallery","featured_images":"1413058,1330801","id":93721,"singleSection":false});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[1] = '5104164,5084297,5084289,4470638,4470633,1577205,1577133,1413058,1330801';
imageSets[2] = '5084299,4743517,4470638,1577205,1577133,1413058,1330801,1300145';
imageSets[3] = '6520097,5104170,5104169,5104168,5104167,5104166,5104165,5104164,5104163,5104162,5104161,5084300,5084299,5084298,5084297,5084295,5084294,5084293,5084292,5084291,5084290,5084289,5084288,5084287,5084286,5084285,5084284,5084283,4743537,4743536,4743535,4743534,4743533,4743532,4743531,4743524,4743520,4743519,4743518,4743517,4743516,4470643,4470642,4470641,4470640,4470639,4470638,4470637,4470636,4470635';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 51:
		val = 'www12.clikpic.com/sangar/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/sangar/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/sangar/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/sangar/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/sangar/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/sangar/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/sangar/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/sangar/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/sangar/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/sangar/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/sangar/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/sangar/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/sangar/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/sangar/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/sangar/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/sangar/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/sangar/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/sangar/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/sangar/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/sangar/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/sangar/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/sangar/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/sangar/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/sangar/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 = 'Gary James 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>';
	}
				
				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>Order this print:</p>';
				temp += '<div class="imageinfo" id="imagePrice"><strong>' + this.purchase_instruction + '</strong> ' + (this.item_price).toFixed(2) + '</div>';
		var item_name  = this.purchase_instruction;
		var amount = (this.item_price).toFixed(2);
		var item_option  = 0;
	}
	else if (this.payment_groups_id !== '') {
		temp += '<p>Buy this print online:</p>';
				temp += '<form id="paymentOptions" style="margin:0px;border:0px;" name="paymentOptions">';
											temp += '<select class="paymentlink" name="payment_options_id" onchange="updateItemValues($(this.form).next(\'#paymentForm\')[0],this.form.payment_options_id.options[this.form.payment_options_id.options.selectedIndex].value);">';
		
		temp += getPaymentOptions(this.payment_groups_id);
		temp += '</select>';
		temp += '</form>';
				var item_option  = paymentGroups[this.payment_groups_id].options[0];
		if(paymentOptions[item_option]){
			var item_name  = paymentOptions[item_option].payment_option;
			var amount =  paymentOptions[item_option].price;
		}
			}
	else {
		
	}
	if (this.item_price !== '' || this.payment_groups_id !== '') {
			temp += '<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;
	}
}

			

