window.thumbnails = new Object();
												thumbnails[820229] = new thumbnail(820229,'56578','','Final_22_thumb.jpg',130, 194,15,'photo_820229.html');
												thumbnails[810818] = new thumbnail(810818,'56584','','Type1_thumb.jpg',130, 194,15,'photo_810818.html');
												thumbnails[810842] = new thumbnail(810842,'56579','','water04_thumb.jpg',130, 194,15,'photo_810842.html');
												thumbnails[802225] = new thumbnail(802225,'56577','','_MG_4837-01 A4_thumb.jpg',130, 194,15,'photo_802225.html');
												thumbnails[802230] = new thumbnail(802230,'56277','','_MG_0028-01small_thumb.jpg',130, 194,15,'photo_802230.html');
												thumbnails[778324] = new thumbnail(778324,'56580','','Odyssey 2_thumb.jpg',130, 194,15,'photo_778324.html');
												thumbnails[735890] = new thumbnail(735890,'56583','','they\'re almost gone_thumb.jpg',130, 87,15,'photo_735890.html');
												thumbnails[738027] = new thumbnail(738027,'56576','','img013_thumb.jpg',130, 194,15,'photo_738027.html');
												thumbnails[820242] = new thumbnail(820242,'56579','','DSC_0003_thumb.jpg',130, 87,15,'photo_820242.html');
												thumbnails[810823] = new thumbnail(810823,'56584','','Dermy_thumb.jpg',130, 130,15,'photo_810823.html');
												thumbnails[781606] = new thumbnail(781606,'56577','','DSC_0289b n w_thumb.jpg',130, 130,15,'photo_781606.html');
												thumbnails[781611] = new thumbnail(781611,'56277','','matt gamble 2_thumb.jpg',130, 87,15,'photo_781611.html');
												thumbnails[778327] = new thumbnail(778327,'56580','','Dundrum_thumb.jpg',130, 194,15,'photo_778327.html');
												thumbnails[778332] = new thumbnail(778332,'56583','','Envelope_thumb.jpg',130, 87,15,'photo_778332.html');
												thumbnails[738029] = new thumbnail(738029,'56576','','d1e_thumb.jpg',130, 87,15,'photo_738029.html');
												thumbnails[738031] = new thumbnail(738031,'56578','','df004_thumb.jpg',130, 194,15,'photo_738031.html');
												thumbnails[820255] = new thumbnail(820255,'56579','','DSC_0006_thumb.jpg',130, 194,15,'photo_820255.html');
												thumbnails[810827] = new thumbnail(810827,'56584','','Flower_thumb.jpg',130, 130,15,'photo_810827.html');
												thumbnails[781592] = new thumbnail(781592,'56576','','Gillian21_thumb.jpg',130, 194,15,'photo_781592.html');
												thumbnails[781603] = new thumbnail(781603,'56577','','_DSC2530_thumb.jpg',130, 130,15,'photo_781603.html');
												thumbnails[781612] = new thumbnail(781612,'56277','','P5254635_thumb.jpg',130, 87,15,'photo_781612.html');
												thumbnails[779782] = new thumbnail(779782,'56578','','Portfolio1_thumb.jpg',130, 87,15,'photo_779782.html');
												thumbnails[778328] = new thumbnail(778328,'56580','','W5_thumb.jpg',130, 87,15,'photo_778328.html');
												thumbnails[735877] = new thumbnail(735877,'56583','','they\'re in the walls_thumb.jpg',130, 87,15,'photo_735877.html');
												thumbnails[810833] = new thumbnail(810833,'56584','','chris_thumb.jpg',130, 194,15,'photo_810833.html');
												thumbnails[867414] = new thumbnail(867414,'56580','','arches 5x7_thumb.jpg',130, 87,15,'photo_867414.html');
												thumbnails[867418] = new thumbnail(867418,'56583','','docks_thumb.jpg',130, 87,15,'photo_867418.html');
												thumbnails[810848] = new thumbnail(810848,'56579','','water05_thumb.jpg',130, 194,15,'photo_810848.html');
												thumbnails[781587] = new thumbnail(781587,'56576','','matt gamble 3_thumb.jpg',130, 130,15,'photo_781587.html');
												thumbnails[779785] = new thumbnail(779785,'56277','','Portfolio4_thumb.jpg',130, 194,15,'photo_779785.html');
												thumbnails[779801] = new thumbnail(779801,'56578','','portfolio2_thumb.jpg',130, 194,15,'photo_779801.html');
												thumbnails[778333] = new thumbnail(778333,'56577','','Rectangle_thumb.jpg',130, 194,15,'photo_778333.html');
												thumbnails[867416] = new thumbnail(867416,'56580','','dom_thumb.jpg',130, 194,15,'photo_867416.html');
												thumbnails[823213] = new thumbnail(823213,'56277','','Tall Ships 1st July - 06 Ballons_thumb.jpg',130, 87,15,'photo_823213.html');
												thumbnails[820224] = new thumbnail(820224,'56578','','final_004_thumb.jpg',130, 194,15,'photo_820224.html');
												thumbnails[820260] = new thumbnail(820260,'56583','','tube 72_thumb.jpg',130, 57,15,'photo_820260.html');
												thumbnails[781609] = new thumbnail(781609,'56577','','final 4_thumb.jpg',130, 130,15,'photo_781609.html');
												thumbnails[781634] = new thumbnail(781634,'56576','','IMG_3449_thumb.jpg',130, 87,15,'photo_781634.html');
												thumbnails[819931] = new thumbnail(819931,'56277','','castle5_thumb.jpg',130, 194,15,'photo_819931.html');
												thumbnails[781640] = new thumbnail(781640,'56577','','IMG_7836_thumb.jpg',130, 87,15,'photo_781640.html');
												thumbnails[802227] = new thumbnail(802227,'56577','','_MG_4803-01 A4_thumb.jpg',130, 87,15,'photo_802227.html');
												thumbnails[823226] = new thumbnail(823226,'56577','','DSC_0827_thumb.jpg',130, 130,15,'photo_823226.html');

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  					galleries[56277] = new gallery(56277,'819931','Location','gallery',[802230,781611,781612,779785,823213,819931],0, 0, '', 'gallery_56277.html',0,0);
				  					galleries[56576] = new gallery(56576,'781592','Portraiture','gallery',[738027,738029,781592,781587,781634],0, 0, '', 'gallery_56576.html',0,0);
				  					galleries[56577] = new gallery(56577,'802225','Natural Form','gallery',[802225,781606,781603,778333,781609,781640,802227,823226],0, 0, '', 'gallery_56577.html',0,0);
				  					galleries[56579] = new gallery(56579,'810842','Fine Art - Open','gallery',[810842,820242,820255,810848],0, 0, '', 'gallery_56579.html',0,0);
				  					galleries[56578] = new gallery(56578,'820224','Advertising','gallery',[820229,738031,779782,779801,820224],0, 0, '', 'gallery_56578.html',0,0);
				  					galleries[56580] = new gallery(56580,'778324','Architecture','gallery',[778324,778327,778328,867414,867416],0, 0, '', 'gallery_56580.html',0,0);
				  					galleries[56583] = new gallery(56583,'735890','Fine Art - Digital','gallery',[735890,778332,735877,867418,820260],0, 0, '', 'gallery_56583.html',0,0);
				  					galleries[56584] = new gallery(56584,'810833','BA (Hons)','gallery',[810818,810823,810827,810833],0, 0, '', 'gallery_56584.html',0,0);
/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = new Object();
imageSets[1] = '823213,820242,802227,738029,735877';
imageSets[2] = '820224,819931,810842,810833,802225,781592,778324,735890';
imageSets[3] = '867418,867416,867414,823226,823213,820260,820255,820242,820229,820224,819931,810848,810842,810833,810827,810823,810818,802230,802227,802225,781640,781634,781612,781611,781609,781606,781603,781592,781587,779801,779785,779782,778333,778332,778328,778327,778324,738031,738029,738027,735890,735877';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/photography2007/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/photography2007/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/photography2007/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/photography2007/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/photography2007/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/photography2007/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/photography2007/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/photography2007/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/photography2007/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/photography2007/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/photography2007/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/photography2007/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/photography2007/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/photography2007/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/photography2007/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://admin2.clikpic.com/photography2007/images';
		break;
	}
		switch (server_id) {
		case 33:
		val = 'http://www8.clikpic.com/photography2007/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/photography2007/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/photography2007/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/photography2007/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/photography2007/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/photography2007/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 = 'HND Photography: ' + photoCaption;
			    }
        if (op.$detail.length > 0) {
      temp = op.nextPhoto.fnGetImageDetails();
	    op.$detail.fadeGalleryDetails(temp, op.speed, function(){
	    var options = {photoinfominwidth:200};	    		options.photoinfoadjacent = true;			      	      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>';
	}
					
				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;
	}
}

			

