window.thumbnails = new Object();
												thumbnails[6395595] = new thumbnail(6395595,'','','0011_thumb.jpg',130, 104,18,'							photo_6395595.html');
												thumbnails[6396051] = new thumbnail(6396051,'','','003_thumb.jpg',130, 163,18,'							photo_6396051.html');
												thumbnails[6396057] = new thumbnail(6396057,'','','005_thumb.jpg',130, 104,18,'							photo_6396057.html');
												thumbnails[6396060] = new thumbnail(6396060,'','','006_thumb.jpg',130, 104,18,'							photo_6396060.html');
												thumbnails[6396065] = new thumbnail(6396065,'','','007_thumb.jpg',130, 104,18,'							photo_6396065.html');
												thumbnails[6396073] = new thumbnail(6396073,'','','008_thumb.jpg',130, 163,18,'							photo_6396073.html');
												thumbnails[6396077] = new thumbnail(6396077,'','','009_thumb.jpg',130, 104,18,'							photo_6396077.html');
												thumbnails[6396097] = new thumbnail(6396097,'','','0101_thumb.jpg',130, 163,18,'							photo_6396097.html');
												thumbnails[537934] = new thumbnail(537934,'41841','Brown\'s','browns2_thumb.jpg',130, 132,18,'							photo_537934.html');
												thumbnails[537938] = new thumbnail(537938,'41841','Dog House','doghouse_thumb.jpg',130, 131,18,'							photo_537938.html');
												thumbnails[537944] = new thumbnail(537944,'41841','Snow Drift','snowdrift_thumb.jpg',130, 131,18,'							photo_537944.html');
												thumbnails[537948] = new thumbnail(537948,'41841','GMC','GMC_thumb.jpg',130, 132,18,'							photo_537948.html');
												thumbnails[537951] = new thumbnail(537951,'125922','Hiada Man','Haidaman_thumb.jpg',130, 132,18,'							photo_537951.html');
												thumbnails[537953] = new thumbnail(537953,'125922','Second Haida Man','haidaman2_thumb.jpg',130, 131,18,'							photo_537953.html');
												thumbnails[537958] = new thumbnail(537958,'125922','Fire Truck','firetruck_thumb.jpg',130, 131,18,'							photo_537958.html');
												thumbnails[537969] = new thumbnail(537969,'41844','Motel','Motel_thumb.jpg',130, 87,18,'							photo_537969.html');
												thumbnails[537971] = new thumbnail(537971,'41844','Morning Quiet','nanbed3_thumb.jpg',130, 86,18,'							photo_537971.html');
												thumbnails[537973] = new thumbnail(537973,'41844','Motel Taps','Moteltaps_thumb.jpg',130, 87,18,'							photo_537973.html');
												thumbnails[537975] = new thumbnail(537975,'41844','Shower Head','Motelshower_thumb.jpg',130, 87,18,'							photo_537975.html');
												thumbnails[537977] = new thumbnail(537977,'41844','Floor','loo floor_thumb.jpg',130, 85,18,'							photo_537977.html');
												thumbnails[537979] = new thumbnail(537979,'41844','Smallest Shower','smallestshower_thumb.jpg',130, 87,18,'							photo_537979.html');
												thumbnails[543032] = new thumbnail(543032,'125922','Port Clem Sunset','portclemset_thumb.jpg',130, 131,18,'							photo_543032.html');
												thumbnails[543033] = new thumbnail(543033,'125922','Queen Charlotte City Sunset','sunset_thumb.jpg',130, 131,18,'							photo_543033.html');
												thumbnails[543041] = new thumbnail(543041,'41841','Robert Service Bank','robertservice_thumb.jpg',130, 135,18,'							photo_543041.html');
												thumbnails[543042] = new thumbnail(543042,'41841','Sloap Street','sloapstreet1_thumb.jpg',130, 131,18,'							photo_543042.html');
												thumbnails[543043] = new thumbnail(543043,'41841','Leaning Shack','leaningshack2_thumb.jpg',130, 132,18,'							photo_543043.html');
												thumbnails[543044] = new thumbnail(543044,'41841','The Flora Dora','floradora_thumb.jpg',130, 131,18,'							photo_543044.html');
												thumbnails[543051] = new thumbnail(543051,'41844','Sea Raven Red','searavenred_thumb.jpg',130, 86,18,'							photo_543051.html');
												thumbnails[543052] = new thumbnail(543052,'41844','Rainbow Inn, Paul','rainbowPaul_thumb.jpg',130, 87,18,'							photo_543052.html');
												thumbnails[607499] = new thumbnail(607499,'41841','Night Street','nightstreet_thumb.jpg',130, 133,18,'							photo_607499.html');
												thumbnails[607502] = new thumbnail(607502,'41841','Klondike Kates','katesnight_thumb.jpg',130, 132,18,'							photo_607502.html');
												thumbnails[607522] = new thumbnail(607522,'41844','Bed','bed_thumb.jpg',130, 131,18,'							photo_607522.html');
												thumbnails[1002133] = new thumbnail(1002133,'125922','Lazy Trees','treeset_thumb.jpg',130, 194,18,'							photo_1002133.html');
												thumbnails[1872933] = new thumbnail(1872933,'41841','Dawson City','dawsonview_thumb.jpg',130, 131,18,'							photo_1872933.html');
												thumbnails[1872955] = new thumbnail(1872955,'41841','Mary\'s Rooms','marysrooms_thumb.jpg',130, 132,18,'							photo_1872955.html');
												thumbnails[1872957] = new thumbnail(1872957,'125922','Stones','stones_thumb.jpg',130, 131,18,'							photo_1872957.html');
												thumbnails[1872959] = new thumbnail(1872959,'125922','Simon and Garf','simonandgarfunkle_thumb.jpg',130, 131,18,'							photo_1872959.html');
												thumbnails[1872983] = new thumbnail(1872983,'41844','Light Shade','cosy_thumb.jpg',130, 86,18,'							photo_1872983.html');
												thumbnails[1872985] = new thumbnail(1872985,'41844','Toronto Taps','ttaps_thumb.jpg',130, 86,18,'							photo_1872985.html');
												thumbnails[1872986] = new thumbnail(1872986,'41844','Crappy Kitchen','crappykitchen_thumb.jpg',130, 87,18,'							photo_1872986.html');
												thumbnails[1872988] = new thumbnail(1872988,'41844','Paul','Topaul_thumb.jpg',130, 87,18,'							photo_1872988.html');
												thumbnails[1872991] = new thumbnail(1872991,'41844','It was a rainy day in Pizzaville','pizzaville_thumb.jpg',130, 87,18,'							photo_1872991.html');
												thumbnails[1872992] = new thumbnail(1872992,'41844','Bad Chicken','india_thumb.jpg',130, 87,18,'							photo_1872992.html');
												thumbnails[3280748] = new thumbnail(3280748,'394367','','flowersrings_thumb.jpg',130, 85,18,'							photo_3280748.html');
												thumbnails[3280750] = new thumbnail(3280750,'394367','','glass_thumb.jpg',130, 198,18,'							photo_3280750.html');
												thumbnails[3280753] = new thumbnail(3280753,'394367','','neck_thumb.jpg',130, 198,18,'							photo_3280753.html');
												thumbnails[3280755] = new thumbnail(3280755,'394367','','holdinghands_thumb.jpg',130, 85,18,'							photo_3280755.html');
												thumbnails[3280940] = new thumbnail(3280940,'200071','','A003 full_thumb.jpg',130, 195,18,'							photo_3280940.html');
												thumbnails[3280941] = new thumbnail(3280941,'200071','','B003_thumb.jpg',130, 47,18,'							photo_3280941.html');
												thumbnails[3280942] = new thumbnail(3280942,'200071','','greentop_thumb.jpg',130, 166,18,'							photo_3280942.html');
												thumbnails[3280947] = new thumbnail(3280947,'200071','','slate_thumb.jpg',130, 87,18,'							photo_3280947.html');
												thumbnails[3280948] = new thumbnail(3280948,'200071','','wood detail_thumb.jpg',130, 87,18,'							photo_3280948.html');
												thumbnails[3280950] = new thumbnail(3280950,'200071','','woodstone_thumb.jpg',130, 132,18,'							photo_3280950.html');
												thumbnails[3280951] = new thumbnail(3280951,'200071','','E024 three angle_thumb.jpg',130, 87,18,'							photo_3280951.html');
												thumbnails[3280953] = new thumbnail(3280953,'200071','','Side Vert_thumb.jpg',130, 195,18,'							photo_3280953.html');
												thumbnails[3283240] = new thumbnail(3283240,'200214','Christo, Cochabamba','CHRIST_thumb.jpg',130, 144,18,'							photo_3283240.html');
												thumbnails[3283243] = new thumbnail(3283243,'200214','Barco, Chapare, Amazon Basin','boat_thumb.jpg',130, 132,18,'							photo_3283243.html');
												thumbnails[3283246] = new thumbnail(3283246,'200214','Bicicleta, Chapare Amazon Basin','bike1_thumb.jpg',130, 129,18,'							photo_3283246.html');
												thumbnails[3283249] = new thumbnail(3283249,'200214','Steamer Wheel, chapare amazon Basin','evil wheel_thumb.jpg',130, 132,18,'							photo_3283249.html');
												thumbnails[3283251] = new thumbnail(3283251,'200214','Salar de Yuni, Bolivia','f4_thumb.jpg',130, 86,18,'							photo_3283251.html');
												thumbnails[3283252] = new thumbnail(3283252,'200214','Salar de Yuni, Bolivia','f5_thumb.jpg',130, 86,18,'							photo_3283252.html');
												thumbnails[3283259] = new thumbnail(3283259,'200214','Chapare, Bolivia','fridge_thumb.jpg',130, 132,18,'							photo_3283259.html');
												thumbnails[3283260] = new thumbnail(3283260,'200214','Tongariki, Isla de pascua, Easter Island, Chile','I de P_thumb.jpg',130, 132,18,'							photo_3283260.html');
												thumbnails[3283262] = new thumbnail(3283262,'200214','Tongariki, Isla de pascua, Easter Island, Chile','I de P2_thumb.jpg',130, 132,18,'							photo_3283262.html');
												thumbnails[3283275] = new thumbnail(3283275,'200214','Tongariki, Isla de pascua, Easter Island, Chile','i de p4_thumb.jpg',130, 86,18,'							photo_3283275.html');
												thumbnails[3283277] = new thumbnail(3283277,'200214','Tiawanako, La Paz','La paz2_thumb.jpg',130, 132,18,'							photo_3283277.html');
												thumbnails[3283286] = new thumbnail(3283286,'200214','Mercado de Brujas, Whitches Market, La Paz','lapaz_thumb.jpg',130, 132,18,'							photo_3283286.html');
												thumbnails[3283288] = new thumbnail(3283288,'200214','Te Pito Kura, Magnetic Spherical Stone, Isla de Pascua','mag stones_thumb.jpg',130, 132,18,'							photo_3283288.html');
												thumbnails[3283290] = new thumbnail(3283290,'200214','Aprenda matematica Mental, Learn Mental Arithmetics, Cochabamba, Bolivia','Mathmatical_thumb.jpg',130, 131,18,'							photo_3283290.html');
												thumbnails[3283299] = new thumbnail(3283299,'200214','Plaza Principal, Cochabamba, Bolivia','PP cholita_thumb.jpg',130, 126,18,'							photo_3283299.html');
												thumbnails[3283300] = new thumbnail(3283300,'200214','Plaza Principal, Cochabamba, Bolivia','PP pigieons_thumb.jpg',130, 132,18,'							photo_3283300.html');
												thumbnails[3283304] = new thumbnail(3283304,'200214','Salt Desert, Salar de Yuni, Bolivia','S de U2_thumb.jpg',130, 102,18,'							photo_3283304.html');
												thumbnails[3654825] = new thumbnail(3654825,'223270','','B5_thumb.jpg',130, 86,18,'							photo_3654825.html');
												thumbnails[3654826] = new thumbnail(3654826,'223270','','B6_thumb.jpg',130, 86,18,'							photo_3654826.html');
												thumbnails[3654830] = new thumbnail(3654830,'223270','','B7_thumb.jpg',130, 86,18,'							photo_3654830.html');
												thumbnails[3654831] = new thumbnail(3654831,'223270','','B8_thumb.jpg',130, 86,18,'							photo_3654831.html');
												thumbnails[3654832] = new thumbnail(3654832,'223270','','B10_thumb.jpg',130, 86,18,'							photo_3654832.html');
												thumbnails[3654833] = new thumbnail(3654833,'223270','','B11_thumb.jpg',130, 86,18,'							photo_3654833.html');
												thumbnails[3654834] = new thumbnail(3654834,'223270','','B12_thumb.jpg',130, 86,18,'							photo_3654834.html');
												thumbnails[3654835] = new thumbnail(3654835,'223270','','B13_thumb.jpg',130, 86,18,'							photo_3654835.html');
												thumbnails[3654836] = new thumbnail(3654836,'223270','','B16_thumb.jpg',130, 86,18,'							photo_3654836.html');
												thumbnails[7290857] = new thumbnail(7290857,'394367','','fb1_thumb.jpg',130, 60,18,'							photo_7290857.html');
												thumbnails[7290860] = new thumbnail(7290860,'394367','','fb11_thumb.jpg',130, 163,18,'							photo_7290860.html');
												thumbnails[7290866] = new thumbnail(7290866,'394367','','fb9_thumb.jpg',130, 163,18,'							photo_7290866.html');
												thumbnails[7290874] = new thumbnail(7290874,'394367','','fb2_thumb.jpg',130, 104,18,'							photo_7290874.html');
												thumbnails[7290879] = new thumbnail(7290879,'394367','','003_1160C874-1EC9-DFB6-093DD4181AF513C0_thumb.jpg',130, 163,18,'							photo_7290879.html');
												thumbnails[7290880] = new thumbnail(7290880,'394367','','006_116437A3-1EC9-DFB6-0940318761040CFE_thumb.jpg',130, 104,18,'							photo_7290880.html');
												thumbnails[7290881] = new thumbnail(7290881,'394367','','009_11676F43-1EC9-DFB6-09752BC3172C628C_thumb.jpg',130, 104,18,'							photo_7290881.html');
												thumbnails[7290882] = new thumbnail(7290882,'394367','','008_116AD1A9-1EC9-DFB6-09DC30245CA23012_thumb.jpg',130, 163,18,'							photo_7290882.html');
												thumbnails[4440006] = new thumbnail(4440006,'259664','Using Fabiola’s recipe','1_book_thumb.jpg',130, 86,18,'							photo_4440006.html');
												thumbnails[4440007] = new thumbnail(4440007,'259664','Too many cooks?','2_legs_thumb.jpg',130, 86,18,'							photo_4440007.html');
												thumbnails[4440009] = new thumbnail(4440009,'259664','Meats','3_meat_thumb.jpg',130, 86,18,'							photo_4440009.html');
												thumbnails[4440011] = new thumbnail(4440011,'259664','Dough','4_dough_thumb.jpg',130, 86,18,'							photo_4440011.html');
												thumbnails[4440012] = new thumbnail(4440012,'259664','Eggs & Olives','5_eggs_thumb.jpg',130, 86,18,'							photo_4440012.html');
												thumbnails[4440013] = new thumbnail(4440013,'259664','Too many tasters?','6_hands_thumb.jpg',130, 86,18,'							photo_4440013.html');
												thumbnails[4440015] = new thumbnail(4440015,'259664','Spill','7_spill_thumb.jpg',130, 195,18,'							photo_4440015.html');
												thumbnails[4440017] = new thumbnail(4440017,'259664','Pans','8_pans_thumb.jpg',130, 86,18,'							photo_4440017.html');
												thumbnails[4440018] = new thumbnail(4440018,'259664','Filling','9_filling_thumb.jpg',130, 86,18,'							photo_4440018.html');
												thumbnails[4440019] = new thumbnail(4440019,'259664','Skilled hands making','10_making_thumb.jpg',130, 86,18,'							photo_4440019.html');
												thumbnails[4440020] = new thumbnail(4440020,'259664','Saltena\'s','11_cooked_thumb.jpg',130, 86,18,'							photo_4440020.html');

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  					galleries[125922] = new gallery(125922,'1872959,1872957,1002133,543033,543032,537958,537953,537951','Haida Gwaii, British Columbia','gallery',[537951,537953,537958,543032,543033,1002133,1872957,1872959],0, 1, '125921', '																																																																																																							gallery_125922.html',0,0);
				  					galleries[394367] = new gallery(394367,'7290882,7290881,7290880,7290879,7290874,7290866,7290860,7290857,3280755,3280753','Wedding Photography','gallery',[3280748,3280750,3280753,3280755,7290857,7290860,7290866,7290874,7290879,7290880,7290881,7290882],0, 1, '', '																																																																																																							gallery_394367.html',0,0);
				  					galleries[41841] = new gallery(41841,'543043','Dawson City, Yukon','gallery',[537934,537938,537944,537948,543041,543042,543043,543044,607499,607502,1872933,1872955],0, 1, '125921', '																																																																																																							gallery_41841.html',0,0);
				  					galleries[125921] = new gallery(125921,'543043','Canadian Documentary Travel Photography','gallery',[],0, 1, '', '																																																																																																							gallery_125921.html',0,0);
				  					galleries[200214] = new gallery(200214,'3283304,3283300,3283299,3283290,3283288,3283286,3283277,3283275,3283262,3283260','South American Travel Documentary Photography','gallery',[3283240,3283243,3283246,3283249,3283251,3283252,3283259,3283260,3283262,3283275,3283277,3283286,3283288,3283290,3283299,3283300,3283304],0, 1, '', '																																																																																																							gallery_200214.html',0,0);
				  					galleries[259664] = new gallery(259664,'4440020,4440019,4440018,4440017,4440015,4440013,4440012,4440011,4440009,4440007','Saltena','gallery',[4440006,4440007,4440009,4440011,4440012,4440013,4440015,4440017,4440018,4440019,4440020],0, 1, '', '																																																																																																							gallery_259664.html',0,0);
				  					galleries[41844] = new gallery(41844,'1872992,1872991,1872988,1872986,1872985,1872983,607522,543052,543051,537979','Motel','gallery',[537969,537971,537973,537975,537977,537979,543051,543052,607522,1872983,1872985,1872986,1872988,1872991,1872992],0, 1, '', '																																																																																																							gallery_41844.html',0,0);
				  					galleries[223270] = new gallery(223270,'3654836,3654835,3654834,3654833,3654832,3654831,3654830,3654826,3654825','Interior Decorating Images','gallery',[3654825,3654826,3654830,3654831,3654832,3654833,3654834,3654835,3654836],0, 1, '', '																																																																																																							gallery_223270.html',0,0);
				  					galleries[200071] = new gallery(200071,'3280953,3280951,3280950,3280948,3280947,3280942,3280941,3280940','Architecture Photography ','gallery',[3280940,3280941,3280942,3280947,3280948,3280950,3280951,3280953],0, 1, '', '																																																																																																							gallery_200071.html',0,0);
/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = new Object();
imageSets[1] = '7290882,7290881,7290880,7290879,7290874,7290866,7290860,7290857,6396097,6396077,6396073,6396065,6396060,6396057,6396051,6395595,4440020,4440019,4440018,4440017,4440015,4440013,4440012,4440011,4440009,4440007,4440006,3654836,3654835,3654834,3654833,3654832,3654831,3654830,3654826,3654825,3283304,3283300,3283299,3283290,3283288,3283286,3283277,3283275,3283262,3283260,3283259,3283252,3283251,3283249';
imageSets[2] = '543043';
imageSets[3] = '7290882,7290881,7290880,7290879,7290874,7290866,7290860,7290857,6396097,6396077,6396073,6396065,6396060,6396057,6396051,6395595,4440020,4440019,4440018,4440017,4440015,4440013,4440012,4440011,4440009,4440007,4440006,3654836,3654835,3654834,3654833,3654832,3654831,3654830,3654826,3654825,3283304,3283300,3283299,3283290,3283288,3283286,3283277,3283275,3283262,3283260,3283259,3283252,3283251,3283249';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/hayleyrobinson/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/hayleyrobinson/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/hayleyrobinson/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/hayleyrobinson/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/hayleyrobinson/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/hayleyrobinson/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/hayleyrobinson/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/hayleyrobinson/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/hayleyrobinson/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/hayleyrobinson/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/hayleyrobinson/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/hayleyrobinson/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/hayleyrobinson/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/hayleyrobinson/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/hayleyrobinson/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://admin2.clikpic.com/hayleyrobinson/images';
		break;
	}
		switch (server_id) {
		case 33:
		val = 'http://www8.clikpic.com/hayleyrobinson/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/hayleyrobinson/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/hayleyrobinson/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/hayleyrobinson/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/hayleyrobinson/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/hayleyrobinson/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 = 'Black White Silver 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> 							' + (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 + '<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;
	}
}

		

