window.thumbnails = {};
															thumbnails[3081098] = clik.newPhoto({"id":3081098,"src":"IMG_7524 Web 3_thumb.jpg","galleries_id":"","server_id":1,"link":"#","width":130,"caption":"","height":87});
															thumbnails[4347483] = clik.newPhoto({"id":4347483,"src":"IMG_2601_TU_212_thumb.jpg","galleries_id":"","server_id":1,"link":"#","width":130,"caption":"","height":76});
															thumbnails[9089915] = clik.newPhoto({"id":9089915,"src":"8a_2_thumb.jpg","galleries_id":"","server_id":1,"link":"#","width":260,"caption":"","height":174});
															thumbnails[9089922] = clik.newPhoto({"id":9089922,"src":"5a_1_thumb.jpg","galleries_id":"","server_id":1,"link":"#","width":260,"caption":"","height":174});
															thumbnails[9089939] = clik.newPhoto({"id":9089939,"src":"1a_2_thumb.jpg","galleries_id":"","server_id":1,"link":"#","width":260,"caption":"","height":174});
															thumbnails[9089921] = clik.newPhoto({"id":9089921,"src":"4a_1_thumb.jpg","galleries_id":"","server_id":1,"link":"#","width":260,"caption":"","height":174});
															thumbnails[9089933] = clik.newPhoto({"id":9089933,"src":"1a_1_thumb.jpg","galleries_id":"","server_id":1,"link":"#","width":260,"caption":"","height":174});
															thumbnails[9089924] = clik.newPhoto({"id":9089924,"src":"11a_1_thumb.jpg","galleries_id":"","server_id":1,"link":"#","width":260,"caption":"","height":174});
															thumbnails[3400025] = clik.newPhoto({"id":3400025,"src":"IMG_1443_thumb.jpg","galleries_id":180697,"server_id":1,"link":"photo_3400025.html","width":130,"caption":"Moyola Mattress","height":87});
															thumbnails[3400028] = clik.newPhoto({"id":3400028,"src":"IMG_1497_thumb.jpg","galleries_id":180697,"server_id":1,"link":"photo_3400028.html","width":130,"caption":"Moyola Mattress","height":87});
															thumbnails[9087686] = clik.newPhoto({"id":9087686,"src":"13_1_thumb.jpg","galleries_id":479180,"server_id":1,"link":"photo_9087686.html","width":260,"caption":"","height":193});
															thumbnails[9087687] = clik.newPhoto({"id":9087687,"src":"14_1_thumb.jpg","galleries_id":479180,"server_id":1,"link":"photo_9087687.html","width":260,"caption":"","height":193});
															thumbnails[2923818] = clik.newPhoto({"id":2923818,"src":"IMG_2714_thumb.jpg","galleries_id":180697,"server_id":1,"link":"photo_2923818.html","width":130,"caption":"North West Organics","height":195});
															thumbnails[9084908] = clik.newPhoto({"id":9084908,"src":"1_1_thumb.jpg","galleries_id":479140,"server_id":1,"link":"photo_9084908.html","width":260,"caption":1.0,"height":355});
															thumbnails[9085113] = clik.newPhoto({"id":9085113,"src":"2_3_thumb.jpg","galleries_id":479180,"server_id":1,"link":"photo_9085113.html","width":260,"caption":2.0,"height":190});
															thumbnails[9085145] = clik.newPhoto({"id":9085145,"src":"1_4_thumb.jpg","galleries_id":180696,"server_id":1,"link":"photo_9085145.html","width":260,"caption":1.0,"height":350});
															thumbnails[9090456] = clik.newPhoto({"id":9090456,"src":"IMG_752_thumb.jpg","galleries_id":479609,"server_id":1,"link":"photo_9090456.html","width":260,"caption":"IMG 0751","height":190});
															thumbnails[3357635] = clik.newPhoto({"id":3357635,"src":"IMG_8723_thumb.jpg","galleries_id":180697,"server_id":1,"link":"photo_3357635.html","width":130,"caption":"Quinn Towers, Board Room","height":87});
															thumbnails[2922895] = clik.newPhoto({"id":2922895,"src":"IMG_8833_thumb.jpg","galleries_id":180697,"server_id":1,"link":"photo_2922895.html","width":130,"caption":"Quinn Towers Navan","height":195});
															thumbnails[9084909] = clik.newPhoto({"id":9084909,"src":"2_1_thumb.jpg","galleries_id":479140,"server_id":1,"link":"photo_9084909.html","width":260,"caption":2.0,"height":355});
															thumbnails[9085114] = clik.newPhoto({"id":9085114,"src":"3_3_thumb.jpg","galleries_id":479180,"server_id":1,"link":"photo_9085114.html","width":260,"caption":3.0,"height":190});
															thumbnails[9085146] = clik.newPhoto({"id":9085146,"src":"2_4_thumb.jpg","galleries_id":180696,"server_id":1,"link":"photo_9085146.html","width":260,"caption":2.0,"height":350});
															thumbnails[9090457] = clik.newPhoto({"id":9090457,"src":"IMG_762_thumb.jpg","galleries_id":479609,"server_id":1,"link":"photo_9090457.html","width":260,"caption":"IMG 0761","height":190});
															thumbnails[3357527] = clik.newPhoto({"id":3357527,"src":"IMG_9743 TU_thumb.jpg","galleries_id":180697,"server_id":1,"link":"photo_3357527.html","width":130,"caption":"Esker Coaches","height":47});
															thumbnails[3298334] = clik.newPhoto({"id":3298334,"src":"IMG_96891_thumb.jpg","galleries_id":180697,"server_id":1,"link":"photo_3298334.html","width":130,"caption":"Esker Coaches","height":195});
															thumbnails[9084911] = clik.newPhoto({"id":9084911,"src":"3_1_thumb.jpg","galleries_id":479140,"server_id":1,"link":"photo_9084911.html","width":260,"caption":3.0,"height":355});
															thumbnails[9085115] = clik.newPhoto({"id":9085115,"src":"4_3_thumb.jpg","galleries_id":479180,"server_id":1,"link":"photo_9085115.html","width":260,"caption":4.0,"height":190});
															thumbnails[9085148] = clik.newPhoto({"id":9085148,"src":"3_4_thumb.jpg","galleries_id":180696,"server_id":1,"link":"photo_9085148.html","width":260,"caption":3.0,"height":350});
															thumbnails[9090458] = clik.newPhoto({"id":9090458,"src":"IMG_0953_BW_1_thumb.jpg","galleries_id":479609,"server_id":1,"link":"photo_9090458.html","width":260,"caption":"IMG 0953 BW","height":355});
															thumbnails[9084912] = clik.newPhoto({"id":9084912,"src":"4_1_thumb.jpg","galleries_id":479140,"server_id":1,"link":"photo_9084912.html","width":260,"caption":4.0,"height":355});
															thumbnails[9085116] = clik.newPhoto({"id":9085116,"src":"5_3_thumb.jpg","galleries_id":479180,"server_id":1,"link":"photo_9085116.html","width":260,"caption":5.0,"height":190});
															thumbnails[9085150] = clik.newPhoto({"id":9085150,"src":"4_4_thumb.jpg","galleries_id":180696,"server_id":1,"link":"photo_9085150.html","width":260,"caption":4.0,"height":350});
															thumbnails[9090459] = clik.newPhoto({"id":9090459,"src":"IMG_4550_thumb.jpg","galleries_id":479609,"server_id":1,"link":"photo_9090459.html","width":260,"caption":"IMG 4549","height":190});
															thumbnails[2924062] = clik.newPhoto({"id":2924062,"src":"IMG_2747_thumb.jpg","galleries_id":180697,"server_id":1,"link":"photo_2924062.html","width":130,"caption":"Organic Product Image No.1","height":195});
															thumbnails[2924623] = clik.newPhoto({"id":2924623,"src":"IMG_2778_thumb.jpg","galleries_id":180697,"server_id":1,"link":"photo_2924623.html","width":130,"caption":"Organic Product Image No.2","height":195});
															thumbnails[2923821] = clik.newPhoto({"id":2923821,"src":"IMG_9596_thumb.jpg","galleries_id":180697,"server_id":1,"link":"photo_2923821.html","width":130,"caption":"Louth County Court House","height":195});
															thumbnails[9084913] = clik.newPhoto({"id":9084913,"src":"5_1_thumb.jpg","galleries_id":479140,"server_id":1,"link":"photo_9084913.html","width":260,"caption":5.0,"height":355});
															thumbnails[9085117] = clik.newPhoto({"id":9085117,"src":"6_3_thumb.jpg","galleries_id":479180,"server_id":1,"link":"photo_9085117.html","width":260,"caption":6.0,"height":190});
															thumbnails[9085153] = clik.newPhoto({"id":9085153,"src":"5_4_thumb.jpg","galleries_id":180696,"server_id":1,"link":"photo_9085153.html","width":260,"caption":5.0,"height":350});
															thumbnails[9090460] = clik.newPhoto({"id":9090460,"src":"IMG_5233_TU_1_thumb.jpg","galleries_id":479609,"server_id":1,"link":"photo_9090460.html","width":260,"caption":"IMG 5233 TU","height":190});
															thumbnails[3357674] = clik.newPhoto({"id":3357674,"src":"IMG_0007_thumb.jpg","galleries_id":180697,"server_id":1,"link":"photo_3357674.html","width":130,"caption":"K.B.B Product Shot","height":195});
															thumbnails[3164798] = clik.newPhoto({"id":3164798,"src":"2nd_thumb.jpg","galleries_id":180697,"server_id":1,"link":"photo_3164798.html","width":130,"caption":"C3 computers","height":195});
															thumbnails[3170671] = clik.newPhoto({"id":3170671,"src":"IMG_0514_thumb.jpg","galleries_id":180697,"server_id":1,"link":"photo_3170671.html","width":130,"caption":"C3 Computers","height":195});
															thumbnails[3298305] = clik.newPhoto({"id":3298305,"src":"Page-41_thumb.jpg","galleries_id":180697,"server_id":1,"link":"photo_3298305.html","width":130,"caption":"Raddison S.A.S Spa","height":195});
															thumbnails[3357558] = clik.newPhoto({"id":3357558,"src":"IMG_7940 TU Fin Logo_thumb.jpg","galleries_id":180697,"server_id":1,"link":"photo_3357558.html","width":130,"caption":"Specialist Joinery Group","height":47});
															thumbnails[2924096] = clik.newPhoto({"id":2924096,"src":"IMG_0917_thumb.jpg","galleries_id":180697,"server_id":1,"link":"photo_2924096.html","width":130,"caption":"Essential Designs","height":195});
															thumbnails[3219743] = clik.newPhoto({"id":3219743,"src":"IMG_7804 TU_thumb.jpg","galleries_id":180697,"server_id":1,"link":"photo_3219743.html","width":130,"caption":"Specialist Joinery Group","height":87});
															thumbnails[9084915] = clik.newPhoto({"id":9084915,"src":"6_1_thumb.jpg","galleries_id":479140,"server_id":1,"link":"photo_9084915.html","width":260,"caption":6.0,"height":355});
															thumbnails[9085118] = clik.newPhoto({"id":9085118,"src":"7_3_thumb.jpg","galleries_id":479180,"server_id":1,"link":"photo_9085118.html","width":260,"caption":7.0,"height":190});
															thumbnails[9085157] = clik.newPhoto({"id":9085157,"src":"6_4_thumb.jpg","galleries_id":180696,"server_id":1,"link":"photo_9085157.html","width":260,"caption":6.0,"height":350});
															thumbnails[9090461] = clik.newPhoto({"id":9090461,"src":"IMG_5431_thumb.jpg","galleries_id":479609,"server_id":1,"link":"photo_9090461.html","width":260,"caption":"IMG 5430","height":355});
															thumbnails[9084916] = clik.newPhoto({"id":9084916,"src":"7_1_thumb.jpg","galleries_id":479140,"server_id":1,"link":"photo_9084916.html","width":260,"caption":7.0,"height":355});
															thumbnails[9085119] = clik.newPhoto({"id":9085119,"src":"8_3_thumb.jpg","galleries_id":479180,"server_id":1,"link":"photo_9085119.html","width":260,"caption":8.0,"height":190});
															thumbnails[9085160] = clik.newPhoto({"id":9085160,"src":"7_4_thumb.jpg","galleries_id":180696,"server_id":1,"link":"photo_9085160.html","width":260,"caption":7.0,"height":350});
															thumbnails[9090462] = clik.newPhoto({"id":9090462,"src":"IMG_6312_thumb.jpg","galleries_id":479609,"server_id":1,"link":"photo_9090462.html","width":260,"caption":"IMG 6311","height":190});
															thumbnails[3357632] = clik.newPhoto({"id":3357632,"src":"IMG_0975_thumb.jpg","galleries_id":180697,"server_id":1,"link":"photo_3357632.html","width":130,"caption":"Dublin Hilton","height":87});
															thumbnails[9084917] = clik.newPhoto({"id":9084917,"src":"8_1_thumb.jpg","galleries_id":479140,"server_id":1,"link":"photo_9084917.html","width":260,"caption":8.0,"height":355});
															thumbnails[9085120] = clik.newPhoto({"id":9085120,"src":"9_2_thumb.jpg","galleries_id":479180,"server_id":1,"link":"photo_9085120.html","width":260,"caption":9.0,"height":190});
															thumbnails[9085164] = clik.newPhoto({"id":9085164,"src":"8_4_thumb.jpg","galleries_id":180696,"server_id":1,"link":"photo_9085164.html","width":260,"caption":8.0,"height":350});
															thumbnails[9090464] = clik.newPhoto({"id":9090464,"src":"IMG_6639_thumb.jpg","galleries_id":479609,"server_id":1,"link":"photo_9090464.html","width":260,"caption":"IMG 6638","height":355});
															thumbnails[9085121] = clik.newPhoto({"id":9085121,"src":"10_2_thumb.jpg","galleries_id":479180,"server_id":1,"link":"photo_9085121.html","width":260,"caption":10.0,"height":190});
															thumbnails[9085167] = clik.newPhoto({"id":9085167,"src":"9_3_thumb.jpg","galleries_id":180696,"server_id":1,"link":"photo_9085167.html","width":260,"caption":9.0,"height":350});
															thumbnails[9090465] = clik.newPhoto({"id":9090465,"src":"IMG_6949_thumb.jpg","galleries_id":479609,"server_id":1,"link":"photo_9090465.html","width":260,"caption":"IMG 6948","height":355});
															thumbnails[9085122] = clik.newPhoto({"id":9085122,"src":"11_2_thumb.jpg","galleries_id":479180,"server_id":1,"link":"photo_9085122.html","width":260,"caption":11.0,"height":190});
															thumbnails[9090467] = clik.newPhoto({"id":9090467,"src":"IMG_7008_thumb.jpg","galleries_id":479609,"server_id":1,"link":"photo_9090467.html","width":260,"caption":"IMG 7007","height":355});
															thumbnails[9085123] = clik.newPhoto({"id":9085123,"src":"12_1_thumb.jpg","galleries_id":479180,"server_id":1,"link":"photo_9085123.html","width":260,"caption":12.0,"height":190});
															thumbnails[9085173] = clik.newPhoto({"id":9085173,"src":"11_3_thumb.jpg","galleries_id":180696,"server_id":1,"link":"photo_9085173.html","width":260,"caption":11.0,"height":350});
															thumbnails[9090468] = clik.newPhoto({"id":9090468,"src":"IMG_7024_thumb.jpg","galleries_id":479609,"server_id":1,"link":"photo_9090468.html","width":260,"caption":"IMG 7023","height":190});
															thumbnails[9085124] = clik.newPhoto({"id":9085124,"src":"1_3_thumb.jpg","galleries_id":479180,"server_id":1,"link":"photo_9085124.html","width":260,"caption":1.0,"height":190});
															thumbnails[9090470] = clik.newPhoto({"id":9090470,"src":"IMG_7077_thumb.jpg","galleries_id":479609,"server_id":1,"link":"photo_9090470.html","width":260,"caption":"IMG 7076","height":190});
															thumbnails[9090471] = clik.newPhoto({"id":9090471,"src":"IMG_7119_thumb.jpg","galleries_id":479609,"server_id":1,"link":"photo_9090471.html","width":260,"caption":"IMG 7118","height":190});
															thumbnails[9090472] = clik.newPhoto({"id":9090472,"src":"NL_GC_32_of_76_thumb.jpg","galleries_id":479609,"server_id":1,"link":"photo_9090472.html","width":260,"caption":"NL GC (32 of 75)","height":190});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  						galleries[479609] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"PR Photography","link":"gallery_479609.html","maxRecords":0.0,"photoIDs":[9090456.0,9090457.0,9090458.0,9090459.0,9090460.0,9090461.0,9090462.0,9090464.0,9090465.0,9090467.0,9090468.0,9090470.0,9090471.0,9090472.0],"skipIndex":0,"section_code":"gallery","featured_images":9090458.0,"id":479609,"singleSection":false});				  						galleries[180696] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Weddings 1","link":"gallery_180696.html","maxRecords":0.0,"photoIDs":[9085145.0,9085146.0,9085148.0,9085150.0,9085153.0,9085157.0,9085160.0,9085164.0,9085167.0,9085173.0],"skipIndex":0,"section_code":"gallery","featured_images":"9085173,9085167,9085164,9085160,9085157,9085153,9085150,9085148,9085146,9085145","id":180696,"singleSection":false});				  						galleries[479180] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Weddings 2","link":"gallery_479180.html","maxRecords":0.0,"photoIDs":[9087686.0,9087687.0,9085113.0,9085114.0,9085115.0,9085116.0,9085117.0,9085118.0,9085119.0,9085120.0,9085121.0,9085122.0,9085123.0,9085124.0],"skipIndex":0,"section_code":"gallery","featured_images":9085119.0,"id":479180,"singleSection":false});				  						galleries[180697] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Commercial","link":"gallery_180697.html","maxRecords":0.0,"photoIDs":[3400025.0,3400028.0,2923818.0,3357635.0,2922895.0,3357527.0,3298334.0,2924062.0,2924623.0,2923821.0,3357674.0,3164798.0,3170671.0,3298305.0,3357558.0,2924096.0,3219743.0,3357632.0],"skipIndex":0,"section_code":"gallery","featured_images":2922895.0,"id":180697,"singleSection":false});				  						galleries[479140] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Fantasy Fotos","link":"gallery_479140.html","maxRecords":0.0,"photoIDs":[9084908.0,9084909.0,9084911.0,9084912.0,9084913.0,9084915.0,9084916.0,9084917.0],"skipIndex":0,"section_code":"gallery","featured_images":"9084916,9084909","id":479140,"singleSection":false});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[1] = '9089915,9089922,9089939,9089921,9089933,9089924';
imageSets[2] = '9084909,2922895,9090458,9085119,9084916';
imageSets[3] = '9090472,9090471,9090470,9090468,9090467,9090465,9090464,9090462,9090461,9090460,9090459,9090458,9090457,9090456,9089939,9089933,9089924,9089922,9089921,9089915,9087687,9087686,9085173,9085167,9085164,9085160,9085157,9085153,9085150,9085148,9085146,9085145,9085124,9085123,9085122,9085121,9085120,9085119,9085118,9085117,9085116,9085115,9085114,9085113,9084917,9084916,9084915,9084913,9084912,9084911';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 51:
		val = 'http://www12.clikpic.com/paulbronagh/images';
		break;
	}
		switch (server_id) {
		case 0:
		val = 'http://www.clikpic.com/paulbronagh/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/paulbronagh/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/paulbronagh/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/paulbronagh/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/paulbronagh/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/paulbronagh/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/paulbronagh/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/paulbronagh/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/paulbronagh/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/paulbronagh/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/paulbronagh/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/paulbronagh/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/paulbronagh/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/paulbronagh/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/paulbronagh/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/paulbronagh/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/paulbronagh/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/paulbronagh/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/paulbronagh/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/paulbronagh/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/paulbronagh/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/paulbronagh/images';
		break;
	}
		switch (server_id) {
		case 53:
		val = 'http://images.clikpic.com/paulbronagh/images';
		break;
	}
		switch (server_id) {
		case 52:
		val = 'http://tpc22/clikpic/paulbronagh/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/paulbronagh/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/paulbronagh/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 = 'Acorn Images: ' + 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.item_price !== '') {
			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;
	}
}

			

