window.thumbnails = new Object();
												thumbnails[683216] = new thumbnail(683216,'52262','','00041_thumb.jpg',130, 87,15,'							photo_683216.html');
												thumbnails[683220] = new thumbnail(683220,'52262','','0007_thumb.jpg',130, 87,15,'							photo_683220.html');
												thumbnails[683224] = new thumbnail(683224,'52262','','0011_thumb.jpg',130, 87,15,'							photo_683224.html');
												thumbnails[683232] = new thumbnail(683232,'52262','','0002_thumb.jpg',130, 195,15,'							photo_683232.html');
												thumbnails[683236] = new thumbnail(683236,'52262','','0015_thumb.jpg',130, 195,15,'							photo_683236.html');
												thumbnails[683238] = new thumbnail(683238,'52262','','0017_thumb.jpg',130, 195,15,'							photo_683238.html');
												thumbnails[683239] = new thumbnail(683239,'52262','','0018_thumb.jpg',130, 87,15,'							photo_683239.html');
												thumbnails[683651] = new thumbnail(683651,'52262','','0027_thumb.jpg',130, 87,15,'							photo_683651.html');
												thumbnails[683655] = new thumbnail(683655,'52262','','0028_thumb.jpg',130, 195,15,'							photo_683655.html');
												thumbnails[683660] = new thumbnail(683660,'52262','','0031_thumb.jpg',130, 87,15,'							photo_683660.html');
												thumbnails[683665] = new thumbnail(683665,'52262','','0033_thumb.jpg',130, 195,15,'							photo_683665.html');
												thumbnails[683672] = new thumbnail(683672,'52262','','0037_thumb.jpg',130, 87,15,'							photo_683672.html');
												thumbnails[683679] = new thumbnail(683679,'52262','','0040_thumb.jpg',130, 87,15,'							photo_683679.html');
												thumbnails[683682] = new thumbnail(683682,'52262','','0042_thumb.jpg',130, 195,15,'							photo_683682.html');
												thumbnails[683685] = new thumbnail(683685,'52262','','0044_thumb.jpg',130, 195,15,'							photo_683685.html');
												thumbnails[683690] = new thumbnail(683690,'52262','','0047_thumb.jpg',130, 86,15,'							photo_683690.html');
												thumbnails[684614] = new thumbnail(684614,'52359','','00051_thumb.jpg',130, 195,15,'							photo_684614.html');
												thumbnails[684616] = new thumbnail(684616,'52359','','00071_thumb.jpg',130, 195,15,'							photo_684616.html');
												thumbnails[684619] = new thumbnail(684619,'52359','','00101_thumb.jpg',130, 195,15,'							photo_684619.html');
												thumbnails[684660] = new thumbnail(684660,'52359','','00131_thumb.jpg',130, 87,15,'							photo_684660.html');
												thumbnails[684664] = new thumbnail(684664,'52359','','00171_thumb.jpg',130, 195,15,'							photo_684664.html');
												thumbnails[684669] = new thumbnail(684669,'52359','','00201_thumb.jpg',130, 87,15,'							photo_684669.html');
												thumbnails[684672] = new thumbnail(684672,'52359','','00212_thumb.jpg',130, 171,15,'							photo_684672.html');
												thumbnails[684674] = new thumbnail(684674,'52359','','00231_thumb.jpg',130, 85,15,'							photo_684674.html');
												thumbnails[684681] = new thumbnail(684681,'52359','','00271_thumb.jpg',130, 87,15,'							photo_684681.html');
												thumbnails[684682] = new thumbnail(684682,'52359','','00281_thumb.jpg',130, 87,15,'							photo_684682.html');
												thumbnails[684683] = new thumbnail(684683,'52359','','00301_thumb.jpg',130, 87,15,'							photo_684683.html');
												thumbnails[684684] = new thumbnail(684684,'52359','','00311_thumb.jpg',130, 137,15,'							photo_684684.html');
												thumbnails[684686] = new thumbnail(684686,'52359','','00331_thumb.jpg',130, 87,15,'							photo_684686.html');
												thumbnails[684690] = new thumbnail(684690,'52359','','00361_thumb.jpg',130, 87,15,'							photo_684690.html');
												thumbnails[684695] = new thumbnail(684695,'52359','','00401_thumb.jpg',130, 87,15,'							photo_684695.html');
												thumbnails[684696] = new thumbnail(684696,'52359','','00421_thumb.jpg',130, 195,15,'							photo_684696.html');
												thumbnails[689669] = new thumbnail(689669,'52790','','a02_thumb.jpg',130, 156,15,'							photo_689669.html');
												thumbnails[689672] = new thumbnail(689672,'52790','','a04_thumb.jpg',130, 85,15,'							photo_689672.html');
												thumbnails[689673] = new thumbnail(689673,'52790','','a05_thumb.jpg',130, 195,15,'							photo_689673.html');
												thumbnails[689674] = new thumbnail(689674,'52790','','a06_thumb.jpg',130, 164,15,'							photo_689674.html');
												thumbnails[689676] = new thumbnail(689676,'52790','','a07_thumb.jpg',130, 87,15,'							photo_689676.html');
												thumbnails[689677] = new thumbnail(689677,'52790','','a08_thumb.jpg',130, 87,15,'							photo_689677.html');
												thumbnails[689679] = new thumbnail(689679,'52790','','a09_thumb.jpg',130, 87,15,'							photo_689679.html');
												thumbnails[689680] = new thumbnail(689680,'52790','','a10_thumb.jpg',130, 143,15,'							photo_689680.html');
												thumbnails[689681] = new thumbnail(689681,'52790','','a11_thumb.jpg',130, 202,15,'							photo_689681.html');
												thumbnails[689682] = new thumbnail(689682,'52790','','a12_thumb.jpg',130, 87,15,'							photo_689682.html');
												thumbnails[689683] = new thumbnail(689683,'52790','','a13_thumb.jpg',130, 87,15,'							photo_689683.html');
												thumbnails[689686] = new thumbnail(689686,'52790','','a15_thumb.jpg',130, 92,15,'							photo_689686.html');
												thumbnails[689687] = new thumbnail(689687,'52790','','a16_thumb.jpg',130, 67,15,'							photo_689687.html');
												thumbnails[689688] = new thumbnail(689688,'52790','','a17_thumb.jpg',130, 163,15,'							photo_689688.html');
												thumbnails[689690] = new thumbnail(689690,'52790','','a18_thumb.jpg',130, 165,15,'							photo_689690.html');
												thumbnails[690753] = new thumbnail(690753,'52874','','01_thumb.jpg',130, 87,15,'							photo_690753.html');
												thumbnails[690754] = new thumbnail(690754,'52874','','02_thumb.jpg',130, 195,15,'							photo_690754.html');
												thumbnails[690755] = new thumbnail(690755,'52874','','03_thumb.jpg',130, 83,15,'							photo_690755.html');
												thumbnails[690758] = new thumbnail(690758,'52874','','04_thumb.jpg',130, 90,15,'							photo_690758.html');
												thumbnails[690761] = new thumbnail(690761,'52874','','06_thumb.jpg',130, 195,15,'							photo_690761.html');
												thumbnails[690767] = new thumbnail(690767,'52874','','09_thumb.jpg',130, 87,15,'							photo_690767.html');
												thumbnails[690770] = new thumbnail(690770,'52874','','11_thumb.jpg',130, 87,15,'							photo_690770.html');
												thumbnails[690773] = new thumbnail(690773,'52874','','12_thumb.jpg',130, 195,15,'							photo_690773.html');
												thumbnails[690774] = new thumbnail(690774,'52874','','13_thumb.jpg',130, 90,15,'							photo_690774.html');
												thumbnails[690775] = new thumbnail(690775,'52874','','14_thumb.jpg',130, 76,15,'							photo_690775.html');
												thumbnails[690776] = new thumbnail(690776,'52874','','15_thumb.jpg',130, 87,15,'							photo_690776.html');
												thumbnails[690777] = new thumbnail(690777,'52874','','16_thumb.jpg',130, 158,15,'							photo_690777.html');
												thumbnails[690778] = new thumbnail(690778,'52874','','17_thumb.jpg',130, 87,15,'							photo_690778.html');
												thumbnails[691100] = new thumbnail(691100,'52922','','021_thumb.jpg',130, 86,15,'							photo_691100.html');
												thumbnails[691102] = new thumbnail(691102,'52922','','031_thumb.jpg',130, 196,15,'							photo_691102.html');
												thumbnails[691103] = new thumbnail(691103,'52922','','041_thumb.jpg',130, 86,15,'							photo_691103.html');
												thumbnails[691105] = new thumbnail(691105,'52922','','061_thumb.jpg',130, 86,15,'							photo_691105.html');
												thumbnails[691107] = new thumbnail(691107,'52922','','071_thumb.jpg',130, 86,15,'							photo_691107.html');
												thumbnails[691110] = new thumbnail(691110,'52922','','091_thumb.jpg',130, 75,15,'							photo_691110.html');
												thumbnails[691111] = new thumbnail(691111,'52922','','101_thumb.jpg',130, 86,15,'							photo_691111.html');
												thumbnails[691113] = new thumbnail(691113,'52922','','121_thumb.jpg',130, 196,15,'							photo_691113.html');
												thumbnails[691114] = new thumbnail(691114,'52922','','131_thumb.jpg',130, 196,15,'							photo_691114.html');
												thumbnails[691115] = new thumbnail(691115,'52922','','141_thumb.jpg',130, 86,15,'							photo_691115.html');
												thumbnails[691116] = new thumbnail(691116,'52922','','151_thumb.jpg',130, 196,15,'							photo_691116.html');
												thumbnails[691117] = new thumbnail(691117,'52922','','161_thumb.jpg',130, 86,15,'							photo_691117.html');
												thumbnails[691119] = new thumbnail(691119,'52922','','181_thumb.jpg',130, 86,15,'							photo_691119.html');
												thumbnails[691121] = new thumbnail(691121,'52922','','20_thumb.jpg',130, 196,15,'							photo_691121.html');
												thumbnails[1752009] = new thumbnail(1752009,'117682','','pic003_thumb.jpg',130, 87,15,'							photo_1752009.html');
												thumbnails[1752013] = new thumbnail(1752013,'117682','','pic0021_thumb.jpg',130, 92,15,'							photo_1752013.html');
												thumbnails[1752014] = new thumbnail(1752014,'117682','','pic004_thumb.jpg',130, 87,15,'							photo_1752014.html');
												thumbnails[1752015] = new thumbnail(1752015,'117682','','pic005_thumb.jpg',130, 87,15,'							photo_1752015.html');
												thumbnails[1752018] = new thumbnail(1752018,'117682','','pic012_thumb.jpg',130, 195,15,'							photo_1752018.html');
												thumbnails[1752019] = new thumbnail(1752019,'117682','','pic011_thumb.jpg',130, 195,15,'							photo_1752019.html');
												thumbnails[1752024] = new thumbnail(1752024,'117682','','pic010_thumb.jpg',130, 87,15,'							photo_1752024.html');
												thumbnails[1752025] = new thumbnail(1752025,'117682','','pic009_thumb.jpg',130, 87,15,'							photo_1752025.html');
												thumbnails[1752026] = new thumbnail(1752026,'117682','','pic008_thumb.jpg',130, 195,15,'							photo_1752026.html');
												thumbnails[1752037] = new thumbnail(1752037,'117682','','pic007_thumb.jpg',130, 87,15,'							photo_1752037.html');
												thumbnails[1752038] = new thumbnail(1752038,'117682','','pic006_thumb.jpg',130, 195,15,'							photo_1752038.html');
												thumbnails[1752040] = new thumbnail(1752040,'117682','','pic0011_thumb.jpg',130, 87,15,'							photo_1752040.html');
												thumbnails[1752058] = new thumbnail(1752058,'117686','','pic0012_thumb.jpg',130, 195,15,'							photo_1752058.html');
												thumbnails[1752061] = new thumbnail(1752061,'117686','','pic0022_thumb.jpg',130, 87,15,'							photo_1752061.html');
												thumbnails[1752062] = new thumbnail(1752062,'117686','','pic0031_thumb.jpg',130, 87,15,'							photo_1752062.html');
												thumbnails[1752063] = new thumbnail(1752063,'117686','','pic0041_thumb.jpg',130, 195,15,'							photo_1752063.html');
												thumbnails[1752070] = new thumbnail(1752070,'117686','','pic0052_thumb.jpg',130, 80,15,'							photo_1752070.html');
												thumbnails[1752072] = new thumbnail(1752072,'117686','','pic0061_thumb.jpg',130, 87,15,'							photo_1752072.html');
												thumbnails[1752074] = new thumbnail(1752074,'117686','','pic0071_thumb.jpg',130, 195,15,'							photo_1752074.html');
												thumbnails[1752075] = new thumbnail(1752075,'117686','','pic0081_thumb.jpg',130, 87,15,'							photo_1752075.html');
												thumbnails[1752077] = new thumbnail(1752077,'117686','','pic0091_thumb.jpg',130, 87,15,'							photo_1752077.html');
												thumbnails[1752078] = new thumbnail(1752078,'117686','','pic0101_thumb.jpg',130, 87,15,'							photo_1752078.html');
												thumbnails[1805119] = new thumbnail(1805119,'121375','','pic0013_thumb.jpg',130, 87,15,'							photo_1805119.html');
												thumbnails[1805120] = new thumbnail(1805120,'121375','','pic0023_thumb.jpg',130, 195,15,'							photo_1805120.html');
												thumbnails[1805122] = new thumbnail(1805122,'121375','','pic0032_thumb.jpg',130, 195,15,'							photo_1805122.html');
												thumbnails[1805123] = new thumbnail(1805123,'121375','','pic0042_thumb.jpg',130, 87,15,'							photo_1805123.html');
												thumbnails[1805124] = new thumbnail(1805124,'121375','','pic0053_thumb.jpg',130, 85,15,'							photo_1805124.html');
												thumbnails[1805126] = new thumbnail(1805126,'121375','','pic0062_thumb.jpg',130, 87,15,'							photo_1805126.html');
												thumbnails[1805127] = new thumbnail(1805127,'121375','','pic0072_thumb.jpg',130, 87,15,'							photo_1805127.html');
												thumbnails[1805128] = new thumbnail(1805128,'121375','','pic0082_thumb.jpg',130, 87,15,'							photo_1805128.html');
												thumbnails[1805129] = new thumbnail(1805129,'121375','','pic0092_thumb.jpg',130, 54,15,'							photo_1805129.html');
												thumbnails[1805130] = new thumbnail(1805130,'121375','','pic0102_thumb.jpg',130, 72,15,'							photo_1805130.html');
												thumbnails[1805132] = new thumbnail(1805132,'121376','','pic0014_thumb.jpg',130, 89,15,'							photo_1805132.html');
												thumbnails[1805135] = new thumbnail(1805135,'121376','','pic0024_thumb.jpg',130, 178,15,'							photo_1805135.html');
												thumbnails[1805136] = new thumbnail(1805136,'121376','','pic0033_thumb.jpg',130, 87,15,'							photo_1805136.html');
												thumbnails[1805137] = new thumbnail(1805137,'121376','','pic0043_thumb.jpg',130, 145,15,'							photo_1805137.html');
												thumbnails[1805138] = new thumbnail(1805138,'121376','','pic0054_thumb.jpg',130, 184,15,'							photo_1805138.html');
												thumbnails[1805139] = new thumbnail(1805139,'121376','','pic0063_thumb.jpg',130, 148,15,'							photo_1805139.html');
												thumbnails[1805140] = new thumbnail(1805140,'121376','','pic0073_thumb.jpg',130, 87,15,'							photo_1805140.html');
												thumbnails[1805141] = new thumbnail(1805141,'121376','','pic0083_thumb.jpg',130, 195,15,'							photo_1805141.html');
												thumbnails[1805142] = new thumbnail(1805142,'121376','','pic0093_thumb.jpg',130, 87,15,'							photo_1805142.html');
												thumbnails[1805143] = new thumbnail(1805143,'121376','','pic0103_thumb.jpg',130, 87,15,'							photo_1805143.html');
												thumbnails[1805148] = new thumbnail(1805148,'121376','','pic0111_thumb.jpg',130, 87,15,'							photo_1805148.html');
												thumbnails[1805149] = new thumbnail(1805149,'121376','','pic0121_thumb.jpg',130, 65,15,'							photo_1805149.html');
												thumbnails[1805150] = new thumbnail(1805150,'121376','','pic013_thumb.jpg',130, 195,15,'							photo_1805150.html');
												thumbnails[1805151] = new thumbnail(1805151,'121376','','pic014_thumb.jpg',130, 87,15,'							photo_1805151.html');

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  					galleries[52874] = new gallery(52874,'690778,690777,690776,690775,690774,690773,690770,690767,690761,690758','Alan & Katie','gallery',[690753,690754,690755,690758,690761,690767,690770,690773,690774,690775,690776,690777,690778],0, 0, '', '																																																																																																							gallery_52874.html',0,0);
				  					galleries[52790] = new gallery(52790,'689690,689688,689687,689686,689683,689682,689681,689680,689679,689677','Anthony & Sarah','gallery',[689669,689672,689673,689674,689676,689677,689679,689680,689681,689682,689683,689686,689687,689688,689690],0, 0, '', '																																																																																																							gallery_52790.html',0,0);
				  					galleries[117682] = new gallery(117682,'1752040,1752038,1752037,1752026,1752025,1752024,1752019,1752018,1752015,1752014','Barry & Linda','gallery',[1752009,1752013,1752014,1752015,1752018,1752019,1752024,1752025,1752026,1752037,1752038,1752040],0, 0, '', '																																																																																																							gallery_117682.html',0,0);
				  					galleries[121375] = new gallery(121375,'1805130,1805129,1805128,1805127,1805126,1805124,1805123,1805122,1805120,1805119','BRETT & HAYLEY','gallery',[1805119,1805120,1805122,1805123,1805124,1805126,1805127,1805128,1805129,1805130],0, 0, '', '																																																																																																							gallery_121375.html',0,0);
				  					galleries[52262] = new gallery(52262,'683690,683685,683682,683679,683672,683665,683660,683655,683651,683239','David & Rebecca','gallery',[683216,683220,683224,683232,683236,683238,683239,683651,683655,683660,683665,683672,683679,683682,683685,683690],0, 0, '', '																																																																																																							gallery_52262.html',0,0);
				  					galleries[52922] = new gallery(52922,'691121,691119,691117,691116,691115,691114,691113,691111,691110,691107','Married in Cyprus','gallery',[691100,691102,691103,691105,691107,691110,691111,691113,691114,691115,691116,691117,691119,691121],0, 0, '', '																																																																																																							gallery_52922.html',0,0);
				  					galleries[117686] = new gallery(117686,'1752078,1752077,1752075,1752074,1752072,1752070,1752063,1752062,1752061,1752058','Michael & Margaret','gallery',[1752058,1752061,1752062,1752063,1752070,1752072,1752074,1752075,1752077,1752078],0, 0, '', '																																																																																																							gallery_117686.html',0,0);
				  					galleries[52359] = new gallery(52359,'684696,684695,684690,684686,684684,684683,684682,684681,684674,684672','Paul & Elizabeth','gallery',[684614,684616,684619,684660,684664,684669,684672,684674,684681,684682,684683,684684,684686,684690,684695,684696],0, 0, '', '																																																																																																							gallery_52359.html',0,0);
				  					galleries[121376] = new gallery(121376,'1805151,1805150,1805149,1805148,1805143,1805142,1805141,1805140,1805139,1805138','WAYNE & AMY','gallery',[1805132,1805135,1805136,1805137,1805138,1805139,1805140,1805141,1805142,1805143,1805148,1805149,1805150,1805151],0, 0, '', '																																																																																																							gallery_121376.html',0,0);
/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = new Object();
imageSets[1] = '1805123,1752070,691121,690753,689686,684682';
imageSets[3] = '1805151,1805150,1805149,1805148,1805143,1805142,1805141,1805140,1805139,1805138,1805137,1805136,1805135,1805132,1805130,1805129,1805128,1805127,1805126,1805124,1805123,1805122,1805120,1805119,1752078,1752077,1752075,1752074,1752072,1752070,1752063,1752062,1752061,1752058,1752040,1752038,1752037,1752026,1752025,1752024,1752019,1752018,1752015,1752014,1752013,1752009,691121,691119,691117,691116';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/marinersmad/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/marinersmad/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/marinersmad/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/marinersmad/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://www.clikchurch.com/marinersmad/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/marinersmad/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/marinersmad/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/marinersmad/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/marinersmad/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/marinersmad/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/marinersmad/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/marinersmad/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/marinersmad/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/marinersmad/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://admin2.clikpic.com/marinersmad/images';
		break;
	}
		switch (server_id) {
		case 33:
		val = 'http://www8.clikpic.com/marinersmad/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/marinersmad/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/marinersmad/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/marinersmad/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/marinersmad/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/marinersmad/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 = 'Michael White Photography: ' + photoCaption;
			    }
        if (op.$detail.length > 0) {
      temp = op.nextPhoto.fnGetImageDetails();
	    op.$detail.fadeGalleryDetails(temp, op.speed, function(){
	    var options = {photoinfominwidth:220};	    	      	      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;
	}
}

		

