window.thumbnails = {};
															thumbnails[2340332] = clik.newPhoto({"id":2340332,"src":"Beginnings_thumb.jpg","galleries_id":121076,"server_id":18,"link":"photo_2340332.html","width":130,"caption":"Beginnings","height":98});
															thumbnails[2340347] = clik.newPhoto({"id":2340347,"src":"Triangulate_thumb.jpg","galleries_id":121076,"server_id":18,"link":"photo_2340347.html","width":130,"caption":"Triangulate","height":89});
															thumbnails[2340365] = clik.newPhoto({"id":2340365,"src":"Viola_thumb.jpg","galleries_id":121076,"server_id":18,"link":"photo_2340365.html","width":130,"caption":"Viola","height":89});
															thumbnails[2340370] = clik.newPhoto({"id":2340370,"src":"Causal-Connection_thumb.jpg","galleries_id":121076,"server_id":18,"link":"photo_2340370.html","width":130,"caption":"Causal Connection","height":89});
															thumbnails[2340386] = clik.newPhoto({"id":2340386,"src":"Ammonite_thumb.jpg","galleries_id":121076,"server_id":18,"link":"photo_2340386.html","width":130,"caption":"Ammonite","height":89});
															thumbnails[2340392] = clik.newPhoto({"id":2340392,"src":"Charisma_thumb.jpg","galleries_id":121076,"server_id":18,"link":"photo_2340392.html","width":130,"caption":"Charisma","height":89});
															thumbnails[2340397] = clik.newPhoto({"id":2340397,"src":"Resolution_thumb.jpg","galleries_id":121076,"server_id":18,"link":"photo_2340397.html","width":130,"caption":"Resolution","height":89});
															thumbnails[2340407] = clik.newPhoto({"id":2340407,"src":"Twirl_thumb.jpg","galleries_id":114688,"server_id":18,"link":"photo_2340407.html","width":130,"caption":"Twirl","height":89});
															thumbnails[2340409] = clik.newPhoto({"id":2340409,"src":"Restraint_thumb.jpg","galleries_id":114688,"server_id":18,"link":"photo_2340409.html","width":130,"caption":"Restraint","height":89});
															thumbnails[2340465] = clik.newPhoto({"id":2340465,"src":"Maypole_thumb.jpg","galleries_id":114688,"server_id":18,"link":"photo_2340465.html","width":130,"caption":"Maypole","height":89});
															thumbnails[2340487] = clik.newPhoto({"id":2340487,"src":"Captivate_thumb.jpg","galleries_id":114688,"server_id":18,"link":"photo_2340487.html","width":130,"caption":"Captivate","height":89});
															thumbnails[2340555] = clik.newPhoto({"id":2340555,"src":"Rose-Infinitum_thumb.jpg","galleries_id":121079,"server_id":18,"link":"photo_2340555.html","width":130,"caption":"Rose Infinitum","height":89});
															thumbnails[2340563] = clik.newPhoto({"id":2340563,"src":"Singularity_thumb.jpg","galleries_id":121079,"server_id":18,"link":"photo_2340563.html","width":130,"caption":"Singularity","height":89});
															thumbnails[2340565] = clik.newPhoto({"id":2340565,"src":"Tailspin_thumb.jpg","galleries_id":121079,"server_id":18,"link":"photo_2340565.html","width":130,"caption":"Tailspin","height":89});
															thumbnails[2340579] = clik.newPhoto({"id":2340579,"src":"Blossom-Forth_thumb.jpg","galleries_id":121079,"server_id":18,"link":"photo_2340579.html","width":130,"caption":"Blossom Forth","height":89});
															thumbnails[2340583] = clik.newPhoto({"id":2340583,"src":"Nautilus_thumb.jpg","galleries_id":121079,"server_id":18,"link":"photo_2340583.html","width":130,"caption":"Nautilus","height":89});
															thumbnails[2340864] = clik.newPhoto({"id":2340864,"src":"Argonaut_thumb.jpg","galleries_id":121079,"server_id":18,"link":"photo_2340864.html","width":130,"caption":"Argonaut","height":89});
															thumbnails[2340874] = clik.newPhoto({"id":2340874,"src":"Pansy-Garland_thumb.jpg","galleries_id":121079,"server_id":18,"link":"photo_2340874.html","width":130,"caption":"Pansy Garland","height":89});
															thumbnails[2340890] = clik.newPhoto({"id":2340890,"src":"Underwater_thumb.jpg","galleries_id":152492,"server_id":18,"link":"photo_2340890.html","width":130,"caption":"Underwater","height":89});
															thumbnails[2340894] = clik.newPhoto({"id":2340894,"src":"Lambent_thumb.jpg","galleries_id":152492,"server_id":18,"link":"photo_2340894.html","width":130,"caption":"Lambent","height":89});
															thumbnails[2340907] = clik.newPhoto({"id":2340907,"src":"Consistence_thumb.jpg","galleries_id":152492,"server_id":18,"link":"photo_2340907.html","width":130,"caption":"Consistence","height":89});
															thumbnails[2340908] = clik.newPhoto({"id":2340908,"src":"Crimson-Glory_thumb.jpg","galleries_id":152492,"server_id":18,"link":"photo_2340908.html","width":130,"caption":"Crimson Glory","height":89});
															thumbnails[2340911] = clik.newPhoto({"id":2340911,"src":"Carina_thumb.jpg","galleries_id":152492,"server_id":18,"link":"photo_2340911.html","width":130,"caption":"Carina","height":89});
															thumbnails[2340918] = clik.newPhoto({"id":2340918,"src":"Fossils_thumb.jpg","galleries_id":152492,"server_id":18,"link":"photo_2340918.html","width":130,"caption":"Fossils","height":89});
															thumbnails[2340920] = clik.newPhoto({"id":2340920,"src":"Danse-de-Feu_thumb.jpg","galleries_id":152492,"server_id":18,"link":"photo_2340920.html","width":130,"caption":"Danse de Feu","height":89});
															thumbnails[2340923] = clik.newPhoto({"id":2340923,"src":"Luminance_thumb.jpg","galleries_id":152492,"server_id":18,"link":"photo_2340923.html","width":130,"caption":"Luminance","height":89});
															thumbnails[2340931] = clik.newPhoto({"id":2340931,"src":"Pockets_thumb.jpg","galleries_id":152492,"server_id":18,"link":"photo_2340931.html","width":130,"caption":"Pockets","height":89});
															thumbnails[2343056] = clik.newPhoto({"id":2343056,"src":"Arcana3_thumb.jpg","galleries_id":121079,"server_id":18,"link":"photo_2343056.html","width":130,"caption":"Arcana","height":89});
															thumbnails[2343057] = clik.newPhoto({"id":2343057,"src":"Blue-Rose3_thumb.jpg","galleries_id":114688,"server_id":18,"link":"photo_2343057.html","width":130,"caption":"Blue Rose","height":89});
															thumbnails[2343058] = clik.newPhoto({"id":2343058,"src":"Broken-Rings3_thumb.jpg","galleries_id":121076,"server_id":18,"link":"photo_2343058.html","width":130,"caption":"Broken Rings","height":89});
															thumbnails[2343067] = clik.newPhoto({"id":2343067,"src":"Fascination3_thumb.jpg","galleries_id":121076,"server_id":18,"link":"photo_2343067.html","width":130,"caption":"Fascination","height":89});
															thumbnails[2343068] = clik.newPhoto({"id":2343068,"src":"Folderol2_thumb.jpg","galleries_id":152492,"server_id":18,"link":"photo_2343068.html","width":130,"caption":"Folderol","height":89});
															thumbnails[2343069] = clik.newPhoto({"id":2343069,"src":"Folds2_thumb.jpg","galleries_id":121079,"server_id":18,"link":"photo_2343069.html","width":130,"caption":"Folds","height":89});
															thumbnails[2343072] = clik.newPhoto({"id":2343072,"src":"Entranced_thumb.jpg","galleries_id":152492,"server_id":18,"link":"photo_2343072.html","width":130,"caption":"Entranced","height":98});
															thumbnails[2343073] = clik.newPhoto({"id":2343073,"src":"Just-Colour3_thumb.jpg","galleries_id":121076,"server_id":18,"link":"photo_2343073.html","width":130,"caption":"Just Colour","height":89});
															thumbnails[2343075] = clik.newPhoto({"id":2343075,"src":"Parabola3_thumb.jpg","galleries_id":121076,"server_id":18,"link":"photo_2343075.html","width":130,"caption":"Parabola","height":89});
															thumbnails[2343078] = clik.newPhoto({"id":2343078,"src":"Portals3_thumb.jpg","galleries_id":121079,"server_id":18,"link":"photo_2343078.html","width":130,"caption":"Portals","height":89});
															thumbnails[2343080] = clik.newPhoto({"id":2343080,"src":"Ripples3_thumb.jpg","galleries_id":121079,"server_id":18,"link":"photo_2343080.html","width":130,"caption":"Ripples","height":87});
															thumbnails[2343083] = clik.newPhoto({"id":2343083,"src":"Subtlety2_thumb.jpg","galleries_id":114688,"server_id":18,"link":"photo_2343083.html","width":130,"caption":"Subtlety","height":89});
															thumbnails[2343085] = clik.newPhoto({"id":2343085,"src":"Trellis2_thumb.jpg","galleries_id":114688,"server_id":18,"link":"photo_2343085.html","width":130,"caption":"Trellis","height":89});
															thumbnails[2343086] = clik.newPhoto({"id":2343086,"src":"Waterfall2_thumb.jpg","galleries_id":121076,"server_id":18,"link":"photo_2343086.html","width":130,"caption":"Waterfall","height":89});
															thumbnails[2447708] = clik.newPhoto({"id":2447708,"src":"Calypso1_thumb.jpg","galleries_id":152492,"server_id":18,"link":"photo_2447708.html","width":130,"caption":"Calypso","height":89});
															thumbnails[2458585] = clik.newPhoto({"id":2458585,"src":"Extinction_thumb.jpg","galleries_id":121079,"server_id":18,"link":"photo_2458585.html","width":130,"caption":"Extinction","height":89});
															thumbnails[2458593] = clik.newPhoto({"id":2458593,"src":"Magnanamity_thumb.jpg","galleries_id":152492,"server_id":18,"link":"photo_2458593.html","width":130,"caption":"Magnanimity","height":89});
															thumbnails[2634053] = clik.newPhoto({"id":2634053,"src":"Discernment_thumb.jpg","galleries_id":121076,"server_id":18,"link":"photo_2634053.html","width":130,"caption":"Discernment","height":98});
															thumbnails[2634055] = clik.newPhoto({"id":2634055,"src":"Bounty_thumb.jpg","galleries_id":121076,"server_id":18,"link":"photo_2634055.html","width":130,"caption":"Bounty","height":98});
															thumbnails[2634061] = clik.newPhoto({"id":2634061,"src":"Exuberance_thumb.jpg","galleries_id":121076,"server_id":18,"link":"photo_2634061.html","width":130,"caption":"Exuberance","height":98});
															thumbnails[2634119] = clik.newPhoto({"id":2634119,"src":"Serenity_thumb.jpg","galleries_id":114688,"server_id":18,"link":"photo_2634119.html","width":130,"caption":"Serenity","height":98});
															thumbnails[2634123] = clik.newPhoto({"id":2634123,"src":"Swallowtails_thumb.jpg","galleries_id":114688,"server_id":18,"link":"photo_2634123.html","width":130,"caption":"Swallowtails","height":98});
															thumbnails[2634226] = clik.newPhoto({"id":2634226,"src":"Luxuriant_thumb.jpg","galleries_id":114688,"server_id":18,"link":"photo_2634226.html","width":130,"caption":"Luxuriant","height":98});
															thumbnails[2634370] = clik.newPhoto({"id":2634370,"src":"Profusion_thumb.jpg","galleries_id":114688,"server_id":18,"link":"photo_2634370.html","width":130,"caption":"Profusion","height":98});
															thumbnails[2634372] = clik.newPhoto({"id":2634372,"src":"Wayfarer_thumb.jpg","galleries_id":114688,"server_id":18,"link":"photo_2634372.html","width":130,"caption":"Wayfarer","height":98});
															thumbnails[2634374] = clik.newPhoto({"id":2634374,"src":"Emergence_thumb.jpg","galleries_id":114688,"server_id":18,"link":"photo_2634374.html","width":130,"caption":"Emergence","height":98});
															thumbnails[2634376] = clik.newPhoto({"id":2634376,"src":"Entice_thumb.jpg","galleries_id":121079,"server_id":18,"link":"photo_2634376.html","width":130,"caption":"Entice","height":98});
															thumbnails[2634378] = clik.newPhoto({"id":2634378,"src":"Charybdis_thumb.jpg","galleries_id":121079,"server_id":18,"link":"photo_2634378.html","width":130,"caption":"Charybdis","height":98});
															thumbnails[2634380] = clik.newPhoto({"id":2634380,"src":"Burgeon_thumb.jpg","galleries_id":121079,"server_id":18,"link":"photo_2634380.html","width":130,"caption":"Burgeon","height":98});
															thumbnails[2634382] = clik.newPhoto({"id":2634382,"src":"Infinite_thumb.jpg","galleries_id":152492,"server_id":18,"link":"photo_2634382.html","width":130,"caption":"Infinite","height":98});
															thumbnails[2634385] = clik.newPhoto({"id":2634385,"src":"Umbellifer_thumb.jpg","galleries_id":152492,"server_id":18,"link":"photo_2634385.html","width":130,"caption":"Umbellifer","height":98});
															thumbnails[2639052] = clik.newPhoto({"id":2639052,"src":"Evolution6_thumb.jpg","galleries_id":114688,"server_id":18,"link":"photo_2639052.html","width":130,"caption":"Evolution","height":98});
															thumbnails[4588599] = clik.newPhoto({"id":4588599,"src":"English-Courtry-Garden_thumb.gif","galleries_id":265723,"server_id":18,"link":"photo_4588599.html","width":130,"caption":"EnglishCountryGarden","height":90});
															thumbnails[4588606] = clik.newPhoto({"id":4588606,"src":"Home_thumb.gif","galleries_id":265723,"server_id":18,"link":"photo_4588606.html","width":130,"caption":"Home","height":90});
															thumbnails[4588615] = clik.newPhoto({"id":4588615,"src":"Sea-Shore_thumb.gif","galleries_id":265723,"server_id":18,"link":"photo_4588615.html","width":130,"caption":"TheSeashore","height":90});
															thumbnails[4588619] = clik.newPhoto({"id":4588619,"src":"Woodland_thumb.gif","galleries_id":265723,"server_id":18,"link":"photo_4588619.html","width":130,"caption":"EnglishWoodland","height":90});
															thumbnails[4588625] = clik.newPhoto({"id":4588625,"src":"Word-Cloud-You-Are-copy-copy_thumb.gif","galleries_id":265723,"server_id":18,"link":"photo_4588625.html","width":130,"caption":"YouAre ...","height":94});
															thumbnails[4588630] = clik.newPhoto({"id":4588630,"src":"Word-Cloud---Barley-copy_thumb.gif","galleries_id":265723,"server_id":18,"link":"photo_4588630.html","width":130,"caption":"BarleyVillage","height":94});
															thumbnails[4588631] = clik.newPhoto({"id":4588631,"src":"Word-Cloud---Bees-copy-copy_thumb.gif","galleries_id":265723,"server_id":18,"link":"photo_4588631.html","width":130,"caption":"Bees","height":94});
															thumbnails[4588636] = clik.newPhoto({"id":4588636,"src":"Word-Cloud---Love-copy-copy_thumb.gif","galleries_id":265723,"server_id":18,"link":"photo_4588636.html","width":130,"caption":"Love","height":94});
															thumbnails[4771849] = clik.newPhoto({"id":4771849,"src":"Time_Web_Image_thumb.jpg","galleries_id":265723,"server_id":18,"link":"photo_4771849.html","width":130,"caption":"Time","height":94});
															thumbnails[9111753] = clik.newPhoto({"id":9111753,"src":"Lustre1_1.jpg","galleries_id":114688,"server_id":18,"link":"photo_9111753.html","width":130,"caption":"Lustre","height":104});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  						galleries[121076] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Fractals 1","link":"gallery_121076.html","maxRecords":0.0,"photoIDs":[2340332.0,2340347.0,2340365.0,2340370.0,2340386.0,2340392.0,2340397.0,2343058.0,2343067.0,2343073.0,2343075.0,2343086.0,2634053.0,2634055.0,2634061.0],"skipIndex":0,"section_code":"gallery","featured_images":"2634061,2634055,2634053,2343086,2343075,2343073,2343067,2343058,2340397,2340392","id":121076,"singleSection":false});				  						galleries[114688] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Fractals 2","link":"gallery_114688.html","maxRecords":0.0,"photoIDs":[2340407.0,2340409.0,2340465.0,2340487.0,2343057.0,2343083.0,2343085.0,2634119.0,2634123.0,2634226.0,2634370.0,2634372.0,2634374.0,2639052.0,9111753.0],"skipIndex":0,"section_code":"gallery","featured_images":"9111753,2639052,2634374,2634372,2634370,2634226,2634123,2634119,2343085,2343083","id":114688,"singleSection":false});				  						galleries[121079] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Fractals 3","link":"gallery_121079.html","maxRecords":0.0,"photoIDs":[2340555.0,2340563.0,2340565.0,2340579.0,2340583.0,2340864.0,2340874.0,2343056.0,2343069.0,2343078.0,2343080.0,2458585.0,2634376.0,2634378.0,2634380.0],"skipIndex":0,"section_code":"gallery","featured_images":"2634380,2634378,2634376,2458585,2343080,2343078,2343069,2343056,2340874,2340864","id":121079,"singleSection":false});				  						galleries[152492] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Fractals 4","link":"gallery_152492.html","maxRecords":0.0,"photoIDs":[2340890.0,2340894.0,2340907.0,2340908.0,2340911.0,2340918.0,2340920.0,2340923.0,2340931.0,2343068.0,2343072.0,2447708.0,2458593.0,2634382.0,2634385.0],"skipIndex":0,"section_code":"gallery","featured_images":"2634385,2634382,2458593,2447708,2343072,2343068,2340931,2340923,2340920,2340918","id":152492,"singleSection":false});				  						galleries[265723] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Word Clouds","link":"gallery_265723.html","maxRecords":0.0,"photoIDs":[4588599.0,4588606.0,4588615.0,4588619.0,4588625.0,4588630.0,4588631.0,4588636.0,4771849.0],"skipIndex":0,"section_code":"gallery","featured_images":"4771849,4588636,4588631,4588630,4588625,4588619,4588615,4588606,4588599","id":265723,"singleSection":false});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[1] = '4588636,4588625,4588599,2634380,2634370,2634119,2634055,2634053,2447708,2343083,2343075,2343069,2343067,2340920,2340918,2340908,2340907,2340579,2340563,2340555,2340465,2340409,2340407,2340397,2340386,2340332';
imageSets[3] = '4771849,4588636,4588631,4588630,4588625,4588619,4588615,4588606,4588599,2639052,2634385,2634382,2634380,2634378,2634376,2634374,2634372,2634370,2634226,2634123,2634119,2634061,2634055,2634053,2458593,2458585,2447708,2343086,2343085,2343083,2343080,2343078,2343075,2343073,2343072,2343069,2343068';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 51:
		val = 'http://www12.clikpic.com/SuzanneC/images';
		break;
	}
		switch (server_id) {
		case 0:
		val = 'http://www.clikpic.com/SuzanneC/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/SuzanneC/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/SuzanneC/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/SuzanneC/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/SuzanneC/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/SuzanneC/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/SuzanneC/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/SuzanneC/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/SuzanneC/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/SuzanneC/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/SuzanneC/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/SuzanneC/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/SuzanneC/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/SuzanneC/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/SuzanneC/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/SuzanneC/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/SuzanneC/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/SuzanneC/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/SuzanneC/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/SuzanneC/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/SuzanneC/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/SuzanneC/images';
		break;
	}
		switch (server_id) {
		case 53:
		val = 'http://images.clikpic.com/SuzanneC/images';
		break;
	}
		switch (server_id) {
		case 52:
		val = 'http://tpc22/clikpic/SuzanneC/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/SuzanneC/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/SuzanneC/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 = 'QUALIA PRINTS by Suzanne Crouchman: ' + 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="sue.crouchman@btinternet.com">';
					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="sue.crouchman@btinternet.com">';
				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;
	}
}

			

