window.thumbnails = {};
thumbnails[7680666] = clik.newPhoto({"link":"photo_7680666.html","caption":"","height":91,"id":7680666,"server_id":31,"src":"tigerhuntb_thumb.jpg","galleries_id":415135,"width":130});
thumbnails[8327313] = clik.newPhoto({"link":"photo_8327313.html","caption":"","height":189,"id":8327313,"server_id":31,"src":"automobile_website12_thumb.jpg","galleries_id":415135,"width":130});
thumbnails[7679746] = clik.newPhoto({"link":"photo_7679746.html","caption":"","height":150,"id":7679746,"server_id":31,"src":"sonny3b2_thumb.jpg","galleries_id":415134,"width":130});
thumbnails[7680659] = clik.newPhoto({"link":"photo_7680659.html","caption":"","height":142,"id":7680659,"server_id":31,"src":"chocolateb_thumb.jpg","galleries_id":415135,"width":130});
thumbnails[7679761] = clik.newPhoto({"link":"photo_7679761.html","caption":"","height":141,"id":7679761,"server_id":31,"src":"sonny2b_thumb.jpg","galleries_id":415134,"width":130});
thumbnails[7680660] = clik.newPhoto({"link":"photo_7680660.html","caption":"","height":144,"id":7680660,"server_id":31,"src":"ganeshb_thumb.jpg","galleries_id":415135,"width":130});
thumbnails[7672825] = clik.newPhoto({"link":"photo_7672825.html","caption":"","height":75,"id":7672825,"server_id":31,"src":"sonny1b_thumb.jpg","galleries_id":415134,"width":130});
thumbnails[7679780] = clik.newPhoto({"link":"photo_7679780.html","caption":"","height":74,"id":7679780,"server_id":31,"src":"sonny5b_thumb.jpg","galleries_id":415134,"width":130});
thumbnails[7680664] = clik.newPhoto({"link":"photo_7680664.html","caption":"","height":147,"id":7680664,"server_id":31,"src":"skeletonb_thumb.jpg","galleries_id":415135,"width":130});
thumbnails[7679797] = clik.newPhoto({"link":"photo_7679797.html","caption":"","height":75,"id":7679797,"server_id":31,"src":"sonny4b1_thumb.jpg","galleries_id":415134,"width":130});
thumbnails[7680658] = clik.newPhoto({"link":"photo_7680658.html","caption":"","height":184,"id":7680658,"server_id":31,"src":"balloonb_thumb.jpg","galleries_id":415135,"width":130});
thumbnails[7679835] = clik.newPhoto({"link":"photo_7679835.html","caption":"","height":75,"id":7679835,"server_id":31,"src":"sonny6b_thumb.jpg","galleries_id":415134,"width":130});
thumbnails[7680667] = clik.newPhoto({"link":"photo_7680667.html","caption":"","height":184,"id":7680667,"server_id":31,"src":"tvattackb_thumb.jpg","galleries_id":415135,"width":130});
thumbnails[7679836] = clik.newPhoto({"link":"photo_7679836.html","caption":"","height":75,"id":7679836,"server_id":31,"src":"sonny7b_thumb.jpg","galleries_id":415134,"width":130});
thumbnails[7680665] = clik.newPhoto({"link":"photo_7680665.html","caption":"","height":80,"id":7680665,"server_id":31,"src":"superbugb_thumb.jpg","galleries_id":415135,"width":130});
thumbnails[7672820] = clik.newPhoto({"link":"photo_7672820.html","caption":"","height":192,"id":7672820,"server_id":31,"src":"explorers1b_thumb.jpg","galleries_id":415134,"width":130});
thumbnails[7680661] = clik.newPhoto({"link":"photo_7680661.html","caption":"","height":86,"id":7680661,"server_id":31,"src":"orangeb_thumb.jpg","galleries_id":415135,"width":130});
thumbnails[7672821] = clik.newPhoto({"link":"photo_7672821.html","caption":"","height":176,"id":7672821,"server_id":31,"src":"explorers2b_thumb.jpg","galleries_id":415134,"width":130});
thumbnails[7672776] = clik.newPhoto({"link":"photo_7672776.html","caption":"","height":90,"id":7672776,"server_id":31,"src":"explorers3b2_thumb.jpg","galleries_id":415134,"width":130});
thumbnails[9148590] = clik.newPhoto({"link":"photo_9148590.html","caption":"Rubber Skeleton #1 (Cover)","height":176,"id":9148590,"server_id":31,"src":"cover2_1_thumb.jpg","galleries_id":483076,"width":130});
thumbnails[9148583] = clik.newPhoto({"link":"photo_9148583.html","caption":"Rubber Skeleton #1 (Page 1)","height":90,"id":9148583,"server_id":31,"src":"pg1_b_1_thumb.jpg","galleries_id":483076,"width":130});
thumbnails[9148570] = clik.newPhoto({"link":"photo_9148570.html","caption":"Rubber Skeleton #1 (Page 2)","height":86,"id":9148570,"server_id":31,"src":"page2_fin_1_thumb.jpg","galleries_id":483076,"width":130});
thumbnails[9148586] = clik.newPhoto({"link":"photo_9148586.html","caption":"Rubber Skeleton #1 (Page 3)","height":85,"id":9148586,"server_id":31,"src":"page3_1_thumb.jpg","galleries_id":483076,"width":130});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
galleries[483076] = clik.newGallery({"photoIDs":[9148590,9148583,9148570,9148586],"link":"section589216.html","skipIndex":0,"section_code":"section589216","id":483076,"parentGallery":"","featured_images":"9148590,9148586,9148583,9148570","maxRecords":0,"usePopups":true,"singleSection":true,"title":"Rubber Skeleton #1"});galleries[415134] = clik.newGallery({"photoIDs":[7679746,7679761,7672825,7679780,7679797,7679835,7679836,7672820,7672821,7672776],"link":"GALLERY_415134.html","skipIndex":0,"section_code":"GALLERY","id":415134,"parentGallery":"","featured_images":7679797,"maxRecords":0,"usePopups":true,"singleSection":false,"title":"Kid's Books"});galleries[415135] = clik.newGallery({"photoIDs":[7680666,8327313,7680659,7680660,7680664,7680658,7680667,7680665,7680661],"link":"GALLERY_415135.html","skipIndex":0,"section_code":"GALLERY","id":415135,"parentGallery":"","featured_images":7680661,"maxRecords":0,"usePopups":true,"singleSection":false,"title":"Other Illustration"});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[3] = '9148590,9148586,9148583,9148570,8327313,7680667,7680666,7680665,7680664,7680661,7680660,7680659,7680658,7679836,7679835,7679797,7679780,7679761,7679746,7672825,7672821,7672820,7672776';
imageSets[2] = '7679797,7680661';
imageSets[1] = '7680666';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/davidplant/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/davidplant/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/davidplant/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/davidplant/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/davidplant/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/davidplant/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/davidplant/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/davidplant/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/davidplant/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/davidplant/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/davidplant/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/davidplant/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/davidplant/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/davidplant/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/davidplant/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/davidplant/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/davidplant/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/davidplant/images';
		break;
	}
		switch (server_id) {
		case 0:
		val = 'http://www.clikpic.com/davidplant/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/davidplant/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/davidplant/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/davidplant/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/davidplant/images';
		break;
	}
		switch (server_id) {
		case 51:
		val = 'http://www12.clikpic.com/davidplant/images';
		break;
	}
		switch (server_id) {
		case 52:
		val = 'http://tpc22/clikpic/davidplant/images';
		break;
	}
		switch (server_id) {
		case 53:
		val = 'http://images.clikpic.com/davidplant/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/davidplant/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 = 'DAVID  J  PLANT  ILLUSTRATION: ' + 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> &pound;' + (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 += '<form id="paymentForm" style="margin:0px;border:0px;" name="paymentForm" target="_blank" action="https://www.paypal.com/cgi-bin/webscr" method="post">';
			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 += '<input type="hidden" name="cmd" value="_cart">';
					temp += '<input type="hidden" name="business" value="b_c_a_s@hotmail.com">';
					temp += '<input type="hidden" name="currency_code" value="GBP">';
					temp += '<input type="hidden" name="add" value="1">';
													temp += '<input type="hidden" name="amount" value="'+amount+'">';
					temp += '<input type="hidden" name="item_number" value="'+ref+'">';
													temp += '<input type=\"Submit\" value=\"Add to cart\" id=\"paymentAddButton\" class=\"button\" onmouseover=\"this.className=\'buttonHi\';\" onmouseout=\"this.className=\'button\';\">';
										temp += '</form>';
										temp += '<form id="paymentCartForm" style="margin:0px;" name="paymentCartForm" target="_blank" action="https://www.paypal.com/cgi-bin/webscr" method="post">';
				temp += '<input type="hidden" name="cmd" value="_cart">';
				temp += '<input type="hidden" name="business" value="b_c_a_s@hotmail.com">';
				temp += '<input type="hidden" name="display" value="1">';
				temp += '<input type=\"Submit\" value=\"View cart\" id=\"paymentViewButton\" class=\"button\" onmouseover=\"this.className=\'buttonHi\';\" onmouseout=\"this.className=\'button\';\">';
				temp += '</form>';
				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;
	}
}

		

