window.thumbnails = {};
															thumbnails[4850269] = clik.newPhoto({"id":4850269,"src":"butterflies_thumb.jpg","galleries_id":"","server_id":15,"link":"#","width":130,"caption":"Tattoo Design","height":233});
															thumbnails[4850273] = clik.newPhoto({"id":4850273,"src":"alfie_thumb.JPG","galleries_id":"","server_id":15,"link":"#","width":130,"caption":"Tattoo Lettering","height":93});
															thumbnails[6332166] = clik.newPhoto({"id":6332166,"src":"tatt_1_copy_thumb.jpg","galleries_id":"","server_id":15,"link":"#","width":130,"caption":"","height":58});
															thumbnails[6332169] = clik.newPhoto({"id":6332169,"src":"tatt2_copy_thumb.jpg","galleries_id":"","server_id":15,"link":"#","width":130,"caption":"","height":51});
															thumbnails[6332176] = clik.newPhoto({"id":6332176,"src":"tatt_3_copy_thumb.jpg","galleries_id":"","server_id":15,"link":"#","width":130,"caption":"","height":48});
															thumbnails[3926016] = clik.newPhoto({"id":3926016,"src":"DSCN0307-1_thumb.JPG","galleries_id":238145,"server_id":15,"link":"photo_3926016.html","width":130,"caption":"She - SOLD large canvas","height":132});
															thumbnails[3926033] = clik.newPhoto({"id":3926033,"src":"DSCN0287-1_thumb.JPG","galleries_id":238145,"server_id":15,"link":"photo_3926033.html","width":130,"caption":"Pinstripes and Fishnets SOLD","height":135});
															thumbnails[3926047] = clik.newPhoto({"id":3926047,"src":"bounty_thumb.jpg","galleries_id":238145,"server_id":15,"link":"photo_3926047.html","width":130,"caption":"Bounty SOLD","height":172});
															thumbnails[3926058] = clik.newPhoto({"id":3926058,"src":"DSCN0242-1_thumb.JPG","galleries_id":238145,"server_id":15,"link":"photo_3926058.html","width":130,"caption":"Cocktail Dress #1 - FOR SALE large canvas exhibited at Camden Tube Station £850 inc. UK P&P","height":132});
															thumbnails[3926072] = clik.newPhoto({"id":3926072,"src":"DSCN0286-1_thumb.JPG","galleries_id":238145,"server_id":15,"link":"photo_3926072.html","width":130,"caption":"Bolero SOLD","height":155});
															thumbnails[3926140] = clik.newPhoto({"id":3926140,"src":"DSCN0284-1_thumb.JPG","galleries_id":238145,"server_id":15,"link":"photo_3926140.html","width":130,"caption":"Cleo Lane - SOLD","height":131});
															thumbnails[3926155] = clik.newPhoto({"id":3926155,"src":"DSCN0313-1_thumb.JPG","galleries_id":238145,"server_id":15,"link":"photo_3926155.html","width":130,"caption":"Cocktail Dress #2 SOLD","height":130});
															thumbnails[3926645] = clik.newPhoto({"id":3926645,"src":"DSCF1023-1_thumb.JPG","galleries_id":238145,"server_id":15,"link":"photo_3926645.html","width":130,"caption":"The Original Rock Star SOLD","height":194});
															thumbnails[3926647] = clik.newPhoto({"id":3926647,"src":"DSCF1026-1_thumb.JPG","galleries_id":238145,"server_id":15,"link":"photo_3926647.html","width":130,"caption":"SOLD","height":142});
															thumbnails[3926691] = clik.newPhoto({"id":3926691,"src":"DSCF1009-1_thumb.JPG","galleries_id":238146,"server_id":15,"link":"photo_3926691.html","width":130,"caption":"Oh #1","height":161});
															thumbnails[3926713] = clik.newPhoto({"id":3926713,"src":"DSCF1008-1_thumb.JPG","galleries_id":238146,"server_id":15,"link":"photo_3926713.html","width":130,"caption":"Lucky 10","height":150});
															thumbnails[3926720] = clik.newPhoto({"id":3926720,"src":"drawings_skirts_thumb.jpg","galleries_id":238146,"server_id":15,"link":"photo_3926720.html","width":130,"caption":"Drawing Skirts","height":171});
															thumbnails[3926730] = clik.newPhoto({"id":3926730,"src":"DSCN0147-1_thumb.JPG","galleries_id":238146,"server_id":15,"link":"photo_3926730.html","width":130,"caption":"Adora Girls ","height":173});
															thumbnails[3926756] = clik.newPhoto({"id":3926756,"src":"DSCF0877-1_thumb.JPG","galleries_id":238146,"server_id":15,"link":"photo_3926756.html","width":130,"caption":"Extrovert Logo","height":216});
															thumbnails[3926760] = clik.newPhoto({"id":3926760,"src":"DSCF1137-2_thumb.JPG","galleries_id":238146,"server_id":15,"link":"photo_3926760.html","width":130,"caption":"Emma De Vere's Promotional Work","height":141});
															thumbnails[3926790] = clik.newPhoto({"id":3926790,"src":"DSCF091311_thumb.JPG","galleries_id":238146,"server_id":15,"link":"photo_3926790.html","width":130,"caption":"Adora Girls Original Artwork","height":104});
															thumbnails[3926791] = clik.newPhoto({"id":3926791,"src":"DSCF1185-1_thumb.JPG","galleries_id":238146,"server_id":15,"link":"photo_3926791.html","width":130,"caption":"Private Commission","height":166});
															thumbnails[3926792] = clik.newPhoto({"id":3926792,"src":"DSCF1187-1_thumb.JPG","galleries_id":238146,"server_id":15,"link":"photo_3926792.html","width":130,"caption":"Double Private Commission","height":180});
															thumbnails[3926839] = clik.newPhoto({"id":3926839,"src":"DSCN0120-2_thumb.JPG","galleries_id":238146,"server_id":15,"link":"photo_3926839.html","width":130,"caption":"Future Sex ","height":131});
															thumbnails[3926845] = clik.newPhoto({"id":3926845,"src":"DSCF09581_thumb.JPG","galleries_id":238146,"server_id":15,"link":"photo_3926845.html","width":130,"caption":"G-12","height":137});
															thumbnails[3926875] = clik.newPhoto({"id":3926875,"src":"On_these_shoulders_thumb.jpg","galleries_id":238146,"server_id":15,"link":"photo_3926875.html","width":130,"caption":"On These Shoulders","height":157});
															thumbnails[3926878] = clik.newPhoto({"id":3926878,"src":"drink_girl_thumb.jpg","galleries_id":238146,"server_id":15,"link":"photo_3926878.html","width":130,"caption":"Drinking Girl","height":161});
															thumbnails[3926978] = clik.newPhoto({"id":3926978,"src":"DSCN0252-2_thumb.JPG","galleries_id":238146,"server_id":15,"link":"photo_3926978.html","width":130,"caption":"Purse","height":184});
															thumbnails[3926993] = clik.newPhoto({"id":3926993,"src":"DSCN0256-1_thumb.JPG","galleries_id":238146,"server_id":15,"link":"photo_3926993.html","width":130,"caption":"","height":180});
															thumbnails[3927008] = clik.newPhoto({"id":3927008,"src":"Kat_thumb.jpg","galleries_id":238146,"server_id":15,"link":"photo_3927008.html","width":130,"caption":"Kat Von D","height":186});
															thumbnails[3927017] = clik.newPhoto({"id":3927017,"src":"GemmaKenwardDrawings004-2_thumb.jpg","galleries_id":238146,"server_id":15,"link":"photo_3927017.html","width":130,"caption":"Floor Cru","height":148});
															thumbnails[3927019] = clik.newPhoto({"id":3927019,"src":"GemmaKenwardDrawings0053_thumb.jpg","galleries_id":238146,"server_id":15,"link":"photo_3927019.html","width":130,"caption":"Adore-her","height":89});
															thumbnails[3927022] = clik.newPhoto({"id":3927022,"src":"Photo001-2_thumb.JPG","galleries_id":238146,"server_id":15,"link":"photo_3927022.html","width":130,"caption":"Dazed and Confused ","height":224});
															thumbnails[3927024] = clik.newPhoto({"id":3927024,"src":"DSCN0274-2_thumb.JPG","galleries_id":238146,"server_id":15,"link":"photo_3927024.html","width":130,"caption":"Fashion ","height":201});
															thumbnails[3927026] = clik.newPhoto({"id":3927026,"src":"DSCF1074-1_thumb.JPG","galleries_id":238146,"server_id":15,"link":"photo_3927026.html","width":130,"caption":"Self-Portrait","height":212});
															thumbnails[3927028] = clik.newPhoto({"id":3927028,"src":"bubbleguts_2_thumb.jpg","galleries_id":238224,"server_id":15,"link":"photo_3927028.html","width":130,"caption":"Bubbleguts","height":157});
															thumbnails[3927029] = clik.newPhoto({"id":3927029,"src":"bubbleguts_thumb.jpg","galleries_id":238224,"server_id":15,"link":"photo_3927029.html","width":130,"caption":"Granny","height":176});
															thumbnails[3927030] = clik.newPhoto({"id":3927030,"src":"bubbleguts_3_thumb.jpg","galleries_id":238224,"server_id":15,"link":"photo_3927030.html","width":130,"caption":"And then","height":166});
															thumbnails[3927041] = clik.newPhoto({"id":3927041,"src":"DSCF1201-1_thumb.JPG","galleries_id":238224,"server_id":15,"link":"photo_3927041.html","width":130,"caption":"Granny #2","height":178});
															thumbnails[3927053] = clik.newPhoto({"id":3927053,"src":"DSCF1016-1_thumb.JPG","galleries_id":238224,"server_id":15,"link":"photo_3927053.html","width":130,"caption":"Clouds","height":178});
															thumbnails[3927054] = clik.newPhoto({"id":3927054,"src":"DSCF1018-1_thumb.JPG","galleries_id":238224,"server_id":15,"link":"photo_3927054.html","width":130,"caption":"The Deliverance Machine","height":179});
															thumbnails[3927055] = clik.newPhoto({"id":3927055,"src":"DSCF1021-1_thumb.JPG","galleries_id":238224,"server_id":15,"link":"photo_3927055.html","width":130,"caption":"Cow Goes Mooo","height":137});
															thumbnails[3927056] = clik.newPhoto({"id":3927056,"src":"DSCF1022-1_thumb.JPG","galleries_id":238224,"server_id":15,"link":"photo_3927056.html","width":130,"caption":"Sax","height":281});
															thumbnails[3927057] = clik.newPhoto({"id":3927057,"src":"DSCF1028-1_thumb.JPG","galleries_id":238224,"server_id":15,"link":"photo_3927057.html","width":130,"caption":"Deliverance","height":135});
															thumbnails[3927059] = clik.newPhoto({"id":3927059,"src":"DSCF1029-1_thumb.JPG","galleries_id":238224,"server_id":15,"link":"photo_3927059.html","width":130,"caption":"Sadly Delivering","height":200});
															thumbnails[3927060] = clik.newPhoto({"id":3927060,"src":"DSCF1031-1_thumb.JPG","galleries_id":238224,"server_id":15,"link":"photo_3927060.html","width":130,"caption":"","height":172});
															thumbnails[3927062] = clik.newPhoto({"id":3927062,"src":"DSCF1035-1_thumb.JPG","galleries_id":238224,"server_id":15,"link":"photo_3927062.html","width":130,"caption":"Mechanical Mouse","height":97});
															thumbnails[3927079] = clik.newPhoto({"id":3927079,"src":"DSCF1037-1_thumb.JPG","galleries_id":238224,"server_id":15,"link":"photo_3927079.html","width":130,"caption":"Heron","height":180});
															thumbnails[3927081] = clik.newPhoto({"id":3927081,"src":"DSCF1038-1_thumb.JPG","galleries_id":238224,"server_id":15,"link":"photo_3927081.html","width":130,"caption":"","height":260});
															thumbnails[3927083] = clik.newPhoto({"id":3927083,"src":"DSCF1041-1_thumb.JPG","galleries_id":238224,"server_id":15,"link":"photo_3927083.html","width":130,"caption":"The Wave Goodbye","height":173});
															thumbnails[3927084] = clik.newPhoto({"id":3927084,"src":"nigel_bennet_thumb.jpg","galleries_id":238224,"server_id":15,"link":"photo_3927084.html","width":130,"caption":"Nigel Bennett","height":291});
															thumbnails[4850284] = clik.newPhoto({"id":4850284,"src":"lindsay_thumb.jpg","galleries_id":238145,"server_id":15,"link":"photo_4850284.html","width":130,"caption":"FOR SALE executed on wood, no frame because it looks better that way just placed on a white wall. £200 inc. UK P&P","height":161});
															thumbnails[4979336] = clik.newPhoto({"id":4979336,"src":"custom_kicks_red_thumb.jpg","galleries_id":282893,"server_id":15,"link":"photo_4979336.html","width":130,"caption":"Illustrated ready to wear high heels in a size 5. £90 free UK postage and packaging.","height":56});
															thumbnails[4979345] = clik.newPhoto({"id":4979345,"src":"custom_kicks_blue_thumb.jpg","galleries_id":282893,"server_id":15,"link":"photo_4979345.html","width":130,"caption":"Illustrated ready to wear high heels in a size 5. £90 free UK postage and packaging.","height":56});
															thumbnails[5182834] = clik.newPhoto({"id":5182834,"src":"robots_thumb.jpg","galleries_id":282893,"server_id":15,"link":"photo_5182834.html","width":130,"caption":"Tranformers Private Commission","height":47});
															thumbnails[6332200] = clik.newPhoto({"id":6332200,"src":"american_thumb.jpg","galleries_id":238145,"server_id":15,"link":"photo_6332200.html","width":130,"caption":"SOLD","height":166});
															thumbnails[6340091] = clik.newPhoto({"id":6340091,"src":"sarah_thumb.jpg","galleries_id":238145,"server_id":15,"link":"photo_6340091.html","width":130,"caption":"Madam Jo Jo's SOLD","height":163});
															thumbnails[8710418] = clik.newPhoto({"id":8710418,"src":"205106_164810606908439_100001385020996_383281_1762025_n_thumb.jpg","galleries_id":459398,"server_id":15,"link":"photo_8710418.html","width":130,"caption":"Pride in Bournemouth Initial Design","height":98});
															thumbnails[8710420] = clik.newPhoto({"id":8710420,"src":"206285_164810410241792_100001385020996_383278_4011284_n_thumb.jpg","galleries_id":459398,"server_id":15,"link":"photo_8710420.html","width":130,"caption":"","height":98});
															thumbnails[8710422] = clik.newPhoto({"id":8710422,"src":"320135_10150855367040651_739515650_20727199_210859216_n_thumb.jpg","galleries_id":459398,"server_id":15,"link":"photo_8710422.html","width":130,"caption":"","height":73});
															thumbnails[8710423] = clik.newPhoto({"id":8710423,"src":"227286_170177603038406_100001385020996_418553_6361920_n_thumb.jpg","galleries_id":459398,"server_id":15,"link":"photo_8710423.html","width":130,"caption":"","height":188});
															thumbnails[8710425] = clik.newPhoto({"id":8710425,"src":"221635_164810476908452_100001385020996_383279_8085031_n_thumb.jpg","galleries_id":459398,"server_id":15,"link":"photo_8710425.html","width":130,"caption":"","height":98});
															thumbnails[8710428] = clik.newPhoto({"id":8710428,"src":"216867_164810663575100_100001385020996_383282_7856196_n_thumb.jpg","galleries_id":459398,"server_id":15,"link":"photo_8710428.html","width":130,"caption":"","height":98});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  						galleries[238145] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Wonderings In Paint","link":"gallery_238145.html","maxRecords":0.0,"photoIDs":[3926016.0,3926033.0,3926047.0,3926058.0,3926072.0,3926140.0,3926155.0,3926645.0,3926647.0,4850284.0,6332200.0,6340091.0],"skipIndex":0,"section_code":"gallery","featured_images":3926072.0,"id":238145,"singleSection":false});				  						galleries[238146] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Sketchbook Doodling","link":"gallery_238146.html","maxRecords":0.0,"photoIDs":[3926691.0,3926713.0,3926720.0,3926730.0,3926756.0,3926760.0,3926790.0,3926791.0,3926792.0,3926839.0,3926845.0,3926875.0,3926878.0,3926978.0,3926993.0,3927008.0,3927017.0,3927019.0,3927022.0,3927024.0,3927026.0],"skipIndex":0,"section_code":"gallery","featured_images":3926720.0,"id":238146,"singleSection":false});				  						galleries[238224] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Children's Book Illustration","link":"gallery_238224.html","maxRecords":0.0,"photoIDs":[3927028.0,3927029.0,3927030.0,3927041.0,3927053.0,3927054.0,3927055.0,3927056.0,3927057.0,3927059.0,3927060.0,3927062.0,3927079.0,3927081.0,3927083.0,3927084.0],"skipIndex":0,"section_code":"gallery","featured_images":3927059.0,"id":238224,"singleSection":false});				  						galleries[282893] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Custom Kicks","link":"gallery_282893.html","maxRecords":0.0,"photoIDs":[4979336.0,4979345.0,5182834.0],"skipIndex":0,"section_code":"gallery","featured_images":"5182834,4979345,4979336","id":282893,"singleSection":false});				  						galleries[459398] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Coast Lion","link":"gallery_459398.html","maxRecords":0.0,"photoIDs":[8710418.0,8710420.0,8710422.0,8710423.0,8710425.0,8710428.0],"skipIndex":0,"section_code":"gallery","featured_images":"8710428,8710425,8710423,8710422,8710420,8710418","id":459398,"singleSection":false});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[1] = '3926033';
imageSets[2] = '3927059,3926720,3926072';
imageSets[3] = '8710428,8710425,8710423,8710422,8710420,8710418,6340091,6332200,6332176,6332169,6332166,5182834,4979345,4979336,4850284,4850273,4850269,3927084,3927083,3927081,3927079,3927062,3927060,3927059,3927057,3927056,3927055,3927054,3927053,3927041,3927030,3927029,3927028,3927026,3927024,3927022,3927019,3927017,3927008,3926993,3926978,3926878,3926875,3926845,3926839,3926792,3926791,3926790,3926760,3926756';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 51:
		val = 'www12.clikpic.com/gemmakenward/images';
		break;
	}
		switch (server_id) {
		case 0:
		val = 'http://www.clikpic.com/gemmakenward/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/gemmakenward/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/gemmakenward/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/gemmakenward/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/gemmakenward/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/gemmakenward/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/gemmakenward/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/gemmakenward/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/gemmakenward/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/gemmakenward/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/gemmakenward/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/gemmakenward/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/gemmakenward/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/gemmakenward/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/gemmakenward/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/gemmakenward/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/gemmakenward/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/gemmakenward/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/gemmakenward/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/gemmakenward/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/gemmakenward/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/gemmakenward/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/gemmakenward/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/gemmakenward/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 = 'Gemma Kenward Illustrations: ' + 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="gemsiek@hotmail.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="gemsiek@hotmail.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({					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;
	}
}

			

