window.thumbnails = {};
thumbnails[7371090] = clik.newPhoto({"link":"#","caption":"","height":173,"id":7371090,"server_id":31,"src":"CopperPatinabatBlkBack_thumb.jpg","galleries_id":"","width":130});
thumbnails[7372503] = clik.newPhoto({"link":"#","caption":"","height":193,"id":7372503,"server_id":31,"src":"ParchTEst4_thumb.jpg","galleries_id":"","width":130});
thumbnails[7398570] = clik.newPhoto({"link":"#","caption":"","height":175,"id":7398570,"server_id":31,"src":"Notecards-240_thumb.jpg","galleries_id":"","width":130});
thumbnails[7398857] = clik.newPhoto({"link":"#","caption":"","height":270,"id":7398857,"server_id":31,"src":"His_Story212_thumb.jpg","galleries_id":"","width":180});
thumbnails[7408445] = clik.newPhoto({"link":"#","caption":"","height":130,"id":7408445,"server_id":31,"src":"CleanCompass185cropped_thumb.jpg","galleries_id":"","width":130});
thumbnails[7408480] = clik.newPhoto({"link":"#","caption":"","height":132,"id":7408480,"server_id":31,"src":"hampton-court-palace-flowers-showT_thumb.jpg","galleries_id":"","width":130});
thumbnails[7408487] = clik.newPhoto({"link":"#","caption":"","height":28,"id":7408487,"server_id":31,"src":"BaincoNeroGalleryLogo_thumb.jpg","galleries_id":"","width":130});
thumbnails[7408490] = clik.newPhoto({"link":"#","caption":"","height":31,"id":7408490,"server_id":31,"src":"ansteylogo_thumb.jpg","galleries_id":"","width":130});
thumbnails[7408559] = clik.newPhoto({"link":"#","caption":"","height":86,"id":7408559,"server_id":31,"src":"Parchmap_thumb.jpg","galleries_id":"","width":130});
thumbnails[7532389] = clik.newPhoto({"link":"#","caption":"","height":590,"id":7532389,"server_id":31,"src":"Notecards-140wide_thumb.jpg","galleries_id":"","width":130});
thumbnails[7834510] = clik.newPhoto({"link":"#","caption":"","height":46,"id":7834510,"server_id":31,"src":"HorizontalNotecards_thumb.jpg","galleries_id":"","width":130});
thumbnails[7401020] = clik.newPhoto({"link":"#","caption":"Bats","height":173,"id":7401020,"server_id":31,"src":"batsnewgp_thumb.jpg","galleries_id":"","width":130});
thumbnails[8848025] = clik.newPhoto({"link":"photo_8848025.html","caption":"Rook with Butterfly, ","height":173,"id":8848025,"server_id":31,"src":"ButterflyRook300x400_thumb.jpg","galleries_id":422870,"width":130});
thumbnails[8848027] = clik.newPhoto({"link":"photo_8848027.html","caption":"Doug!","height":173,"id":8848027,"server_id":31,"src":"DougRook300x400_thumb.jpg","galleries_id":422870,"width":130});
thumbnails[8848028] = clik.newPhoto({"link":"photo_8848028.html","caption":"Doug! detail","height":173,"id":8848028,"server_id":31,"src":"ForkTopRook300x400_thumb.jpg","galleries_id":422870,"width":130});
thumbnails[8848030] = clik.newPhoto({"link":"photo_8848030.html","caption":"King of the Castle","height":173,"id":8848030,"server_id":31,"src":"King-of-the-CastleRook300x400_thumb.jpg","galleries_id":422870,"width":130});
thumbnails[8848031] = clik.newPhoto({"link":"photo_8848031.html","caption":"Let's Rook","height":173,"id":8848031,"server_id":31,"src":"Lets-RookRook300x400_thumb.jpg","galleries_id":422870,"width":130});
thumbnails[8848032] = clik.newPhoto({"link":"photo_8848032.html","caption":"Rook's Nest","height":167,"id":8848032,"server_id":31,"src":"NestRook300x400_thumb.jpg","galleries_id":422870,"width":130});
thumbnails[8848034] = clik.newPhoto({"link":"photo_8848034.html","caption":"After You","height":173,"id":8848034,"server_id":31,"src":"PoleRook300x400_thumb.jpg","galleries_id":422870,"width":130});
thumbnails[8848035] = clik.newPhoto({"link":"photo_8848035.html","caption":"Pot Broilers","height":173,"id":8848035,"server_id":31,"src":"Pot-BroilersRook300x400_thumb.jpg","galleries_id":422870,"width":130});
thumbnails[8848037] = clik.newPhoto({"link":"photo_8848037.html","caption":"Rook Climber","height":173,"id":8848037,"server_id":31,"src":"RookClimber300x400_thumb.jpg","galleries_id":422870,"width":130});
thumbnails[8848038] = clik.newPhoto({"link":"photo_8848038.html","caption":"Rook ","height":173,"id":8848038,"server_id":31,"src":"Rook-n-Roll-Rook300x400_thumb.jpg","galleries_id":422870,"width":130});
thumbnails[8848040] = clik.newPhoto({"link":"photo_8848040.html","caption":"Rook Sack","height":173,"id":8848040,"server_id":31,"src":"RookSackRook300x400_thumb.jpg","galleries_id":422870,"width":130});
thumbnails[8848044] = clik.newPhoto({"link":"photo_8848044.html","caption":"Tag, detail","height":173,"id":8848044,"server_id":31,"src":"TagRook300x400_thumb.jpg","galleries_id":422870,"width":130});
thumbnails[8848047] = clik.newPhoto({"link":"photo_8848047.html","caption":"After You, detail","height":173,"id":8848047,"server_id":31,"src":"UmbrellaRook300x400_thumb.jpg","galleries_id":422870,"width":130});
thumbnails[8848049] = clik.newPhoto({"link":"photo_8848049.html","caption":"Washing Broiler","height":173,"id":8848049,"server_id":31,"src":"Washing-BoilerRook300x400_thumb.jpg","galleries_id":422870,"width":130});
thumbnails[7372112] = clik.newPhoto({"link":"photo_7372112.html","caption":"Individual Bats","height":186,"id":7372112,"server_id":31,"src":"3batsnewgp400Hlores_thumb.jpg","galleries_id":400851,"width":130});
thumbnails[7401022] = clik.newPhoto({"link":"photo_7401022.html","caption":"LoveBats","height":173,"id":7401022,"server_id":31,"src":"CopperLoveBats2_thumb.jpg","galleries_id":400851,"width":130});
thumbnails[7372115] = clik.newPhoto({"link":"photo_7372115.html","caption":"Wyvern","height":186,"id":7372115,"server_id":31,"src":"Wyevern-greybackGuasBlur400_thumb.jpg","galleries_id":422868,"width":130});
thumbnails[7835363] = clik.newPhoto({"link":"photo_7835363.html","caption":"","height":87,"id":7835363,"server_id":31,"src":"toadth4_thumb.jpg","galleries_id":422871,"width":130});
thumbnails[7401034] = clik.newPhoto({"link":"photo_7401034.html","caption":"Raben Mutter","height":174,"id":7401034,"server_id":31,"src":"Rooknestingarden_thumb.jpg","galleries_id":422870,"width":130});
thumbnails[7401030] = clik.newPhoto({"link":"photo_7401030.html","caption":"Toad","height":242,"id":7401030,"server_id":31,"src":"LilytoadCropped90R_thumb.jpg","galleries_id":422871,"width":180});
thumbnails[7835366] = clik.newPhoto({"link":"photo_7835366.html","caption":"","height":87,"id":7835366,"server_id":31,"src":"toadth3_thumb.jpg","galleries_id":422871,"width":130});
thumbnails[7401121] = clik.newPhoto({"link":"photo_7401121.html","caption":"Butterflies","height":136,"id":7401121,"server_id":31,"src":"Butterfly_thumb.jpg","galleries_id":422868,"width":130});
thumbnails[7372114] = clik.newPhoto({"link":"photo_7372114.html","caption":"Serpent","height":184,"id":7372114,"server_id":31,"src":"SerpentJonothon400Hlores_thumb.jpg","galleries_id":400851,"width":130});
thumbnails[7372113] = clik.newPhoto({"link":"photo_7372113.html","caption":"Chrysalis","height":185,"id":7372113,"server_id":31,"src":"Chrysalis400Hlores_thumb.jpg","galleries_id":400851,"width":130});
thumbnails[7371441] = clik.newPhoto({"link":"photo_7371441.html","caption":"","height":174,"id":7371441,"server_id":31,"src":"heron3onpad_thumb.jpg","galleries_id":400843,"width":130});
thumbnails[7400901] = clik.newPhoto({"link":"photo_7400901.html","caption":"","height":174,"id":7400901,"server_id":31,"src":"7HeronAinflightonrock_thumb.jpg","galleries_id":400843,"width":130});
thumbnails[7400913] = clik.newPhoto({"link":"photo_7400913.html","caption":"","height":174,"id":7400913,"server_id":31,"src":"7HeronB_thumb.jpg","galleries_id":400843,"width":130});
thumbnails[7400915] = clik.newPhoto({"link":"photo_7400915.html","caption":"","height":174,"id":7400915,"server_id":31,"src":"7HeronCBeak_thumb.jpg","galleries_id":400843,"width":130});
thumbnails[7400971] = clik.newPhoto({"link":"photo_7400971.html","caption":"","height":174,"id":7400971,"server_id":31,"src":"heron4silhoutte_thumb.jpg","galleries_id":400843,"width":130});
thumbnails[7400973] = clik.newPhoto({"link":"photo_7400973.html","caption":"","height":174,"id":7400973,"server_id":31,"src":"heron11w-hedge_thumb.jpg","galleries_id":400843,"width":130});
thumbnails[7400975] = clik.newPhoto({"link":"photo_7400975.html","caption":"","height":174,"id":7400975,"server_id":31,"src":"heronflightingrass2_thumb.jpg","galleries_id":400843,"width":130});
thumbnails[7400977] = clik.newPhoto({"link":"photo_7400977.html","caption":"","height":174,"id":7400977,"server_id":31,"src":"heronfront-hillinback_thumb.jpg","galleries_id":400843,"width":130});
thumbnails[7400981] = clik.newPhoto({"link":"photo_7400981.html","caption":"","height":174,"id":7400981,"server_id":31,"src":"heron-hillinback_thumb.jpg","galleries_id":400843,"width":130});
thumbnails[7400985] = clik.newPhoto({"link":"photo_7400985.html","caption":"","height":174,"id":7400985,"server_id":31,"src":"heron7_thumb.jpg","galleries_id":400843,"width":130});
thumbnails[7401166] = clik.newPhoto({"link":"photo_7401166.html","caption":"","height":172,"id":7401166,"server_id":31,"src":"ph1_thumb.jpg","galleries_id":400860,"width":130});
thumbnails[7401169] = clik.newPhoto({"link":"photo_7401169.html","caption":"","height":97,"id":7401169,"server_id":31,"src":"ph2_thumb.jpg","galleries_id":400860,"width":130});
thumbnails[7401173] = clik.newPhoto({"link":"photo_7401173.html","caption":"","height":195,"id":7401173,"server_id":31,"src":"ph3_thumb.jpg","galleries_id":400860,"width":130});
thumbnails[7401175] = clik.newPhoto({"link":"photo_7401175.html","caption":"","height":195,"id":7401175,"server_id":31,"src":"ph4_thumb.jpg","galleries_id":400860,"width":130});
thumbnails[7401177] = clik.newPhoto({"link":"photo_7401177.html","caption":"","height":195,"id":7401177,"server_id":31,"src":"ph5_thumb.jpg","galleries_id":400860,"width":130});
thumbnails[7401179] = clik.newPhoto({"link":"photo_7401179.html","caption":"","height":195,"id":7401179,"server_id":31,"src":"ph6_thumb.jpg","galleries_id":400860,"width":130});
thumbnails[7401198] = clik.newPhoto({"link":"photo_7401198.html","caption":"","height":173,"id":7401198,"server_id":31,"src":"duck3chainedrock_thumb.jpg","galleries_id":400859,"width":130});
thumbnails[7401214] = clik.newPhoto({"link":"photo_7401214.html","caption":"","height":174,"id":7401214,"server_id":31,"src":"dr7_thumb.jpg","galleries_id":400858,"width":130});
thumbnails[7401216] = clik.newPhoto({"link":"photo_7401216.html","caption":"","height":174,"id":7401216,"server_id":31,"src":"dr8_thumb.jpg","galleries_id":400858,"width":130});
thumbnails[7401217] = clik.newPhoto({"link":"photo_7401217.html","caption":"","height":174,"id":7401217,"server_id":31,"src":"dr9_thumb.jpg","galleries_id":400858,"width":130});
thumbnails[7401218] = clik.newPhoto({"link":"photo_7401218.html","caption":"","height":174,"id":7401218,"server_id":31,"src":"dr10_thumb.jpg","galleries_id":400858,"width":130});
thumbnails[7401219] = clik.newPhoto({"link":"photo_7401219.html","caption":"","height":174,"id":7401219,"server_id":31,"src":"dr11_thumb.jpg","galleries_id":400858,"width":130});
thumbnails[7401220] = clik.newPhoto({"link":"photo_7401220.html","caption":"","height":174,"id":7401220,"server_id":31,"src":"dr14_thumb.jpg","galleries_id":400858,"width":130});
thumbnails[7408738] = clik.newPhoto({"link":"photo_7408738.html","caption":"","height":195,"id":7408738,"server_id":31,"src":"Duck-TBPond_thumb.jpg","galleries_id":400859,"width":130});
thumbnails[7408739] = clik.newPhoto({"link":"photo_7408739.html","caption":"","height":173,"id":7408739,"server_id":31,"src":"orchth2_thumb.jpg","galleries_id":400859,"width":130});
thumbnails[7401194] = clik.newPhoto({"link":"photo_7401194.html","caption":"","height":174,"id":7401194,"server_id":31,"src":"Tree2_thumb.jpg","galleries_id":400861,"width":130});
thumbnails[7401192] = clik.newPhoto({"link":"photo_7401192.html","caption":"","height":97,"id":7401192,"server_id":31,"src":"Bensontree2th_thumb.jpg","galleries_id":400861,"width":130});
thumbnails[7401193] = clik.newPhoto({"link":"photo_7401193.html","caption":"","height":174,"id":7401193,"server_id":31,"src":"Tree1_thumb.jpg","galleries_id":400861,"width":130});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
galleries[400843] = clik.newGallery({"photoIDs":[7371441,7400901,7400913,7400915,7400971,7400973,7400975,7400977,7400981,7400985],"link":"section507043_400843.html","skipIndex":0,"section_code":"section507043","id":400843,"parentGallery":"","featured_images":7371441,"maxRecords":0,"usePopups":false,"singleSection":false,"title":"Herons"});galleries[400851] = clik.newGallery({"photoIDs":[7372112,7401022,7372114,7372113],"link":"gallery_400851.html","skipIndex":0,"section_code":"gallery","id":400851,"parentGallery":"","featured_images":"7401022,7372112","maxRecords":0,"usePopups":false,"singleSection":false,"title":"Readily Available"});galleries[422868] = clik.newGallery({"photoIDs":[7372115,7401121],"link":"gallery_422868.html","skipIndex":0,"section_code":"gallery","id":422868,"parentGallery":"","featured_images":"7401121,7372115","maxRecords":0,"usePopups":false,"singleSection":false,"title":"Infrequent Visitors"});galleries[400858] = clik.newGallery({"photoIDs":[7401214,7401216,7401217,7401218,7401219,7401220],"link":"section507043_400858.html","skipIndex":0,"section_code":"section507043","id":400858,"parentGallery":"","featured_images":7401220,"maxRecords":0,"usePopups":false,"singleSection":false,"title":"Welsh Dragon"});galleries[400860] = clik.newGallery({"photoIDs":[7401166,7401169,7401173,7401175,7401177,7401179],"link":"section507043_400860.html","skipIndex":0,"section_code":"section507043","id":400860,"parentGallery":"","featured_images":7401166,"maxRecords":0,"usePopups":false,"singleSection":false,"title":"Phoenix"});galleries[422870] = clik.newGallery({"photoIDs":[8848025,8848027,8848028,8848030,8848031,8848032,8848034,8848035,8848037,8848038,8848040,8848044,8848047,8848049,7401034],"link":"gallery_422870.html","skipIndex":0,"section_code":"gallery","id":422870,"parentGallery":"","featured_images":"8848049,8848047,8848044,8848040,8848038,8848037,8848035,8848034,8848032,8848031","maxRecords":0,"usePopups":false,"singleSection":false,"title":"Appearances by Request"});galleries[400859] = clik.newGallery({"photoIDs":[7401198,7408738,7408739],"link":"section507043_400859.html","skipIndex":0,"section_code":"section507043","id":400859,"parentGallery":"","featured_images":7401198,"maxRecords":0,"usePopups":false,"singleSection":false,"title":"Garden Dwellers"});galleries[422871] = clik.newGallery({"photoIDs":[7835363,7401030,7835366],"link":"gallery_422871.html","skipIndex":0,"section_code":"gallery","id":422871,"parentGallery":"","featured_images":7401030,"maxRecords":0,"usePopups":false,"singleSection":false,"title":"Extinct"});galleries[400861] = clik.newGallery({"photoIDs":[7401194,7401192,7401193],"link":"section507043_400861.html","skipIndex":0,"section_code":"section507043","id":400861,"parentGallery":"","featured_images":7401193,"maxRecords":0,"usePopups":false,"singleSection":false,"title":"Tree of Life"});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[3] = '7372503';
imageSets[2] = '7401220,7401198,7401166,7371441,7401193,7401022,7372112,7372115,7401030,7401121';
imageSets[1] = '7371441,7372112,7372115,7372114,7372113';
imageSets[239584] = '7398857';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/graculuswebsite/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/graculuswebsite/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/graculuswebsite/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/graculuswebsite/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/graculuswebsite/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/graculuswebsite/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/graculuswebsite/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/graculuswebsite/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/graculuswebsite/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/graculuswebsite/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/graculuswebsite/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/graculuswebsite/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/graculuswebsite/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/graculuswebsite/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/graculuswebsite/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/graculuswebsite/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/graculuswebsite/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/graculuswebsite/images';
		break;
	}
		switch (server_id) {
		case 0:
		val = 'http://www.clikpic.com/graculuswebsite/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/graculuswebsite/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/graculuswebsite/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/graculuswebsite/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/graculuswebsite/images';
		break;
	}
		switch (server_id) {
		case 51:
		val = 'http://www12.clikpic.com/graculuswebsite/images';
		break;
	}
		switch (server_id) {
		case 52:
		val = 'http://tpc22/clikpic/graculuswebsite/images';
		break;
	}
		switch (server_id) {
		case 53:
		val = 'http://images.clikpic.com/graculuswebsite/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/graculuswebsite/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 = 'Graculus Sculptures: ' + 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;
	}
}

		

