window.thumbnails = {};
															thumbnails[230934] = clik.newPhoto({"id":230934,"src":"carlyx3 copy_thumb.jpg","galleries_id":175799,"server_id":18,"link":"photo_230934.html","width":130,"caption":"portfolio","height":188});
															thumbnails[231123] = clik.newPhoto({"id":231123,"src":"carly2 copy_thumb.jpg","galleries_id":175799,"server_id":18,"link":"photo_231123.html","width":130,"caption":"portfolio","height":87});
															thumbnails[231146] = clik.newPhoto({"id":231146,"src":"garlic_thumb.jpg","galleries_id":20819,"server_id":18,"link":"photo_231146.html","width":130,"caption":"","height":85});
															thumbnails[231151] = clik.newPhoto({"id":231151,"src":"misty_thumb.jpg","galleries_id":20815,"server_id":18,"link":"photo_231151.html","width":130,"caption":"","height":86});
															thumbnails[231157] = clik.newPhoto({"id":231157,"src":"misty1 copy1_thumb.jpg","galleries_id":20815,"server_id":18,"link":"photo_231157.html","width":130,"caption":"","height":193});
															thumbnails[235399] = clik.newPhoto({"id":235399,"src":"iceflower_thumb.jpg","galleries_id":20819,"server_id":18,"link":"photo_235399.html","width":130,"caption":"","height":89});
															thumbnails[235410] = clik.newPhoto({"id":235410,"src":"album1_thumb.jpg","galleries_id":20817,"server_id":18,"link":"photo_235410.html","width":130,"caption":"album cover","height":87});
															thumbnails[384657] = clik.newPhoto({"id":384657,"src":"DSC_0117 copy_thumb.jpg","galleries_id":20817,"server_id":18,"link":"photo_384657.html","width":130,"caption":"Website pic","height":87});
															thumbnails[492947] = clik.newPhoto({"id":492947,"src":"wedding 114 copy_thumb.jpg","galleries_id":38443,"server_id":18,"link":"photo_492947.html","width":130,"caption":"","height":195});
															thumbnails[492957] = clik.newPhoto({"id":492957,"src":"wedding-020-copy_thumb.jpg","galleries_id":38443,"server_id":18,"link":"photo_492957.html","width":130,"caption":"","height":195});
															thumbnails[492958] = clik.newPhoto({"id":492958,"src":"wedding-028-copy_thumb.jpg","galleries_id":38443,"server_id":18,"link":"photo_492958.html","width":130,"caption":"","height":195});
															thumbnails[492960] = clik.newPhoto({"id":492960,"src":"wedding-048-copy_thumb.jpg","galleries_id":38443,"server_id":18,"link":"photo_492960.html","width":130,"caption":"","height":87});
															thumbnails[492961] = clik.newPhoto({"id":492961,"src":"wedding-060-copy_thumb.jpg","galleries_id":38443,"server_id":18,"link":"photo_492961.html","width":130,"caption":"","height":195});
															thumbnails[492977] = clik.newPhoto({"id":492977,"src":"sept10thvw-018-copy_thumb.jpg","galleries_id":20815,"server_id":18,"link":"photo_492977.html","width":130,"caption":"","height":87});
															thumbnails[492978] = clik.newPhoto({"id":492978,"src":"sept10thvw-037-copy_thumb.jpg","galleries_id":20815,"server_id":18,"link":"photo_492978.html","width":130,"caption":"","height":87});
															thumbnails[696488] = clik.newPhoto({"id":696488,"src":"elreycopy_thumb.jpg","galleries_id":20815,"server_id":18,"link":"photo_696488.html","width":130,"caption":"VW book","height":87});
															thumbnails[931568] = clik.newPhoto({"id":931568,"src":"tommyanniewed2_thumb.jpg","galleries_id":38443,"server_id":18,"link":"photo_931568.html","width":130,"caption":"","height":87});
															thumbnails[931571] = clik.newPhoto({"id":931571,"src":"tommyanniewed3_thumb.jpg","galleries_id":38443,"server_id":18,"link":"photo_931571.html","width":130,"caption":"","height":135});
															thumbnails[931614] = clik.newPhoto({"id":931614,"src":"deli1_thumb.jpg","galleries_id":20820,"server_id":18,"link":"photo_931614.html","width":130,"caption":"","height":87});
															thumbnails[931649] = clik.newPhoto({"id":931649,"src":"johnm4 copy_thumb.jpg","galleries_id":20820,"server_id":18,"link":"photo_931649.html","width":130,"caption":"","height":188});
															thumbnails[988238] = clik.newPhoto({"id":988238,"src":"trebah18 copy_thumb.jpg","galleries_id":20820,"server_id":18,"link":"photo_988238.html","width":130,"caption":"","height":87});
															thumbnails[1169714] = clik.newPhoto({"id":1169714,"src":"furniss3 copy_thumb.jpg","galleries_id":20820,"server_id":18,"link":"photo_1169714.html","width":130,"caption":"","height":87});
															thumbnails[1169715] = clik.newPhoto({"id":1169715,"src":"glass2 copy_thumb.jpg","galleries_id":20820,"server_id":18,"link":"photo_1169715.html","width":130,"caption":"","height":87});
															thumbnails[1200028] = clik.newPhoto({"id":1200028,"src":"amy20 copy_thumb.jpg","galleries_id":20817,"server_id":18,"link":"photo_1200028.html","width":130,"caption":"Amy at Eden","height":191});
															thumbnails[1200031] = clik.newPhoto({"id":1200031,"src":"amy4 copy_thumb.jpg","galleries_id":20817,"server_id":18,"link":"photo_1200031.html","width":130,"caption":"Amy in tears","height":186});
															thumbnails[1458491] = clik.newPhoto({"id":1458491,"src":"wedding 007 copy_thumb.jpg","galleries_id":38443,"server_id":18,"link":"photo_1458491.html","width":130,"caption":"","height":195});
															thumbnails[1458495] = clik.newPhoto({"id":1458495,"src":"wedding 076 copy_thumb.jpg","galleries_id":38443,"server_id":18,"link":"photo_1458495.html","width":130,"caption":"","height":195});
															thumbnails[2322095] = clik.newPhoto({"id":2322095,"src":"bee copy_thumb.jpg","galleries_id":20820,"server_id":18,"link":"photo_2322095.html","width":130,"caption":"","height":87});
															thumbnails[2322099] = clik.newPhoto({"id":2322099,"src":"heli1tonyjones copy_thumb.jpg","galleries_id":20820,"server_id":18,"link":"photo_2322099.html","width":130,"caption":"","height":87});
															thumbnails[2322135] = clik.newPhoto({"id":2322135,"src":"upholster3 copy_thumb.jpg","galleries_id":20820,"server_id":18,"link":"photo_2322135.html","width":130,"caption":"","height":195});
															thumbnails[2322354] = clik.newPhoto({"id":2322354,"src":"rowe3 copy_thumb.jpg","galleries_id":20820,"server_id":18,"link":"photo_2322354.html","width":130,"caption":"","height":195});
															thumbnails[2369984] = clik.newPhoto({"id":2369984,"src":"tearsheet_thumb.jpg","galleries_id":154165,"server_id":18,"link":"photo_2369984.html","width":130,"caption":"","height":172});
															thumbnails[2568459] = clik.newPhoto({"id":2568459,"src":"184246_thumb.jpg","galleries_id":154165,"server_id":18,"link":"photo_2568459.html","width":130,"caption":"","height":172});
															thumbnails[2811425] = clik.newPhoto({"id":2811425,"src":"jh5bcopy_thumb.jpg","galleries_id":38443,"server_id":18,"link":"photo_2811425.html","width":130,"caption":"","height":195});
															thumbnails[2811478] = clik.newPhoto({"id":2811478,"src":"jh48ccopy_thumb.jpg","galleries_id":38443,"server_id":18,"link":"photo_2811478.html","width":130,"caption":"","height":87});
															thumbnails[2811479] = clik.newPhoto({"id":2811479,"src":"jh51dcopy_thumb.jpg","galleries_id":38443,"server_id":18,"link":"photo_2811479.html","width":130,"caption":"","height":195});
															thumbnails[2811529] = clik.newPhoto({"id":2811529,"src":"jh68fcopy_thumb.jpg","galleries_id":38443,"server_id":18,"link":"photo_2811529.html","width":130,"caption":"","height":87});
															thumbnails[2811533] = clik.newPhoto({"id":2811533,"src":"jh81gcopy_thumb.jpg","galleries_id":38443,"server_id":18,"link":"photo_2811533.html","width":130,"caption":"","height":87});
															thumbnails[2811536] = clik.newPhoto({"id":2811536,"src":"jh89hcopy_thumb.jpg","galleries_id":38443,"server_id":18,"link":"photo_2811536.html","width":130,"caption":"","height":87});
															thumbnails[2811540] = clik.newPhoto({"id":2811540,"src":"jh115jcopy_thumb.jpg","galleries_id":38443,"server_id":18,"link":"photo_2811540.html","width":130,"caption":"","height":87});
															thumbnails[2813114] = clik.newPhoto({"id":2813114,"src":"she7 copy_thumb.jpg","galleries_id":175799,"server_id":18,"link":"photo_2813114.html","width":130,"caption":"","height":161});
															thumbnails[2857314] = clik.newPhoto({"id":2857314,"src":"carly3 copy_thumb.jpg","galleries_id":175799,"server_id":18,"link":"photo_2857314.html","width":130,"caption":"","height":195});
															thumbnails[3777276] = clik.newPhoto({"id":3777276,"src":"Barkla1_thumb.gif","galleries_id":20817,"server_id":18,"link":"photo_3777276.html","width":130,"caption":"Barkla Shop","height":195});
															thumbnails[4240985] = clik.newPhoto({"id":4240985,"src":"IMG_4551_copy2_thumb.jpg","galleries_id":38443,"server_id":18,"link":"photo_4240985.html","width":130,"caption":"","height":195});
															thumbnails[4240993] = clik.newPhoto({"id":4240993,"src":"IMG_4564_copy2_thumb.jpg","galleries_id":38443,"server_id":18,"link":"photo_4240993.html","width":130,"caption":"","height":87});
															thumbnails[4240996] = clik.newPhoto({"id":4240996,"src":"IMG_4652_copysep_copy_thumb.jpg","galleries_id":38443,"server_id":18,"link":"photo_4240996.html","width":130,"caption":"","height":195});
															thumbnails[4755373] = clik.newPhoto({"id":4755373,"src":"IMG_5070_copy2_thumb.jpg","galleries_id":38443,"server_id":18,"link":"photo_4755373.html","width":130,"caption":"","height":195});
															thumbnails[4755379] = clik.newPhoto({"id":4755379,"src":"IMG_5087_copy_thumb.jpg","galleries_id":38443,"server_id":18,"link":"photo_4755379.html","width":130,"caption":"","height":87});
															thumbnails[4755385] = clik.newPhoto({"id":4755385,"src":"IMG_5419_copy_thumb.jpg","galleries_id":38443,"server_id":18,"link":"photo_4755385.html","width":130,"caption":"","height":87});
															thumbnails[4755388] = clik.newPhoto({"id":4755388,"src":"IMG_5649_copy_thumb.jpg","galleries_id":38443,"server_id":18,"link":"photo_4755388.html","width":130,"caption":"","height":195});
															thumbnails[4755393] = clik.newPhoto({"id":4755393,"src":"IMG_5666_copy_thumb.jpg","galleries_id":38443,"server_id":18,"link":"photo_4755393.html","width":130,"caption":"","height":87});
															thumbnails[4755398] = clik.newPhoto({"id":4755398,"src":"IMG_5764_copy_thumb.jpg","galleries_id":38443,"server_id":18,"link":"photo_4755398.html","width":130,"caption":"","height":195});
															thumbnails[4755403] = clik.newPhoto({"id":4755403,"src":"IMG_5797_copy_thumb.jpg","galleries_id":38443,"server_id":18,"link":"photo_4755403.html","width":130,"caption":"","height":87});
															thumbnails[6468992] = clik.newPhoto({"id":6468992,"src":"web2_thumb.jpg","galleries_id":175799,"server_id":18,"link":"photo_6468992.html","width":130,"caption":"","height":87});
															thumbnails[6469001] = clik.newPhoto({"id":6469001,"src":"web21_thumb.jpg","galleries_id":38443,"server_id":18,"link":"photo_6469001.html","width":130,"caption":"","height":87});
															thumbnails[6469011] = clik.newPhoto({"id":6469011,"src":"web5_thumb.jpg","galleries_id":38443,"server_id":18,"link":"photo_6469011.html","width":130,"caption":"","height":87});
															thumbnails[6469059] = clik.newPhoto({"id":6469059,"src":"web42_thumb.jpg","galleries_id":38443,"server_id":18,"link":"photo_6469059.html","width":130,"caption":"","height":202});
															thumbnails[6469069] = clik.newPhoto({"id":6469069,"src":"web32_thumb.jpg","galleries_id":38443,"server_id":18,"link":"photo_6469069.html","width":130,"caption":"","height":87});
															thumbnails[7490724] = clik.newPhoto({"id":7490724,"src":"tillyWEB1_thumb.jpg","galleries_id":20820,"server_id":18,"link":"photo_7490724.html","width":160,"caption":"","height":107});
															thumbnails[7589658] = clik.newPhoto({"id":7589658,"src":"AnnaDSouza2_thumb.jpg","galleries_id":154165,"server_id":18,"link":"photo_7589658.html","width":160,"caption":"","height":227});
															thumbnails[7589726] = clik.newPhoto({"id":7589726,"src":"CWEAR_thumb.jpg","galleries_id":154165,"server_id":18,"link":"photo_7589726.html","width":160,"caption":"","height":123});
															thumbnails[8137201] = clik.newPhoto({"id":8137201,"src":"wed1_thumb.jpg","galleries_id":38443,"server_id":18,"link":"photo_8137201.html","width":160,"caption":"","height":107});
															thumbnails[8137205] = clik.newPhoto({"id":8137205,"src":"wed2_thumb.jpg","galleries_id":38443,"server_id":18,"link":"photo_8137205.html","width":160,"caption":"","height":110});
															thumbnails[8137214] = clik.newPhoto({"id":8137214,"src":"vanfrance_0002_copy_2_thumb.jpg","galleries_id":20819,"server_id":18,"link":"photo_8137214.html","width":160,"caption":"","height":112});
															thumbnails[8326934] = clik.newPhoto({"id":8326934,"src":"bubbles_copy_thumb.jpg","galleries_id":20819,"server_id":18,"link":"photo_8326934.html","width":160,"caption":"","height":156});
															thumbnails[8326935] = clik.newPhoto({"id":8326935,"src":"fort_copy_thumb.jpg","galleries_id":20819,"server_id":18,"link":"photo_8326935.html","width":160,"caption":"","height":156});
															thumbnails[8326936] = clik.newPhoto({"id":8326936,"src":"residencial_copy_thumb.jpg","galleries_id":20819,"server_id":18,"link":"photo_8326936.html","width":160,"caption":"","height":157});
															thumbnails[8326937] = clik.newPhoto({"id":8326937,"src":"river_copy_thumb.jpg","galleries_id":20819,"server_id":18,"link":"photo_8326937.html","width":160,"caption":"","height":156});
															thumbnails[8712088] = clik.newPhoto({"id":8712088,"src":"IMG_0113_copy_thumb.jpg","galleries_id":38443,"server_id":18,"link":"photo_8712088.html","width":160,"caption":"","height":107});
															thumbnails[8712096] = clik.newPhoto({"id":8712096,"src":"IMG_0169_copy_thumb.jpg","galleries_id":38443,"server_id":18,"link":"photo_8712096.html","width":160,"caption":"","height":240});
															thumbnails[8712097] = clik.newPhoto({"id":8712097,"src":"IMG_0183_copy_thumb.jpg","galleries_id":38443,"server_id":18,"link":"photo_8712097.html","width":160,"caption":"","height":107});
															thumbnails[8712102] = clik.newPhoto({"id":8712102,"src":"IMG_0340_copy_thumb.jpg","galleries_id":38443,"server_id":18,"link":"photo_8712102.html","width":160,"caption":"","height":240});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  						galleries[20815] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"VWs","link":"gallery_20815.html","maxRecords":0.0,"photoIDs":[231151.0,231157.0,492977.0,492978.0,696488.0],"skipIndex":0,"section_code":"gallery","featured_images":"696488,492978,492977,231157,231151","id":20815,"singleSection":false});				  						galleries[20819] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Personal work","link":"gallery_20819.html","maxRecords":0.0,"photoIDs":[231146.0,235399.0,8137214.0,8326934.0,8326935.0,8326936.0,8326937.0],"skipIndex":0,"section_code":"gallery","featured_images":"8326937,8326936,8326935,8326934,8137214,235399,231146","id":20819,"singleSection":false});				  						galleries[20820] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Editorial \/ Press","link":"gallery_20820.html","maxRecords":0.0,"photoIDs":[931614.0,931649.0,988238.0,1169714.0,1169715.0,2322095.0,2322099.0,2322135.0,2322354.0,7490724.0],"skipIndex":0,"section_code":"gallery","featured_images":"7490724,2322354,2322135,2322099,2322095,1169715,1169714,988238,931649,931614","id":20820,"singleSection":false});				  						galleries[20817] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Bands","link":"gallery_20817.html","maxRecords":0.0,"photoIDs":[235410.0,384657.0,1200028.0,1200031.0,3777276.0],"skipIndex":0,"section_code":"gallery","featured_images":"3777276,1200031,1200028,384657,235410","id":20817,"singleSection":false});				  						galleries[38443] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Weddings","link":"gallery_38443.html","maxRecords":0.0,"photoIDs":[492947.0,492957.0,492958.0,492960.0,492961.0,931568.0,931571.0,1458491.0,1458495.0,2811425.0,2811478.0,2811479.0,2811529.0,2811533.0,2811536.0,2811540.0,4240985.0,4240993.0,4240996.0,4755373.0,4755379.0,4755385.0,4755388.0,4755393.0,4755398.0,4755403.0,6469001.0,6469011.0,6469059.0,6469069.0,8137201.0,8137205.0,8712088.0,8712096.0,8712097.0,8712102.0],"skipIndex":0,"section_code":"gallery","featured_images":"8712102,8712097,8712096,8712088,8137205,8137201,6469069,6469059,6469011,6469001","id":38443,"singleSection":false});				  						galleries[154165] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Tearsheets","link":"gallery_154165.html","maxRecords":0.0,"photoIDs":[2369984.0,2568459.0,7589658.0,7589726.0],"skipIndex":0,"section_code":"gallery","featured_images":"7589726,7589658,2568459,2369984","id":154165,"singleSection":false});				  						galleries[175799] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Portraits","link":"gallery_175799.html","maxRecords":0.0,"photoIDs":[230934.0,231123.0,2813114.0,2857314.0,6468992.0],"skipIndex":0,"section_code":"gallery","featured_images":"6468992,2857314,2813114,231123,230934","id":175799,"singleSection":false});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[1] = '8712102,8712097,8137214,8137205,8137201,7490724,6469069,6469001,4755403,4755393,2813114,2811529,2322099,2322095,1200028,931614,235410,235399,231151,231146,231123';
imageSets[3] = '3777276';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 51:
		val = 'www12.clikpic.com/josiep/images';
		break;
	}
		switch (server_id) {
		case 0:
		val = 'http://www.clikpic.com/josiep/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/josiep/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/josiep/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/josiep/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/josiep/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/josiep/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/josiep/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/josiep/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/josiep/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/josiep/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/josiep/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/josiep/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/josiep/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/josiep/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/josiep/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/josiep/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/josiep/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/josiep/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/josiep/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/josiep/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/josiep/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/josiep/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/josiep/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/josiep/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 = 'Elrey Photography and PR: ' + 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;
	}
}

			

