window.thumbnails = {};
															thumbnails[2202450] = clik.newPhoto({"id":2202450,"src":"kitchen2_thumb.jpg","galleries_id":145600,"server_id":32,"link":"photo_2202450.html","width":130,"caption":"Kitchen with Doors to Garden","height":87});
															thumbnails[2202457] = clik.newPhoto({"id":2202457,"src":"Private-road_thumb.jpg","galleries_id":162041,"server_id":32,"link":"photo_2202457.html","width":130,"caption":"Private road","height":87});
															thumbnails[2526207] = clik.newPhoto({"id":2526207,"src":"Library-and-television_thumb.jpg","galleries_id":145373,"server_id":32,"link":"photo_2526207.html","width":130,"caption":"First Floor Sitting Room","height":87});
															thumbnails[2526210] = clik.newPhoto({"id":2526210,"src":"Double-room-1_thumb.jpg","galleries_id":145596,"server_id":32,"link":"photo_2526210.html","width":130,"caption":"Master Bedroom","height":87});
															thumbnails[2526219] = clik.newPhoto({"id":2526219,"src":"Pool-and-view_thumb.jpg","galleries_id":145594,"server_id":32,"link":"photo_2526219.html","width":130,"caption":"Pool Views","height":87});
															thumbnails[2526242] = clik.newPhoto({"id":2526242,"src":"West-elevation_thumb.jpg","galleries_id":145593,"server_id":32,"link":"photo_2526242.html","width":130,"caption":"Sun Terrace and Covered Loggia","height":87});
															thumbnails[2603810] = clik.newPhoto({"id":2603810,"src":"servigliano_thumb.jpg","galleries_id":161842,"server_id":32,"link":"photo_2603810.html","width":130,"caption":"Gateway to Servigliano","height":87});
															thumbnails[2603968] = clik.newPhoto({"id":2603968,"src":"penna1_thumb.jpg","galleries_id":161840,"server_id":32,"link":"photo_2603968.html","width":130,"caption":"View from Penna San Giovanni","height":87});
															thumbnails[2603972] = clik.newPhoto({"id":2603972,"src":"santangelo_thumb.jpg","galleries_id":162041,"server_id":32,"link":"photo_2603972.html","width":130,"caption":"View from Sant Angelo in Pontano","height":87});
															thumbnails[2202440] = clik.newPhoto({"id":2202440,"src":"dinningroom1_thumb.jpg","galleries_id":145373,"server_id":32,"link":"photo_2202440.html","width":130,"caption":"Dining Room","height":87});
															thumbnails[2202442] = clik.newPhoto({"id":2202442,"src":"doublebedroom1_thumb.jpg","galleries_id":145596,"server_id":32,"link":"photo_2202442.html","width":130,"caption":"Double Bedroom with En-suite","height":87});
															thumbnails[2202449] = clik.newPhoto({"id":2202449,"src":"kitchen1_thumb.jpg","galleries_id":145600,"server_id":32,"link":"photo_2202449.html","width":130,"caption":"Kitchen with Doors to Loggia","height":87});
															thumbnails[2202456] = clik.newPhoto({"id":2202456,"src":"pennasangiovanni1_thumb.jpg","galleries_id":162041,"server_id":32,"link":"photo_2202456.html","width":130,"caption":"Looking up to Penna San Giovanni","height":98});
															thumbnails[2202462] = clik.newPhoto({"id":2202462,"src":"swimmingpool1_thumb.jpg","galleries_id":145594,"server_id":32,"link":"photo_2202462.html","width":130,"caption":"Roman Steps","height":98});
															thumbnails[2202473] = clik.newPhoto({"id":2202473,"src":"wintersun1_thumb.jpg","galleries_id":162041,"server_id":32,"link":"photo_2202473.html","width":130,"caption":"Snow capped mountains in Winter","height":98});
															thumbnails[2526193] = clik.newPhoto({"id":2526193,"src":"Casa-Olivia_thumb.jpg","galleries_id":145593,"server_id":32,"link":"photo_2526193.html","width":130,"caption":"Casa Olivia","height":87});
															thumbnails[2526212] = clik.newPhoto({"id":2526212,"src":"Twin-room-1_thumb.jpg","galleries_id":145596,"server_id":32,"link":"photo_2526212.html","width":130,"caption":"Family Room","height":87});
															thumbnails[2526460] = clik.newPhoto({"id":2526460,"src":"Lake-Fiastra_thumb.jpg","galleries_id":161840,"server_id":32,"link":"photo_2526460.html","width":130,"caption":"Lake Fiastra","height":98});
															thumbnails[2603808] = clik.newPhoto({"id":2603808,"src":"tower_thumb.jpg","galleries_id":161842,"server_id":32,"link":"photo_2603808.html","width":130,"caption":"Tolentino Castle","height":98});
															thumbnails[2526518] = clik.newPhoto({"id":2526518,"src":"Penna-door_thumb.jpg","galleries_id":161842,"server_id":32,"link":"photo_2526518.html","width":87,"caption":"Classic Italian Architecture","height":130});
															thumbnails[2198920] = clik.newPhoto({"id":2198920,"src":"sittingroom_thumb.jpg","galleries_id":145373,"server_id":32,"link":"photo_2198920.html","width":130,"caption":"Sitting Room","height":87});
															thumbnails[2202460] = clik.newPhoto({"id":2202460,"src":"sunset1_thumb.jpg","galleries_id":162041,"server_id":32,"link":"photo_2202460.html","width":130,"caption":"Sunset from the Terrace","height":98});
															thumbnails[2202468] = clik.newPhoto({"id":2202468,"src":"twinroom1_thumb.jpg","galleries_id":145596,"server_id":32,"link":"photo_2202468.html","width":130,"caption":"Twin Bedroom with En-Suite","height":87});
															thumbnails[2526248] = clik.newPhoto({"id":2526248,"src":"Tents-and-shade_thumb.jpg","galleries_id":145593,"server_id":32,"link":"photo_2526248.html","width":130,"caption":"Shaded South-Facing Garden","height":87});
															thumbnails[2530485] = clik.newPhoto({"id":2530485,"src":"Tolentino_thumb.jpg","galleries_id":161842,"server_id":32,"link":"photo_2530485.html","width":130,"caption":"Tolentino","height":87});
															thumbnails[2603896] = clik.newPhoto({"id":2603896,"src":"dining1_thumb.jpg","galleries_id":145373,"server_id":32,"link":"photo_2603896.html","width":130,"caption":"Dining Room with Doors to Garden","height":87});
															thumbnails[5034923] = clik.newPhoto({"id":5034923,"src":"Childrens-bedroom_thumb.jpg","galleries_id":145596,"server_id":32,"link":"photo_5034923.html","width":130,"caption":"Children's room ","height":87});
															thumbnails[2202433] = clik.newPhoto({"id":2202433,"src":"En-suite-bathroom_thumb.jpg","galleries_id":145596,"server_id":32,"link":"photo_2202433.html","width":130,"caption":"Master Bathroom","height":87});
															thumbnails[2526533] = clik.newPhoto({"id":2526533,"src":"lowerterrace_thumb.jpg","galleries_id":145593,"server_id":32,"link":"photo_2526533.html","width":130,"caption":"Covered Loggia","height":87});
															thumbnails[2526536] = clik.newPhoto({"id":2526536,"src":"loungedinningroom_thumb.jpg","galleries_id":145373,"server_id":32,"link":"photo_2526536.html","width":87,"caption":"Open Plan Living","height":130});
															thumbnails[2202435] = clik.newPhoto({"id":2202435,"src":"En-suite-shower_thumb.jpg","galleries_id":145596,"server_id":32,"link":"photo_2202435.html","width":87,"caption":"En-Suite Shower","height":130});
															thumbnails[2526538] = clik.newPhoto({"id":2526538,"src":"terracepool_thumb.jpg","galleries_id":145593,"server_id":32,"link":"photo_2526538.html","width":130,"caption":"West-Facing Terrace","height":87});
															thumbnails[2603897] = clik.newPhoto({"id":2603897,"src":"hammock_thumb.jpg","galleries_id":145593,"server_id":32,"link":"photo_2603897.html","width":130,"caption":"Hammock","height":87});
															thumbnails[2526530] = clik.newPhoto({"id":2526530,"src":"gardensunbed_thumb.jpg","galleries_id":145593,"server_id":32,"link":"photo_2526530.html","width":130,"caption":"Mature Trees for Shade","height":87});
															thumbnails[2526471] = clik.newPhoto({"id":2526471,"src":"Monti-Sibillini_thumb.jpg","galleries_id":161840,"server_id":32,"link":"photo_2526471.html","width":98,"caption":"The Sibillini Mountains","height":130});
															thumbnails[2603862] = clik.newPhoto({"id":2603862,"src":"msmview1_thumb.jpg","galleries_id":162041,"server_id":32,"link":"photo_2603862.html","width":130,"caption":"View from Monte San Martino","height":87});
															thumbnails[5034931] = clik.newPhoto({"id":5034931,"src":"Garden-view_thumb.jpg","galleries_id":162041,"server_id":32,"link":"photo_5034931.html","width":98,"caption":"Garden view to Penna San Giovanni","height":130});
															thumbnails[2603967] = clik.newPhoto({"id":2603967,"src":"penna_thumb.jpg","galleries_id":161842,"server_id":32,"link":"photo_2603967.html","width":87,"caption":"Town Hall at Penna San Giovanni","height":130});
															thumbnails[2603807] = clik.newPhoto({"id":2603807,"src":"utility_thumb.jpg","galleries_id":145600,"server_id":32,"link":"photo_2603807.html","width":87,"caption":"Utiliy Room","height":130});
															thumbnails[2603813] = clik.newPhoto({"id":2603813,"src":"psgbikes_thumb.jpg","galleries_id":167121,"server_id":32,"link":"photo_2603813.html","width":87,"caption":"Porto San Giorgio","height":130});
															thumbnails[2603895] = clik.newPhoto({"id":2603895,"src":"500_thumb.jpg","galleries_id":161842,"server_id":32,"link":"photo_2603895.html","width":87,"caption":"Santa Vittoria in Matenano","height":130});
															thumbnails[2530446] = clik.newPhoto({"id":2530446,"src":"icecreamshop_thumb.jpg","galleries_id":161842,"server_id":32,"link":"photo_2530446.html","width":87,"caption":"Gelateria in Servigliano","height":130});
															thumbnails[2603969] = clik.newPhoto({"id":2603969,"src":"psgbeach1_thumb.jpg","galleries_id":167121,"server_id":32,"link":"photo_2603969.html","width":98,"caption":"Grottamare","height":130});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  						galleries[145600] = clik.newGallery({"parentGallery":161831,"usePopups":false,"title":"Kitchen & Utility","link":"gallery_145600.html","maxRecords":0.0,"photoIDs":[2202450.0,2202449.0,2603807.0],"skipIndex":0,"section_code":"gallery","featured_images":2202449.0,"id":145600,"singleSection":false});				  						galleries[161840] = clik.newGallery({"parentGallery":161833,"usePopups":false,"title":"Lakes & Mountains","link":"gallery_161840.html","maxRecords":0.0,"photoIDs":[2603968.0,2526460.0,2526471.0],"skipIndex":0,"section_code":"gallery","featured_images":2603968.0,"id":161840,"singleSection":false});				  						galleries[161831] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"The House","link":"gallery_161831.html","maxRecords":0.0,"photoIDs":[],"skipIndex":0,"section_code":"gallery","featured_images":"2526219,2526210,2526193,2202457,2202449,2198920","id":161831,"singleSection":false});				  						galleries[161842] = clik.newGallery({"parentGallery":161833,"usePopups":false,"title":"Hilltop Towns and Medieval Villages","link":"gallery_161842.html","maxRecords":0.0,"photoIDs":[2603810.0,2603808.0,2526518.0,2530485.0,2603967.0,2603895.0,2530446.0],"skipIndex":0,"section_code":"gallery","featured_images":2603810.0,"id":161842,"singleSection":false});				  						galleries[145373] = clik.newGallery({"parentGallery":161831,"usePopups":false,"title":"Living Rooms","link":"gallery_145373.html","maxRecords":0.0,"photoIDs":[2526207.0,2202440.0,2198920.0,2603896.0,2526536.0],"skipIndex":0,"section_code":"gallery","featured_images":2198920.0,"id":145373,"singleSection":false});				  						galleries[145596] = clik.newGallery({"parentGallery":161831,"usePopups":false,"title":"Bedrooms & Bathrooms","link":"gallery_145596.html","maxRecords":0.0,"photoIDs":[2526210.0,2202442.0,2526212.0,2202468.0,5034923.0,2202433.0,2202435.0],"skipIndex":0,"section_code":"gallery","featured_images":2526210.0,"id":145596,"singleSection":false});				  						galleries[167121] = clik.newGallery({"parentGallery":161833,"usePopups":false,"title":"Coast","link":"gallery_167121.html","maxRecords":0.0,"photoIDs":[2603813.0,2603969.0],"skipIndex":0,"section_code":"gallery","featured_images":"2603969,2603813","id":167121,"singleSection":false});				  						galleries[161833] = clik.newGallery({"parentGallery":"","usePopups":false,"title":"Le Marche","link":"gallery_161833.html","maxRecords":0.0,"photoIDs":[],"skipIndex":0,"section_code":"gallery","featured_images":"2603968,2603810","id":161833,"singleSection":false});				  						galleries[145593] = clik.newGallery({"parentGallery":161831,"usePopups":false,"title":"Outside Living","link":"gallery_145593.html","maxRecords":0.0,"photoIDs":[2526242.0,2526193.0,2526248.0,2526533.0,2526538.0,2603897.0,2526530.0],"skipIndex":0,"section_code":"gallery","featured_images":2526193.0,"id":145593,"singleSection":false});				  						galleries[145594] = clik.newGallery({"parentGallery":161831,"usePopups":false,"title":"Pool","link":"gallery_145594.html","maxRecords":0.0,"photoIDs":[2526219.0,2202462.0],"skipIndex":0,"section_code":"gallery","featured_images":2526219.0,"id":145594,"singleSection":false});				  						galleries[162041] = clik.newGallery({"parentGallery":161831,"usePopups":false,"title":"Local Area","link":"gallery_162041.html","maxRecords":0.0,"photoIDs":[2202457.0,2603972.0,2202456.0,2202473.0,2202460.0,2603862.0,5034931.0],"skipIndex":0,"section_code":"gallery","featured_images":2202457.0,"id":162041,"singleSection":false});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[1] = '2526242';
imageSets[2] = '2603968,2603810,2526219,2526210,2526193,2202457,2202449,2198920';
imageSets[3] = '5034931,5034923,2603972,2603969,2603968,2603967,2603897,2603896,2603895,2603862,2603813,2603810,2603808,2603807,2530485,2530446,2526538,2526536,2526533,2526530,2526518,2526471,2526460,2526248,2526242,2526219,2526212,2526210,2526207,2526193,2202473,2202468,2202462,2202460,2202457,2202456,2202450,2202449,2202442,2202440,2202435,2202433,2198920';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/dougsbiz/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/dougsbiz/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/dougsbiz/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/dougsbiz/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/dougsbiz/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/dougsbiz/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/dougsbiz/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/dougsbiz/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/dougsbiz/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/dougsbiz/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/dougsbiz/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/dougsbiz/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/dougsbiz/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/dougsbiz/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/dougsbiz/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/dougsbiz/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://admin2.clikpic.com/dougsbiz/images';
		break;
	}
		switch (server_id) {
		case 33:
		val = 'http://www8.clikpic.com/dougsbiz/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/dougsbiz/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/dougsbiz/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/dougsbiz/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/dougsbiz/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/dougsbiz/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/dougsbiz/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:'',$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 = 'Casa Olivia: ' + 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.payment_groups_id !== '') {
		temp += '<p>Buy this print online:</p>';
				temp += '<form id="paymentOptions" style="margin:0px;border:0px;" name="paymentOptions">';
											temp += '<select class="paymentlink" name="payment_options_id" onchange="updateItemValues($(this.form).next(\'#paymentForm\')[0],this.form.payment_options_id.options[this.form.payment_options_id.options.selectedIndex].value);">';
		
		temp += getPaymentOptions(this.payment_groups_id);
		temp += '</select>';
		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 += '<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 += '<a href="' + galleries[i].section_code + '_' + galleries[i].id + '.html">' + galleries[i].title + '</a>';
							}
		}
		document.all.galleryLinks.innerHTML = 'Other galleries: ' + temp;
	}
}

			

