window.thumbnails = new Object();
												thumbnails[1549290] = new thumbnail(1549290,'104154','Bandstand in the Fog','Bandstand-in-the-FogClik_thumb.jpg',130, 195,18,'photo_1549290.html');
												thumbnails[1635587] = new thumbnail(1635587,'104154','Number One Whitefriars','Whitefriars_clik_thumb.jpg',130, 195,18,'photo_1635587.html');
												thumbnails[2171502] = new thumbnail(2171502,'104154','Eastgate Clock and Steps','Eastgate-Clock-9x6_clik_thumb.jpg',130, 195,18,'photo_2171502.html');
												thumbnails[1531120] = new thumbnail(1531120,'104154','Queens Park Suspension Bridge','CH_05_thumb.jpg',130, 87,18,'photo_1531120.html');
												thumbnails[1529806] = new thumbnail(1529806,'104154','Old Dee Bridge','Bridge_at_Nightclik_thumb.jpg',130, 87,18,'photo_1529806.html');
												thumbnails[1517347] = new thumbnail(1517347,'104154','Kaleyard Steps','Chester_scenics_80_thumb.jpg',130, 86,18,'photo_1517347.html');
												thumbnails[1612405] = new thumbnail(1612405,'104154','Queens Park Footbridge','Queens_Park_Bridge_clik_thumb.jpg',130, 195,18,'photo_1612405.html');
												thumbnails[1517321] = new thumbnail(1517321,'104154','King Street in Chester','Chester_scenics_70_thumb.jpg',130, 189,18,'photo_1517321.html');
												thumbnails[3283138] = new thumbnail(3283138,'104154','The Groves','CH_62Clik_thumb.jpg',130, 195,18,'photo_3283138.html');
												thumbnails[2181221] = new thumbnail(2181221,'104154','Grosvenor Bridge at Sunset','Grosvenor-Bridge-Sunset_Clik_thumb.jpg',130, 87,18,'photo_2181221.html');
												thumbnails[1684464] = new thumbnail(1684464,'104154','Old Dee Bridge and Handbridge','Old-Dee-Bridge_and Handbridge_Clik_thumb.jpg',130, 88,18,'photo_1684464.html');
												thumbnails[1640146] = new thumbnail(1640146,'104154','The Falcon','Falcon_Clik_thumb.jpg',130, 87,18,'photo_1640146.html');
												thumbnails[1529804] = new thumbnail(1529804,'104154','Groves Steps','Stepsclik_thumb.jpg',130, 87,18,'photo_1529804.html');
												thumbnails[2160627] = new thumbnail(2160627,'104154','River Dee Sunrise','River-Dee-Sunrise_Clik_thumb.jpg',130, 87,18,'photo_2160627.html');
												thumbnails[1681629] = new thumbnail(1681629,'104154','M56 Chester at Night','Motorway_Clik_thumb.jpg',130, 87,18,'photo_1681629.html');
												thumbnails[1531709] = new thumbnail(1531709,'104154','St Werburgh Street','St-Werburgh-Streetclik_thumb.jpg',130, 87,18,'photo_1531709.html');
												thumbnails[1645666] = new thumbnail(1645666,'104154','Christmas Lights','Christmas-Lights_Clik_thumb.jpg',130, 88,18,'photo_1645666.html');
												thumbnails[1517322] = new thumbnail(1517322,'104154','Kaleyard Steps','Stepsclik2_thumb.jpg',130, 87,18,'photo_1517322.html');
												thumbnails[1667352] = new thumbnail(1667352,'104154','Chester Cathedral West Door','Cathedral_West_Clik_thumb.jpg',130, 195,18,'photo_1667352.html');
												thumbnails[1620840] = new thumbnail(1620840,'104154','Eastgate Clock','Eastgate_Clock_clik_thumb.jpg',130, 195,18,'photo_1620840.html');
												thumbnails[2200125] = new thumbnail(2200125,'104154','The Old Rectory','CH_50_thumb.jpg',130, 194,18,'photo_2200125.html');
												thumbnails[1683379] = new thumbnail(1683379,'104154','The Olde Edgar','Olde-Edgar_Clik_thumb.jpg',130, 87,18,'photo_1683379.html');
												thumbnails[2200154] = new thumbnail(2200154,'104154','Chester Town Hall','CH_51_thumb.jpg',130, 87,18,'photo_2200154.html');
												thumbnails[5369745] = new thumbnail(5369745,'104154','Chester Cross in the Snow','CH-84-Clik_thumb.jpg',130, 87,18,'photo_5369745.html');
												thumbnails[5369748] = new thumbnail(5369748,'104154','Chester Groves','CH-86-Clik_thumb.jpg',130, 87,18,'photo_5369748.html');
												thumbnails[5369746] = new thumbnail(5369746,'104154','Eastgate Clock','CH-85-Clik_thumb.jpg',130, 87,18,'photo_5369746.html');
												thumbnails[1684203] = new thumbnail(1684203,'104154','Bridge Place','Bridge-Place_Clik_thumb.jpg',130, 87,18,'photo_1684203.html');
												thumbnails[1517323] = new thumbnail(1517323,'104154','King Street Chester','Chester_scenics_50_thumb.jpg',130, 197,18,'photo_1517323.html');
												thumbnails[5369743] = new thumbnail(5369743,'104154','Chester Walls in The Snow','CH-83-Clik_thumb.jpg',130, 195,18,'photo_5369743.html');
												thumbnails[7317377] = new thumbnail(7317377,'104154','Foggy Stroll','CH_88-Clik_thumb.jpg',160, 240,18,'photo_7317377.html');
												thumbnails[3283509] = new thumbnail(3283509,'104154','Eastgate Clock','CH_73Clik1_thumb.jpg',130, 87,18,'photo_3283509.html');
												thumbnails[7192371] = new thumbnail(7192371,'104154','Chester Big Wheel','_CH-67-clik3_thumb.jpg',130, 87,18,'photo_7192371.html');
												thumbnails[7192345] = new thumbnail(7192345,'104154','Chester Big Wheel','_CH-88-clik3_thumb.jpg',130, 87,18,'photo_7192345.html');
												thumbnails[2174052] = new thumbnail(2174052,'103934','Old Dee Bridge Arches','Old-Dee-Bridge-From-Handbridge_Clik_thumb.jpg',130, 87,18,'photo_2174052.html');
												thumbnails[2179316] = new thumbnail(2179316,'103934','Chester Cross','Chester-Cross_Clik_thumb.jpg',130, 87,18,'photo_2179316.html');
												thumbnails[1517365] = new thumbnail(1517365,'103934','Old Dee Bridge','Old-Dee-BridgeCLIK_thumb.jpg',130, 87,18,'photo_1517365.html');
												thumbnails[2160891] = new thumbnail(2160891,'103934','Eastgate Clock ','Eastgate-Clock_Clik_thumb.jpg',130, 195,18,'photo_2160891.html');
												thumbnails[2188562] = new thumbnail(2188562,'103934','Chester Cathedral Garden','Chester-Cathedral-Garden_Clik_thumb.jpg',130, 195,18,'photo_2188562.html');
												thumbnails[2174199] = new thumbnail(2174199,'103934','Chester Wier','Chester-Wier_Clik_thumb.jpg',130, 195,18,'photo_2174199.html');
												thumbnails[1578439] = new thumbnail(1578439,'103934','Peaceful Stroll','Peaceful-StrollClik_thumb.jpg',130, 194,18,'photo_1578439.html');
												thumbnails[1612462] = new thumbnail(1612462,'103934','Chester Groves','Groves_Benches_clik_thumb.jpg',130, 195,18,'photo_1612462.html');
												thumbnails[1737970] = new thumbnail(1737970,'103934','Groves in the fog','Groves-in-The-Fog_Clik_thumb.jpg',130, 195,18,'photo_1737970.html');
												thumbnails[2179283] = new thumbnail(2179283,'103934','Newgate Arch','Newgate-Arch_Clik_thumb.jpg',130, 87,18,'photo_2179283.html');
												thumbnails[2174097] = new thumbnail(2174097,'103934','Under The Arch','Under-The-Arch_Clik_thumb.jpg',130, 87,18,'photo_2174097.html');
												thumbnails[2179112] = new thumbnail(2179112,'103934','Grosvenor Shopping Centre','Grosvenor-Precinct_Clik_thumb.jpg',130, 87,18,'photo_2179112.html');
												thumbnails[5369784] = new thumbnail(5369784,'103934','Queens Park Suspension Bridge','CH-87-Clik_thumb.jpg',130, 195,18,'photo_5369784.html');
												thumbnails[2182587] = new thumbnail(2182587,'103934','St Marys Church ','St-Marys-Church_Clik_thumb.jpg',130, 195,18,'photo_2182587.html');
												thumbnails[2232394] = new thumbnail(2232394,'103934','Bandstand and Benches','CH_16_thumb.jpg',130, 195,18,'photo_2232394.html');
												thumbnails[2209268] = new thumbnail(2209268,'103934','Eccleston Church','CH_60_thumb.jpg',130, 87,18,'photo_2209268.html');
												thumbnails[2209266] = new thumbnail(2209266,'103934','Eccleston Church','CH_59_thumb.jpg',130, 87,18,'photo_2209266.html');
												thumbnails[5369735] = new thumbnail(5369735,'103934','','CH-82-Clik_thumb.jpg',130, 87,18,'photo_5369735.html');
												thumbnails[7294902] = new thumbnail(7294902,'103934','Frosty Tree','Clik_thumb.jpg',160, 107,18,'photo_7294902.html');
												thumbnails[2818008] = new thumbnail(2818008,'176007','Liverpool and Ark Royal','Ark-Royal-and-Liverpool_Clik_thumb.jpg',130, 87,18,'photo_2818008.html');
												thumbnails[2818013] = new thumbnail(2818013,'176007','Liverpool & Grand Princess','Grand-Princess_Clik_thumb.jpg',130, 87,18,'photo_2818013.html');
												thumbnails[2818015] = new thumbnail(2818015,'176007','Grand Princess','Grand-Princess-2_Clik_thumb.jpg',130, 87,18,'photo_2818015.html');
												thumbnails[2818017] = new thumbnail(2818017,'176007','Liverpool Skyline','Liverpool-Seagull_Clik_thumb.jpg',130, 87,18,'photo_2818017.html');
												thumbnails[2818019] = new thumbnail(2818019,'176007','HMS Ark Royal','Liverpool-Skyline-Sat_Clik_thumb.jpg',130, 87,18,'photo_2818019.html');
												thumbnails[2818090] = new thumbnail(2818090,'176007','Tall Ships','TS13_Clik_thumb.jpg',130, 87,18,'photo_2818090.html');
												thumbnails[2818095] = new thumbnail(2818095,'176007','Tall Ships','TS44_Clik_thumb.jpg',130, 87,18,'photo_2818095.html');
												thumbnails[2818097] = new thumbnail(2818097,'176007','Tall Ships','TS55_8x12_Clik_thumb.jpg',130, 87,18,'photo_2818097.html');
												thumbnails[5034808] = new thumbnail(5034808,'176007','Queen Mary 2 ','CH-74_thumb.jpg',130, 87,18,'photo_5034808.html');
												thumbnails[5035557] = new thumbnail(5035557,'176007','Port of Liverpool Office','CH-77_thumb.jpg',130, 87,18,'photo_5035557.html');
												thumbnails[5035566] = new thumbnail(5035566,'176007','St Georges Hall','CH-78_thumb.jpg',130, 87,18,'photo_5035566.html');
												thumbnails[5035597] = new thumbnail(5035597,'176007','Liverpool Waterfront at Night','CH-79_thumb.jpg',130, 87,18,'photo_5035597.html');
												thumbnails[5035603] = new thumbnail(5035603,'176007','Liverpool at Night','CH-80_thumb.jpg',130, 87,18,'photo_5035603.html');
												thumbnails[5035608] = new thumbnail(5035608,'176007','Liver Building','CH-81_thumb.jpg',130, 87,18,'photo_5035608.html');
												thumbnails[5035009] = new thumbnail(5035009,'176007','Queen Mary 2','CH-76_thumb.jpg',130, 87,18,'photo_5035009.html');
												thumbnails[5035443] = new thumbnail(5035443,'285029','Dolbadarn Castle','NW-1_thumb.jpg',130, 87,18,'photo_5035443.html');
												thumbnails[5035446] = new thumbnail(5035446,'285029','Dinorwic Slate Quarry','NW-2_thumb.jpg',130, 87,18,'photo_5035446.html');
												thumbnails[5035449] = new thumbnail(5035449,'285029','Electric Mountain','NW-3_thumb.jpg',130, 87,18,'photo_5035449.html');
												thumbnails[5035456] = new thumbnail(5035456,'285029','Quarry Buildings','NW-5_thumb.jpg',130, 86,18,'photo_5035456.html');
												thumbnails[5035461] = new thumbnail(5035461,'285029','Lake Vyrnwy Dam','NW-6_thumb.jpg',130, 87,18,'photo_5035461.html');
												thumbnails[5035468] = new thumbnail(5035468,'285029','Long Trek','NW-8_thumb.jpg',130, 86,18,'photo_5035468.html');
												thumbnails[5035472] = new thumbnail(5035472,'285029','Quarry Buildings','NW-9_thumb.jpg',130, 86,18,'photo_5035472.html');
												thumbnails[5035475] = new thumbnail(5035475,'285029','Quarry Lake','NW-10_thumb.jpg',130, 87,18,'photo_5035475.html');
												thumbnails[5035500] = new thumbnail(5035500,'285029','LLyn y Dywarchen','NW-111_thumb.jpg',130, 87,18,'photo_5035500.html');
												thumbnails[5035504] = new thumbnail(5035504,'285029','Conway Castle','NW-12_thumb.jpg',130, 93,18,'photo_5035504.html');
												thumbnails[5035507] = new thumbnail(5035507,'285029','Vyrnwy Dam','NW-13_thumb.jpg',130, 85,18,'photo_5035507.html');
												thumbnails[5035509] = new thumbnail(5035509,'285029','Pystyll Rhaedr Waterfall','NW-14_thumb.jpg',130, 87,18,'photo_5035509.html');
												thumbnails[5035512] = new thumbnail(5035512,'285029','Castle Steps','NW-15_thumb.jpg',130, 195,18,'photo_5035512.html');
												thumbnails[5035516] = new thumbnail(5035516,'285029','Rusty and Desolate','NW-17_thumb.jpg',130, 195,18,'photo_5035516.html');
												thumbnails[5035530] = new thumbnail(5035530,'285029','Point of Ayr Lighthouse','CH_49_thumb.jpg',130, 195,18,'photo_5035530.html');
												thumbnails[5035835] = new thumbnail(5035835,'285029','Nantlle Valley','NW-4_thumb.jpg',130, 87,18,'photo_5035835.html');
												thumbnails[5035841] = new thumbnail(5035841,'285029','Menai Bridge','NW-18_thumb.jpg',130, 87,18,'photo_5035841.html');
												thumbnails[5035862] = new thumbnail(5035862,'285029','Glaslyn','NW-19_thumb.jpg',130, 87,18,'photo_5035862.html');

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  					galleries[104154] = new gallery(104154,'1529806','Photos of Chester By Night','gallery',[1549290,1635587,2171502,1531120,1529806,1517347,1612405,1517321,3283138,2181221,1684464,1640146,1529804,2160627,1681629,1531709,1645666,1517322,1667352,1620840,2200125,1683379,2200154,5369745,5369748,5369746,1684203,1517323,5369743,7317377,3283509,7192371,7192345],0, 0, '', 'gallery.html',0,0);
				  					galleries[103934] = new gallery(103934,'7294902,5369784,5369735,2232394,2209268,2209266,2188562,2182587,2179316,2179283','Photos of Chester by Day','section138364',[2174052,2179316,1517365,2160891,2188562,2174199,1578439,1612462,1737970,2179283,2174097,2179112,5369784,2182587,2232394,2209268,2209266,5369735,7294902],0, 0, '', 'section138364.html',0,0);
				  					galleries[176007] = new gallery(176007,'2818090','Liverpool','section219196',[2818008,2818013,2818015,2818017,2818019,2818090,2818095,2818097,5034808,5035557,5035566,5035597,5035603,5035608,5035009],0, 0, '', 'section219196.html',0,0);
				  					galleries[285029] = new gallery(285029,'5035862,5035841,5035835,5035530,5035516,5035512,5035509,5035507,5035504,5035500','North Wales and Snowdonia','section341784',[5035443,5035446,5035449,5035456,5035461,5035468,5035472,5035475,5035500,5035504,5035507,5035509,5035512,5035516,5035530,5035835,5035841,5035862],0, 0, '', 'section341784.html',0,0);
/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = new Object();
imageSets[1] = '2171502,1529806';
imageSets[2] = '2818090,1529806';
imageSets[3] = '7317377,7294902,7192371,7192345,5369784,5369748,5369746,5369745,5369743,5369735,5035862,5035841,5035835,5035608,5035603,5035597,5035566,5035557,5035530,5035516,5035512,5035509,5035507,5035504,5035500,5035475,5035472,5035468,5035461,5035456,5035449,5035446,5035443,5035009,5034808,3283509,3283138,2818097,2818095,2818090,2818019,2818017,2818015,2818013,2818008,2232394,2209268,2209266,2200154,2200125';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/jeffdalton/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/jeffdalton/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/jeffdalton/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/jeffdalton/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/jeffdalton/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/jeffdalton/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/jeffdalton/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/jeffdalton/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/jeffdalton/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/jeffdalton/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/jeffdalton/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/jeffdalton/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/jeffdalton/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/jeffdalton/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/jeffdalton/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://admin2.clikpic.com/jeffdalton/images';
		break;
	}
		switch (server_id) {
		case 33:
		val = 'http://www8.clikpic.com/jeffdalton/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/jeffdalton/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/jeffdalton/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/jeffdalton/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/jeffdalton/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/jeffdalton/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));		  $('body').trigger('clikUpdate');		}, 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 = 'Chester Scenic Photos: ' + 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));      $('body').trigger('clikUpdate');    }        
    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="updateItemValues(document.forms.paymentForm,this.form.payment_options_id.options[this.form.payment_options_id.options.selectedIndex].value);">';
				
		temp = temp + getPaymentOptions(this.payment_groups_id);
		temp = temp + '</select>';
		temp = temp + '</form>';
				var item_option  = paymentGroups[this.payment_groups_id].options[0];
		if(paymentOptions[item_option]){
			var item_name  = paymentOptions[item_option].payment_option;
			var amount =  paymentOptions[item_option].price;
		}
			}
	else {
				
	}
	if (this.item_price !== '' || this.payment_groups_id !== '') {
																				temp = temp + '<form id="paymentForm" style="margin:0px;border:0px;" name="paymentForm" target="_blank" action="https://www.paypal.com/cgi-bin/webscr" method="post">';
	temp = temp + '<input type="hidden" name="item_name" value="'+item_name+'">';
								ref = '';
				if(this.photo_ref != ''){
					ref = this.photo_ref+' - '+this.caption;
				}
				else{
					ref = this.id+' - '+this.caption;
				}
				price = amount;					temp = temp + '<input type="hidden" name="cmd" value="_cart">';
	temp = temp + '<input type="hidden" name="business" value="jeffdalton@mac.com">';
	temp = temp + '<input type="hidden" name="currency_code" value="GBP">';
	temp = temp + '<input type="hidden" name="add" value="1">';
					temp = temp + '<input type="hidden" name="amount" value="'+amount+'">';
	temp = temp + '<input type="hidden" name="item_number" value="'+ref+'">';
					temp = temp + '<input type=\"Submit\" value=\"Add to cart\" id=\"paymentAddButton\" class=\"button\" onmouseover=\"this.className=\'buttonHi\';\" onmouseout=\"this.className=\'button\';\">';
									temp = temp + '</form>';
								temp = temp + '<form id="paymentCartForm" style="margin:0px;" name="paymentCartForm" target="_blank" action="https://www.paypal.com/cgi-bin/webscr" method="post">';
	temp = temp + '<input type="hidden" name="cmd" value="_cart">';
	temp = temp + '<input type="hidden" name="business" value="jeffdalton@mac.com">';
	temp = temp + '<input type="hidden" name="display" value="1">';
	temp = temp + '<input type=\"Submit\" value=\"View cart\" id=\"paymentViewButton\" class=\"button\" onmouseover=\"this.className=\'buttonHi\';\" onmouseout=\"this.className=\'button\';\">';
	temp = temp + '</form>';
							temp = temp + '<div class="clearing">&nbsp;</div>';
	}
	return temp;};

/***************************************************************************
* Pick a photo at random from the featured images of a gallery.            *
* Gallery_id = id of gallery to choose,                                    *
* img = reference to html image in                                         *
* which to show image                                                      *
***************************************************************************/
function showGalleryImage(gallery_id, img, updateLink) {
		
	if(img){
	      if (location.hash.match('galleries_id=' + gallery_id) && (imageID = location.hash.match('.*photos_id=(.+)$'))) {
        imageID = imageID[1];
      } else {
			  imageID = randomListVal(galleries[gallery_id].featured_images);
      }
							
			if (imageID != 0) {
				img.src = thumbnails[imageID].src;
				img.width = thumbnails[imageID].width;
				img.height = thumbnails[imageID].height;
				img.alt = galleries[gallery_id].title;
        if (updateLink) {
          $(img).parent().attr({            href: thumbnails[imageID].fnGalleryLink(gallery_id),            title: galleries[gallery_id].title          });
        }
							}
										}
}

/***************************************************************************
* If we have dynamic HTML, replace the galleries link with a list that     *
* doesn't include thecurrent gallery                                       *
***************************************************************************/
function showGalleries(gallery_id) {
		
	
	if (!basic) {
		temp = '';
		for (i = 0; i < galleries.length; i++) {
						
			
			if (galleries[i].id != gallery_id) {
								
				if (temp != '') {
					temp = temp + ' | ';
				}
				temp = temp + '<a href="' + galleries[i].section_code + '_' + galleries[i].id + '.html">' + galleries[i].title + '</a>';
			}
		}
		document.all.galleryLinks.innerHTML = 'Other galleries: ' + temp;
	}
}

			

