window.thumbnails = {};
thumbnails[8739031] = clik.newPhoto({"link":"photo_8739031.html","caption":"Skipping Girls","height":130,"id":8739031,"server_id":31,"src":"skipping_girls1_thumb.jpg","galleries_id":460493,"width":130});
thumbnails[8765596] = clik.newPhoto({"link":"photo_8765596.html","caption":"Beach Hut at Wells, Norfolk","height":130,"id":8765596,"server_id":31,"src":"wells_beach_hut5_thumb.jpg","galleries_id":449284,"width":130});
thumbnails[8774898] = clik.newPhoto({"link":"photo_8774898.html","caption":"3 Handmade Cards","height":130,"id":8774898,"server_id":31,"src":"3_cards_a_thumb.jpg","galleries_id":460545,"width":130});
thumbnails[8862200] = clik.newPhoto({"link":"photo_8862200.html","caption":"Lady Smelling Flowers","height":130,"id":8862200,"server_id":31,"src":"lady_smelling_flowers_thumb.jpg","galleries_id":466000,"width":130});
thumbnails[8891131] = clik.newPhoto({"link":"photo_8891131.html","caption":"Acer. Canvas Print","height":130,"id":8891131,"server_id":31,"src":"acer_thumb.jpg","galleries_id":452994,"width":130});
thumbnails[8765594] = clik.newPhoto({"link":"photo_8765594.html","caption":"Elm Hill, Norwich","height":130,"id":8765594,"server_id":31,"src":"elm_hill_C165B231-1E4F-37DC-71D087CCB23E1B85_thumb.jpg","galleries_id":449284,"width":130});
thumbnails[8774899] = clik.newPhoto({"link":"photo_8774899.html","caption":"3 Handmade Cards","height":130,"id":8774899,"server_id":31,"src":"3_cards_b_thumb.jpg","galleries_id":460545,"width":130});
thumbnails[8891167] = clik.newPhoto({"link":"photo_8891167.html","caption":"Clematis. Canvas Print","height":130,"id":8891167,"server_id":31,"src":"clematis_thumb.jpg","galleries_id":452994,"width":130});
thumbnails[8765601] = clik.newPhoto({"link":"photo_8765601.html","caption":"V.E. Street Party","height":130,"id":8765601,"server_id":31,"src":"ve_street_party_C1699FA9-1E4F-37DC-71EDA4C983B5F252_thumb.jpg","galleries_id":449284,"width":130});
thumbnails[8774901] = clik.newPhoto({"link":"photo_8774901.html","caption":"3 Handmade Cards","height":130,"id":8774901,"server_id":31,"src":"3_cards_c_thumb.jpg","galleries_id":460545,"width":130});
thumbnails[8891182] = clik.newPhoto({"link":"photo_8891182.html","caption":"Rosa Felicite Parmentier. Canvas Print","height":130,"id":8891182,"server_id":31,"src":"rosa_felicite_parmentier_thumb.jpg","galleries_id":452994,"width":130});
thumbnails[8765605] = clik.newPhoto({"link":"photo_8765605.html","caption":"Jack Russell Play Time","height":130,"id":8765605,"server_id":31,"src":"jack_russells_C16D386A-1E4F-37DC-7175B7615B687667_thumb.jpg","galleries_id":449284,"width":130});
thumbnails[8774902] = clik.newPhoto({"link":"photo_8774902.html","caption":"3 Handmade Cards","height":130,"id":8774902,"server_id":31,"src":"3_cards_d_thumb.jpg","galleries_id":460545,"width":130});
thumbnails[8891190] = clik.newPhoto({"link":"photo_8891190.html","caption":"Californian Poppy. Canvas Print","height":130,"id":8891190,"server_id":31,"src":"californian_poppy_thumb.jpg","galleries_id":452994,"width":130});
thumbnails[8765591] = clik.newPhoto({"link":"photo_8765591.html","caption":"Lambeth Walk","height":130,"id":8765591,"server_id":31,"src":"lambeth_walk_C170E508-1E4F-37DC-716A57315976F079_thumb.jpg","galleries_id":449284,"width":130});
thumbnails[8774905] = clik.newPhoto({"link":"photo_8774905.html","caption":"3 Handmade Cards","height":130,"id":8774905,"server_id":31,"src":"3_cards_e_thumb.jpg","galleries_id":460545,"width":130});
thumbnails[8765604] = clik.newPhoto({"link":"photo_8765604.html","caption":"Beach Huts","height":130,"id":8765604,"server_id":31,"src":"beach_huts_C173EC6B-1E4F-37DC-712537615F1B2AD3_thumb.jpg","galleries_id":449284,"width":130});
thumbnails[8774950] = clik.newPhoto({"link":"photo_8774950.html","caption":"5 Handmade Cards","height":130,"id":8774950,"server_id":31,"src":"5_cards_a_thumb.jpg","galleries_id":460545,"width":130});
thumbnails[8774955] = clik.newPhoto({"link":"photo_8774955.html","caption":"5 Handmade Cards","height":130,"id":8774955,"server_id":31,"src":"5_cards_b_thumb.jpg","galleries_id":460545,"width":130});
thumbnails[8992979] = clik.newPhoto({"link":"photo_8992979.html","caption":"The Feathers Pub in 1938","height":130,"id":8992979,"server_id":31,"src":"the_feathers_pub_lambeth_1938_thumb.jpg","galleries_id":449284,"width":130});
thumbnails[8774963] = clik.newPhoto({"link":"photo_8774963.html","caption":"5 Handmade Cards","height":130,"id":8774963,"server_id":31,"src":"5_cards_c1_thumb.jpg","galleries_id":460545,"width":130});
thumbnails[8774967] = clik.newPhoto({"link":"photo_8774967.html","caption":"5 Handmade Cards","height":130,"id":8774967,"server_id":31,"src":"5_cards_d_thumb.jpg","galleries_id":460545,"width":130});
thumbnails[8502212] = clik.newPhoto({"link":"photo_8502212.html","caption":"Carousel Horse","height":130,"id":8502212,"server_id":31,"src":"carousel_horse_C11DE4FD-1E4F-37DC-71BF6A6998ADD5A1_thumb.jpg","galleries_id":449283,"width":130});
thumbnails[8570194] = clik.newPhoto({"link":"photo_8570194.html","caption":"Swan Lake. A2 Poster","height":130,"id":8570194,"server_id":31,"src":"swan_lake_C274B278-1EC9-D45B-1C01046247DC1A22_thumb.jpg","galleries_id":452994,"width":130});
thumbnails[8570662] = clik.newPhoto({"link":"photo_8570662.html","caption":"Roundel","height":130,"id":8570662,"server_id":31,"src":"stained_glass_roundel_a_C2597317-1EC9-D45B-1C73394B0700C01B_thumb.jpg","galleries_id":449393,"width":130});
thumbnails[8570778] = clik.newPhoto({"link":"photo_8570778.html","caption":"Oliver","height":130,"id":8570778,"server_id":31,"src":"oliver_C1257A08-1E4F-37DC-7109BEF50FAFF05A_thumb.jpg","galleries_id":449394,"width":130});
thumbnails[8739847] = clik.newPhoto({"link":"photo_8739847.html","caption":"Green Man","height":130,"id":8739847,"server_id":31,"src":"green_man_A1C8B6ED-1EC9-D45B-1C0232FB79AA1FB2_thumb.jpg","galleries_id":449394,"width":130});
thumbnails[8570202] = clik.newPhoto({"link":"photo_8570202.html","caption":"Philemon Cochet A2 Poster","height":130,"id":8570202,"server_id":31,"src":"souv_de_philemon_cochet_C2778CAD-1EC9-D45B-1C84F9FB6CFA6007_thumb.jpg","galleries_id":452994,"width":130});
thumbnails[8570671] = clik.newPhoto({"link":"photo_8570671.html","caption":"Lillies","height":130,"id":8570671,"server_id":31,"src":"stained_glass_lillies_C25D3722-1EC9-D45B-1CD09863C35C68D9_thumb.jpg","galleries_id":449393,"width":130});
thumbnails[8570785] = clik.newPhoto({"link":"photo_8570785.html","caption":"Rosie","height":130,"id":8570785,"server_id":31,"src":"rosie_1_C12DAB38-1E4F-37DC-71F8C6C2F8700C73_thumb.jpg","galleries_id":449394,"width":130});
thumbnails[8759611] = clik.newPhoto({"link":"photo_8759611.html","caption":"Peter Beales","height":130,"id":8759611,"server_id":31,"src":"man_of_roses_thumb.jpg","galleries_id":449394,"width":130});
thumbnails[9051895] = clik.newPhoto({"link":"photo_9051895.html","caption":"Lewis","height":130,"id":9051895,"server_id":31,"src":"lewis_thumb.jpg","galleries_id":449394,"width":130});
thumbnails[8759955] = clik.newPhoto({"link":"photo_8759955.html","caption":"Lauren","height":130,"id":8759955,"server_id":31,"src":"lauren_3_thumb.jpg","galleries_id":449394,"width":130});
thumbnails[8759956] = clik.newPhoto({"link":"photo_8759956.html","caption":"Lauren (Close Up)","height":130,"id":8759956,"server_id":31,"src":"lauren_close_up_thumb.jpg","galleries_id":449394,"width":130});
thumbnails[8862023] = clik.newPhoto({"link":"photo_8862023.html","caption":"Matilda","height":130,"id":8862023,"server_id":31,"src":"matilda_thumb.jpg","galleries_id":449394,"width":130});
thumbnails[8862024] = clik.newPhoto({"link":"photo_8862024.html","caption":"Matilda (Close Up)","height":130,"id":8862024,"server_id":31,"src":"matilda_close_up_thumb.jpg","galleries_id":449394,"width":130});
thumbnails[8570689] = clik.newPhoto({"link":"photo_8570689.html","caption":"Norfolk","height":130,"id":8570689,"server_id":31,"src":"stained_glass_norfolk_count_C25FF917-1EC9-D45B-1CC5D9F1CEC1DFC9_thumb.jpg","galleries_id":449393,"width":130});
thumbnails[8570796] = clik.newPhoto({"link":"photo_8570796.html","caption":"Compassion A2 Poster","height":130,"id":8570796,"server_id":31,"src":"compassion_C27D59E3-1EC9-D45B-1C89138579AEC1D7_thumb.jpg","galleries_id":452994,"width":130});
thumbnails[8570214] = clik.newPhoto({"link":"photo_8570214.html","caption":"Baroness Rothschild A2 Poster","height":130,"id":8570214,"server_id":31,"src":"baroness_rothschild_C27AA551-1EC9-D45B-1CAD325C88CCFAE7_thumb.jpg","galleries_id":452994,"width":130});
thumbnails[8570631] = clik.newPhoto({"link":"photo_8570631.html","caption":"Blue Floral Squares. Poster","height":130,"id":8570631,"server_id":31,"src":"floral_squares_blue_C280899F-1EC9-D45B-1CDFA65EFA7ACB6C_thumb.jpg","galleries_id":452994,"width":130});
thumbnails[8570696] = clik.newPhoto({"link":"photo_8570696.html","caption":"Purple Curves","height":130,"id":8570696,"server_id":31,"src":"stained_glass_purple_curves_C264651F-1EC9-D45B-1C7A555FD9BA2AB6_thumb.jpg","galleries_id":449393,"width":130});
thumbnails[8570634] = clik.newPhoto({"link":"photo_8570634.html","caption":"Orange Floral Squares. Poster","height":130,"id":8570634,"server_id":31,"src":"floral_squares_orange_C282EE3B-1EC9-D45B-1C6074ED1ABF7759_thumb.jpg","galleries_id":452994,"width":130});
thumbnails[8570707] = clik.newPhoto({"link":"photo_8570707.html","caption":"Zig Zag","height":130,"id":8570707,"server_id":31,"src":"stained_glass_zigzag_C266D944-1EC9-D45B-1C3CE2779F20449A_thumb.jpg","galleries_id":449393,"width":130});
thumbnails[8570715] = clik.newPhoto({"link":"photo_8570715.html","caption":"Roses and Thornes","height":130,"id":8570715,"server_id":31,"src":"stained_glass_roses_and_tho_C2699391-1EC9-D45B-1CA98FAA87B3B717_thumb.jpg","galleries_id":449393,"width":130});
thumbnails[8570726] = clik.newPhoto({"link":"photo_8570726.html","caption":"Daisies","height":130,"id":8570726,"server_id":31,"src":"stained_glass_daisies_C26CD67B-1EC9-D45B-1CB3AB8AAB2CBE54_thumb.jpg","galleries_id":449393,"width":130});
thumbnails[8570740] = clik.newPhoto({"link":"photo_8570740.html","caption":"The Pink Window","height":130,"id":8570740,"server_id":31,"src":"stained_glass_the_pink_wind_C26F12B6-1EC9-D45B-1C5E58D3B9EF773C_thumb.jpg","galleries_id":449393,"width":130});
thumbnails[8570754] = clik.newPhoto({"link":"photo_8570754.html","caption":"Arches","height":130,"id":8570754,"server_id":31,"src":"stained_glass_arches_C27194EC-1EC9-D45B-1C70386A0508D645_thumb.jpg","galleries_id":449393,"width":130});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
galleries[449394] = clik.newGallery({"photoIDs":[8570778,8739847,8570785,8759611,9051895,8759955,8759956,8862023,8862024],"link":"gallery_449394.html","skipIndex":0,"section_code":"gallery","id":449394,"parentGallery":"","featured_images":"9051895,8862024,8862023,8759956,8759955,8759611,8739847,8570785,8570778","maxRecords":0,"usePopups":false,"singleSection":false,"title":"Modern Portraits by Julia"});galleries[449283] = clik.newGallery({"photoIDs":[8502212],"link":"gallery_449283.html","skipIndex":0,"section_code":"gallery","id":449283,"parentGallery":"","featured_images":8502212,"maxRecords":0,"usePopups":false,"singleSection":false,"title":"Paintings by Julia"});galleries[449393] = clik.newGallery({"photoIDs":[8570662,8570671,8570689,8570696,8570707,8570715,8570726,8570740,8570754],"link":"gallery_449393.html","skipIndex":0,"section_code":"gallery","id":449393,"parentGallery":"","featured_images":"8570754,8570740,8570726,8570715,8570707,8570696,8570689,8570671,8570662","maxRecords":0,"usePopups":false,"singleSection":false,"title":"Stained Glass"});galleries[449395] = clik.newGallery({"photoIDs":[],"link":"gallery_449395.html","skipIndex":0,"section_code":"gallery","id":449395,"parentGallery":"","featured_images":"","maxRecords":0,"usePopups":false,"singleSection":false,"title":"Light Catchers"});galleries[452994] = clik.newGallery({"photoIDs":[8891131,8891167,8891182,8891190,8570194,8570202,8570796,8570214,8570631,8570634],"link":"gallery_452994.html","skipIndex":0,"section_code":"gallery","id":452994,"parentGallery":"","featured_images":"8891190,8891182,8891167,8891131,8570796,8570634,8570631,8570214,8570202,8570194","maxRecords":0,"usePopups":false,"singleSection":false,"title":"Photographic Prints"});galleries[460545] = clik.newGallery({"photoIDs":[8774898,8774899,8774901,8774902,8774905,8774950,8774955,8774963,8774967],"link":"gallery_460545.html","skipIndex":0,"section_code":"gallery","id":460545,"parentGallery":"","featured_images":"8774967,8774963,8774955,8774950,8774905,8774902,8774901,8774899,8774898","maxRecords":0,"usePopups":false,"singleSection":false,"title":"Handmade Cards"});galleries[449284] = clik.newGallery({"photoIDs":[8765596,8765594,8765601,8765605,8765591,8765604,8992979],"link":"gallery_449284.html","skipIndex":0,"section_code":"gallery","id":449284,"parentGallery":"","featured_images":"8992979,8765605,8765604,8765601,8765596,8765594,8765591","maxRecords":0,"usePopups":false,"singleSection":false,"title":"Terry's Oils"});galleries[460493] = clik.newGallery({"photoIDs":[8739031],"link":"gallery_460493.html","skipIndex":0,"section_code":"gallery","id":460493,"parentGallery":"","featured_images":8739031,"maxRecords":0,"usePopups":false,"singleSection":false,"title":"Whirligigs"});galleries[466000] = clik.newGallery({"photoIDs":[8862200],"link":"gallery_466000.html","skipIndex":0,"section_code":"gallery","id":466000,"parentGallery":"","featured_images":8862200,"maxRecords":0,"usePopups":false,"singleSection":false,"title":"Screen Prints by Jess"});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[3] = '9051895,8992979,8891190,8891182,8891167,8891131,8862200,8862024,8862023,8774967,8774963,8774955,8774950,8774905,8774902,8774901,8774899,8774898,8765605,8765604,8765601,8765596,8765594,8765591,8759956,8759955,8759611,8739847,8739031,8570796,8570785,8570778,8570754,8570740,8570726,8570715,8570707,8570696,8570689,8570671,8570662,8570634,8570631,8570214,8570202,8570194,8502212';
imageSets[1] = '9051895,8992979,8891190,8891182,8891167,8891131,8862200,8862024,8862023,8774967,8774963,8774955,8774950,8774905,8774902,8774901,8774899,8774898,8765605,8765604,8765601,8765596,8765594,8765591,8759956,8759955,8759611,8739847,8739031,8570796,8570785,8570778,8570754,8570740,8570726,8570715,8570707,8570696,8570689,8570671,8570662,8570634,8570631,8570214,8570202,8570194,8502212';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/artandglass/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/artandglass/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/artandglass/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/artandglass/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/artandglass/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/artandglass/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/artandglass/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/artandglass/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/artandglass/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/artandglass/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/artandglass/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/artandglass/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/artandglass/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/artandglass/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/artandglass/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/artandglass/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/artandglass/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/artandglass/images';
		break;
	}
		switch (server_id) {
		case 0:
		val = 'http://www.clikpic.com/artandglass/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/artandglass/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/artandglass/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/artandglass/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/artandglass/images';
		break;
	}
		switch (server_id) {
		case 51:
		val = 'http://www12.clikpic.com/artandglass/images';
		break;
	}
		switch (server_id) {
		case 52:
		val = 'http://tpc22/clikpic/artandglass/images';
		break;
	}
		switch (server_id) {
		case 53:
		val = 'http://images.clikpic.com/artandglass/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/artandglass/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 = 'Art and Glass: ' + 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.item_price !== '') {
					temp += '<form id="paymentForm" style="margin:0px;border:0px;" name="paymentForm">';
			temp += '	<input type="hidden" name="item_option" value="' + item_option + '">';
			temp += '	<input type="hidden" name="site" value="ARTANDGLASS">';
			temp += '	<input type="hidden" name="item_number" value="'+ this.id +'">';
			temp += '	<input type="hidden" name="quantity" value="1">';
						temp += '	<input value="Add to cart" id="paymentAddButton" class="button" onmouseover="this.className=\'buttonHi\'\;" onmouseout="this.className=\'button\'\;" type="Button">';
							temp += '	<input value="View cart" id="paymentViewButton" class="button" onmouseover="this.className=\'buttonHi\';" onmouseout="this.className=\'button\';" type="Button" onclick="javascript:window.location=\'cart.html\'">';
			temp += '</form>';
						temp += '<div class="clearing">&nbsp;</div>';
			temp += '<div id="confirmContainer">';
			temp += '<div id="paymentConfirm">Item added to cart</div>';
			temp += '</div>';
			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;
	}
}

		

