window.thumbnails = {};
															thumbnails[8940853] = clik.newPhoto({"id":8940853,"src":"lingua_franca_webpic4_thumb.jpg","galleries_id":219204,"server_id":15,"link":"photo_8940853.html","width":130,"caption":"lngua franca","height":132});
															thumbnails[8910779] = clik.newPhoto({"id":8910779,"src":"genjiiwebpic4_thumb.jpg","galleries_id":219204,"server_id":15,"link":"photo_8910779.html","width":130,"caption":"Tales of the Gejii","height":133});
															thumbnails[8910775] = clik.newPhoto({"id":8910775,"src":"greelywebpic4_thumb.jpg","galleries_id":219204,"server_id":15,"link":"photo_8910775.html","width":130,"caption":"Horace Greely's Admonition","height":131});
															thumbnails[8777420] = clik.newPhoto({"id":8777420,"src":"pomona3webpic4_thumb.jpg","galleries_id":219204,"server_id":15,"link":"photo_8777420.html","width":130,"caption":"","height":131});
															thumbnails[8754511] = clik.newPhoto({"id":8754511,"src":"malibu13webpic4_thumb.jpg","galleries_id":219204,"server_id":15,"link":"photo_8754511.html","width":130,"caption":"80x80cm Acrylic & Oil on Canvas","height":134});
															thumbnails[8654532] = clik.newPhoto({"id":8654532,"src":"Malibu10webpic4_thumb.jpg","galleries_id":219204,"server_id":15,"link":"photo_8654532.html","width":130,"caption":"Sketch for Utopia Road","height":132});
															thumbnails[3930870] = clik.newPhoto({"id":3930870,"src":"plague_time_webpic_thumb.jpg","galleries_id":228773,"server_id":15,"link":"photo_3930870.html","width":130,"caption":"'Plague Time'","height":123});
															thumbnails[8546678] = clik.newPhoto({"id":8546678,"src":"malibu4webpic4_thumb.jpg","galleries_id":219204,"server_id":15,"link":"photo_8546678.html","width":130,"caption":"","height":132});
															thumbnails[8741098] = clik.newPhoto({"id":8741098,"src":"Malibu11webpic4_thumb.jpg","galleries_id":219204,"server_id":15,"link":"photo_8741098.html","width":130,"caption":"","height":132});
															thumbnails[8546673] = clik.newPhoto({"id":8546673,"src":"malibu3webpic4_thumb.jpg","galleries_id":219204,"server_id":15,"link":"photo_8546673.html","width":130,"caption":"","height":133});
															thumbnails[8738729] = clik.newPhoto({"id":8738729,"src":"Malibu9webpic4_thumb.jpg","galleries_id":219204,"server_id":15,"link":"photo_8738729.html","width":130,"caption":"","height":132});
															thumbnails[3787709] = clik.newPhoto({"id":3787709,"src":"Head_a-7_website_a_thumb.jpg","galleries_id":228773,"server_id":15,"link":"photo_3787709.html","width":130,"caption":"'Head H-7'","height":129});
															thumbnails[8546672] = clik.newPhoto({"id":8546672,"src":"DSCF1839bwebpic4_thumb.jpg","galleries_id":219204,"server_id":15,"link":"photo_8546672.html","width":130,"caption":"","height":131});
															thumbnails[3794894] = clik.newPhoto({"id":3794894,"src":"head_a-12_website_a_thumb.jpg","galleries_id":228773,"server_id":15,"link":"photo_3794894.html","width":130,"caption":"'Head a-12'","height":129});
															thumbnails[8546664] = clik.newPhoto({"id":8546664,"src":"DSCF1840awebpic_thumb.jpg","galleries_id":219204,"server_id":15,"link":"photo_8546664.html","width":130,"caption":"","height":132});
															thumbnails[3794907] = clik.newPhoto({"id":3794907,"src":"Head_a-14_website_a_thumb.jpg","galleries_id":228773,"server_id":15,"link":"photo_3794907.html","width":130,"caption":"'Head a-14'","height":130});
															thumbnails[8060280] = clik.newPhoto({"id":8060280,"src":"Requiem_for_Balthazarweb_thumb.jpg","galleries_id":219204,"server_id":15,"link":"photo_8060280.html","width":130,"caption":"Requiem for Balthazar","height":131});
															thumbnails[8060273] = clik.newPhoto({"id":8060273,"src":"Pentimentoweb_thumb.jpg","galleries_id":219204,"server_id":15,"link":"photo_8060273.html","width":130,"caption":"Pentimento","height":132});
															thumbnails[8060203] = clik.newPhoto({"id":8060203,"src":"Duneweb_thumb.jpg","galleries_id":219204,"server_id":15,"link":"photo_8060203.html","width":130,"caption":"Dune","height":132});
															thumbnails[7230576] = clik.newPhoto({"id":7230576,"src":"Wonderland3for_webpage_thumb.jpg","galleries_id":219204,"server_id":15,"link":"photo_7230576.html","width":130,"caption":"Wonderland","height":165});
															thumbnails[6133522] = clik.newPhoto({"id":6133522,"src":"ranchweb_thumb.jpg","galleries_id":219204,"server_id":15,"link":"photo_6133522.html","width":130,"caption":"Ember","height":118});
															thumbnails[5878240] = clik.newPhoto({"id":5878240,"src":"Tailing_ponds_Snow2clik_thumb.jpg","galleries_id":219204,"server_id":15,"link":"photo_5878240.html","width":130,"caption":"Tailing Ponds Oil on Canvas 120x190","height":207});
															thumbnails[3769509] = clik.newPhoto({"id":3769509,"src":"Tundra_D_E_W_Line_sized_for_website_thumb.jpg","galleries_id":228773,"server_id":15,"link":"photo_3769509.html","width":130,"caption":"'Tundra 4 D.E.W. Line'","height":159});
															thumbnails[6437956] = clik.newPhoto({"id":6437956,"src":"Kelowna-encroachingfclik2_thumb.jpg","galleries_id":219204,"server_id":15,"link":"photo_6437956.html","width":130,"caption":"","height":125});
															thumbnails[3769498] = clik.newPhoto({"id":3769498,"src":"Tundra_Apotheosis_sized_for_website_thumb.jpg","galleries_id":228773,"server_id":15,"link":"photo_3769498.html","width":130,"caption":"'Tundra Apotheosis'","height":160});
															thumbnails[5878091] = clik.newPhoto({"id":5878091,"src":"Goin_Down_the_Road_East_of_the_Saultwebapic_thumb.jpg","galleries_id":219204,"server_id":15,"link":"photo_5878091.html","width":130,"caption":"East of Sault Oil on Canvas 180x190","height":137});
															thumbnails[3778789] = clik.newPhoto({"id":3778789,"src":"Night_Fishing_On_The_Euphrates_sized_for_website_thumb.jpg","galleries_id":228773,"server_id":15,"link":"photo_3778789.html","width":130,"caption":"'Night Fishing On The Euphrates","height":161});
															thumbnails[5878046] = clik.newPhoto({"id":5878046,"src":"deer2webapic_thumb.jpg","galleries_id":219204,"server_id":15,"link":"photo_5878046.html","width":130,"caption":"Saugueney Oil on Canvas   180X190","height":144});
															thumbnails[3757220] = clik.newPhoto({"id":3757220,"src":"When_we_drove_in_my_car_website_a_thumb.jpg","galleries_id":228773,"server_id":15,"link":"photo_3757220.html","width":130,"caption":"'Remember When We Drove In My Car'","height":162});
															thumbnails[6437972] = clik.newPhoto({"id":6437972,"src":"blue_barn_pond2clik_thumb.jpg","galleries_id":219204,"server_id":15,"link":"photo_6437972.html","width":130,"caption":"","height":136});
															thumbnails[3782037] = clik.newPhoto({"id":3782037,"src":"Madd-rid_Cafe_sized_for_website_thumb.jpg","galleries_id":228773,"server_id":15,"link":"photo_3782037.html","width":130,"caption":"Cafe Madd rid","height":163});
															thumbnails[5635668] = clik.newPhoto({"id":5635668,"src":"Lady_Franklin_website_a_thumb.jpg","galleries_id":219204,"server_id":15,"link":"photo_5635668.html","width":130,"caption":"Lady Franklin","height":141});
															thumbnails[3778735] = clik.newPhoto({"id":3778735,"src":"Odessa_website_a_thumb.jpg","galleries_id":228773,"server_id":15,"link":"photo_3778735.html","width":130,"caption":"'Odessa'","height":144});
															thumbnails[4066954] = clik.newPhoto({"id":4066954,"src":"Franklin13webpic600_thumb.jpg","galleries_id":219204,"server_id":15,"link":"photo_4066954.html","width":130,"caption":"'Northwest Passage'","height":122});
															thumbnails[3787618] = clik.newPhoto({"id":3787618,"src":"At_Play_In_The_Fields_Of_A_Lesser_God_sized_for_website_thumb.jpg","galleries_id":228773,"server_id":15,"link":"photo_3787618.html","width":130,"caption":"'At Play In The Fields Of A Lesser God'","height":160});
															thumbnails[3800314] = clik.newPhoto({"id":3800314,"src":"The_Last_Best_Year2_sized_for_website_thumb.jpg","galleries_id":228773,"server_id":15,"link":"photo_3800314.html","width":130,"caption":"The Last Best Year","height":160});
															thumbnails[3776805] = clik.newPhoto({"id":3776805,"src":"Figure_E-14_website_a_thumb.jpg","galleries_id":228773,"server_id":15,"link":"photo_3776805.html","width":130,"caption":"'Figure E - 14'","height":167});
															thumbnails[3751903] = clik.newPhoto({"id":3751903,"src":"Figure_E-11_website_a_thumb.jpg","galleries_id":228773,"server_id":15,"link":"photo_3751903.html","width":130,"caption":"'Figure E-11'","height":167});
															thumbnails[3774134] = clik.newPhoto({"id":3774134,"src":"Figure_C_-_12_website_a_thumb.jpg","galleries_id":228773,"server_id":15,"link":"photo_3774134.html","width":130,"caption":"'Figure C - 12'","height":168});
															thumbnails[3781523] = clik.newPhoto({"id":3781523,"src":"figure_E-16_website_a_thumb.jpg","galleries_id":228773,"server_id":15,"link":"photo_3781523.html","width":130,"caption":"'Figure E-16'","height":166});
															thumbnails[3787651] = clik.newPhoto({"id":3787651,"src":"Figure_E_25_website_a_thumb.jpg","galleries_id":228773,"server_id":15,"link":"photo_3787651.html","width":130,"caption":"'Figure E 25'","height":168});
															thumbnails[3787686] = clik.newPhoto({"id":3787686,"src":"Figure_E_20_website_a_thumb.jpg","galleries_id":228773,"server_id":15,"link":"photo_3787686.html","width":130,"caption":"'Figure E 20'","height":167});
															thumbnails[3783714] = clik.newPhoto({"id":3783714,"src":"IMG005_website_a_thumb.jpg","galleries_id":228773,"server_id":15,"link":"photo_3783714.html","width":130,"caption":"'Figure L 5'","height":166});
															thumbnails[3795730] = clik.newPhoto({"id":3795730,"src":"IMG008_website_a_thumb.jpg","galleries_id":228773,"server_id":15,"link":"photo_3795730.html","width":130,"caption":"","height":167});
															thumbnails[3795768] = clik.newPhoto({"id":3795768,"src":"IMG009_website_a_thumb.jpg","galleries_id":228773,"server_id":15,"link":"photo_3795768.html","width":130,"caption":"","height":168});
															thumbnails[3795784] = clik.newPhoto({"id":3795784,"src":"IMG012_website_a_thumb.jpg","galleries_id":228773,"server_id":15,"link":"photo_3795784.html","width":130,"caption":"","height":163});
															thumbnails[3795780] = clik.newPhoto({"id":3795780,"src":"IMG011_website_a_thumb.jpg","galleries_id":228773,"server_id":15,"link":"photo_3795780.html","width":130,"caption":"","height":278});
															thumbnails[3795786] = clik.newPhoto({"id":3795786,"src":"IMG013_website_a_thumb.jpg","galleries_id":228773,"server_id":15,"link":"photo_3795786.html","width":130,"caption":"","height":162});
															thumbnails[3795795] = clik.newPhoto({"id":3795795,"src":"IMG014_website_a_thumb.jpg","galleries_id":228773,"server_id":15,"link":"photo_3795795.html","width":130,"caption":"","height":156});
															thumbnails[3781576] = clik.newPhoto({"id":3781576,"src":"figure_D_15_website_a_thumb.jpg","galleries_id":228773,"server_id":15,"link":"photo_3781576.html","width":130,"caption":"'Figure D 15'","height":162});
															thumbnails[3781992] = clik.newPhoto({"id":3781992,"src":"figure_d_D12_website_a_thumb.jpg","galleries_id":228773,"server_id":15,"link":"photo_3781992.html","width":130,"caption":"'Figure D 12'","height":161});
															thumbnails[3781999] = clik.newPhoto({"id":3781999,"src":"figure_D_8_website_a_thumb.jpg","galleries_id":228773,"server_id":15,"link":"photo_3781999.html","width":130,"caption":"'Figure D 8'","height":166});
															thumbnails[3793489] = clik.newPhoto({"id":3793489,"src":"P-town_8_website_a_thumb.jpg","galleries_id":228773,"server_id":15,"link":"photo_3793489.html","width":130,"caption":"'P-town 8'","height":161});
															thumbnails[3800320] = clik.newPhoto({"id":3800320,"src":"P-town_5_website_a_thumb.jpg","galleries_id":228773,"server_id":15,"link":"photo_3800320.html","width":130,"caption":"'P-town 10'","height":162});
															thumbnails[3801447] = clik.newPhoto({"id":3801447,"src":"SLIDE-5-300_website_a_thumb.jpg","galleries_id":228773,"server_id":15,"link":"photo_3801447.html","width":130,"caption":"'P-town 11'","height":161});
															thumbnails[3752899] = clik.newPhoto({"id":3752899,"src":"Swim_1_website_a_thumb.jpg","galleries_id":228773,"server_id":15,"link":"photo_3752899.html","width":130,"caption":"'At Swim - 1'","height":156});
															thumbnails[3764616] = clik.newPhoto({"id":3764616,"src":"swim_4_website_a_thumb.jpg","galleries_id":228773,"server_id":15,"link":"photo_3764616.html","width":130,"caption":"'At Swim - 4'","height":151});
															thumbnails[3787635] = clik.newPhoto({"id":3787635,"src":"At_Swim_4_website_a_thumb.jpg","galleries_id":228773,"server_id":15,"link":"photo_3787635.html","width":130,"caption":"'At Swim 5'","height":156});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  						galleries[219204] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Paintings - selected recent work","link":"gallery_219204.html","maxRecords":0.0,"photoIDs":[8940853.0,8910779.0,8910775.0,8777420.0,8754511.0,8654532.0,8546678.0,8741098.0,8546673.0,8738729.0,8546672.0,8546664.0,8060280.0,8060273.0,8060203.0,7230576.0,6133522.0,5878240.0,6437956.0,5878091.0,5878046.0,6437972.0,5635668.0,4066954.0],"skipIndex":0,"section_code":"gallery","featured_images":8910779.0,"id":219204,"singleSection":false});				  						galleries[228773] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Archive of Selected Older Work","link":"gallery_228773.html","maxRecords":0.0,"photoIDs":[3930870.0,3787709.0,3794894.0,3794907.0,3769509.0,3769498.0,3778789.0,3757220.0,3782037.0,3778735.0,3787618.0,3800314.0,3776805.0,3751903.0,3774134.0,3781523.0,3787651.0,3787686.0,3783714.0,3795730.0,3795768.0,3795784.0,3795780.0,3795786.0,3795795.0,3781576.0,3781992.0,3781999.0,3793489.0,3800320.0,3801447.0,3752899.0,3764616.0,3787635.0],"skipIndex":0,"section_code":"gallery","featured_images":3752899.0,"id":228773,"singleSection":false});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[1] = '8940853';
imageSets[2] = '8910779,3752899';
imageSets[3] = '8940853,8910779,8910775,8777420,8754511,8741098,8738729,8654532,8546678,8546673,8546672,8546664,8060280,8060273,8060203,7230576,6437972,6437956,6133522,5878240,5878091,5878046,5635668,4066954,3930870,3801447,3800320,3800314,3795795,3795786,3795784,3795780,3795768,3795730,3794907,3794894,3793489,3787709,3787686,3787651,3787635,3787618,3783714,3782037,3781999,3781992,3781576,3781523,3778789,3778735';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 51:
		val = 'http://www12.clikpic.com/alistairjmacrae/images';
		break;
	}
		switch (server_id) {
		case 0:
		val = 'http://www.clikpic.com/alistairjmacrae/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/alistairjmacrae/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/alistairjmacrae/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/alistairjmacrae/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/alistairjmacrae/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/alistairjmacrae/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/alistairjmacrae/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/alistairjmacrae/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/alistairjmacrae/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/alistairjmacrae/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/alistairjmacrae/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/alistairjmacrae/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/alistairjmacrae/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/alistairjmacrae/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/alistairjmacrae/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/alistairjmacrae/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/alistairjmacrae/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/alistairjmacrae/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/alistairjmacrae/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/alistairjmacrae/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/alistairjmacrae/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/alistairjmacrae/images';
		break;
	}
		switch (server_id) {
		case 53:
		val = 'http://images.clikpic.com/alistairjmacrae/images';
		break;
	}
		switch (server_id) {
		case 52:
		val = 'http://tpc22/clikpic/alistairjmacrae/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/alistairjmacrae/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/alistairjmacrae/images';
		break;
	}
		return val;
}

/***************************************************************************
* img = reference to image object in which to show image                   *
***************************************************************************/
function showHomeImage(img) {
	imageID = randomListVal('');
	if (!basic) {
		img.src = photos[imageID].src;
		img.width = photos[imageID].width;
		img.height = photos[imageID].height;
		img.parentNode.title = img.alt = photos[imageID].caption;
	} else {
		newImage = new Image(photos[imageID].width,photos[imageID].height);
		newImage.src = photos[imageID].src;
		document.images[img.name] = newImage;
		
	}
}

function getHomeImageLink(imageID) {
  	var href='', photo = (backgrounds || photos || {})[imageID];
	if(photo){
		if (photo && photo.galleries_id != '') {
  			href = photo.fnGalleryLink();
  		}
  		  		else {
  				href += 'gallery.html';
  	  		}
	}
    return href;
}

/***************************************************************************
* Show a random image on home page from featured images                    *
***************************************************************************/
function showHomeImageInline(el, image_sets_id, href) {
	
	var css = {}, imageID,
	    imageSetsId = 1;
	if(image_sets_id){
		imageSetsId = image_sets_id;
	}
	imageID = randomListVal(imageSets[imageSetsId]);
	if (href == null && 'gallery' != '') {
					href = getHomeImageLink(imageID);
	}
	
	updateImage({nextPhoto: backgrounds[imageID], img:el.find('img')[0],
                $photo:el, $title:$('#homeimageTitleContainer'), $detail:$('#homeimageDetailsContainer'),                speed:0, href:href, css:css, onAfter: function(){                  this.closest('.contentsection').doManualAlign({				    inner: 'img',				    crop: 'a'				  });                }              });
}

/***************************************************************************
* Set 'img' to be a new image given its photo() object                     *
***************************************************************************/
function updateImage (options) {
	var defaults = {nextPhoto:'',field:'',img:'',$photo:'',$title:'',$detail:'',$detailContainer:'',
                    updateDocumentTitle:false,speed:0,href:false,css:false,updateHash:false,onAfter:null,onBefore:null},
		op = $.extend({},defaults,options),
		html = '', temp = '',
		photoId = op.nextPhoto.id,
		photoCaption = ''+op.nextPhoto.caption,
		photoSrc = op.nextPhoto.src;
	
	if (op.updateHash && clik.getIDInUrl(location.href,'photo') != op.nextPhoto.id) {
		clik.changeHash('photos_id=' + op.nextPhoto.id, true);
	}
		
	    if (op.$title.length > 0) {
  		op.$title.fadeGalleryDetails(photoCaption, op.speed);
    }
        if (op.updateDocumentTitle) {
						  document.title = 'Alistair MacRae: ' + photoCaption;
			    }
        if (op.$detail.length > 0) {
      	temp = op.nextPhoto.fnGetImageDetails();
	    op.$detail.fadeGalleryDetails(temp, op.speed, function(){
			if (typeof(backgrounds) != 'undefined' && op.nextPhoto == backgrounds[op.nextPhoto.id]) {
				toggleAddToCartConfirm(backgrounds, op.$detail);
			} else if (typeof(photos) != 'undefined' && op.nextPhoto == photos[op.nextPhoto.id]) {
				toggleAddToCartConfirm(photos, op.$detail);
			}
			$('body').trigger('clikUpdate.popup');
	    });
    }
        $(op.$detailContainer).find('.replaceable[class*=replaceable_photo-]').each(function(){
    	var field = clik.getPrefixedClass(this.className, 'replaceable_photo-');
    	if (field in op.nextPhoto) {
    		$(this).fadeGalleryDetails(op.nextPhoto[field], op.speed);
    	}
    }).end().find('.replaceable.photoPayment').fadeGalleryDetails(op.nextPhoto.fnGetPaymentInfo(), op.speed, function(){
		if (typeof(backgrounds) != 'undefined' && op.nextPhoto == backgrounds[op.nextPhoto.id]) {
			toggleAddToCartConfirm(backgrounds, op.$detailContainer);
		} else if (typeof(photos) != 'undefined' && op.nextPhoto == photos[op.nextPhoto.id]) {
			toggleAddToCartConfirm(photos, op.$detailContainer);
		}
		$('body').trigger('clikUpdate.popup');
	});
		if (op.$photo.length > 0) {
		html = $('<img/>',{
			'class': 'mainphoto photo',
			src: photoSrc,
			id: 'mainPic',
			name: 'mainPic',
			width: op.nextPhoto.width,
			height: op.nextPhoto.height,
			alt: photoCaption,
			css: op.css || {}
		});
		if (op.href) {
			if (op.href.match(/<a/)) {
				html = $(op.href).append(html);
			} else {
				html = $('<a/>', {
					href: op.href,
					title: photoCaption
				}).append(html);
			}
		} else {
			html = $('<a/>', {
				title: photoCaption
			}).append(html);
		}
		if (op.speed == 0) {			op.$photo.html(html);			if (op.onBefore) {			  	op.onBefore.apply(op.$photo);			}			if (op.onAfter) {			  	op.onAfter.apply(op.$photo);			}		} else {			op.$photo.stop(true,true).fadeReplaceWith(html,op.speed,'',function(){  				if (op.onAfter) {				  	op.onAfter.apply(this);				}				clik.doColumnResize(false, $(this).add(op.$detail).add(op.$title));			}, op.onBefore);
		}	}
    if (op.field) {
		op.field.value = photoId;
	} else {
		op.$photo.data('image_id', photoId);
    }
        if (!op.speed) {
      	clik.doColumnResize(false, op.$photo.add(op.$detail).add(op.$title));
    }
        
    return html;
	}

/***************************************************************************
* Toggle add to cart confirmation element and set up the click event for   *
* the 'Add to cart' button.                                                *
***************************************************************************/
function toggleAddToCartConfirm(array, root){
	if (typeof(array) !== 'object' || array === null) {
	  	array = photos;
	}
	if (!$(root).length) {		root = $('body');	}	if($('#paymentConfirm', root).length > 0){
		$('#paymentConfirm', root).hide();
		$('#paymentAddButton', root)
		.unbind()
		.click(function(){
						form = $('#paymentForm', root)[0];
			option_id = 0;
			if(form.item_option.value){
				option_id = form.item_option.value;
			}
			if(addItemToBasket(form.item_number.value,array,form.site.value,parseInt(form.quantity.value, 10),option_id)){
				if($.browser.msie){$('#paymentConfirm', root).text('Item added to cart').show();}
				else{
					$('#paymentConfirm', root).text('Item added to cart').fadeIn();
					dspOrderDetails(form.site.value);
				}
			}
			else{
				$('#paymentConfirm', root).text('Item not added - check cookies are enabled in your browser.').fadeIn();
			}
		});
	}
}

/***************************************************************************
* Get payment info for image - add as 'method' to photo object             *
***************************************************************************/
clik.photo.fnGetImageDetails = function(){
	var temp = '';
	if (this.description != '') {
		temp +=  '<div id="imageDescription">' + this.description + '</div>';
	}
		if (this.photo_ref != '') {
		temp += '<div class="imageinfo" id="imageRef"><strong>Ref: </strong>' + this.photo_ref + '</div>';
	}
		if (this.takendate != '') {
		
		temp += '<div class="imageinfo" id="imageDate"><strong>Date: </strong>' + this.takendate + '</div>';
	}
	
	if (this.location != '') {
		
		temp += '<div class="imageinfo" id="imageLocation"><strong>Location: </strong>' +  this.location + '</div>';
	}
	
	if (this.photographer != '') {
		
		temp += '<div class="imageinfo" id="imagePhotographer"><strong>Photographer: </strong>' + this.photographer + '</div>';
	}
				
				if (temp != '') {
		temp += '<div class="spacer"></div>';
	}
	return temp;
};

/***************************************************************************
* Get payment info for image - add as 'method' to photo object             *
***************************************************************************/
clik.photo.fnGetPaymentInfo = function(){
	var temp = '';
	if (this.item_price !== '') {
				temp += '<p>Order this print:</p>';
				temp += '<div class="imageinfo" id="imagePrice"><strong>' + this.purchase_instruction + '</strong> ' + (this.item_price).toFixed(2) + '</div>';
		var item_name  = this.purchase_instruction;
		var amount = (this.item_price).toFixed(2);
		var item_option  = 0;
	}
		else {
		
	}
	if (this.item_price !== '') {
			temp += '<div class="clearing">&nbsp;</div>';
	}
	return temp;};

/***************************************************************************
* Pick a photo at random from the featured images of a gallery.            *
* Gallery_id = id of gallery to choose,                                    *
* img = reference to html image in                                         *
* which to show image                                                      *
***************************************************************************/
function showGalleryImage(gallery_id, img, updateLink) {
	
	if(img){
		if (location.hash.match('galleries_id=' + gallery_id) && (imageID = location.hash.match('.*photos_id=(.+)$'))) {
		  	imageID = imageID[1];
		} else {
		  	imageID = randomListVal(galleries[gallery_id].featured_images);
		}
		
		if (imageID != 0) {
			img.src = thumbnails[imageID].src;
			img.width = thumbnails[imageID].width;
			img.height = thumbnails[imageID].height;
			img.alt = galleries[gallery_id].title;
			if (updateLink) {
				$(img).parent().attr({					title: galleries[gallery_id].title				}).filter(function(){return this.href;}).attr({					href: thumbnails[imageID].fnGalleryLink(gallery_id)				});
			}
		}
	}
}

/***************************************************************************
* If we have dynamic HTML, replace the galleries link with a list that     *
* doesn't include thecurrent gallery                                       *
***************************************************************************/
function showGalleries(gallery_id) {
		
	
	if (!basic) {
		temp = '';
		for (i = 0; i < galleries.length; i++) {
						
			
			if (galleries[i].id != gallery_id) {
								
				if (temp != '') {
					temp += ' | ';
				}
								temp += '<a href="' + galleries[i].section_code + '_' + galleries[i].id + '.html">' + galleries[i].title + '</a>';
							}
		}
		document.all.galleryLinks.innerHTML = 'Other galleries: ' + temp;
	}
}

			

