window.thumbnails = {};
															thumbnails[3810294] = clik.newPhoto({"id":3810294,"src":"IsvaraMar07131C_thumb.jpg","galleries_id":232098,"server_id":5,"link":"photo_3810294.html","width":87,"caption":"","height":130});
															thumbnails[3810335] = clik.newPhoto({"id":3810335,"src":"Clikpic0271_thumb.jpg","galleries_id":231969,"server_id":5,"link":"photo_3810335.html","width":130,"caption":"Margaret Gardner, Director of Communications, at aid charity Practical Action","height":88});
															thumbnails[4472082] = clik.newPhoto({"id":4472082,"src":"LDT113_thumb.jpg","galleries_id":280518,"server_id":5,"link":"photo_4472082.html","width":89,"caption":"Arc De Triomphe","height":130});
															thumbnails[5431233] = clik.newPhoto({"id":5431233,"src":"samappa_027_thumb.jpg","galleries_id":306926,"server_id":5,"link":"photo_5431233.html","width":130,"caption":"","height":87});
															thumbnails[3810292] = clik.newPhoto({"id":3810292,"src":"Clikpic01212_thumb.jpg","galleries_id":232098,"server_id":5,"link":"photo_3810292.html","width":130,"caption":"","height":93});
															thumbnails[3810336] = clik.newPhoto({"id":3810336,"src":"Clikpic0831_thumb.jpg","galleries_id":231969,"server_id":5,"link":"photo_3810336.html","width":130,"caption":"Sir Trevor McDonald with Sharon Doughty and characters from children's charity Kids Taskforce","height":87});
															thumbnails[4472083] = clik.newPhoto({"id":4472083,"src":"Tour_Eiffel212_thumb.jpg","galleries_id":280518,"server_id":5,"link":"photo_4472083.html","width":130,"caption":"Tour Eiffel","height":87});
															thumbnails[3810337] = clik.newPhoto({"id":3810337,"src":"ER2Oct06_thumb.jpg","galleries_id":231969,"server_id":5,"link":"photo_3810337.html","width":106,"caption":"Esther Rantzen supporting the Anti Bullying Campaign","height":130});
															thumbnails[3810293] = clik.newPhoto({"id":3810293,"src":"Clikpic03112_thumb.jpg","galleries_id":232098,"server_id":5,"link":"photo_3810293.html","width":130,"caption":"","height":88});
															thumbnails[3810295] = clik.newPhoto({"id":3810295,"src":"Zoe_HP164esf_thumb.jpg","galleries_id":232098,"server_id":5,"link":"photo_3810295.html","width":130,"caption":"","height":101});
															thumbnails[3810338] = clik.newPhoto({"id":3810338,"src":"HH05edit_thumb.jpg","galleries_id":231969,"server_id":5,"link":"photo_3810338.html","width":94,"caption":"Harry Hill promoting his book Tim the Tiny Horse ","height":130});
															thumbnails[3810361] = clik.newPhoto({"id":3810361,"src":"Clikpic0531_thumb.jpg","galleries_id":231969,"server_id":5,"link":"photo_3810361.html","width":130,"caption":"Gordon Brown and young people from the Anti-Bullying Alliance","height":87});
															thumbnails[4311566] = clik.newPhoto({"id":4311566,"src":"AudenFinal-44_copy_thumb.jpg","galleries_id":232098,"server_id":5,"link":"photo_4311566.html","width":130,"caption":"","height":87});
															thumbnails[3810291] = clik.newPhoto({"id":3810291,"src":"BL163_thumb.jpg","galleries_id":232098,"server_id":5,"link":"photo_3810291.html","width":87,"caption":"","height":130});
															thumbnails[3810339] = clik.newPhoto({"id":3810339,"src":"RCameron_thumb.jpg","galleries_id":231969,"server_id":5,"link":"photo_3810339.html","width":90,"caption":"Rhona Cameron promoting her new book The Naked Drinking Club","height":130});
															thumbnails[3810362] = clik.newPhoto({"id":3810362,"src":"SWalters_thumb.jpg","galleries_id":231969,"server_id":5,"link":"photo_3810362.html","width":115,"caption":"Sarah Walters at the York Lesbian Arts Festival","height":130});
															thumbnails[3810360] = clik.newPhoto({"id":3810360,"src":"Clikpic0511_thumb.jpg","galleries_id":231969,"server_id":5,"link":"photo_3810360.html","width":130,"caption":"Mediatheque at BFI Southbank","height":99});
															thumbnails[3810359] = clik.newPhoto({"id":3810359,"src":"Clikpic0161_thumb.jpg","galleries_id":231969,"server_id":5,"link":"photo_3810359.html","width":130,"caption":"Benugo Bar at BFI Southbank","height":90});
															thumbnails[3810659] = clik.newPhoto({"id":3810659,"src":"PM250407e173_thumb.jpg","galleries_id":231969,"server_id":5,"link":"photo_3810659.html","width":130,"caption":"Parker McMillan Sessions","height":87});
															thumbnails[4928672] = clik.newPhoto({"id":4928672,"src":"DaretoSpeak6a_thumb.jpg","galleries_id":231969,"server_id":5,"link":"photo_4928672.html","width":130,"caption":"Royal College of Physicians ","height":93});
															thumbnails[4928671] = clik.newPhoto({"id":4928671,"src":"DaretoSpeak48a_thumb.jpg","galleries_id":231969,"server_id":5,"link":"photo_4928671.html","width":130,"caption":"Professor Jonathan Elford of City University speaking at the Naz Project London Dare to Speak Conference   ","height":97});
															thumbnails[4930378] = clik.newPhoto({"id":4930378,"src":"DaretoSpeak98a_thumb.jpg","galleries_id":231969,"server_id":5,"link":"photo_4930378.html","width":95,"caption":"Brian Teixeira, Chief Executive, speaking at the Dare to Speak Conference at the Royal College of Physicians London","height":130});
															thumbnails[4930489] = clik.newPhoto({"id":4930489,"src":"DaretoSpeak111a_thumb.jpg","galleries_id":231969,"server_id":5,"link":"photo_4930489.html","width":92,"caption":"Yusef Azad, Director of Policy and Campaigns, NAT, speaking at the Naz Project London's Dare to Speak Conference","height":130});
															thumbnails[4928674] = clik.newPhoto({"id":4928674,"src":"SFSC51a_thumb.jpg","galleries_id":231969,"server_id":5,"link":"photo_4928674.html","width":130,"caption":"Delegates at the Race Equality Foundation Annual Conference Stronger Families Stronger Communities at SOAS in London","height":87});
															thumbnails[3810303] = clik.newPhoto({"id":3810303,"src":"Parul266edit_thumb.jpg","galleries_id":232098,"server_id":5,"link":"photo_3810303.html","width":130,"caption":"","height":86});
															thumbnails[4928673] = clik.newPhoto({"id":4928673,"src":"SFSC27a_thumb.jpg","galleries_id":231969,"server_id":5,"link":"photo_4928673.html","width":130,"caption":"Delegates at the Race Equality Foundation Annual Conference Stronger Families Stronger Communities held at SOAS London","height":87});
															thumbnails[3810306] = clik.newPhoto({"id":3810306,"src":"Victor089_thumb.jpg","galleries_id":232098,"server_id":5,"link":"photo_3810306.html","width":87,"caption":"","height":130});
															thumbnails[3810305] = clik.newPhoto({"id":3810305,"src":"Ruben_thumb.jpg","galleries_id":232098,"server_id":5,"link":"photo_3810305.html","width":130,"caption":"","height":87});
															thumbnails[4928675] = clik.newPhoto({"id":4928675,"src":"SFSC61a_thumb.jpg","galleries_id":231969,"server_id":5,"link":"photo_4928675.html","width":130,"caption":"Jabeer Butt, Chair of the Race Equality Foundation, speaking at the Annual Stronger Families Stronger Communities Conference  ","height":97});
															thumbnails[3810304] = clik.newPhoto({"id":3810304,"src":"Rosie1a_thumb.jpg","galleries_id":232098,"server_id":5,"link":"photo_3810304.html","width":93,"caption":"","height":130});
															thumbnails[4930380] = clik.newPhoto({"id":4930380,"src":"SFSC109a_thumb.jpg","galleries_id":231969,"server_id":5,"link":"photo_4930380.html","width":110,"caption":"Yasmin Alibhai-Brown speaking at the Race Equality Foundation's Annual Stronger Families Stronger Communities Conference","height":130});
															thumbnails[3810302] = clik.newPhoto({"id":3810302,"src":"MWR08e54_thumb.jpg","galleries_id":232098,"server_id":5,"link":"photo_3810302.html","width":97,"caption":"","height":130});
															thumbnails[3810358] = clik.newPhoto({"id":3810358,"src":"Clikpic0011_thumb.jpg","galleries_id":280518,"server_id":5,"link":"photo_3810358.html","width":130,"caption":"Street Scene in Soho","height":87});
															thumbnails[4930383] = clik.newPhoto({"id":4930383,"src":"SFSC74a_thumb.jpg","galleries_id":231969,"server_id":5,"link":"photo_4930383.html","width":87,"caption":"Delegate at the Race Equality Foundation's Annual Conference Stronger Families Stronger Communities","height":130});
															thumbnails[3810673] = clik.newPhoto({"id":3810673,"src":"Clikpic0171_thumb.jpg","galleries_id":280518,"server_id":5,"link":"photo_3810673.html","width":130,"caption":"Big Ben","height":87});
															thumbnails[4930387] = clik.newPhoto({"id":4930387,"src":"SFSC96a_thumb.jpg","galleries_id":231969,"server_id":5,"link":"photo_4930387.html","width":130,"caption":"Joanna Moorhead, journalist, speaking at the Race Equality Foundation's Annual Stronger Families Stronger Communities Conference","height":87});
															thumbnails[3810674] = clik.newPhoto({"id":3810674,"src":"Clikpic0291_thumb.jpg","galleries_id":280518,"server_id":5,"link":"photo_3810674.html","width":130,"caption":"Canary Wharf","height":87});
															thumbnails[4930385] = clik.newPhoto({"id":4930385,"src":"SFSC78a_thumb.jpg","galleries_id":231969,"server_id":5,"link":"photo_4930385.html","width":116,"caption":"Delegate at the Race Equality Foundation's Annual Stronger Families Stronger Communities Conference","height":130});
															thumbnails[3810675] = clik.newPhoto({"id":3810675,"src":"Clikpic0421_thumb.jpg","galleries_id":280518,"server_id":5,"link":"photo_3810675.html","width":130,"caption":"Hayward Gallery","height":92});
															thumbnails[5450873] = clik.newPhoto({"id":5450873,"src":"JLaneHoL57_thumb.jpg","galleries_id":231969,"server_id":5,"link":"photo_5450873.html","width":130,"caption":"Jane Lane speaking at the launch of her new book Young Children and Racial Justice at the House of Lords","height":87});
															thumbnails[3810676] = clik.newPhoto({"id":3810676,"src":"Clikpic0431_thumb.jpg","galleries_id":280518,"server_id":5,"link":"photo_3810676.html","width":130,"caption":"Houses of Parliament","height":87});
															thumbnails[5450872] = clik.newPhoto({"id":5450872,"src":"JLaneHoL-99_thumb.jpg","galleries_id":231969,"server_id":5,"link":"photo_5450872.html","width":130,"caption":"Lord Navnit Dholakia speaking at the launch of Jane Lane's book at the House of Lords","height":89});
															thumbnails[3810677] = clik.newPhoto({"id":3810677,"src":"Clikpic0501_thumb.jpg","galleries_id":280518,"server_id":5,"link":"photo_3810677.html","width":130,"caption":"Former Greater London Council Building","height":89});
															thumbnails[5450869] = clik.newPhoto({"id":5450869,"src":"JLaneHoL-117_thumb.jpg","galleries_id":231969,"server_id":5,"link":"photo_5450869.html","width":130,"caption":"Meryl Shepherd speaking at the launch of Jane Lane's book at the House of Lords","height":89});
															thumbnails[3810685] = clik.newPhoto({"id":3810685,"src":"Clikpic0521_thumb.jpg","galleries_id":280518,"server_id":5,"link":"photo_3810685.html","width":130,"caption":"National Portrait Gallery ","height":91});
															thumbnails[5450870] = clik.newPhoto({"id":5450870,"src":"JLaneHoL-2_thumb.jpg","galleries_id":231969,"server_id":5,"link":"photo_5450870.html","width":130,"caption":"Guest at the reception of Jane Lane's book launch at the House of Lords ","height":83});
															thumbnails[3810686] = clik.newPhoto({"id":3810686,"src":"Clikpic0811_thumb.jpg","galleries_id":280518,"server_id":5,"link":"photo_3810686.html","width":130,"caption":"St Paul's Cathedral","height":83});
															thumbnails[5450871] = clik.newPhoto({"id":5450871,"src":"JLaneHoL-23_copy_thumb.jpg","galleries_id":231969,"server_id":5,"link":"photo_5450871.html","width":130,"caption":"Guest at the reception of Jane Lane's book launch at the House of Lords","height":89});
															thumbnails[3810687] = clik.newPhoto({"id":3810687,"src":"Clikpic0821_thumb.jpg","galleries_id":280518,"server_id":5,"link":"photo_3810687.html","width":130,"caption":"Times Square","height":87});
															thumbnails[5451249] = clik.newPhoto({"id":5451249,"src":"WF2010AMA-3sml_copy_thumb.jpg","galleries_id":231969,"server_id":5,"link":"photo_5451249.html","width":130,"caption":"Greg Dyke giving the keynote speech at the Work Foundation's Workworld Media Awards ","height":74});
															thumbnails[3810688] = clik.newPhoto({"id":3810688,"src":"Clikpic0841_thumb.jpg","galleries_id":280518,"server_id":5,"link":"photo_3810688.html","width":130,"caption":"Trafalgar Square","height":87});
															thumbnails[5451250] = clik.newPhoto({"id":5451250,"src":"WF2010AMA-41sml_thumb.jpg","galleries_id":231969,"server_id":5,"link":"photo_5451250.html","width":130,"caption":"Will Hutton, Executive Vice Chair of The Work Foundation, speaking at the Workworld Media Awards  ","height":87});
															thumbnails[3810689] = clik.newPhoto({"id":3810689,"src":"larcdetriomphe_thumb.jpg","galleries_id":280518,"server_id":5,"link":"photo_3810689.html","width":130,"caption":"L'arc de Triomphe","height":87});
															thumbnails[5451248] = clik.newPhoto({"id":5451248,"src":"WF2010AMA-1sml_copy_thumb.jpg","galleries_id":231969,"server_id":5,"link":"photo_5451248.html","width":130,"caption":"Vincent De Rivaz, EDF Energy Chief Executive, speaking at The Work Foundation's WorkWorld Media Awards ","height":81});
															thumbnails[5451251] = clik.newPhoto({"id":5451251,"src":"WF2010AMA-82sml_thumb.jpg","galleries_id":231969,"server_id":5,"link":"photo_5451251.html","width":130,"caption":"Guest at the reception of The Work Foundation Workworld Media Awards","height":87});
															thumbnails[3810704] = clik.newPhoto({"id":3810704,"src":"toureiffel_thumb.jpg","galleries_id":280518,"server_id":5,"link":"photo_3810704.html","width":93,"caption":"Tour Eiffel","height":130});
															thumbnails[5451252] = clik.newPhoto({"id":5451252,"src":"WF2010AMA-86_thumb.jpg","galleries_id":231969,"server_id":5,"link":"photo_5451252.html","width":130,"caption":"Will Hutton with guests at the reception of The Work Foundation's Workworld Media Awards ","height":77});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  						galleries[231969] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Charities\/Corporate ","link":"gallery_231969.html","maxRecords":0.0,"photoIDs":[3810335.0,3810336.0,3810337.0,3810338.0,3810361.0,3810339.0,3810362.0,3810360.0,3810359.0,3810659.0,4928672.0,4928671.0,4930378.0,4930489.0,4928674.0,4928673.0,4928675.0,4930380.0,4930383.0,4930387.0,4930385.0,5450873.0,5450872.0,5450869.0,5450870.0,5450871.0,5451249.0,5451250.0,5451248.0,5451251.0,5451252.0],"skipIndex":0,"section_code":"gallery","featured_images":"5451252,5451251,5451250,5451249,5451248,5450873,5450872,5450871,5450870,5450869","id":231969,"singleSection":false});				  						galleries[306926] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Weddings","link":"gallery_306926.html","maxRecords":0.0,"photoIDs":[5431233.0],"skipIndex":0,"section_code":"gallery","featured_images":5431233.0,"id":306926,"singleSection":false});				  						galleries[232098] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Portraits","link":"gallery_232098.html","maxRecords":0.0,"photoIDs":[3810294.0,3810292.0,3810293.0,3810295.0,4311566.0,3810291.0,3810303.0,3810306.0,3810305.0,3810304.0,3810302.0],"skipIndex":0,"section_code":"gallery","featured_images":"4311566,3810306,3810305,3810304,3810303,3810302,3810295,3810294,3810293,3810292","id":232098,"singleSection":false});				  						galleries[280518] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Personal Work","link":"gallery_280518.html","maxRecords":0.0,"photoIDs":[4472082.0,4472083.0,3810358.0,3810673.0,3810674.0,3810675.0,3810676.0,3810677.0,3810685.0,3810686.0,3810687.0,3810688.0,3810689.0,3810704.0],"skipIndex":0,"section_code":"gallery","featured_images":"4472083,4472082,3810704,3810689,3810688,3810687,3810686,3810685,3810677,3810676","id":280518,"singleSection":false});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[1] = '5451252,5451251,5451250,5451249,5451248,5450873,5450872,5450871,5450870,5450869,5431233,4930489,4930387,4930385,4930383,4930380,4930378,4928675,4928674,4928673,4928672,4928671,4472083,4472082,4311566,3810704,3810689,3810688,3810687,3810686,3810685,3810677,3810676,3810675,3810674,3810673,3810659,3810362,3810361,3810360,3810359,3810358,3810339,3810338,3810337,3810336,3810335,3810306,3810305,3810304';
imageSets[3] = '5451252,5451251,5451250,5451249,5451248,5450873,5450872,5450871,5450870,5450869,5431233,4930489,4930387,4930385,4930383,4930380,4930378,4928675,4928674,4928673,4928672,4928671,4472083,4472082,4311566,3810704,3810689,3810688,3810687,3810686,3810685,3810677,3810676,3810675,3810674,3810673,3810659,3810362,3810361,3810360,3810359,3810358,3810339,3810338,3810337,3810336,3810335,3810306,3810305,3810304';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/shamil42/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/shamil42/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/shamil42/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/shamil42/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/shamil42/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/shamil42/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/shamil42/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/shamil42/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/shamil42/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/shamil42/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/shamil42/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/shamil42/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/shamil42/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/shamil42/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/shamil42/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/shamil42/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/shamil42/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/shamil42/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/shamil42/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/shamil42/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/shamil42/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/shamil42/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/shamil42/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 = 'Sam Appa Photography: ' + photoCaption;
			    }
        if (op.$detail.length > 0) {
      	temp = op.nextPhoto.fnGetImageDetails();
	    op.$detail.fadeGalleryDetails(temp, op.speed, function(){
			if (typeof(backgrounds) != 'undefined' && op.nextPhoto == backgrounds[op.nextPhoto.id]) {
				toggleAddToCartConfirm(backgrounds, op.$detail);
			} else if (typeof(photos) != 'undefined' && op.nextPhoto == photos[op.nextPhoto.id]) {
				toggleAddToCartConfirm(photos, op.$detail);
			}
			$('body').trigger('clikUpdate.popup');
	    });
    }
        $(op.$detailContainer).find('.replaceable[class*=replaceable_photo-]').each(function(){
    	var field = clik.getPrefixedClass(this.className, 'replaceable_photo-');
    	if (field in op.nextPhoto) {
    		$(this).fadeGalleryDetails(op.nextPhoto[field], op.speed);
    	}
    }).end().find('.replaceable.photoPayment').fadeGalleryDetails(op.nextPhoto.fnGetPaymentInfo(), op.speed, function(){
		if (typeof(backgrounds) != 'undefined' && op.nextPhoto == backgrounds[op.nextPhoto.id]) {
			toggleAddToCartConfirm(backgrounds, op.$detailContainer);
		} else if (typeof(photos) != 'undefined' && op.nextPhoto == photos[op.nextPhoto.id]) {
			toggleAddToCartConfirm(photos, op.$detailContainer);
		}
		$('body').trigger('clikUpdate.popup');
	});
		if (op.$photo.length > 0) {
		html = $('<img/>',{
			'class': 'mainphoto photo',
			src: photoSrc,
			id: 'mainPic',
			name: 'mainPic',
			width: op.nextPhoto.width,
			height: op.nextPhoto.height,
			alt: photoCaption,
			css: op.css || {}
		});
		if (op.href) {
			if (op.href.match(/<a/)) {
				html = $(op.href).append(html);
			} else {
				html = $('<a/>', {
					href: op.href,
					title: photoCaption
				}).append(html);
			}
		} else {
			html = $('<a/>', {
				title: photoCaption
			}).append(html);
		}
		if (op.speed == 0) {			op.$photo.html(html);			if (op.onBefore) {			  	op.onBefore.apply(op.$photo);			}			if (op.onAfter) {			  	op.onAfter.apply(op.$photo);			}		} else {			op.$photo.stop(true,true).fadeReplaceWith(html,op.speed,'',function(){  				if (op.onAfter) {				  	op.onAfter.apply(this);				}				clik.doColumnResize(false, $(this).add(op.$detail).add(op.$title));			}, op.onBefore);
		}	}
    if (op.field) {
		op.field.value = photoId;
	} else {
		op.$photo.data('image_id', photoId);
    }
        if (!op.speed) {
      	clik.doColumnResize(false, op.$photo.add(op.$detail).add(op.$title));
    }
        
    return html;
	}

/***************************************************************************
* Toggle add to cart confirmation element and set up the click event for   *
* the 'Add to cart' button.                                                *
***************************************************************************/
function toggleAddToCartConfirm(array, root){
	if (typeof(array) !== 'object' || array === null) {
	  	array = photos;
	}
	if (!$(root).length) {		root = $('body');	}	if($('#paymentConfirm', root).length > 0){
		$('#paymentConfirm', root).hide();
		$('#paymentAddButton', root)
		.unbind()
		.click(function(){
						form = $('#paymentForm', root)[0];
			option_id = 0;
			if(form.item_option.value){
				option_id = form.item_option.value;
			}
			if(addItemToBasket(form.item_number.value,array,form.site.value,parseInt(form.quantity.value, 10),option_id)){
				if($.browser.msie){$('#paymentConfirm', root).text('Item added to cart').show();}
				else{
					$('#paymentConfirm', root).text('Item added to cart').fadeIn();
					dspOrderDetails(form.site.value);
				}
			}
			else{
				$('#paymentConfirm', root).text('Item not added - check cookies are enabled in your browser.').fadeIn();
			}
		});
	}
}

/***************************************************************************
* Get payment info for image - add as 'method' to photo object             *
***************************************************************************/
clik.photo.fnGetImageDetails = function(){
	var temp = '';
	if (this.description != '') {
		temp +=  '<div id="imageDescription">' + this.description + '</div>';
	}
		if (this.photo_ref != '') {
		temp += '<div class="imageinfo" id="imageRef"><strong>Ref: </strong>' + this.photo_ref + '</div>';
	}
		if (this.takendate != '') {
		
		temp += '<div class="imageinfo" id="imageDate"><strong>Date: </strong>' + this.takendate + '</div>';
	}
	
	if (this.location != '') {
		
		temp += '<div class="imageinfo" id="imageLocation"><strong>Location: </strong>' +  this.location + '</div>';
	}
	
	if (this.photographer != '') {
		
		temp += '<div class="imageinfo" id="imagePhotographer"><strong>Photographer: </strong>' + this.photographer + '</div>';
	}
				
	temp += this.fnGetPaymentInfo();
				if (temp != '') {
		temp += '<div class="spacer"></div>';
	}
	return temp;
};

/***************************************************************************
* Get payment info for image - add as 'method' to photo object             *
***************************************************************************/
clik.photo.fnGetPaymentInfo = function(){
	var temp = '';
	if (this.item_price !== '') {
																		temp += '<p>Buy now using PayPal:</p>';
				temp += '<div class="imageinfo" id="imagePrice"><strong>' + this.purchase_instruction + '</strong> &pound;' + (this.item_price).toFixed(2) + '</div>';
		var item_name  = this.purchase_instruction;
		var amount = (this.item_price).toFixed(2);
		var item_option  = 0;
	}
	else if (this.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 += '<form id="paymentForm" style="margin:0px;border:0px;" name="paymentForm" target="_blank" action="https://www.paypal.com/cgi-bin/webscr" method="post">';
			temp += '<input type="hidden" name="item_name" value="'+item_name+'">';
			ref = '';
			if(this.photo_ref != ''){
				ref = this.photo_ref+' - '+this.caption;
			}
			else{
				ref = this.id+' - '+this.caption;
			}
			price = amount;								temp += '<input type="hidden" name="cmd" value="_cart">';
					temp += '<input type="hidden" name="business" value="photography@appature.com">';
					temp += '<input type="hidden" name="currency_code" value="GBP">';
					temp += '<input type="hidden" name="add" value="1">';
													temp += '<input type="hidden" name="amount" value="'+amount+'">';
					temp += '<input type="hidden" name="item_number" value="'+ref+'">';
													temp += '<input type=\"Submit\" value=\"Add to cart\" id=\"paymentAddButton\" class=\"button\" onmouseover=\"this.className=\'buttonHi\';\" onmouseout=\"this.className=\'button\';\">';
										temp += '</form>';
										temp += '<form id="paymentCartForm" style="margin:0px;" name="paymentCartForm" target="_blank" action="https://www.paypal.com/cgi-bin/webscr" method="post">';
				temp += '<input type="hidden" name="cmd" value="_cart">';
				temp += '<input type="hidden" name="business" value="photography@appature.com">';
				temp += '<input type="hidden" name="display" value="1">';
				temp += '<input type=\"Submit\" value=\"View cart\" id=\"paymentViewButton\" class=\"button\" onmouseover=\"this.className=\'buttonHi\';\" onmouseout=\"this.className=\'button\';\">';
				temp += '</form>';
						temp += '<div class="clearing">&nbsp;</div>';
	}
	return temp;};

/***************************************************************************
* Pick a photo at random from the featured images of a gallery.            *
* Gallery_id = id of gallery to choose,                                    *
* img = reference to html image in                                         *
* which to show image                                                      *
***************************************************************************/
function showGalleryImage(gallery_id, img, updateLink) {
	
	if(img){
		if (location.hash.match('galleries_id=' + gallery_id) && (imageID = location.hash.match('.*photos_id=(.+)$'))) {
		  	imageID = imageID[1];
		} else {
		  	imageID = randomListVal(galleries[gallery_id].featured_images);
		}
		
		if (imageID != 0) {
			img.src = thumbnails[imageID].src;
			img.width = thumbnails[imageID].width;
			img.height = thumbnails[imageID].height;
			img.alt = galleries[gallery_id].title;
			if (updateLink) {
				$(img).parent().attr({					href: thumbnails[imageID].fnGalleryLink(gallery_id),					title: galleries[gallery_id].title				});
			}
		}
	}
}

/***************************************************************************
* 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;
	}
}

			

