window.thumbnails = {};
thumbnails[7413919] = clik.newPhoto({"link":"#","caption":"","height":160,"id":7413919,"server_id":31,"src":"rob_profile_thumb.jpg","galleries_id":"","width":148});
thumbnails[7595399] = clik.newPhoto({"link":"#","caption":"Rear view","height":160,"id":7595399,"server_id":31,"src":"a._Rear_view_1_thumb.jpg","galleries_id":"","width":106});
thumbnails[7600007] = clik.newPhoto({"link":"#","caption":"In the very big river<br \/><br \/><br \/>","height":160,"id":7600007,"server_id":31,"src":"b1._In_a_very_big_river_1_thumb.jpg","galleries_id":"","width":106});
thumbnails[7600027] = clik.newPhoto({"link":"#","caption":"In the small river<br \/><br \/><br \/>","height":160,"id":7600027,"server_id":31,"src":"c._In_a_small_river_1_thumb.jpg","galleries_id":"","width":106});
thumbnails[7600028] = clik.newPhoto({"link":"#","caption":"In the very big river again<br \/><br \/><br \/>","height":106,"id":7600028,"server_id":31,"src":"d._In_a_very_big_river_again_thumb.jpg","galleries_id":"","width":160});
thumbnails[7600034] = clik.newPhoto({"link":"#","caption":"Final briefing from Wing Commander<br \/><br \/><br \/>","height":106,"id":7600034,"server_id":31,"src":"e._Final_briefing_from_Wing_Commander_thumb.jpg","galleries_id":"","width":160});
thumbnails[7600035] = clik.newPhoto({"link":"#","caption":"Water located and captured<br \/><br \/><br \/>","height":106,"id":7600035,"server_id":31,"src":"f._Water_located_and_captured_thumb.jpg","galleries_id":"","width":160});
thumbnails[7600037] = clik.newPhoto({"link":"#","caption":"Digging for victory<br \/><br \/><br \/>","height":106,"id":7600037,"server_id":31,"src":"g._Digging_for_victory_thumb.jpg","galleries_id":"","width":160});
thumbnails[7600039] = clik.newPhoto({"link":"#","caption":"Tired but happy. A challenging day<br \/><br \/><br \/>","height":106,"id":7600039,"server_id":31,"src":"h._Tired_but_happy._A_challenging_day_thumb.jpg","galleries_id":"","width":160});
thumbnails[7413619] = clik.newPhoto({"link":"photo_7413619.html","caption":"City of Arts and Sciences 1, Valencia","height":160,"id":7413619,"server_id":31,"src":"City_of_Arts_and_Sciences_1_Valencia_at_650_pix._vert_thumb.jpg","galleries_id":401494,"width":106});
thumbnails[7400814] = clik.newPhoto({"link":"photo_7400814.html","caption":"Olive tree, Calig","height":106,"id":7400814,"server_id":31,"src":"Olive_tree_Calig_1_2_thumb.jpg","galleries_id":401493,"width":160});
thumbnails[7400347] = clik.newPhoto({"link":"photo_7400347.html","caption":"Olive trees and grasses, Calig","height":107,"id":7400347,"server_id":31,"src":"Olive_trees_and_grasses_Calig_3_thumb.jpg","galleries_id":401493,"width":160});
thumbnails[7400329] = clik.newPhoto({"link":"photo_7400329.html","caption":"Grasses, Cap I Corp","height":106,"id":7400329,"server_id":31,"src":"Grasses_Cap_I_Corb_11_thumb.jpg","galleries_id":401493,"width":160});
thumbnails[7400658] = clik.newPhoto({"link":"photo_7400658.html","caption":"Grasses in late sunlight, Cap I Corp ","height":126,"id":7400658,"server_id":31,"src":"Grasses_in_late_sunlight_Cap_I_Corb_6_thumb.jpg","galleries_id":401493,"width":160});
thumbnails[7400834] = clik.newPhoto({"link":"photo_7400834.html","caption":"Reeds in winter sun, Woodbridge","height":106,"id":7400834,"server_id":31,"src":"Reeds_in_winter_sun_Woodbridge_-5_thumb.jpg","galleries_id":401493,"width":160});
thumbnails[7400246] = clik.newPhoto({"link":"photo_7400246.html","caption":"Plant in Sand, Alcossebre","height":107,"id":7400246,"server_id":31,"src":"Plant_in_sand_Alcossebre_1_thumb.jpg","galleries_id":401493,"width":160});
thumbnails[7400708] = clik.newPhoto({"link":"photo_7400708.html","caption":"Desert Forms 1","height":106,"id":7400708,"server_id":31,"src":"Desert_Forms_1_4_thumb.jpg","galleries_id":401495,"width":160});
thumbnails[7400764] = clik.newPhoto({"link":"photo_7400764.html","caption":"Desert Forms 2 ","height":106,"id":7400764,"server_id":31,"src":"Desert_Forms_2_1_thumb.jpg","galleries_id":401495,"width":160});
thumbnails[7402062] = clik.newPhoto({"link":"photo_7402062.html","caption":"Serviette","height":106,"id":7402062,"server_id":31,"src":"Serviette_Sevilla_Plus1_thumb.jpg","galleries_id":401496,"width":160});
thumbnails[8073616] = clik.newPhoto({"link":"photo_8073616.html","caption":"Shoreline Tryptich","height":68,"id":8073616,"server_id":31,"src":"Shoreline_Triptych_USED_for_website_MASTER_Feb_2011_-_Version_2_thumb.jpg","galleries_id":401475,"width":160});
thumbnails[8977786] = clik.newPhoto({"link":"photo_8977786.html","caption":"Carnaval 1","height":160,"id":8977786,"server_id":31,"src":"WEBSITE_2_adj_NEW_BEST_Jan_2012_new_version5_redblue_sat.blur_overall.Sharpen.29_BESTImage0032_-_Version_20_1_thumb.jpg","galleries_id":426583,"width":160});
thumbnails[8987426] = clik.newPhoto({"link":"photo_8987426.html","caption":"Rock Life 1. Supplicant","height":160,"id":8987426,"server_id":31,"src":"aRock_Life_1_USED_in_site_JAN_20122_thumb.jpg","galleries_id":401462,"width":160});
thumbnails[7403097] = clik.newPhoto({"link":"photo_7403097.html","caption":"Chalk Cliff 10, Cliftonville","height":106,"id":7403097,"server_id":31,"src":"Chalk_cliff_10_Cliftonville_new1_thumb.jpg","galleries_id":401496,"width":160});
thumbnails[9003052] = clik.newPhoto({"link":"photo_9003052.html","caption":"Shoreline Tryptich 1","height":160,"id":9003052,"server_id":31,"src":"y550_Jan_2012_Shoreline_Tryptich_1_REVISED_MASTER_SEPT_2011_-_Version_3_thumb.jpg","galleries_id":401475,"width":160});
thumbnails[7400211] = clik.newPhoto({"link":"photo_7400211.html","caption":"Chalk Cliff 11, Cliftonville","height":106,"id":7400211,"server_id":31,"src":"Chalk_cliff_11_Cliftonville_2_thumb.jpg","galleries_id":401496,"width":160});
thumbnails[8989922] = clik.newPhoto({"link":"photo_8989922.html","caption":"Shoreline Tryptich 2","height":160,"id":8989922,"server_id":31,"src":"last550_Jan_2012_Shoreline_Tryptich_2_REVISED_MASTER_SEPT_2011_-_Version_3_thumb.jpg","galleries_id":401475,"width":160});
thumbnails[8989979] = clik.newPhoto({"link":"photo_8989979.html","caption":"Shoreline Tryptich 3","height":160,"id":8989979,"server_id":31,"src":"last550_Jan_2012_Shoreline_Tryptich_3_REVISED_MASTER_SEPT_2011_1_thumb.jpg","galleries_id":401475,"width":160});
thumbnails[8990087] = clik.newPhoto({"link":"photo_8990087.html","caption":"Cool Fire","height":160,"id":8990087,"server_id":31,"src":"b550_Jan_2012_Rock_Mosaic_REVISED_MASTER_SEPT_2011_thumb.jpg","galleries_id":401475,"width":160});
thumbnails[8990158] = clik.newPhoto({"link":"photo_8990158.html","caption":"Crystal","height":160,"id":8990158,"server_id":31,"src":"a550_Jan_2012_REVISED_MASTER_SEPT_2011_NEW_BEST_MARCH_2011_2011__-_Version_3_thumb.jpg","galleries_id":401475,"width":160});
thumbnails[9003026] = clik.newPhoto({"link":"photo_9003026.html","caption":"Dune 1","height":160,"id":9003026,"server_id":31,"src":"x550_Jan_2012_Dune_1_REVISED_MASTER_SEPT_2011_1_thumb.jpg","galleries_id":401475,"width":160});
thumbnails[8996940] = clik.newPhoto({"link":"photo_8996940.html","caption":"Dune 2","height":160,"id":8996940,"server_id":31,"src":"final550_jan_2012_Dune_2_REVISED_MASTER_SEPT_Feb_2011_thumb.jpg","galleries_id":401475,"width":160});
thumbnails[8990383] = clik.newPhoto({"link":"photo_8990383.html","caption":"Dune 4","height":160,"id":8990383,"server_id":31,"src":"1.550_Jan_2012_Dune_4_REVISED_MASTER_SEPT_2011_thumb.jpg","galleries_id":401475,"width":160});
thumbnails[8071114] = clik.newPhoto({"link":"photo_8071114.html","caption":"Ice Glow 1","height":106,"id":8071114,"server_id":31,"src":"Ice_Glow_1_MASTER_USED_for_website_-_Version_2_thumb.jpg","galleries_id":401467,"width":160});
thumbnails[8973542] = clik.newPhoto({"link":"photo_8973542.html","caption":"Carnaval 2 ","height":160,"id":8973542,"server_id":31,"src":"550_Carnaval_2_3_Image0031_-_Version_21_thumb.jpg","galleries_id":426583,"width":160});
thumbnails[8987418] = clik.newPhoto({"link":"photo_8987418.html","caption":"Rock Life 2. Sprite","height":160,"id":8987418,"server_id":31,"src":"bRock_Life_2_USED_in_site_MASTER_550__Green_Jan_2012_-_Version_2_6_thumb.jpg","galleries_id":401462,"width":160});
thumbnails[8071855] = clik.newPhoto({"link":"photo_8071855.html","caption":"Ice glow 2","height":106,"id":8071855,"server_id":31,"src":"Ice_Glow_2_MASTER_-_Version_2_1_thumb.jpg","galleries_id":401467,"width":160});
thumbnails[8072205] = clik.newPhoto({"link":"photo_8072205.html","caption":"Ice Glow 3","height":106,"id":8072205,"server_id":31,"src":"Ice_Glow_3_USED_in_website_MASTER_-_Version_2_11_thumb.jpg","galleries_id":401467,"width":160});
thumbnails[9174753] = clik.newPhoto({"link":"photo_9174753.html","caption":"Carnaval 3","height":160,"id":9174753,"server_id":31,"src":"7.BEST_SO_FAR_ADJ_For_Website-_Version_13_thumb.jpg","galleries_id":426583,"width":160});
thumbnails[8972834] = clik.newPhoto({"link":"photo_8972834.html","caption":"Blue","height":120,"id":8972834,"server_id":31,"src":"WEBSITE_Version_.50_sharpen_BEST_Image0521_-_Version_8_1_thumb.jpg","galleries_id":426583,"width":160});
thumbnails[8984830] = clik.newPhoto({"link":"photo_8984830.html","caption":"Rock Life 3. Grotesques","height":160,"id":8984830,"server_id":31,"src":"fRock_Life_3_Used_in_site_MASTER_Feb_2011_-_Version_2_1_thumb.jpg","galleries_id":401462,"width":160});
thumbnails[7413634] = clik.newPhoto({"link":"photo_7413634.html","caption":"Chalk Cliff 13, Cliftonville","height":160,"id":7413634,"server_id":31,"src":"Chalk_cliff_13_Cliftonville.650_pix_vert_thumb.jpg","galleries_id":401496,"width":106});
thumbnails[8972974] = clik.newPhoto({"link":"photo_8972974.html","caption":"Yellow, green, blue ","height":120,"id":8972974,"server_id":31,"src":"65034_sharpen_BEST_RETOUCHEDImage0506_-_Version_13_thumb.jpg","galleries_id":426583,"width":160});
thumbnails[8984879] = clik.newPhoto({"link":"photo_8984879.html","caption":"Rock Life 4. Armed Man","height":160,"id":8984879,"server_id":31,"src":"aRock_Life_4_USED_in_site_MASTER_Feb_2011_-_Version_2_1_thumb.jpg","galleries_id":401462,"width":160});
thumbnails[8067991] = clik.newPhoto({"link":"photo_8067991.html","caption":"Plasma Beam","height":120,"id":8067991,"server_id":31,"src":"2._.05exp._.21def._0.5sharpen_thumb.jpg","galleries_id":426583,"width":160});
thumbnails[8984902] = clik.newPhoto({"link":"photo_8984902.html","caption":"Rock Life 5. Big Head","height":160,"id":8984902,"server_id":31,"src":"aRock_Life_5_USED_in_site_MASTER_for_website_1_thumb.jpg","galleries_id":401462,"width":160});
thumbnails[8972783] = clik.newPhoto({"link":"photo_8972783.html","caption":"Auto ","height":160,"id":8972783,"server_id":31,"src":"Auto_8_650_dpibrighcontdef_BEST_Image0519_-_Version_6_1_thumb.jpg","galleries_id":426583,"width":120});
thumbnails[8987583] = clik.newPhoto({"link":"photo_8987583.html","caption":"Rock Life 6. Orator","height":160,"id":8987583,"server_id":31,"src":"aRock_Life_6_USED_in_site_MASTER_550_Jan_2012_-_Version_2_thumb.jpg","galleries_id":401462,"width":160});
thumbnails[8985105] = clik.newPhoto({"link":"photo_8985105.html","caption":"Rock Life 7. Wood Spirit","height":160,"id":8985105,"server_id":31,"src":"bRock_Life_7_USED_in_site_MASTER_Feb_2011_-_Version_2_1_thumb.jpg","galleries_id":401462,"width":160});
thumbnails[8985168] = clik.newPhoto({"link":"photo_8985168.html","caption":"Rock Life 8. Guardian","height":160,"id":8985168,"server_id":31,"src":"dRock_Life_8_USED_in_site_MASTER_Feb_2011_-_Version_2_1_thumb.jpg","galleries_id":401462,"width":160});
thumbnails[8985561] = clik.newPhoto({"link":"photo_8985561.html","caption":"Rock Life 9. Grotto","height":160,"id":8985561,"server_id":31,"src":"bRock_Life_9_MASTER_Used_in_site__Feb_2011-see_title_-_Version_2_1_thumb.jpg","galleries_id":401462,"width":160});
thumbnails[8987404] = clik.newPhoto({"link":"photo_8987404.html","caption":"Rock Life 10. Harlequin","height":160,"id":8987404,"server_id":31,"src":"cRock_Life_10_USED_in_siteMASTER_Feb_2011__-_Version_2_1_thumb.jpg","galleries_id":401462,"width":160});
thumbnails[9003379] = clik.newPhoto({"link":"photo_9003379.html","caption":"Rock Life. Polychrome","height":114,"id":9003379,"server_id":31,"src":"qWEBSITE_MASTER_VERSION_3._Used_to_duplicate_then_adjust__for_website_BG26_sharpen_Centre_not_sharp_at_v.large_OK__55cms._Paco_to_combine_1_thumb.jpg","galleries_id":401462,"width":160});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
galleries[401462] = clik.newGallery({"photoIDs":[8987426,8987418,8984830,8984879,8984902,8987583,8985105,8985168,8985561,8987404,9003379],"link":"gallery_401462.html","skipIndex":0,"section_code":"gallery","id":401462,"parentGallery":"","featured_images":"9003379,8987583,8987426,8987418,8987404,8985561,8985168,8985105,8984902,8984879","maxRecords":0,"usePopups":false,"singleSection":false,"title":"Rock Life"});galleries[426583] = clik.newGallery({"photoIDs":[8977786,8973542,9174753,8972834,8972974,8067991,8972783],"link":"gallery_426583.html","skipIndex":0,"section_code":"gallery","id":426583,"parentGallery":"","featured_images":"9174753,8977786,8973542,8972974,8972834,8972783,8067991","maxRecords":0,"usePopups":false,"singleSection":false,"title":"Electric"});galleries[401475] = clik.newGallery({"photoIDs":[8073616,9003052,8989922,8989979,8990087,8990158,9003026,8996940,8990383],"link":"gallery_401475.html","skipIndex":0,"section_code":"gallery","id":401475,"parentGallery":"","featured_images":"9003052,9003026,8996940,8990383,8990158,8990087,8989979,8989922,8073616","maxRecords":0,"usePopups":false,"singleSection":false,"title":"Coastal"});galleries[401467] = clik.newGallery({"photoIDs":[8071114,8071855,8072205],"link":"gallery_401467.html","skipIndex":0,"section_code":"gallery","id":401467,"parentGallery":"","featured_images":"8072205,8071855,8071114","maxRecords":0,"usePopups":false,"singleSection":false,"title":"Ice "});galleries[401493] = clik.newGallery({"photoIDs":[7400814,7400347,7400329,7400658,7400834,7400246],"link":"gallery_401493.html","skipIndex":0,"section_code":"gallery","id":401493,"parentGallery":"","featured_images":"7400834,7400814,7400658,7400347,7400329,7400246","maxRecords":0,"usePopups":false,"singleSection":false,"title":"Trees and Grasses"});galleries[401495] = clik.newGallery({"photoIDs":[7400708,7400764],"link":"gallery_401495.html","skipIndex":0,"section_code":"gallery","id":401495,"parentGallery":"","featured_images":"7400764,7400708","maxRecords":0,"usePopups":false,"singleSection":false,"title":"Desert"});galleries[401494] = clik.newGallery({"photoIDs":[7413619],"link":"gallery_401494.html","skipIndex":0,"section_code":"gallery","id":401494,"parentGallery":"","featured_images":7413619,"maxRecords":0,"usePopups":false,"singleSection":false,"title":"Architecture"});galleries[401496] = clik.newGallery({"photoIDs":[7402062,7403097,7400211,7413634],"link":"gallery_401496.html","skipIndex":0,"section_code":"gallery","id":401496,"parentGallery":"","featured_images":"7413634,7403097,7402062,7400211","maxRecords":0,"usePopups":false,"singleSection":false,"title":"Unquiet"});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[3] = '7400814,7400347,7400329,7400658,7400834,7400246,7400708,7400764,7402062,7403097,7400211';
imageSets[1] = '8973542';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/rmathes/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/rmathes/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/rmathes/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/rmathes/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/rmathes/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/rmathes/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/rmathes/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/rmathes/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/rmathes/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/rmathes/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/rmathes/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/rmathes/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/rmathes/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/rmathes/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/rmathes/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/rmathes/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/rmathes/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/rmathes/images';
		break;
	}
		switch (server_id) {
		case 0:
		val = 'http://www.clikpic.com/rmathes/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/rmathes/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/rmathes/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/rmathes/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/rmathes/images';
		break;
	}
		switch (server_id) {
		case 51:
		val = 'http://www12.clikpic.com/rmathes/images';
		break;
	}
		switch (server_id) {
		case 52:
		val = 'http://tpc22/clikpic/rmathes/images';
		break;
	}
		switch (server_id) {
		case 53:
		val = 'http://images.clikpic.com/rmathes/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/rmathes/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 = 'Rob Matheson Editions: ' + 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="rob@robmatheson.co.uk">';
					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="rob@robmatheson.co.uk">';
				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;
	}
}

		

