window.thumbnails = {};
thumbnails[8775807] = clik.newPhoto({"link":"#","caption":"Judy Tadman","height":173,"id":8775807,"server_id":31,"src":"Judy_thumb.jpg","galleries_id":"","width":130});
thumbnails[8796400] = clik.newPhoto({"link":"#","caption":"","height":195,"id":8796400,"server_id":31,"src":"Backup_of_Small_Vessel_011_thumb.jpg","galleries_id":"","width":130});
thumbnails[8796520] = clik.newPhoto({"link":"#","caption":"Three Giant Seed Pods","height":92,"id":8796520,"server_id":31,"src":"Pod1_thumb.jpg","galleries_id":"","width":130});
thumbnails[8810019] = clik.newPhoto({"link":"#","caption":"Work shop group","height":94,"id":8810019,"server_id":31,"src":"workshop_group_thumb.jpg","galleries_id":"","width":130});
thumbnails[8796251] = clik.newPhoto({"link":"photo_8796251.html","caption":"Symmetry","height":112,"id":8796251,"server_id":31,"src":"abstract_3_thumb.jpg","galleries_id":455808,"width":130});
thumbnails[8796288] = clik.newPhoto({"link":"photo_8796288.html","caption":"Christmas bauble","height":122,"id":8796288,"server_id":31,"src":"bauble_thumb.jpg","galleries_id":455808,"width":130});
thumbnails[8796303] = clik.newPhoto({"link":"photo_8796303.html","caption":"Bowl","height":109,"id":8796303,"server_id":31,"src":"bowl_thumb.jpg","galleries_id":455808,"width":130});
thumbnails[8796553] = clik.newPhoto({"link":"photo_8796553.html","caption":"Creature","height":145,"id":8796553,"server_id":31,"src":"creature_2_thumb.jpg","galleries_id":455808,"width":130});
thumbnails[8796661] = clik.newPhoto({"link":"photo_8796661.html","caption":"Figure 5","height":195,"id":8796661,"server_id":31,"src":"fig_5_thumb.jpg","galleries_id":455808,"width":130});
thumbnails[8796762] = clik.newPhoto({"link":"photo_8796762.html","caption":"Close up of seed pod","height":98,"id":8796762,"server_id":31,"src":"close_up_of_pod_thumb.jpg","galleries_id":455808,"width":130});
thumbnails[8796770] = clik.newPhoto({"link":"photo_8796770.html","caption":"Bending figure","height":195,"id":8796770,"server_id":31,"src":"fig_7_thumb.jpg","galleries_id":455808,"width":130});
thumbnails[8796775] = clik.newPhoto({"link":"photo_8796775.html","caption":"Figure 8","height":198,"id":8796775,"server_id":31,"src":"fig_8_thumb.jpg","galleries_id":455808,"width":130});
thumbnails[8796825] = clik.newPhoto({"link":"photo_8796825.html","caption":"Figures 1 and 2","height":155,"id":8796825,"server_id":31,"src":"figs_1_and_2_thumb.jpg","galleries_id":455808,"width":130});
thumbnails[8796830] = clik.newPhoto({"link":"photo_8796830.html","caption":"Figure 3","height":134,"id":8796830,"server_id":31,"src":"fig_3_thumb.jpg","galleries_id":455808,"width":130});
thumbnails[8796836] = clik.newPhoto({"link":"photo_8796836.html","caption":"Perceived Identity","height":173,"id":8796836,"server_id":31,"src":"perceived_identity_thumb.jpg","galleries_id":455808,"width":130});
thumbnails[8796847] = clik.newPhoto({"link":"photo_8796847.html","caption":"Recoil","height":316,"id":8796847,"server_id":31,"src":"recoil_thumb.jpg","galleries_id":455808,"width":130});
thumbnails[8796851] = clik.newPhoto({"link":"photo_8796851.html","caption":"Straight Jacket","height":205,"id":8796851,"server_id":31,"src":"Straight_Jacket_thumb.jpg","galleries_id":455808,"width":130});
thumbnails[8796855] = clik.newPhoto({"link":"photo_8796855.html","caption":"Vessel 1","height":107,"id":8796855,"server_id":31,"src":"Vessel_2_thumb.jpg","galleries_id":455808,"width":130});
thumbnails[8796858] = clik.newPhoto({"link":"photo_8796858.html","caption":"Vessel 2","height":184,"id":8796858,"server_id":31,"src":"Vessel_thumb.jpg","galleries_id":455808,"width":130});
thumbnails[8796860] = clik.newPhoto({"link":"photo_8796860.html","caption":"Wheelchair","height":174,"id":8796860,"server_id":31,"src":"wheelchair_2_thumb.jpg","galleries_id":455808,"width":130});
thumbnails[8796766] = clik.newPhoto({"link":"photo_8796766.html","caption":"Figure 6","height":234,"id":8796766,"server_id":31,"src":"fig_6_thumb.jpg","galleries_id":455808,"width":130});
thumbnails[8828311] = clik.newPhoto({"link":"photo_8828311.html","caption":"Giant Seed Pods","height":92,"id":8828311,"server_id":31,"src":"Textile_Art_3_HOST_thumb.jpg","galleries_id":455808,"width":130});
thumbnails[8775586] = clik.newPhoto({"link":"photo_8775586.html","caption":"Figure 4","height":195,"id":8775586,"server_id":31,"src":"fig_4_thumb.jpg","galleries_id":455808,"width":130});
thumbnails[8775771] = clik.newPhoto({"link":"photo_8775771.html","caption":"Abstract 1","height":194,"id":8775771,"server_id":31,"src":"abstract_11_thumb.jpg","galleries_id":455808,"width":130});
thumbnails[8775790] = clik.newPhoto({"link":"photo_8775790.html","caption":"Untitled","height":103,"id":8775790,"server_id":31,"src":"abstract_21_thumb.jpg","galleries_id":455808,"width":130});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
galleries[455808] = clik.newGallery({"photoIDs":[8796251,8796288,8796303,8796553,8796661,8796762,8796770,8796775,8796825,8796830,8796836,8796847,8796851,8796855,8796858,8796860,8796766,8828311,8775586,8775771,8775790],"link":"gallery.html","skipIndex":0,"section_code":"gallery","id":455808,"parentGallery":"","featured_images":"8828311,8796860,8796858,8796855,8796851,8796847,8796836,8796830,8796825,8796775,8796766,8796762,8796661,8796303,8796288,8796251,8775790,8775771,8775586","maxRecords":0,"usePopups":false,"singleSection":true,"title":"Gallery 1"});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[3] = '8775807,8775771,8810019,8775790';
imageSets[2] = '8796860,8796858,8796855,8796851,8796847,8796836,8796830,8796825,8796775,8796766,8796762,8796661,8796400,8796303,8796288,8796251,8828311,8775586,8775771,8810019,8775790';
imageSets[1] = '8796520';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/judytadman/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/judytadman/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/judytadman/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/judytadman/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/judytadman/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/judytadman/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/judytadman/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/judytadman/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/judytadman/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/judytadman/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/judytadman/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/judytadman/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/judytadman/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/judytadman/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/judytadman/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/judytadman/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/judytadman/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/judytadman/images';
		break;
	}
		switch (server_id) {
		case 0:
		val = 'http://www.clikpic.com/judytadman/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/judytadman/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/judytadman/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/judytadman/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/judytadman/images';
		break;
	}
		switch (server_id) {
		case 51:
		val = 'http://www12.clikpic.com/judytadman/images';
		break;
	}
		switch (server_id) {
		case 52:
		val = 'http://tpc22/clikpic/judytadman/images';
		break;
	}
		switch (server_id) {
		case 53:
		val = 'http://images.clikpic.com/judytadman/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/judytadman/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 || photos || {})[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:'',$detailContainer:'',
                    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 (op.updateHash && clik.getIDInUrl(location.href,'photo') != op.nextPhoto.id) {
		clik.changeHash('photos_id=' + op.nextPhoto.id, true);
	}
		
	    if (op.$title.length > 0) {
  		op.$title.fadeGalleryDetails(photoCaption, op.speed);
    }
        if (op.updateDocumentTitle) {
				  document.title = 'Judy Tadman Textile Artist: ' + photoCaption;
			    }
        if (op.$detail.length > 0) {
      	temp = op.nextPhoto.fnGetImageDetails();
	    op.$detail.fadeGalleryDetails(temp, op.speed, function(){
			if (typeof(backgrounds) != 'undefined' && op.nextPhoto == backgrounds[op.nextPhoto.id]) {
				toggleAddToCartConfirm(backgrounds, op.$detail);
			} else if (typeof(photos) != 'undefined' && op.nextPhoto == photos[op.nextPhoto.id]) {
				toggleAddToCartConfirm(photos, op.$detail);
			}
			$('body').trigger('clikUpdate.popup');
	    });
    }
        $(op.$detailContainer).find('.replaceable[class*=replaceable_photo-]').each(function(){
    	var field = clik.getPrefixedClass(this.className, 'replaceable_photo-');
    	if (field in op.nextPhoto) {
    		$(this).fadeGalleryDetails(op.nextPhoto[field], op.speed);
    	}
    }).end().find('.replaceable.photoPayment').fadeGalleryDetails(op.nextPhoto.fnGetPaymentInfo(), op.speed, function(){
		if (typeof(backgrounds) != 'undefined' && op.nextPhoto == backgrounds[op.nextPhoto.id]) {
			toggleAddToCartConfirm(backgrounds, op.$detailContainer);
		} else if (typeof(photos) != 'undefined' && op.nextPhoto == photos[op.nextPhoto.id]) {
			toggleAddToCartConfirm(photos, op.$detailContainer);
		}
		$('body').trigger('clikUpdate.popup');
	});
		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.speed) {
      	clik.doColumnResize(false, op.$photo.add(op.$detail).add(op.$title));
    }
        
    return html;
	}

/***************************************************************************
* Toggle add to cart confirmation element and set up the click event for   *
* the 'Add to cart' button.                                                *
***************************************************************************/
function toggleAddToCartConfirm(array, root){
	if (typeof(array) !== 'object' || array === null) {
	  	array = photos;
	}
	if (!$(root).length) {		root = $('body');	}	if($('#paymentConfirm', root).length > 0){
		$('#paymentConfirm', root).hide();
		$('#paymentAddButton', root)
		.unbind()
		.click(function(){
						form = $('#paymentForm', root)[0];
			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', root).text('Item added to cart').show();}
				else{
					$('#paymentConfirm', root).text('Item added to cart').fadeIn();
					dspOrderDetails(form.site.value);
				}
			}
			else{
				$('#paymentConfirm', root).text('Item not added - check cookies are enabled in your browser.').fadeIn();
			}
		});
	}
}

/***************************************************************************
* Get payment info for image - add as 'method' to photo object             *
***************************************************************************/
clik.photo.fnGetImageDetails = function(){
	var temp = '';
	if (this.description != '') {
		temp +=  '<div id="imageDescription">' + this.description + '</div>';
	}
		if (this.photo_ref != '') {
		temp += '<div class="imageinfo" id="imageRef"><strong>Ref: </strong>' + this.photo_ref + '</div>';
	}
		if (this.takendate != '') {
		
		temp += '<div class="imageinfo" id="imageDate"><strong>Date: </strong>' + this.takendate + '</div>';
	}
	
	if (this.location != '') {
		
		temp += '<div class="imageinfo" id="imageLocation"><strong>Location: </strong>' +  this.location + '</div>';
	}
	
	if (this.photographer != '') {
		
		temp += '<div class="imageinfo" id="imagePhotographer"><strong>Photographer: </strong>' + this.photographer + '</div>';
	}
			
				if (temp != '') {
		temp += '<div class="spacer"></div>';
	}
	return temp;
};

/***************************************************************************
* Get payment info for image - add as 'method' to photo object             *
***************************************************************************/
clik.photo.fnGetPaymentInfo = function(){
	var temp = '';
	if (this.item_price !== '') {
				temp += '<p>Order this print:</p>';
				temp += '<div class="imageinfo" id="imagePrice"><strong>' + this.purchase_instruction + '</strong> ' + (this.item_price).toFixed(2) + '</div>';
		var item_name  = this.purchase_instruction;
		var amount = (this.item_price).toFixed(2);
		var item_option  = 0;
	}
		else {
		
	}
	if (this.item_price !== '') {
			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({					title: galleries[gallery_id].title				}).filter(function(){return this.href;}).attr({					href: thumbnails[imageID].fnGalleryLink(gallery_id)				});
			}
		}
	}
}

/***************************************************************************
* 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 += '<a href="' + galleries[i].section_code + '_' + galleries[i].id + '.html">' + galleries[i].title + '</a>';
							}
		}
		document.all.galleryLinks.innerHTML = 'Other galleries: ' + temp;
	}
}

		

