window.thumbnails = {};
															thumbnails[4050564] = clik.newPhoto({"id":4050564,"src":"IMG_2396_thumb.jpg","galleries_id":402470,"server_id":15,"link":"photo_4050564.html","width":130,"caption":"Disseminated Organism","height":87});
															thumbnails[7604111] = clik.newPhoto({"id":7604111,"src":"this_storm_is_what_we_call_progress_191_thumb.jpg","galleries_id":402470,"server_id":15,"link":"photo_7604111.html","width":130,"caption":"Air","height":87});
															thumbnails[7604159] = clik.newPhoto({"id":7604159,"src":"orbs_and_others_1591_thumb.jpg","galleries_id":402472,"server_id":15,"link":"photo_7604159.html","width":130,"caption":"Orb no.1","height":130});
															thumbnails[7604162] = clik.newPhoto({"id":7604162,"src":"orbs_and_others_1661_thumb.jpg","galleries_id":402472,"server_id":15,"link":"photo_7604162.html","width":130,"caption":"Orb no.2","height":130});
															thumbnails[3602649] = clik.newPhoto({"id":3602649,"src":"shivasrainbow_thumb.JPG","galleries_id":219534,"server_id":15,"link":"photo_3602649.html","width":130,"caption":"Shivas Rainbow","height":87});
															thumbnails[7604176] = clik.newPhoto({"id":7604176,"src":"orbs_and_others_184_thumb.jpg","galleries_id":402472,"server_id":15,"link":"photo_7604176.html","width":130,"caption":"Orb no.3","height":130});
															thumbnails[3602652] = clik.newPhoto({"id":3602652,"src":"shivasrainbowdetail_thumb.JPG","galleries_id":219534,"server_id":15,"link":"photo_3602652.html","width":130,"caption":"Shivas Rainbow (detail)","height":98});
															thumbnails[8280988] = clik.newPhoto({"id":8280988,"src":"orbs_and_others_217edit_thumb.jpg","galleries_id":402472,"server_id":19,"link":"photo_8280988.html","width":130,"caption":"Orb no.4","height":130});
															thumbnails[5056529] = clik.newPhoto({"id":5056529,"src":"gloria_202_thumb.jpg","galleries_id":402470,"server_id":15,"link":"photo_5056529.html","width":130,"caption":"Peppered","height":87});
															thumbnails[7604090] = clik.newPhoto({"id":7604090,"src":"memoomahmeh_119_thumb.jpg","galleries_id":402471,"server_id":15,"link":"photo_7604090.html","width":130,"caption":"This Storm is What we Call Progress","height":87});
															thumbnails[8281856] = clik.newPhoto({"id":8281856,"src":"assortment_050edit_thumb.jpg","galleries_id":402472,"server_id":37,"link":"photo_8281856.html","width":130,"caption":"Orb no.5","height":130});
															thumbnails[5056533] = clik.newPhoto({"id":5056533,"src":"gloria_189_thumb.jpg","galleries_id":402470,"server_id":15,"link":"photo_5056533.html","width":130,"caption":"Peppered (detail)","height":87});
															thumbnails[7604093] = clik.newPhoto({"id":7604093,"src":"memoomahmeh_141_thumb.jpg","galleries_id":402471,"server_id":15,"link":"photo_7604093.html","width":130,"caption":"This Storm is What we Call Progress (detail)","height":87});
															thumbnails[8281862] = clik.newPhoto({"id":8281862,"src":"assortment_059edit_thumb.jpg","galleries_id":402472,"server_id":37,"link":"photo_8281862.html","width":130,"caption":"Orb no.6","height":130});
															thumbnails[8281865] = clik.newPhoto({"id":8281865,"src":"orbs_and_others_182edit_thumb.jpg","galleries_id":402472,"server_id":37,"link":"photo_8281865.html","width":130,"caption":"Orb no.7","height":130});
															thumbnails[7604225] = clik.newPhoto({"id":7604225,"src":"Inorganic_Organism_thumb.jpg","galleries_id":402471,"server_id":15,"link":"photo_7604225.html","width":130,"caption":"Inorganic Organism","height":87});
															thumbnails[8281867] = clik.newPhoto({"id":8281867,"src":"assortment_062edit_thumb.jpg","galleries_id":402472,"server_id":37,"link":"photo_8281867.html","width":130,"caption":"Orb no.8","height":130});
															thumbnails[3602615] = clik.newPhoto({"id":3602615,"src":"cellularscape_thumb.jpg","galleries_id":402469,"server_id":15,"link":"photo_3602615.html","width":130,"caption":"Cellular Scape","height":97});
															thumbnails[7604223] = clik.newPhoto({"id":7604223,"src":"Inorganic_Organism_natural_light_thumb.jpg","galleries_id":402471,"server_id":15,"link":"photo_7604223.html","width":130,"caption":"Inorganic Organism","height":87});
															thumbnails[8282011] = clik.newPhoto({"id":8282011,"src":"orbs_and_others_207edit_thumb.jpg","galleries_id":402472,"server_id":37,"link":"photo_8282011.html","width":130,"caption":"Orb no.9","height":130});
															thumbnails[3602627] = clik.newPhoto({"id":3602627,"src":"Island_thumb.JPG","galleries_id":402469,"server_id":15,"link":"photo_3602627.html","width":130,"caption":"Island","height":98});
															thumbnails[5056488] = clik.newPhoto({"id":5056488,"src":"zoo_work_etc_129_thumb.jpg","galleries_id":402470,"server_id":15,"link":"photo_5056488.html","width":130,"caption":"Gloria","height":87});
															thumbnails[7604099] = clik.newPhoto({"id":7604099,"src":"this_storm_is_what_we_call_progress_086_thumb.jpg","galleries_id":402471,"server_id":15,"link":"photo_7604099.html","width":130,"caption":"The Etherial View","height":87});
															thumbnails[7604183] = clik.newPhoto({"id":7604183,"src":"Contortion_3_thumb.jpg","galleries_id":402472,"server_id":15,"link":"photo_7604183.html","width":130,"caption":"Contortion no.3","height":195});
															thumbnails[3602607] = clik.newPhoto({"id":3602607,"src":"bunkercanyon1_thumb.JPG","galleries_id":219534,"server_id":15,"link":"photo_3602607.html","width":130,"caption":"Bunker\/Canyon","height":87});
															thumbnails[3602628] = clik.newPhoto({"id":3602628,"src":"Islanddetail_thumb.JPG","galleries_id":402469,"server_id":15,"link":"photo_3602628.html","width":130,"caption":"Island (detail)","height":98});
															thumbnails[5056504] = clik.newPhoto({"id":5056504,"src":"gloria_148_thumb.jpg","galleries_id":402470,"server_id":15,"link":"photo_5056504.html","width":130,"caption":"Trade","height":87});
															thumbnails[7604084] = clik.newPhoto({"id":7604084,"src":"this_storm_is_what_we_call_progress_097_thumb.jpg","galleries_id":402471,"server_id":15,"link":"photo_7604084.html","width":130,"caption":"Solid Flux","height":87});
															thumbnails[7604186] = clik.newPhoto({"id":7604186,"src":"Contortion_8_thumb.jpg","galleries_id":402472,"server_id":15,"link":"photo_7604186.html","width":130,"caption":"Contortion no.8","height":195});
															thumbnails[3602608] = clik.newPhoto({"id":3602608,"src":"bunkercanyon2_thumb.JPG","galleries_id":219534,"server_id":15,"link":"photo_3602608.html","width":130,"caption":"Bunker\/Canyon","height":87});
															thumbnails[5056454] = clik.newPhoto({"id":5056454,"src":"Commerce_detail_Joe_Doldon_2009_thumb.jpg","galleries_id":402470,"server_id":15,"link":"photo_5056454.html","width":130,"caption":"Trade (detail)","height":163});
															thumbnails[7604080] = clik.newPhoto({"id":7604080,"src":"memoomahmeh_047_thumb.jpg","galleries_id":402471,"server_id":15,"link":"photo_7604080.html","width":130,"caption":"Solid Flux (detail)","height":195});
															thumbnails[7604194] = clik.newPhoto({"id":7604194,"src":"contortions_238_thumb.jpg","galleries_id":402472,"server_id":15,"link":"photo_7604194.html","width":130,"caption":"Contortion no.8 (detail)","height":195});
															thumbnails[3602663] = clik.newPhoto({"id":3602663,"src":"untitledfloor_thumb.jpg","galleries_id":402469,"server_id":15,"link":"photo_3602663.html","width":130,"caption":"Untitled (floor)","height":81});
															thumbnails[7604101] = clik.newPhoto({"id":7604101,"src":"this_storm_is_what_we_call_progress_146_thumb.jpg","galleries_id":402471,"server_id":15,"link":"photo_7604101.html","width":130,"caption":"The Aftermath","height":195});
															thumbnails[7604188] = clik.newPhoto({"id":7604188,"src":"contortion_7_detail_thumb.jpg","galleries_id":402472,"server_id":15,"link":"photo_7604188.html","width":130,"caption":"Contortion no.7 (detail)","height":195});
															thumbnails[7604218] = clik.newPhoto({"id":7604218,"src":"Infinity_Tower_2_thumb.jpg","galleries_id":402470,"server_id":15,"link":"photo_7604218.html","width":130,"caption":"Infinity Tower","height":195});
															thumbnails[3602666] = clik.newPhoto({"id":3602666,"src":"untitledfloordetail_thumb.jpg","galleries_id":402469,"server_id":15,"link":"photo_3602666.html","width":130,"caption":"Untitled (floor)","height":207});
															thumbnails[7604105] = clik.newPhoto({"id":7604105,"src":"this_storm_is_what_we_call_progress_169_thumb.jpg","galleries_id":402471,"server_id":15,"link":"photo_7604105.html","width":130,"caption":"The Aftermath (detail)","height":87});
															thumbnails[7604202] = clik.newPhoto({"id":7604202,"src":"Infinity_Tower_thumb.jpg","galleries_id":402470,"server_id":15,"link":"photo_7604202.html","width":130,"caption":"Infinity Tower","height":195});
															thumbnails[8281972] = clik.newPhoto({"id":8281972,"src":"Contortion_no.11edit_thumb.jpg","galleries_id":402472,"server_id":37,"link":"photo_8281972.html","width":130,"caption":"Contortion no.2","height":87});
															thumbnails[3602674] = clik.newPhoto({"id":3602674,"src":"newcont3_thumb.JPG","galleries_id":219534,"server_id":15,"link":"photo_3602674.html","width":130,"caption":"Untitled (floor)","height":98});
															thumbnails[8281871] = clik.newPhoto({"id":8281871,"src":"Contortion_no1.7edit_thumb.jpg","galleries_id":402472,"server_id":37,"link":"photo_8281871.html","width":130,"caption":"Contortion no.14","height":195});
															thumbnails[3602617] = clik.newPhoto({"id":3602617,"src":"Crease_thumb.JPG","galleries_id":219534,"server_id":15,"link":"photo_3602617.html","width":130,"caption":"Crease","height":98});
															thumbnails[8281888] = clik.newPhoto({"id":8281888,"src":"orange_wedding__heart_in_the_hand_of_the_matter_138edit_thumb.jpg","galleries_id":402472,"server_id":37,"link":"photo_8281888.html","width":130,"caption":"A Perfect Marriage","height":87});
															thumbnails[3602618] = clik.newPhoto({"id":3602618,"src":"creasedetail_thumb.JPG","galleries_id":219534,"server_id":15,"link":"photo_3602618.html","width":130,"caption":"Crease (detail)","height":98});
															thumbnails[8281892] = clik.newPhoto({"id":8281892,"src":"orange_wedding__heart_in_the_hand_of_the_matter_186edit_thumb.jpg","galleries_id":402472,"server_id":37,"link":"photo_8281892.html","width":130,"caption":"A Perfect Marriage","height":87});
															thumbnails[8281989] = clik.newPhoto({"id":8281989,"src":"Thrifty_Geodeedit_thumb.jpg","galleries_id":402472,"server_id":37,"link":"photo_8281989.html","width":130,"caption":"Thrifty Geode","height":87});
															thumbnails[8281973] = clik.newPhoto({"id":8281973,"src":"orange_wedding__heart_in_the_hand_of_the_matter_296edit_thumb.jpg","galleries_id":402472,"server_id":37,"link":"photo_8281973.html","width":130,"caption":"Pixellated World","height":87});
															thumbnails[8281975] = clik.newPhoto({"id":8281975,"src":"orange_wedding__heart_in_the_hand_of_the_matter_297edit_thumb.jpg","galleries_id":402472,"server_id":37,"link":"photo_8281975.html","width":130,"caption":"Pixellated World","height":87});
															thumbnails[8281894] = clik.newPhoto({"id":8281894,"src":"orange_wedding__heart_in_the_hand_of_the_matter_044edit_thumb.jpg","galleries_id":402472,"server_id":37,"link":"photo_8281894.html","width":130,"caption":"Antarctica Divided: East","height":87});
															thumbnails[3602594] = clik.newPhoto({"id":3602594,"src":"briefhistoryofmexicocity_thumb.JPG","galleries_id":219534,"server_id":15,"link":"photo_3602594.html","width":130,"caption":"A Brief History of Mexico City","height":98});
															thumbnails[8281954] = clik.newPhoto({"id":8281954,"src":"orange_wedding__heart_in_the_hand_of_the_matter_047edit_thumb.jpg","galleries_id":402472,"server_id":37,"link":"photo_8281954.html","width":130,"caption":"Antarctica Divided: West","height":87});
															thumbnails[3602600] = clik.newPhoto({"id":3602600,"src":"abriefhistoryofdetail_thumb.JPG","galleries_id":219534,"server_id":15,"link":"photo_3602600.html","width":130,"caption":"A Brief History of Mexico City (Detail)","height":98});
															thumbnails[8281990] = clik.newPhoto({"id":8281990,"src":"orange_wedding__heart_in_the_hand_of_the_matter_083edit_thumb.jpg","galleries_id":402472,"server_id":37,"link":"photo_8281990.html","width":130,"caption":"Installation Shot","height":87});
															thumbnails[4050990] = clik.newPhoto({"id":4050990,"src":"8_REDRESSING_thumb.JPG","galleries_id":219534,"server_id":15,"link":"photo_4050990.html","width":130,"caption":"Redressing the Balance","height":98});
															thumbnails[8281992] = clik.newPhoto({"id":8281992,"src":"orange_wedding__heart_in_the_hand_of_the_matter_167edit_thumb.jpg","galleries_id":402472,"server_id":37,"link":"photo_8281992.html","width":130,"caption":"Installation Shot","height":87});
															thumbnails[4051065] = clik.newPhoto({"id":4051065,"src":"11_REDRESSINg_thumb.JPG","galleries_id":219534,"server_id":15,"link":"photo_4051065.html","width":130,"caption":"Redressing the Balance (detail)","height":98});
															thumbnails[8290642] = clik.newPhoto({"id":8290642,"src":"orange_wedding__heart_in_the_hand_of_the_matter_341edit_thumb.jpg","galleries_id":402472,"server_id":37,"link":"photo_8290642.html","width":130,"caption":"Through Betterment We May Fall","height":87});
															thumbnails[3602636] = clik.newPhoto({"id":3602636,"src":"sandroom_thumb.JPG","galleries_id":219534,"server_id":15,"link":"photo_3602636.html","width":130,"caption":"The Falmouth Sand Room","height":87});
															thumbnails[8290643] = clik.newPhoto({"id":8290643,"src":"orange_wedding__heart_in_the_hand_of_the_matter_357edit_thumb.jpg","galleries_id":402472,"server_id":37,"link":"photo_8290643.html","width":130,"caption":"Through Betterment We May Fall (detail)","height":87});
															thumbnails[3602637] = clik.newPhoto({"id":3602637,"src":"sandroom2_thumb.JPG","galleries_id":219534,"server_id":15,"link":"photo_3602637.html","width":130,"caption":"The Falmouth Sand Room (detail)","height":195});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  						galleries[402469] = clik.newGallery({"parentGallery":"","usePopups":false,"title":2007.0,"link":"gallery_402469.html","maxRecords":0.0,"photoIDs":[3602615.0,3602627.0,3602628.0,3602663.0,3602666.0],"skipIndex":0,"section_code":"gallery","featured_images":"3602666,3602663,3602628,3602627,3602615","id":402469,"singleSection":false});				  						galleries[219534] = clik.newGallery({"parentGallery":"","usePopups":false,"title":2008.0,"link":"gallery_219534.html","maxRecords":0.0,"photoIDs":[3602649.0,3602652.0,3602607.0,3602608.0,3602674.0,3602617.0,3602618.0,3602594.0,3602600.0,4050990.0,4051065.0,3602636.0,3602637.0],"skipIndex":0,"section_code":"gallery","featured_images":"4051065,4050990,3602674,3602652,3602649,3602637,3602636,3602618,3602617,3602608","id":219534,"singleSection":false});				  						galleries[402470] = clik.newGallery({"parentGallery":"","usePopups":false,"title":2009.0,"link":"gallery_402470.html","maxRecords":0.0,"photoIDs":[4050564.0,7604111.0,5056529.0,5056533.0,5056488.0,5056504.0,5056454.0,7604218.0,7604202.0],"skipIndex":0,"section_code":"gallery","featured_images":"7604218,7604202,7604111,5056533,5056529,5056504,5056488,5056454,4050564","id":402470,"singleSection":false});				  						galleries[402471] = clik.newGallery({"parentGallery":"","usePopups":false,"title":2010.0,"link":"gallery_402471.html","maxRecords":0.0,"photoIDs":[7604090.0,7604093.0,7604225.0,7604223.0,7604099.0,7604084.0,7604080.0,7604101.0,7604105.0],"skipIndex":0,"section_code":"gallery","featured_images":"7604225,7604223,7604105,7604101,7604099,7604093,7604090,7604084,7604080","id":402471,"singleSection":false});				  						galleries[402472] = clik.newGallery({"parentGallery":"","usePopups":false,"title":2011.0,"link":"gallery_402472.html","maxRecords":0.0,"photoIDs":[7604159.0,7604162.0,7604176.0,8280988.0,8281856.0,8281862.0,8281865.0,8281867.0,8282011.0,7604183.0,7604186.0,7604194.0,7604188.0,8281972.0,8281871.0,8281888.0,8281892.0,8281989.0,8281973.0,8281975.0,8281894.0,8281954.0,8281990.0,8281992.0,8290642.0,8290643.0],"skipIndex":0,"section_code":"gallery","featured_images":"8290643,8290642,8282011,8281992,8281990,8281989,8281975,8281973,8281972,8281954","id":402472,"singleSection":false});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[1] = '8290643,8290642,8282011,8281992,8281990,8281989,8281975,8281973,8281972,8281954,8281894,8281892,8281888,8281871,8281867,8281865,8281862,8281856,8280988,7604225,7604223,7604218,7604202,7604194,7604188,7604186,7604183,7604176,7604162,7604159,7604111,7604105,7604101,7604099,7604093,7604090,7604084,7604080,5056533,5056529,5056504,5056488,5056454,4051065,4050990,4050564,3602674,3602666,3602663,3602652';
imageSets[3] = '8290643,8290642,8282011,8281992,8281990,8281989,8281975,8281973,8281972,8281954,8281894,8281892,8281888,8281871,8281867,8281865,8281862,8281856,8280988,7604225,7604223,7604218,7604202,7604194,7604188,7604186,7604183,7604176,7604162,7604159,7604111,7604105,7604101,7604099,7604093,7604090,7604084,7604080,5056533,5056529,5056504,5056488,5056454,4051065,4050990,4050564,3602674,3602666,3602663,3602652';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/joedoldon/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/joedoldon/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/joedoldon/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/joedoldon/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/joedoldon/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/joedoldon/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/joedoldon/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/joedoldon/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/joedoldon/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/joedoldon/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/joedoldon/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/joedoldon/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/joedoldon/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/joedoldon/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/joedoldon/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/joedoldon/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://admin2.clikpic.com/joedoldon/images';
		break;
	}
		switch (server_id) {
		case 33:
		val = 'http://www8.clikpic.com/joedoldon/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/joedoldon/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/joedoldon/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/joedoldon/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/joedoldon/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/joedoldon/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/joedoldon/images';
		break;
	}
		return val;
}

/***************************************************************************
* img = reference to image object in which to show image                   *
***************************************************************************/
function showHomeImage(img) {
	imageID = randomListVal('');
	if (!basic) {
		img.src = photos[imageID].src;
		img.width = photos[imageID].width;
		img.height = photos[imageID].height;
		img.parentNode.title = img.alt = photos[imageID].caption;
	} else {
		newImage = new Image(photos[imageID].width,photos[imageID].height);
		newImage.src = photos[imageID].src;
		document.images[img.name] = newImage;
		
	}
}

function getHomeImageLink(imageID) {
  	var href='', photo = backgrounds && backgrounds[imageID];
	if(photo){
		if (photo && photo.galleries_id != '') {
  			href = photo.fnGalleryLink();
  		}
  		  		else {
  				href += 'gallery.html';
  	  		}
	}
    return href;
}

/***************************************************************************
* Show a random image on home page from featured images                    *
***************************************************************************/
function showHomeImageInline(el, image_sets_id, href) {
	
	var css = {}, imageID,
	    imageSetsId = 1;
	if(image_sets_id){
		imageSetsId = image_sets_id;
	}
	imageID = randomListVal(imageSets[imageSetsId]);
	if (href == null && 'gallery' != '') {
					href = getHomeImageLink(imageID);
	}
	
	updateImage({nextPhoto: backgrounds[imageID], img:el.find('img')[0],
                $photo:el, $title:$('#homeimageTitleContainer'), $detail:$('#homeimageDetailsContainer'),                speed:0, href:href, css:css, onAfter: function(){                  this.closest('.contentsection').doManualAlign({				    inner: 'img',				    crop: 'a'				  });                }              });
}

/***************************************************************************
* Set 'img' to be a new image given its photo() object                     *
***************************************************************************/
function updateImage (options) {
	var defaults = {nextPhoto:'',field:'',img:'',$photo:'',$title:'',$detail:'',$detailContainer:'',
                    updateDocumentTitle:false,speed:0,href:false,css:false,updateHash:false,onAfter:null,onBefore:null},
		op = $.extend({},defaults,options),
		html = '', temp = '',
		photoId = op.nextPhoto.id,
		photoCaption = ''+op.nextPhoto.caption,
		photoSrc = op.nextPhoto.src;
	
	if (op.updateHash && clik.getIDInUrl(location.href,'photo') != op.nextPhoto.id) {
		clik.changeHash('photos_id=' + op.nextPhoto.id, true);
	}
		
	    if (op.$title.length > 0) {
  		op.$title.fadeGalleryDetails(photoCaption, op.speed);
    }
        if (op.updateDocumentTitle) {
						  document.title = 'Joe Doldon - Visual Artist: ' + 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.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 += '<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({					href: thumbnails[imageID].fnGalleryLink(gallery_id),					title: galleries[gallery_id].title				});
			}
		}
	}
}

/***************************************************************************
* 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;
	}
}

			

