window.thumbnails = new Object();
												thumbnails[6935988] = new thumbnail(6935988,'','','Home_Image_712_thumb.jpg',130, 79,15,'															#');
												thumbnails[7324611] = new thumbnail(7324611,'','','Home-Image-8_thumb.jpg',130, 69,15,'															#');
												thumbnails[6484879] = new thumbnail(6484879,'244939','Inverpolly','Inverpolly_thumb.jpg',130, 65,15,'																			photo_6484879.html');
												thumbnails[4408964] = new thumbnail(4408964,'247723','River Bà','Lochan-na-h-Achlaise-Portrait-14x201_thumb.jpg',91, 130,15,'																			photo_4408964.html');
												thumbnails[4372894] = new thumbnail(4372894,'244940','Glencoe','Glencoe2_thumb.jpg',130, 91,15,'																			photo_4372894.html');
												thumbnails[4368377] = new thumbnail(4368377,'247724','Rannoch Moor','Rannoch-Moor_thumb.jpg',130, 91,15,'																			photo_4368377.html');
												thumbnails[4396516] = new thumbnail(4396516,'247724','Meall a\'Bhuiridh','rannoch-moor-Pano-32x161_thumb.jpg',130, 65,15,'																			photo_4396516.html');
												thumbnails[4369979] = new thumbnail(4369979,'244939','Glen Torridon','Glen-Torridon_thumb.jpg',130, 65,15,'																			photo_4369979.html');
												thumbnails[4396567] = new thumbnail(4396567,'247723','Buachaille Etive Mor','Buachaille-Etive-Mor2_thumb.jpg',91, 130,15,'																			photo_4396567.html');
												thumbnails[4402158] = new thumbnail(4402158,'247724','Seaview','Seaview_thumb.jpg',130, 91,15,'																			photo_4402158.html');
												thumbnails[4372857] = new thumbnail(4372857,'244940','Eilean Donan Castle','Eilean-Donan-Castle3_thumb.jpg',130, 91,15,'																			photo_4372857.html');
												thumbnails[4370747] = new thumbnail(4370747,'244939','Stob Ghabhar','Stob-Ghabhar_thumb.jpg',130, 65,15,'																			photo_4370747.html');
												thumbnails[4396798] = new thumbnail(4396798,'247723','Old Man of Storr','Old-Man-of-Storr_thumb.jpg',91, 130,15,'																			photo_4396798.html');
												thumbnails[7325106] = new thumbnail(7325106,'244939','Loch Scavaig','Loch-Scavaig-4_thumb.jpg',130, 65,15,'																			photo_7325106.html');
												thumbnails[6936040] = new thumbnail(6936040,'247724','Small Isles','Small-Isles-2_thumb.jpg',130, 91,15,'																			photo_6936040.html');
												thumbnails[4873229] = new thumbnail(4873229,'244940','Stirlingshire','Stirlingshire_thumb.jpg',130, 91,15,'																			photo_4873229.html');
												thumbnails[7325202] = new thumbnail(7325202,'244939','River Etive','River-Etive_thumb.jpg',130, 65,15,'																			photo_7325202.html');
												thumbnails[5595897] = new thumbnail(5595897,'247723','Cruach Ardrain','Cruach-Ardrain_thumb.jpg',91, 130,15,'																			photo_5595897.html');
												thumbnails[4374015] = new thumbnail(4374015,'244940','Torridon Mountains','Torridon-Mountains_thumb.jpg',130, 91,15,'																			photo_4374015.html');
												thumbnails[5056802] = new thumbnail(5056802,'247724','Loch Scavaig','Loch-Scavaig_CA70B295-1D09-001F-991DC0A689F1F588_thumb.jpg',130, 65,15,'																			photo_5056802.html');
												thumbnails[7325120] = new thumbnail(7325120,'244939','Loch Garry','Loch-Garry_thumb.jpg',130, 65,15,'																			photo_7325120.html');
												thumbnails[4409025] = new thumbnail(4409025,'247723','Sgurr nan Gillean','Sgurr-nan-Gillean2_thumb.jpg',91, 130,15,'																			photo_4409025.html');
												thumbnails[4408882] = new thumbnail(4408882,'244940','Blackrock Cottage','blackrock-cottage-2-Landscape-20x14_thumb.jpg',130, 91,15,'																			photo_4408882.html');
												thumbnails[4370727] = new thumbnail(4370727,'244939','Rannoch Moor','Rannoch-Moor4_thumb.jpg',130, 65,15,'																			photo_4370727.html');
												thumbnails[4409054] = new thumbnail(4409054,'247723','Tarskavaig Bay','tarskavaig-bay-Portrait-14x201_thumb.jpg',91, 130,15,'																			photo_4409054.html');
												thumbnails[4372764] = new thumbnail(4372764,'244940','Glencoe Lochan','Glencoe-Lochan_thumb.jpg',130, 91,15,'																			photo_4372764.html');
												thumbnails[4369410] = new thumbnail(4369410,'244939','Loch Leven','Loch-Leven14_thumb.jpg',130, 65,15,'																			photo_4369410.html');
												thumbnails[4368286] = new thumbnail(4368286,'247723','Buachaille Etive Mor','Buachaille-Etive-Mor-23_thumb.jpg',91, 130,15,'																			photo_4368286.html');
												thumbnails[4373877] = new thumbnail(4373877,'244940','Loch Scavaig','Loch-Scavaig_thumb.jpg',130, 91,15,'																			photo_4373877.html');
												thumbnails[4409018] = new thumbnail(4409018,'247723','Marsco','marsco-2-Portrait-14x201_thumb.jpg',91, 130,15,'																			photo_4409018.html');
												thumbnails[4369923] = new thumbnail(4369923,'244939','Glen Sligachan','Glen-Sligachan_thumb.jpg',130, 65,15,'																			photo_4369923.html');
												thumbnails[4369863] = new thumbnail(4369863,'244939','Buachaille Etive Mor','Buachaille-Etive-Mor3_thumb.jpg',130, 65,15,'																			photo_4369863.html');
												thumbnails[4966651] = new thumbnail(4966651,'247723','Loch Scavaig','Loch-Scavaig1_thumb.jpg',91, 130,15,'																			photo_4966651.html');
												thumbnails[4408903] = new thumbnail(4408903,'244940','Kilchurn Castle','loch-awe-Landscape-20x14_thumb.jpg',130, 91,15,'																			photo_4408903.html');
												thumbnails[4401454] = new thumbnail(4401454,'244939','Eilean Donan Castle','Eilean-Donan-Castle2_thumb.jpg',130, 65,15,'																			photo_4401454.html');
												thumbnails[4979623] = new thumbnail(4979623,'247723','Glencoe Lochan','glencoe-lochan2_thumb.jpg',91, 130,15,'																			photo_4979623.html');
												thumbnails[4402143] = new thumbnail(4402143,'244940','Firth of Clyde','Firth-of-Clyde_thumb.jpg',130, 91,15,'																			photo_4402143.html');
												thumbnails[4396484] = new thumbnail(4396484,'244939','Balephuil Bay','Balephuil-bay-Pano-32x16_thumb.jpg',130, 65,15,'																			photo_4396484.html');
												thumbnails[6485827] = new thumbnail(6485827,'244939','Glen Etive','Glen-Etive_thumb.jpg',130, 65,15,'																			photo_6485827.html');
												thumbnails[6486020] = new thumbnail(6486020,'247723','Glen Etive','Glen-Etive-2_4816B602-1EC9-D45B-1C8E5C376A4BB736_thumb.jpg',91, 130,15,'																			photo_6486020.html');
												thumbnails[4370017] = new thumbnail(4370017,'244939','Glencoe','Glencoe_thumb.jpg',130, 65,15,'																			photo_4370017.html');
												thumbnails[4372788] = new thumbnail(4372788,'244940','Loch Bracadale','Loch-Bracadale_thumb.jpg',130, 91,15,'																			photo_4372788.html');
												thumbnails[4372816] = new thumbnail(4372816,'244940','Lochan na h\'Achlaise','Lochan-na-hAchlaise-21_thumb.jpg',130, 91,15,'																			photo_4372816.html');
												thumbnails[4370511] = new thumbnail(4370511,'244939','Loch Scavaig','Loch-Scavaig-2_thumb.jpg',130, 65,15,'																			photo_4370511.html');
												thumbnails[6485854] = new thumbnail(6485854,'244940','Balevullin Bay','Balevullin-Bay-2_thumb.jpg',130, 91,15,'																			photo_6485854.html');
												thumbnails[6485773] = new thumbnail(6485773,'244939','Slioch','Slioch_thumb.jpg',130, 65,15,'																			photo_6485773.html');
												thumbnails[4369540] = new thumbnail(4369540,'244939','Beinn Dearg Mhor','Beinn-Dearg-Mhor_thumb.jpg',130, 65,15,'																			photo_4369540.html');
												thumbnails[5595861] = new thumbnail(5595861,'244939','Stob Binnein & Ben More','Stob-Binnein--Ben-More_thumb.jpg',130, 65,15,'																			photo_5595861.html');
												thumbnails[4408895] = new thumbnail(4408895,'244940','River Bà','Lochan-na-h-Achlaise-5-Landscape-20x14_thumb.jpg',130, 91,15,'																			photo_4408895.html');
												thumbnails[4372977] = new thumbnail(4372977,'244940','Isle of Rum','Isle-of-Rum_thumb.jpg',130, 91,15,'																			photo_4372977.html');
												thumbnails[4369698] = new thumbnail(4369698,'244939','Beinn na Caillich','Beinn-na-Caillich_thumb.jpg',130, 65,15,'																			photo_4369698.html');
												thumbnails[4979533] = new thumbnail(4979533,'244939','Glencoe Lochan','Glencoe-Lochan_8DF0D719-1D09-001F-9930AE24038BCB92_thumb.jpg',130, 65,15,'																			photo_4979533.html');
												thumbnails[4373942] = new thumbnail(4373942,'244940','Tarskavaig Bay','Tarskavaig-Bay_thumb.jpg',130, 91,15,'																			photo_4373942.html');
												thumbnails[7325338] = new thumbnail(7325338,'244939','Stirling Castle','Stirling-Castle_thumb.jpg',130, 65,15,'																			photo_7325338.html');
												thumbnails[7325889] = new thumbnail(7325889,'244939','Bla Bheinn','Bla-Bheinn-2_thumb.jpg',130, 65,15,'																			photo_7325889.html');
												thumbnails[4370738] = new thumbnail(4370738,'244939','Sgurr nan Gillean','Sgurr-nan-Gillean_thumb.jpg',130, 65,15,'																			photo_4370738.html');
												thumbnails[4370046] = new thumbnail(4370046,'244939','Loch Harport','Loch-Harport_thumb.jpg',130, 65,15,'																			photo_4370046.html');
												thumbnails[4408934] = new thumbnail(4408934,'244940','Portencross','portencross-Landscape-20x14_thumb.jpg',130, 91,15,'																			photo_4408934.html');
												thumbnails[4373970] = new thumbnail(4373970,'244940','The Black Cuillin','The-Black-Cuillin_thumb.jpg',130, 91,15,'																			photo_4373970.html');
												thumbnails[4370756] = new thumbnail(4370756,'244939','The Red Cuillins','The-Red-Cuillins_thumb.jpg',130, 65,15,'																			photo_4370756.html');
												thumbnails[4396506] = new thumbnail(4396506,'244939','Loch Etive','loch-etive-Pano-32x16_thumb.jpg',130, 65,15,'																			photo_4396506.html');
												thumbnails[4408884] = new thumbnail(4408884,'244940','Eilean Donan Castle','Eilean-Donan-Landscape-20x14_thumb.jpg',130, 91,15,'																			photo_4408884.html');
												thumbnails[6485791] = new thumbnail(6485791,'244939','Arkle','Arkle_thumb.jpg',130, 65,15,'																			photo_6485791.html');
												thumbnails[4966519] = new thumbnail(4966519,'244939','Sgorr Dhonuill','Sgorr-Dhonuill_thumb.jpg',130, 65,15,'																			photo_4966519.html');
												thumbnails[5595875] = new thumbnail(5595875,'244939','Loch Leven','Loch-Leven-3_thumb.jpg',130, 65,15,'																			photo_5595875.html');
												thumbnails[7325868] = new thumbnail(7325868,'244939','Sound of Mull','Sound-of-Mull_thumb.jpg',130, 65,15,'																			photo_7325868.html');
												thumbnails[4374012] = new thumbnail(4374012,'244940','Stob Ghabhar','Stob-Ghabhar5_thumb.jpg',130, 91,15,'																			photo_4374012.html');
												thumbnails[4369635] = new thumbnail(4369635,'244939','Beinn Dorain','Beinn-Dorain_thumb.jpg',130, 65,15,'																			photo_4369635.html');
												thumbnails[4372807] = new thumbnail(4372807,'244940','Lochan na h\'Achlaise','Lochan-na-hAchlaise1_thumb.jpg',130, 91,15,'																			photo_4372807.html');
												thumbnails[5595893] = new thumbnail(5595893,'244940','Loch Voil','Loch-Voil_thumb.jpg',130, 91,15,'																			photo_5595893.html');
												thumbnails[6485866] = new thumbnail(6485866,'244940','Ben Nevis','Ben-Nevis-3_thumb.jpg',130, 91,15,'																			photo_6485866.html');
												thumbnails[4969723] = new thumbnail(4969723,'244939','The Green','The-Green_873B7811-1D09-001F-9946E3EB460914EA_thumb.jpg',130, 65,15,'																			photo_4969723.html');
												thumbnails[4369487] = new thumbnail(4369487,'244939','Loch Katrine','Loch-Katrine_thumb.jpg',130, 65,15,'																			photo_4369487.html');
												thumbnails[4966289] = new thumbnail(4966289,'244940','Sgurr nan Gillean','Sgurr-nan-Gillean3_thumb.jpg',130, 91,15,'																			photo_4966289.html');
												thumbnails[6485829] = new thumbnail(6485829,'244939','Spidean Coire nan Clach','Spidean-Coire-nan-Clach_thumb.jpg',130, 65,15,'																			photo_6485829.html');
												thumbnails[6485831] = new thumbnail(6485831,'244939','Falls of Arkaig','Falls-of-Arkaig_thumb.jpg',130, 65,15,'																			photo_6485831.html');
												thumbnails[4966347] = new thumbnail(4966347,'244940','Ben Nevis','Ben-Nevis-2_thumb.jpg',130, 91,15,'																			photo_4966347.html');
												thumbnails[4973945] = new thumbnail(4973945,'244940','Scarastavore','Scarastavore-2_thumb.jpg',130, 91,15,'																			photo_4973945.html');
												thumbnails[5127527] = new thumbnail(5127527,'244940','The Mamores','The-Mamores_thumb.jpg',130, 91,15,'																			photo_5127527.html');
												thumbnails[6485955] = new thumbnail(6485955,'244940','Polin Bay','Polin-Bay_thumb.jpg',130, 91,15,'																			photo_6485955.html');

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  					galleries[244939] = new gallery(244939,'7325889,7325868,7325338,7325202,7325120,7325106,6485831,6485829,6485827,6485791','Panoramic','gallery',[6484879,4369979,4370747,7325106,7325202,7325120,4370727,4369410,4369923,4369863,4401454,4396484,6485827,4370017,4370511,6485773,4369540,5595861,4369698,4979533,7325338,7325889,4370738,4370046,4370756,4396506,6485791,4966519,5595875,7325868,4369635,4969723,4369487,6485829,6485831],0, 1, '', '																																																																																																							gallery_244939.html',0,0);
				  					galleries[244940] = new gallery(244940,'6485955,6485866,6485854,5595893,5127527,4973945,4966347,4966289,4873229,4408934','Landscape','gallery',[4372894,4372857,4873229,4374015,4408882,4372764,4373877,4408903,4402143,4372788,4372816,6485854,4408895,4372977,4373942,4408934,4373970,4408884,4374012,4372807,5595893,6485866,4966289,4966347,4973945,5127527,6485955],0, 1, '', '																																																																																																							gallery_244940.html',0,0);
				  					galleries[247723] = new gallery(247723,'6486020,5595897,4979623,4966651,4409054,4409025,4409018,4408964,4396798,4396567','Portrait','gallery',[4408964,4396567,4396798,5595897,4409025,4409054,4368286,4409018,4966651,4979623,6486020],0, 1, '', '																																																																																																							gallery_247723.html',0,0);
				  					galleries[247724] = new gallery(247724,'4368377','Limited Edition','gallery',[4368377,4396516,4402158,6936040,5056802],0, 1, '', '																																																																																																							gallery_247724.html',0,0);
/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = new Object();
imageSets[1] = '7324611';
imageSets[2] = '4368377';
imageSets[3] = '7325889,7325868,7325338,7325202,7325120,7325106,7324611,6936040,6935988,6486020,6485955,6485866,6485854,6485831,6485829,6485827,6485791,6485773,6484879,5595897,5595893,5595875,5595861,5127527,5056802,4979623,4979533,4973945,4969723,4966651,4966519,4966347,4966289,4873229,4409054,4409025,4409018,4408964,4408934,4408903,4408895,4408884,4408882,4402158,4402143,4401454,4396798,4396567,4396516,4396506';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/alidelaneilly/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/alidelaneilly/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/alidelaneilly/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/alidelaneilly/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/alidelaneilly/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/alidelaneilly/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/alidelaneilly/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/alidelaneilly/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/alidelaneilly/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/alidelaneilly/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/alidelaneilly/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/alidelaneilly/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/alidelaneilly/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/alidelaneilly/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/alidelaneilly/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://admin2.clikpic.com/alidelaneilly/images';
		break;
	}
		switch (server_id) {
		case 33:
		val = 'http://www8.clikpic.com/alidelaneilly/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/alidelaneilly/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/alidelaneilly/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/alidelaneilly/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/alidelaneilly/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/alidelaneilly/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 = 'Capturing Scotland: ' + 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>';
	}
					
	temp = temp + this.fnGetPaymentInfo();
				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>Buy now using PayPal:</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="updateCartValue(document.forms.paymentForm,this.form.payment_options_id.options[this.form.payment_options_id.options.selectedIndex].value); if(divShowing(\'paymentConfirm\')){fadeOut(\'paymentConfirm\', 3)};">';
				
		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">';
	temp = temp + '	<input type="hidden" name="item_option" value="' + item_option + '">';
	temp = temp + '	<input type="hidden" name="site" value="ALIDELANEILLY">';
		temp = temp + '	<input type="hidden" name="item_number" value="'+ this.id +'">';
			temp = temp + '	<input type="hidden" name="quantity" value="1">';
								temp = temp + '	<input value="Add to cart" id="paymentAddButton" class="button" onmouseover="this.className=\'buttonHi\'\;" onmouseout="this.className=\'button\'\;" type="Button">';
			temp = temp + '	<input value="View cart" id="paymentViewButton" class="button" onmouseover="this.className=\'buttonHi\';" onmouseout="this.className=\'button\';" type="Button" onclick="javascript:window.location=\'cart.html\'">';
	temp = temp + '</form>';
		temp = temp + '<div class="clearing">&nbsp;</div>';
	temp = temp + '<div id="confirmContainer">';
	temp = temp + '<div id="paymentConfirm">Item added to cart</div>';
	temp = temp + '</div>';
			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;
	}
}

			

