window.thumbnails = {};
thumbnails[8339269] = clik.newPhoto({"link":"photo_8339269.html","caption":"Butterfly Tangle","height":181,"id":8339269,"server_id":31,"src":"Butterfly-Tangle_thumb.jpg","galleries_id":442547,"width":130});
thumbnails[8347721] = clik.newPhoto({"link":"photo_8347721.html","caption":"Fruit Reflections","height":96,"id":8347721,"server_id":31,"src":"Reflections_thumb.jpg","galleries_id":443572,"width":130});
thumbnails[8347837] = clik.newPhoto({"link":"photo_8347837.html","caption":"Bouquet","height":185,"id":8347837,"server_id":31,"src":"Bouquet_thumb.jpg","galleries_id":443599,"width":130});
thumbnails[8347849] = clik.newPhoto({"link":"photo_8347849.html","caption":"Irises & Wild Strawberries","height":177,"id":8347849,"server_id":31,"src":"Irises-and-wild-strawberrie_thumb.jpg","galleries_id":442548,"width":130});
thumbnails[8347922] = clik.newPhoto({"link":"photo_8347922.html","caption":"Thistles & Poppies","height":324,"id":8347922,"server_id":31,"src":"Thistles-and-Poppies_thumb.jpg","galleries_id":443600,"width":130});
thumbnails[8348089] = clik.newPhoto({"link":"photo_8348089.html","caption":"Florals 1","height":193,"id":8348089,"server_id":31,"src":"Florals-1_thumb.jpg","galleries_id":443618,"width":130});
thumbnails[8332033] = clik.newPhoto({"link":"photo_8332033.html","caption":"Seedhead in Landscape","height":270,"id":8332033,"server_id":31,"src":"Seedhead-in-Landscape_thumb.jpg","galleries_id":443600,"width":130});
thumbnails[8339281] = clik.newPhoto({"link":"photo_8339281.html","caption":"Down Under","height":190,"id":8339281,"server_id":31,"src":"Down-Under_thumb.jpg","galleries_id":442547,"width":130});
thumbnails[8347685] = clik.newPhoto({"link":"photo_8347685.html","caption":"Florals 2","height":187,"id":8347685,"server_id":31,"src":"Florals-2_thumb.jpg","galleries_id":443572,"width":130});
thumbnails[8347841] = clik.newPhoto({"link":"photo_8347841.html","caption":"Butterflies & Irises","height":185,"id":8347841,"server_id":31,"src":"Butterflies--Irises_thumb.jpg","galleries_id":443599,"width":130});
thumbnails[8347867] = clik.newPhoto({"link":"photo_8347867.html","caption":"Roses","height":171,"id":8347867,"server_id":31,"src":"Roses_thumb.jpg","galleries_id":442548,"width":130});
thumbnails[8348151] = clik.newPhoto({"link":"photo_8348151.html","caption":"Lilies 2","height":210,"id":8348151,"server_id":31,"src":"Lilies-2_thumb.jpg","galleries_id":443618,"width":130});
thumbnails[8332482] = clik.newPhoto({"link":"photo_8332482.html","caption":"Fruits of Autumn","height":190,"id":8332482,"server_id":31,"src":"Fruits-of-Autumn_thumb.jpg","galleries_id":442547,"width":130});
thumbnails[8346566] = clik.newPhoto({"link":"photo_8346566.html","caption":"Butterflies B&W","height":186,"id":8346566,"server_id":31,"src":"Butterflies-BW_thumb.jpg","galleries_id":443572,"width":130});
thumbnails[8347901] = clik.newPhoto({"link":"photo_8347901.html","caption":"Still Life with Chair","height":178,"id":8347901,"server_id":31,"src":"Still-Life-with-Chair_thumb.jpg","galleries_id":443599,"width":130});
thumbnails[8347907] = clik.newPhoto({"link":"photo_8347907.html","caption":"Kaleidoscope","height":169,"id":8347907,"server_id":31,"src":"Kaleidoscope_thumb.jpg","galleries_id":442548,"width":130});
thumbnails[8347923] = clik.newPhoto({"link":"photo_8347923.html","caption":"Amber Eye","height":238,"id":8347923,"server_id":31,"src":"Amber-Eye_thumb.jpg","galleries_id":443600,"width":130});
thumbnails[8339302] = clik.newPhoto({"link":"photo_8339302.html","caption":"Sunflowers & Leaves","height":129,"id":8339302,"server_id":31,"src":"SUNFLOWERS--LEAVES_thumb.jpg","galleries_id":442548,"width":130});
thumbnails[8347725] = clik.newPhoto({"link":"photo_8347725.html","caption":"Lilies B&W","height":132,"id":8347725,"server_id":31,"src":"Lilies-BW1_thumb.jpg","galleries_id":443572,"width":130});
thumbnails[8347879] = clik.newPhoto({"link":"photo_8347879.html","caption":"Tulips & Chinese Vase","height":178,"id":8347879,"server_id":31,"src":"TULIPS-AND-CHINESE-VASE_thumb.jpg","galleries_id":442547,"width":130});
thumbnails[8347903] = clik.newPhoto({"link":"photo_8347903.html","caption":"Strawberries & Shells","height":94,"id":8347903,"server_id":31,"src":"Strawberries-and-Shells_thumb.jpg","galleries_id":443599,"width":130});
thumbnails[8347920] = clik.newPhoto({"link":"photo_8347920.html","caption":"Cyclamen","height":131,"id":8347920,"server_id":31,"src":"Cyclamen_thumb.jpg","galleries_id":443600,"width":130});
thumbnails[8332451] = clik.newPhoto({"link":"photo_8332451.html","caption":"Australian Flowers","height":178,"id":8332451,"server_id":31,"src":"Australian-Flowers_thumb.jpg","galleries_id":442547,"width":130});
thumbnails[8339328] = clik.newPhoto({"link":"photo_8339328.html","caption":"Sunflower","height":131,"id":8339328,"server_id":31,"src":"SUNFLOWER_thumb.jpg","galleries_id":442548,"width":130});
thumbnails[8347686] = clik.newPhoto({"link":"photo_8347686.html","caption":"Fabric & Flowers","height":87,"id":8347686,"server_id":31,"src":"Fabric--Flowers_thumb.jpg","galleries_id":443572,"width":130});
thumbnails[8347900] = clik.newPhoto({"link":"photo_8347900.html","caption":"Chapel & Peonies","height":92,"id":8347900,"server_id":31,"src":"Chapel-with-Peonies_thumb.jpg","galleries_id":443599,"width":130});
thumbnails[8347919] = clik.newPhoto({"link":"photo_8347919.html","caption":"Lilies 4","height":92,"id":8347919,"server_id":31,"src":"Lilies-4_thumb.jpg","galleries_id":443600,"width":130});
thumbnails[8347825] = clik.newPhoto({"link":"photo_8347825.html","caption":"Morning Fresh","height":168,"id":8347825,"server_id":31,"src":"Morning-Fresh_thumb.jpg","galleries_id":443572,"width":130});
thumbnails[8382154] = clik.newPhoto({"link":"photo_8382154.html","caption":"Autumn Splendour","height":316,"id":8382154,"server_id":31,"src":"Autumn-Splendour-web_thumb.jpg","galleries_id":442547,"width":130});
thumbnails[8347829] = clik.newPhoto({"link":"photo_8347829.html","caption":"Growing Form","height":190,"id":8347829,"server_id":31,"src":"Growing-Form_thumb.jpg","galleries_id":443572,"width":130});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
galleries[442547] = clik.newGallery({"photoIDs":[8339269,8339281,8332482,8347879,8332451,8382154],"link":"gallery_442547.html","skipIndex":0,"section_code":"gallery","id":442547,"parentGallery":"","featured_images":"8382154,8347879,8339281,8339269,8332482,8332451","maxRecords":0,"usePopups":false,"singleSection":false,"title":"GALLERY 1"});galleries[442548] = clik.newGallery({"photoIDs":[8347849,8347867,8347907,8339302,8339328],"link":"gallery_442548.html","skipIndex":0,"section_code":"gallery","id":442548,"parentGallery":"","featured_images":"8347907,8347867,8347849,8339328,8339302","maxRecords":0,"usePopups":false,"singleSection":false,"title":"GALLERY 2"});galleries[443599] = clik.newGallery({"photoIDs":[8347837,8347841,8347901,8347903,8347900],"link":"gallery_443599.html","skipIndex":0,"section_code":"gallery","id":443599,"parentGallery":"","featured_images":"8347903,8347901,8347900,8347841,8347837","maxRecords":0,"usePopups":false,"singleSection":false,"title":"GALLERY 3"});galleries[443600] = clik.newGallery({"photoIDs":[8347922,8332033,8347923,8347920,8347919],"link":"gallery_443600.html","skipIndex":0,"section_code":"gallery","id":443600,"parentGallery":"","featured_images":"8347923,8347922,8347920,8347919,8332033","maxRecords":0,"usePopups":false,"singleSection":false,"title":"GALLERY 4"});galleries[443618] = clik.newGallery({"photoIDs":[8348089,8348151],"link":"gallery_443618.html","skipIndex":0,"section_code":"gallery","id":443618,"parentGallery":"","featured_images":"8348151,8348089","maxRecords":0,"usePopups":false,"singleSection":false,"title":"GALLERY 5"});galleries[443572] = clik.newGallery({"photoIDs":[8347721,8347685,8346566,8347725,8347686,8347825,8347829],"link":"gallery_443572.html","skipIndex":0,"section_code":"gallery","id":443572,"parentGallery":"","featured_images":"8347829,8347825,8347725,8347721,8347686,8347685,8346566","maxRecords":0,"usePopups":false,"singleSection":false,"title":"PEN & INK LINEAR DESIGNS"});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[3] = '8339269,8339281,8332033,8332482,8339302,8339328,8332451';
imageSets[1] = '8339269,8339281,8332033,8332482,8339302,8339328,8332451';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/cassyduffield/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/cassyduffield/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/cassyduffield/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/cassyduffield/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/cassyduffield/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/cassyduffield/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/cassyduffield/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/cassyduffield/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/cassyduffield/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/cassyduffield/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/cassyduffield/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/cassyduffield/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/cassyduffield/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/cassyduffield/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/cassyduffield/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/cassyduffield/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/cassyduffield/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/cassyduffield/images';
		break;
	}
		switch (server_id) {
		case 0:
		val = 'http://www.clikpic.com/cassyduffield/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/cassyduffield/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/cassyduffield/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/cassyduffield/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/cassyduffield/images';
		break;
	}
		switch (server_id) {
		case 51:
		val = 'http://www12.clikpic.com/cassyduffield/images';
		break;
	}
		switch (server_id) {
		case 52:
		val = 'http://tpc22/clikpic/cassyduffield/images';
		break;
	}
		switch (server_id) {
		case 53:
		val = 'http://images.clikpic.com/cassyduffield/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/cassyduffield/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 = 'CAROLINE DUFFIELD - CONTEMPORARY 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;
	}
}

		

