window.thumbnails = new Object();
												thumbnails[2999288] = new thumbnail(2999288,'','','Vivien 010 SC comp_thumb.jpg',130, 173,5,'															#');
												thumbnails[5269571] = new thumbnail(5269571,'','','sarah_thumb.jpg',130, 173,5,'															#');
												thumbnails[5801190] = new thumbnail(5801190,'','','Copy_of_Erin_060_proc_sc_thumb.jpg',130, 87,5,'															#');
												thumbnails[7111535] = new thumbnail(7111535,'','','custom_order_thumb.jpg',130, 87,5,'															#');
												thumbnails[2749152] = new thumbnail(2749152,'172271','','Child portrait C 8x12 SC2_thumb.jpg',130, 87,5,'																			photo_2749152.html');
												thumbnails[2749155] = new thumbnail(2749155,'172271','','Child Portrait B 8x12 SC_thumb.jpg',130, 195,5,'																			photo_2749155.html');
												thumbnails[2749205] = new thumbnail(2749205,'172272','','Cloisters D 8x12 SC_thumb.jpg',130, 195,5,'																			photo_2749205.html');
												thumbnails[2749233] = new thumbnail(2749233,'172272','','Vivien B 8x12 SC_thumb.jpg',130, 195,5,'																			photo_2749233.html');
												thumbnails[2749385] = new thumbnail(2749385,'172611','Blush','Pink Flower 8x12 SC_thumb.jpg',130, 195,5,'																			photo_2749385.html');
												thumbnails[2749391] = new thumbnail(2749391,'172611','Bunch','Carrots 8x12 SC_thumb.jpg',130, 195,5,'																			photo_2749391.html');
												thumbnails[2749395] = new thumbnail(2749395,'172611','Too many peas?','Peapod Too many peas 8x12 SC_thumb.jpg',130, 87,5,'																			photo_2749395.html');
												thumbnails[2749399] = new thumbnail(2749399,'172611','Red Pepper','Red Pepper on Black 8x12 SC_thumb.jpg',130, 87,5,'																			photo_2749399.html');
												thumbnails[2749422] = new thumbnail(2749422,'172611','On the vine','Vine tomatoes 8x12 SC_thumb.jpg',130, 87,5,'																			photo_2749422.html');
												thumbnails[2749426] = new thumbnail(2749426,'172611','Vivid','Coloured Plates 8x12 SC_thumb.jpg',130, 195,5,'																			photo_2749426.html');
												thumbnails[2749454] = new thumbnail(2749454,'172618','Kibble Palace, Glasgow','Botanic Gardens 8x12 SC]_thumb.jpg',130, 87,5,'																			photo_2749454.html');
												thumbnails[2749456] = new thumbnail(2749456,'172618','Liverpool docks','Liverpool 8x12 SC_thumb.jpg',130, 195,5,'																			photo_2749456.html');
												thumbnails[2749463] = new thumbnail(2749463,'172618','NYC','Top of the Rock 8x12 SC_thumb.jpg',130, 195,5,'																			photo_2749463.html');
												thumbnails[2749466] = new thumbnail(2749466,'172618','Phuket, Thailand','Thailand 8x12 SC_thumb.jpg',130, 87,5,'																			photo_2749466.html');
												thumbnails[2749470] = new thumbnail(2749470,'172618','Taxi ','New York Taxi 8x10 SC_thumb.jpg',130, 104,5,'																			photo_2749470.html');
												thumbnails[2749512] = new thumbnail(2749512,'172618','Central Park, NYC','Central Park 8x10 SC_thumb.jpg',130, 104,5,'																			photo_2749512.html');
												thumbnails[2749513] = new thumbnail(2749513,'172618','Rouken Glen Park, Glasgow','Rouken Glen 8x12 SC_thumb.jpg',130, 195,5,'																			photo_2749513.html');
												thumbnails[2749514] = new thumbnail(2749514,'172618','Glasgow Cathedral','Glasgow Cathedral 8x12 SC_thumb.jpg',130, 190,5,'																			photo_2749514.html');
												thumbnails[2749521] = new thumbnail(2749521,'184784','','Beauford 8x12 SC_thumb.jpg',130, 87,5,'																			photo_2749521.html');
												thumbnails[2749552] = new thumbnail(2749552,'172618','Aberdeen Beach','Umbrella 8x12 SC_thumb.jpg',130, 195,5,'																			photo_2749552.html');
												thumbnails[2754127] = new thumbnail(2754127,'184784','','rob 030908 proc SC_thumb.jpg',130, 97,5,'																			photo_2754127.html');
												thumbnails[2754130] = new thumbnail(2754130,'184784','','Viv Rob 003 proc SC_thumb.jpg',130, 195,5,'																			photo_2754130.html');
												thumbnails[2758554] = new thumbnail(2758554,'172272','','Charlee 035 proc SC_thumb.jpg',130, 195,5,'																			photo_2758554.html');
												thumbnails[2758569] = new thumbnail(2758569,'184784','','Viv Rob 022 proc SC_thumb.jpg',130, 195,5,'																			photo_2758569.html');
												thumbnails[2758570] = new thumbnail(2758570,'184784','','Scott guitar SC_thumb.jpg',130, 182,5,'																			photo_2758570.html');
												thumbnails[2782590] = new thumbnail(2782590,'172611','Lily','Lily proc SC_thumb.jpg',130, 87,5,'																			photo_2782590.html');
												thumbnails[2999127] = new thumbnail(2999127,'172272','','Julie007 proc_pp SC_thumb.jpg',130, 173,5,'																			photo_2999127.html');
												thumbnails[2999130] = new thumbnail(2999130,'172272','','Julie016 proc_pp SC_thumb.jpg',130, 87,5,'																			photo_2999130.html');
												thumbnails[2999357] = new thumbnail(2999357,'184784','','Copy of Ainsley final SC_thumb.jpg',130, 159,5,'																			photo_2999357.html');
												thumbnails[3310710] = new thumbnail(3310710,'172271','','Adam_thumb.jpg',130, 195,5,'																			photo_3310710.html');
												thumbnails[3310719] = new thumbnail(3310719,'172271','','Jake_thumb.jpg',130, 195,5,'																			photo_3310719.html');
												thumbnails[3310936] = new thumbnail(3310936,'172271','','Dylan 7 proc 5x7 SC_thumb.jpg',130, 182,5,'																			photo_3310936.html');
												thumbnails[3310939] = new thumbnail(3310939,'172272','','Group 2 b colour proc texture SC_thumb.jpg',130, 195,5,'																			photo_3310939.html');
												thumbnails[3310940] = new thumbnail(3310940,'172272','','Group 3 c colour proc SC_thumb.jpg',130, 195,5,'																			photo_3310940.html');
												thumbnails[3310942] = new thumbnail(3310942,'172272','','Group 4 j colour SC_thumb.jpg',130, 87,5,'																			photo_3310942.html');
												thumbnails[3310946] = new thumbnail(3310946,'172272','','Group 6 a  proc SC_thumb.jpg',130, 195,5,'																			photo_3310946.html');
												thumbnails[3310957] = new thumbnail(3310957,'172611','Autumn','Autumn leaves filmgrain SC_thumb.jpg',130, 195,5,'																			photo_3310957.html');
												thumbnails[3310958] = new thumbnail(3310958,'172611','Blossom','Blossom proc SC_thumb.jpg',130, 87,5,'																			photo_3310958.html');
												thumbnails[3311032] = new thumbnail(3311032,'172611','Cupcake','Cupcake proc SC_thumb.jpg',130, 195,5,'																			photo_3311032.html');
												thumbnails[3311049] = new thumbnail(3311049,'172618','Altanta, Georgia','buildings 4 proc SC_thumb.jpg',130, 195,5,'																			photo_3311049.html');
												thumbnails[3311051] = new thumbnail(3311051,'172618','New York City','NY buildings 8x12 SC_thumb.jpg',130, 195,5,'																			photo_3311051.html');
												thumbnails[3311061] = new thumbnail(3311061,'172611','Tulips','Tulip SC comp_thumb.jpg',130, 104,5,'																			photo_3311061.html');
												thumbnails[3311081] = new thumbnail(3311081,'172611','Orchid','Orchid 2 proc SC_thumb.jpg',130, 87,5,'																			photo_3311081.html');
												thumbnails[3311082] = new thumbnail(3311082,'172611','Fork & Knife','Plate 2 proc SC_thumb.jpg',130, 130,5,'																			photo_3311082.html');
												thumbnails[3533077] = new thumbnail(3533077,'172272','','VivienMono015_SC_thumb.jpg',130, 87,5,'																			photo_3533077.html');
												thumbnails[3533078] = new thumbnail(3533078,'172272','','VivienMono018_pp_SC_thumb.jpg',130, 195,5,'																			photo_3533078.html');
												thumbnails[3533079] = new thumbnail(3533079,'172272','','VivienMono021_proc_pp_SC_thumb.jpg',130, 87,5,'																			photo_3533079.html');
												thumbnails[3533081] = new thumbnail(3533081,'172272','','VivienMono024_proc_SC_thumb.jpg',130, 195,5,'																			photo_3533081.html');
												thumbnails[3533106] = new thumbnail(3533106,'184784','','namebadge019_processed_rotated_SC_thumb.jpg',130, 87,5,'																			photo_3533106.html');
												thumbnails[4074373] = new thumbnail(4074373,'172272','','Sara019_thumb.jpg',130, 87,5,'																			photo_4074373.html');
												thumbnails[4074380] = new thumbnail(4074380,'172272','','Sara026_thumb.jpg',130, 195,5,'																			photo_4074380.html');
												thumbnails[4074381] = new thumbnail(4074381,'172272','','Sara030_thumb.jpg',130, 195,5,'																			photo_4074381.html');
												thumbnails[4179805] = new thumbnail(4179805,'296490','','28Mar09014_proc_SC_thumb.jpg',130, 98,5,'																			photo_4179805.html');
												thumbnails[4179806] = new thumbnail(4179806,'296490','','28Mar09028_proc_BW_SC_thumb.jpg',130, 87,5,'																			photo_4179806.html');
												thumbnails[4179807] = new thumbnail(4179807,'296490','','28Mar09031_proc_SC_thumb.jpg',130, 98,5,'																			photo_4179807.html');
												thumbnails[4179809] = new thumbnail(4179809,'296490','','28Mar09079_proc_SC_thumb.jpg',130, 195,5,'																			photo_4179809.html');
												thumbnails[4179810] = new thumbnail(4179810,'172271','','28Mar09058_proc_BW_SC_thumb.jpg',130, 87,5,'																			photo_4179810.html');
												thumbnails[4474508] = new thumbnail(4474508,'172272','','Laura027_BW_thumb.jpg',130, 87,5,'																			photo_4474508.html');
												thumbnails[4533031] = new thumbnail(4533031,'184784','','WeddingDress002_proc_SC_thumb.jpg',130, 195,5,'																			photo_4533031.html');
												thumbnails[4533034] = new thumbnail(4533034,'184784','','WeddingDress005_proc_SC_thumb.jpg',130, 195,5,'																			photo_4533034.html');
												thumbnails[4533036] = new thumbnail(4533036,'184784','','WeddingDress008_proc_SC_thumb.jpg',130, 195,5,'																			photo_4533036.html');
												thumbnails[5182921] = new thumbnail(5182921,'172271','','Copy_of_28Jun09015_proc_SC_comp_thumb.jpg',130, 195,5,'																			photo_5182921.html');
												thumbnails[5182929] = new thumbnail(5182929,'296490','','Copy_of_28Jun09023_proc_SC_comp_thumb.jpg',130, 195,5,'																			photo_5182929.html');
												thumbnails[5182976] = new thumbnail(5182976,'172271','','Rhys001_SC_thumb.jpg',130, 182,5,'																			photo_5182976.html');
												thumbnails[5182978] = new thumbnail(5182978,'172271','','Rhys004_SC_thumb.jpg',130, 93,5,'																			photo_5182978.html');
												thumbnails[5267112] = new thumbnail(5267112,'172271','','Cynthia027_proc_SC_72dpi_thumb.jpg',130, 130,5,'																			photo_5267112.html');
												thumbnails[5267113] = new thumbnail(5267113,'172271','','Cynthia046_proc_BW_SC_72dpi_thumb.jpg',130, 87,5,'																			photo_5267113.html');
												thumbnails[5268515] = new thumbnail(5268515,'184784','','Birthday_Bouquet_2_proc_SC_thumb.jpg',130, 87,5,'																			photo_5268515.html');
												thumbnails[5268516] = new thumbnail(5268516,'184784','','Birthday_Bouquet_proc_SC_thumb.jpg',130, 195,5,'																			photo_5268516.html');
												thumbnails[5268536] = new thumbnail(5268536,'184784','','Beauford_3_proc_SC_thumb.jpg',130, 87,5,'																			photo_5268536.html');
												thumbnails[5268538] = new thumbnail(5268538,'184784','','Beauford_7_proc_SC_thumb.jpg',130, 87,5,'																			photo_5268538.html');
												thumbnails[5323977] = new thumbnail(5323977,'172271','','021_SC_thumb.jpg',130, 173,5,'																			photo_5323977.html');
												thumbnails[5323979] = new thumbnail(5323979,'296490','','006_SC_thumb.jpg',130, 173,5,'																			photo_5323979.html');
												thumbnails[5323980] = new thumbnail(5323980,'296490','','029_SC_thumb.jpg',130, 98,5,'																			photo_5323980.html');
												thumbnails[5635258] = new thumbnail(5635258,'172271','','Lucy029_proc_sc_thumb.jpg',130, 87,5,'																			photo_5635258.html');
												thumbnails[5635261] = new thumbnail(5635261,'172271','','Lucy043_proc_BW_sc_thumb.jpg',130, 195,5,'																			photo_5635261.html');
												thumbnails[5635264] = new thumbnail(5635264,'296490','','Fi_004_proc_comp_SCv2_thumb.jpg',130, 195,5,'																			photo_5635264.html');
												thumbnails[5635268] = new thumbnail(5635268,'296490','','Copy_of_Fi_001_proc_comp_sc_thumb.jpg',130, 87,5,'																			photo_5635268.html');
												thumbnails[5801157] = new thumbnail(5801157,'172271','','Rory_040_proc_touched_up_thumb.jpg',130, 87,5,'																			photo_5801157.html');
												thumbnails[5801158] = new thumbnail(5801158,'172271','','Rory_043_proc_BW_blue_star_thumb.jpg',130, 87,5,'																			photo_5801158.html');
												thumbnails[5801168] = new thumbnail(5801168,'296490','','Copy_of_Fi_Apr2010_007_proc_sc_thumb.jpg',130, 87,5,'																			photo_5801168.html');
												thumbnails[5801177] = new thumbnail(5801177,'172611','Sea of Crayons','Copy_of_28Mar10_041_proc_sc_thumb.jpg',130, 87,5,'																			photo_5801177.html');
												thumbnails[6138216] = new thumbnail(6138216,'296490','','HarryRuby_005_proc_pp_comp_sc_thumb.jpg',130, 87,5,'																			photo_6138216.html');
												thumbnails[6138217] = new thumbnail(6138217,'296490','','HarryRuby_006_proc_pp_comp_sc_thumb.jpg',130, 87,5,'																			photo_6138217.html');
												thumbnails[6138218] = new thumbnail(6138218,'296490','','HarryRuby_030_proc_pp_comp_sc_thumb.jpg',130, 195,5,'																			photo_6138218.html');
												thumbnails[6138223] = new thumbnail(6138223,'172271','','Lucan_007_FINAL_seaweed_comp_sc_thumb.jpg',130, 74,5,'																			photo_6138223.html');
												thumbnails[6138224] = new thumbnail(6138224,'172271','','Lucan_008_FINAL_high_key_BW_comp_sc_thumb.jpg',130, 87,5,'																			photo_6138224.html');
												thumbnails[6138227] = new thumbnail(6138227,'172611','Gold','June2010_002_proc_sc_thumb.jpg',130, 92,5,'																			photo_6138227.html');
												thumbnails[6138228] = new thumbnail(6138228,'172611','Killer Heels','June2010_005_proc_sc_thumb.jpg',130, 89,5,'																			photo_6138228.html');
												thumbnails[3310716] = new thumbnail(3310716,'172272','','Alison_thumb.jpg',130, 195,5,'																			photo_3310716.html');
												thumbnails[3310728] = new thumbnail(3310728,'172611','Delicate','Pink Rose proc SC_thumb.jpg',130, 195,5,'																			photo_3310728.html');
												thumbnails[2749151] = new thumbnail(2749151,'172271','','Child portrait monochrome SC2_thumb.jpg',130, 93,5,'																			photo_2749151.html');
												thumbnails[2823463] = new thumbnail(2823463,'172272','','Alison 006_pp proc SC comp_thumb.jpg',130, 195,5,'																			photo_2823463.html');
												thumbnails[2749387] = new thumbnail(2749387,'172611','Tulips','Tulip Pink 8x12 SC_thumb.jpg',130, 196,5,'																			photo_2749387.html');
												thumbnails[2749392] = new thumbnail(2749392,'172611','Top to Toe','Peapod Top to Toe 8x12 SC_thumb.jpg',130, 87,5,'																			photo_2749392.html');
												thumbnails[2749397] = new thumbnail(2749397,'172611','Pears','Three Pears 8x12 SC_thumb.jpg',130, 195,5,'																			photo_2749397.html');

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  					galleries[172271] = new gallery(172271,'2749155','Babies & Children','gallery',[2749152,2749155,3310710,3310719,3310936,4179810,5182921,5182976,5182978,5267112,5267113,5323977,5635258,5635261,5801157,5801158,6138223,6138224,2749151],0, 0, '', '																																																																																																							gallery_172271.html',0,0);
				  					galleries[296490] = new gallery(296490,'4179809','Families','gallery',[4179805,4179806,4179807,4179809,5182929,5323979,5323980,5635264,5635268,5801168,6138216,6138217,6138218],0, 0, '', '																																																																																																							gallery_296490.html',0,0);
				  					galleries[172272] = new gallery(172272,'4074380','Fashion & Beauty','gallery',[2749205,2749233,2758554,2999127,2999130,3310939,3310940,3310942,3310946,3533077,3533078,3533079,3533081,4074373,4074380,4074381,4474508,3310716,2823463],0, 0, '', '																																																																																																							gallery_172272.html',0,0);
				  					galleries[184784] = new gallery(184784,'5268516','Commercial','gallery',[2749521,2754127,2754130,2758569,2758570,2999357,3533106,4533031,4533034,4533036,5268515,5268516,5268536,5268538],0, 0, '', '																																																																																																							gallery_184784.html',0,0);
				  					galleries[172611] = new gallery(172611,'2749391','Still Life','gallery',[2749385,2749391,2749395,2749399,2749422,2749426,2782590,3310957,3310958,3311032,3311061,3311081,3311082,5801177,6138227,6138228,3310728,2749387,2749392,2749397],0, 0, '', '																																																																																																							gallery_172611.html',0,0);
				  					galleries[172618] = new gallery(172618,'2749463','Around the Globe','gallery',[2749454,2749456,2749463,2749466,2749470,2749512,2749513,2749514,2749552,3311049,3311051],0, 0, '', '																																																																																																							gallery_172618.html',0,0);
/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = new Object();
imageSets[1] = '5268536,5268516,5267113,5182978,5182921,4533034,4179809,4179806,4074381,4074373,3533106,3310936,3310728,3310716,3310710,2999357,2749454,2749399,2749397,2749395,2749391,2749387,2749155,2749152,2749151';
imageSets[2] = '7111535,5268516,4179809,4074380,2749463,2749391,2749155';
imageSets[3] = '5267113,5267112,5182978,5182976,5182929,5182921,4533036,4533034,4533031,4474508,4179810,4179809,4179807,4179806,4179805,4074381,4074380,4074373,3533106,3533081,3533079,3533078,3533077,3311082,3311081,3311061,3311051,3311049,3311032,3310958,3310957,3310946,3310942,3310940,3310939,3310936,3310728,3310719,3310716,3310710,2999357,2999288';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/sarahconnolly82/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/sarahconnolly82/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/sarahconnolly82/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/sarahconnolly82/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/sarahconnolly82/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/sarahconnolly82/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/sarahconnolly82/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/sarahconnolly82/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/sarahconnolly82/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/sarahconnolly82/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/sarahconnolly82/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/sarahconnolly82/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/sarahconnolly82/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/sarahconnolly82/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/sarahconnolly82/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://admin2.clikpic.com/sarahconnolly82/images';
		break;
	}
		switch (server_id) {
		case 33:
		val = 'http://www8.clikpic.com/sarahconnolly82/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/sarahconnolly82/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/sarahconnolly82/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/sarahconnolly82/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/sarahconnolly82/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/sarahconnolly82/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:'',
                    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 (!basic) {
    if (op.updateHash && clik.getIDInUrl(location.href,'photo') != op.nextPhoto.id) {
		clik.changeHash('photos_id=' + op.nextPhoto.id, true);
    }
				
    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.$title.length > 0) {
  		op.$title.fadeGalleryDetails(photoCaption, op.speed);
    }
        if (op.updateDocumentTitle) {
						  document.title = 'Sarah Connolly Photography: ' + photoCaption;
			    }
        if (op.$detail.length > 0) {
      temp = op.nextPhoto.fnGetImageDetails();
	    op.$detail.fadeGalleryDetails(temp, op.speed, function(){
	    var options = {};	    	      	      resizePhotoInfo(options);
        if (typeof(backgrounds) != 'undefined' && op.nextPhoto == backgrounds[op.nextPhoto.id]) {
  	      toggleAddToCartConfirm(backgrounds);
  	    } else if (typeof(photos) != 'undefined' && op.nextPhoto == photos[op.nextPhoto.id]) {
  	      toggleAddToCartConfirm(photos);
  	    }
	    });
    }
        if (!op.speed) {      clik.doColumnResize(false, op.$photo.add(op.$detail).add(op.$title));    }        
    return html;			}
	else {
				
		window.location = 'photo_' + nextPhoto.id + '.html';
	}
		
}

/***************************************************************************
* Toggle add to cart confirmation element and set up the click event for   *
* the 'Add to cart' button.                                                *
***************************************************************************/
function toggleAddToCartConfirm(array){
  if (typeof(array) !== 'object') {
    array = photos;
  }
	if($('#paymentConfirm').length > 0){
		$('#paymentConfirm').hide();
		$('#paymentAddButton')
		.unbind()
		.click(function(){
						form = document.getElementById('paymentForm');
			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').text('Item added to cart').show();}
				else{
					$('#paymentConfirm').text('Item added to cart').fadeIn();
					dspOrderDetails(form.site.value);
				}
			}
			else{
				$('#paymentConfirm').text('Item not added - check cookies are enabled in your browser.').fadeIn();
			}
		});
	}
}
/***************************************************************************
* Get payment info for image - add as 'method' to photo object             *
***************************************************************************/
photo.prototype.fnGetImageDetails = function(){
	var temp = '';
	if (this.description != '') {
		temp = temp +  '<p id="imageDescription">' + this.description + '</p>';
	}
		if (this.photo_ref != '') {
		temp = temp + '<p class="imageinfo" id="imageRef"><strong>Ref: </strong>' + this.photo_ref + '</p>';
	}
		if (this.takendate != '') {
				
		temp = temp + '<p class="imageinfo" id="imageDate"><strong>Date: </strong>' + this.takendate + '</p>';
	}
	
	if (this.location != '') {
				
		temp = temp + '<p class="imageinfo" id="imageLocation"><strong>Location: </strong>' +  this.location + '</p>';
	}
	
	if (this.photographer != '') {
				
		temp = temp + '<p class="imageinfo" id="imagePhotographer"><strong>Photographer: </strong>' + this.photographer + '</p>';
	}
					
				if (temp != '') {
		temp = temp + '<div class="spacer"></div>';
	}
	return temp;
};

/***************************************************************************
* Get payment info for image - add as 'method' to photo object             *
***************************************************************************/
photo.prototype.fnGetPaymentInfo = function(){
	var temp = '';
	if (this.item_price !== '') {
				temp = temp + '<p>Order this print:</p>';
				temp = temp + '<p class="imageinfo" id="imagePrice"><strong>' + this.purchase_instruction + '</strong> 				&pound;' + (this.item_price).toFixed(2) + '</p>';
		var item_name  = this.purchase_instruction;
		var amount = (this.item_price).toFixed(2);
		var item_option  = 0;
	}
	else if (this.payment_groups_id !== '') {
		temp = temp + '<p>Buy this print online:</p>';
				temp = temp + '<form id="paymentOptions" style="margin:0px;border:0px;" name="paymentOptions">';
											temp = temp + '<select class="paymentlink" name="payment_options_id" onchange="updateItemValues(document.forms.paymentForm,this.form.payment_options_id.options[this.form.payment_options_id.options.selectedIndex].value);">';
				
		temp = temp + getPaymentOptions(this.payment_groups_id);
		temp = temp + '</select>';
		temp = 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 = temp + '<form id="paymentForm" style="margin:0px;border:0px;" name="paymentForm" target="_blank" action="https://www.paypal.com/cgi-bin/webscr" method="post">';
	temp = 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 = temp + '<input type="hidden" name="cmd" value="_cart">';
	temp = temp + '<input type="hidden" name="business" value="sarahmconnolly@hotmail.co.uk">';
	temp = temp + '<input type="hidden" name="currency_code" value="GBP">';
	temp = temp + '<input type="hidden" name="add" value="1">';
					temp = temp + '<input type="hidden" name="amount" value="'+amount+'">';
	temp = temp + '<input type="hidden" name="item_number" value="'+ref+'">';
					temp = temp + '<input type=\"Submit\" value=\"Add to cart\" id=\"paymentAddButton\" class=\"button\" onmouseover=\"this.className=\'buttonHi\';\" onmouseout=\"this.className=\'button\';\">';
									temp = temp + '</form>';
								temp = temp + '<form id="paymentCartForm" style="margin:0px;" name="paymentCartForm" target="_blank" action="https://www.paypal.com/cgi-bin/webscr" method="post">';
	temp = temp + '<input type="hidden" name="cmd" value="_cart">';
	temp = temp + '<input type="hidden" name="business" value="sarahmconnolly@hotmail.co.uk">';
	temp = temp + '<input type="hidden" name="display" value="1">';
	temp = temp + '<input type=\"Submit\" value=\"View cart\" id=\"paymentViewButton\" class=\"button\" onmouseover=\"this.className=\'buttonHi\';\" onmouseout=\"this.className=\'button\';\">';
	temp = temp + '</form>';
							temp = 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 + ' | ';
				}
				temp = temp + '<a href="' + galleries[i].section_code + '_' + galleries[i].id + '.html">' + galleries[i].title + '</a>';
			}
		}
		document.all.galleryLinks.innerHTML = 'Other galleries: ' + temp;
	}
}

		

