window.thumbnails = {};
															thumbnails[5122939] = clik.newPhoto({"id":5122939,"src":"9027_1196603910284_1084070826_30638135_1413148_n_thumb.jpg","galleries_id":294942,"server_id":18,"link":"photo_5122939.html","width":130,"caption":"","height":202});
															thumbnails[7098778] = clik.newPhoto({"id":7098778,"src":"IMG_7130_website_thumb.jpg","galleries_id":294942,"server_id":18,"link":"photo_7098778.html","width":130,"caption":"","height":87});
															thumbnails[8523853] = clik.newPhoto({"id":8523853,"src":"IMG_0416_thumb.jpg","galleries_id":278157,"server_id":18,"link":"photo_8523853.html","width":130,"caption":"","height":195});
															thumbnails[8523855] = clik.newPhoto({"id":8523855,"src":"IMG_0108_thumb.jpg","galleries_id":278157,"server_id":18,"link":"photo_8523855.html","width":130,"caption":"","height":195});
															thumbnails[8523956] = clik.newPhoto({"id":8523956,"src":"IMG_0690_thumb.jpg","galleries_id":278157,"server_id":18,"link":"photo_8523956.html","width":130,"caption":"","height":195});
															thumbnails[8523977] = clik.newPhoto({"id":8523977,"src":"IMG_2335_thumb.jpg","galleries_id":278157,"server_id":18,"link":"photo_8523977.html","width":130,"caption":"","height":195});
															thumbnails[8524000] = clik.newPhoto({"id":8524000,"src":"IMG_2769_thumb.jpg","galleries_id":278157,"server_id":18,"link":"photo_8524000.html","width":130,"caption":"","height":195});
															thumbnails[8524031] = clik.newPhoto({"id":8524031,"src":"IMG_3108_thumb.jpg","galleries_id":278157,"server_id":18,"link":"photo_8524031.html","width":130,"caption":"","height":195});
															thumbnails[8524034] = clik.newPhoto({"id":8524034,"src":"IMG_3611_thumb.jpg","galleries_id":278157,"server_id":18,"link":"photo_8524034.html","width":130,"caption":"","height":195});
															thumbnails[8524083] = clik.newPhoto({"id":8524083,"src":"IMG_4420_thumb.jpg","galleries_id":278157,"server_id":18,"link":"photo_8524083.html","width":130,"caption":"","height":195});
															thumbnails[8524085] = clik.newPhoto({"id":8524085,"src":"IMG_4619_thumb.jpg","galleries_id":278157,"server_id":18,"link":"photo_8524085.html","width":130,"caption":"","height":195});
															thumbnails[8524087] = clik.newPhoto({"id":8524087,"src":"IMG_6406_thumb.jpg","galleries_id":278157,"server_id":18,"link":"photo_8524087.html","width":130,"caption":"","height":195});
															thumbnails[8524088] = clik.newPhoto({"id":8524088,"src":"IMG_7244_thumb.jpg","galleries_id":278157,"server_id":18,"link":"photo_8524088.html","width":130,"caption":"","height":195});
															thumbnails[8524092] = clik.newPhoto({"id":8524092,"src":"IMG_7321_thumb.jpg","galleries_id":278157,"server_id":18,"link":"photo_8524092.html","width":130,"caption":"","height":195});
															thumbnails[8524097] = clik.newPhoto({"id":8524097,"src":"IMG_7996_thumb.jpg","galleries_id":278157,"server_id":18,"link":"photo_8524097.html","width":130,"caption":"","height":195});
															thumbnails[8524103] = clik.newPhoto({"id":8524103,"src":"IMG_8035_thumb.jpg","galleries_id":278157,"server_id":18,"link":"photo_8524103.html","width":130,"caption":"","height":195});
															thumbnails[8524104] = clik.newPhoto({"id":8524104,"src":"IMG_8066_thumb.jpg","galleries_id":278157,"server_id":18,"link":"photo_8524104.html","width":130,"caption":"","height":195});
															thumbnails[8524107] = clik.newPhoto({"id":8524107,"src":"IMG_8360_thumb.jpg","galleries_id":278157,"server_id":18,"link":"photo_8524107.html","width":130,"caption":"","height":195});
															thumbnails[8524108] = clik.newPhoto({"id":8524108,"src":"IMG_8414_thumb.jpg","galleries_id":278157,"server_id":18,"link":"photo_8524108.html","width":130,"caption":"","height":195});
															thumbnails[8524110] = clik.newPhoto({"id":8524110,"src":"IMG_8471_thumb.jpg","galleries_id":278157,"server_id":18,"link":"photo_8524110.html","width":130,"caption":"","height":195});
															thumbnails[8524112] = clik.newPhoto({"id":8524112,"src":"IMG_8883_thumb.jpg","galleries_id":278157,"server_id":18,"link":"photo_8524112.html","width":130,"caption":"","height":195});
															thumbnails[8524124] = clik.newPhoto({"id":8524124,"src":"IMG_9398_thumb.jpg","galleries_id":278157,"server_id":18,"link":"photo_8524124.html","width":130,"caption":"","height":195});
															thumbnails[8524128] = clik.newPhoto({"id":8524128,"src":"IMG_9231_thumb.jpg","galleries_id":278157,"server_id":18,"link":"photo_8524128.html","width":130,"caption":"","height":195});
															thumbnails[8524135] = clik.newPhoto({"id":8524135,"src":"IMG_9476_thumb.jpg","galleries_id":278157,"server_id":18,"link":"photo_8524135.html","width":130,"caption":"","height":195});
															thumbnails[8524145] = clik.newPhoto({"id":8524145,"src":"IMG_9549_thumb.jpg","galleries_id":278157,"server_id":18,"link":"photo_8524145.html","width":130,"caption":"","height":195});
															thumbnails[8524150] = clik.newPhoto({"id":8524150,"src":"IMG_9872_thumb.jpg","galleries_id":278157,"server_id":18,"link":"photo_8524150.html","width":130,"caption":"","height":195});
															thumbnails[8524152] = clik.newPhoto({"id":8524152,"src":"IMG_9984_thumb.jpg","galleries_id":278157,"server_id":18,"link":"photo_8524152.html","width":130,"caption":"","height":195});
															thumbnails[8524155] = clik.newPhoto({"id":8524155,"src":"IMG_9658_thumb.jpg","galleries_id":278157,"server_id":18,"link":"photo_8524155.html","width":130,"caption":"","height":195});
															thumbnails[8524221] = clik.newPhoto({"id":8524221,"src":"IMG_5787_thumb.jpg","galleries_id":278157,"server_id":18,"link":"photo_8524221.html","width":130,"caption":"","height":195});
															thumbnails[8524226] = clik.newPhoto({"id":8524226,"src":"IMG_7568_thumb.jpg","galleries_id":278157,"server_id":18,"link":"photo_8524226.html","width":130,"caption":"","height":195});
															thumbnails[8524228] = clik.newPhoto({"id":8524228,"src":"IMG_8822_thumb.jpg","galleries_id":278157,"server_id":18,"link":"photo_8524228.html","width":130,"caption":"","height":195});
															thumbnails[8524230] = clik.newPhoto({"id":8524230,"src":"IMG_9502_thumb.jpg","galleries_id":278157,"server_id":18,"link":"photo_8524230.html","width":130,"caption":"","height":195});
															thumbnails[5375565] = clik.newPhoto({"id":5375565,"src":"IMG_3400_thumb.jpg","galleries_id":285690,"server_id":18,"link":"photo_5375565.html","width":130,"caption":"Terrie McEvoy <br>\r\n*Click for Info*","height":190});
															thumbnails[5490492] = clik.newPhoto({"id":5490492,"src":"011_thumb.jpg","galleries_id":285694,"server_id":18,"link":"photo_5490492.html","width":130,"caption":"","height":188});
															thumbnails[5375626] = clik.newPhoto({"id":5375626,"src":"IMG_5845_thumb.jpg","galleries_id":285690,"server_id":18,"link":"photo_5375626.html","width":130,"caption":"Davina Brennan<br>\r\n*Click for Info*","height":195});
															thumbnails[5490498] = clik.newPhoto({"id":5490498,"src":"02_BCA23EB1-1EC9-D45B-1CDBB064246CB224_thumb.JPG","galleries_id":285694,"server_id":18,"link":"photo_5490498.html","width":130,"caption":"","height":195});
															thumbnails[5458147] = clik.newPhoto({"id":5458147,"src":"IMG_8884_thumb.jpg","galleries_id":285690,"server_id":18,"link":"photo_5458147.html","width":130,"caption":"Stephanie Maher<br>\r\n*Click for Info*","height":195});
															thumbnails[5490502] = clik.newPhoto({"id":5490502,"src":"03_BCA344D6-1EC9-D45B-1C5426A2DED73133_thumb.jpg","galleries_id":285694,"server_id":18,"link":"photo_5490502.html","width":130,"caption":"","height":195});
															thumbnails[5490487] = clik.newPhoto({"id":5490487,"src":"01_thumb.jpg","galleries_id":285694,"server_id":18,"link":"photo_5490487.html","width":130,"caption":"","height":87});
															thumbnails[6260857] = clik.newPhoto({"id":6260857,"src":"04_8E8E18A8-1EC9-D45B-1CE2A638FFE2CC74_thumb.jpg","galleries_id":285690,"server_id":18,"link":"photo_6260857.html","width":130,"caption":"Georgie Tracey*Click for Info*","height":195});
															thumbnails[5490515] = clik.newPhoto({"id":5490515,"src":"05_BCA456C3-1EC9-D45B-1C2A9631A0790026_thumb.jpg","galleries_id":285694,"server_id":18,"link":"photo_5490515.html","width":130,"caption":"","height":87});
															thumbnails[6260879] = clik.newPhoto({"id":6260879,"src":"05_8E97D7D5-1EC9-D45B-1CF9569B16038ED6_thumb.jpg","galleries_id":285690,"server_id":18,"link":"photo_6260879.html","width":130,"caption":"Jenny Massey<br>\r\n*Click for Info*","height":195});
															thumbnails[5490528] = clik.newPhoto({"id":5490528,"src":"06_BCA83D7B-1EC9-D45B-1CDFAF92454E28A8_thumb.jpg","galleries_id":285694,"server_id":18,"link":"photo_5490528.html","width":130,"caption":"","height":87});
															thumbnails[5490531] = clik.newPhoto({"id":5490531,"src":"07_BCA9C8ED-1EC9-D45B-1CF3B4FE0F417DCC_thumb.jpg","galleries_id":285694,"server_id":18,"link":"photo_5490531.html","width":130,"caption":"","height":87});
															thumbnails[5490533] = clik.newPhoto({"id":5490533,"src":"08_BCAACA60-1EC9-D45B-1CDAA03E51E686E8_thumb.jpg","galleries_id":285694,"server_id":18,"link":"photo_5490533.html","width":130,"caption":"","height":87});
															thumbnails[5490537] = clik.newPhoto({"id":5490537,"src":"09_BCAC9EC2-1EC9-D45B-1CE413F05FE37412_thumb.jpg","galleries_id":285694,"server_id":18,"link":"photo_5490537.html","width":130,"caption":"","height":87});
															thumbnails[5490539] = clik.newPhoto({"id":5490539,"src":"10_BCADF828-1EC9-D45B-1CB41ED59AEB7653_thumb.jpg","galleries_id":285694,"server_id":18,"link":"photo_5490539.html","width":130,"caption":"","height":195});
															thumbnails[5490541] = clik.newPhoto({"id":5490541,"src":"11_BCB013B5-1EC9-D45B-1CF99FAF2C06F472_thumb.jpg","galleries_id":285694,"server_id":18,"link":"photo_5490541.html","width":130,"caption":"","height":215});
															thumbnails[5490543] = clik.newPhoto({"id":5490543,"src":"12_BCB2B1A1-1EC9-D45B-1CF7C95DFD57A8A2_thumb.jpg","galleries_id":285694,"server_id":18,"link":"photo_5490543.html","width":130,"caption":"","height":191});
															thumbnails[5490548] = clik.newPhoto({"id":5490548,"src":"13_BCB433AD-1EC9-D45B-1CDE01AA0BAA018E_thumb.jpg","galleries_id":285694,"server_id":18,"link":"photo_5490548.html","width":130,"caption":"","height":195});
															thumbnails[5490554] = clik.newPhoto({"id":5490554,"src":"14_BCB5142A-1EC9-D45B-1C06CEB43E5423EC_thumb.jpg","galleries_id":285694,"server_id":18,"link":"photo_5490554.html","width":130,"caption":"","height":195});
															thumbnails[5490557] = clik.newPhoto({"id":5490557,"src":"15_BCB55ECF-1EC9-D45B-1C584244901E446B_thumb.jpg","galleries_id":285694,"server_id":18,"link":"photo_5490557.html","width":130,"caption":"","height":195});
															thumbnails[5490575] = clik.newPhoto({"id":5490575,"src":"16_BCBA6436-1EC9-D45B-1C7E11AA9344F2BD_thumb.jpg","galleries_id":285694,"server_id":18,"link":"photo_5490575.html","width":130,"caption":"","height":163});
															thumbnails[5490582] = clik.newPhoto({"id":5490582,"src":"17_BCBB717F-1EC9-D45B-1C70F6142EA5B872_thumb.jpg","galleries_id":285694,"server_id":18,"link":"photo_5490582.html","width":130,"caption":"","height":163});
															thumbnails[5490585] = clik.newPhoto({"id":5490585,"src":"18_BCBCA54C-1EC9-D45B-1CF2149EAD1F0778_thumb.jpg","galleries_id":285694,"server_id":18,"link":"photo_5490585.html","width":130,"caption":"","height":163});
															thumbnails[5490587] = clik.newPhoto({"id":5490587,"src":"19_BCBE457E-1EC9-D45B-1CEB01B7F60D4620_thumb.jpg","galleries_id":285694,"server_id":18,"link":"photo_5490587.html","width":130,"caption":"","height":163});
															thumbnails[5490589] = clik.newPhoto({"id":5490589,"src":"20_BCBF866A-1EC9-D45B-1C6C93EB3F7B42AD_thumb.jpg","galleries_id":285694,"server_id":18,"link":"photo_5490589.html","width":130,"caption":"","height":163});
															thumbnails[5490592] = clik.newPhoto({"id":5490592,"src":"21_BCC0A651-1EC9-D45B-1C8E8239061F2F2A_thumb.jpg","galleries_id":285694,"server_id":18,"link":"photo_5490592.html","width":130,"caption":"","height":173});
															thumbnails[6259532] = clik.newPhoto({"id":6259532,"src":"IMG_7563_thumb.jpg","galleries_id":285694,"server_id":18,"link":"photo_6259532.html","width":130,"caption":"","height":195});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
				  						galleries[278157] = clik.newGallery({"parentGallery":"","usePopups":true,"title":"ASM Course Shots","link":"gallery_278157.html","maxRecords":0.0,"photoIDs":[8523853.0,8523855.0,8523956.0,8523977.0,8524000.0,8524031.0,8524034.0,8524083.0,8524085.0,8524087.0,8524088.0,8524092.0,8524097.0,8524103.0,8524104.0,8524107.0,8524108.0,8524110.0,8524112.0,8524124.0,8524128.0,8524135.0,8524145.0,8524150.0,8524152.0,8524155.0,8524221.0,8524226.0,8524228.0,8524230.0],"skipIndex":0,"section_code":"gallery","featured_images":"8524230,8524228,8524226,8524221,8524155,8524152,8524150,8524145,8524135,8524128","id":278157,"singleSection":false});				  						galleries[285690] = clik.newGallery({"parentGallery":"","usePopups":true,"title":"ASM Success Stories","link":"gallery_285690.html","maxRecords":0.0,"photoIDs":[5375565.0,5375626.0,5458147.0,6260857.0,6260879.0],"skipIndex":0,"section_code":"gallery","featured_images":5375565.0,"id":285690,"singleSection":false});				  						galleries[285694] = clik.newGallery({"parentGallery":"","usePopups":true,"title":"Beyond ASM - Our Students at Work","link":"gallery_285694.html","maxRecords":0.0,"photoIDs":[5490492.0,5490498.0,5490502.0,5490487.0,5490515.0,5490528.0,5490531.0,5490533.0,5490537.0,5490539.0,5490541.0,5490543.0,5490548.0,5490554.0,5490557.0,5490575.0,5490582.0,5490585.0,5490587.0,5490589.0,5490592.0,6259532.0],"skipIndex":0,"section_code":"gallery","featured_images":5490492.0,"id":285694,"singleSection":false});				  						galleries[294942] = clik.newGallery({"parentGallery":"","usePopups":true,"title":"ASM Flyer","link":"gallery_294942.html","maxRecords":0.0,"photoIDs":[5122939.0,7098778.0],"skipIndex":0,"section_code":"gallery","featured_images":"7098778,5122939","id":294942,"singleSection":false});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[1] = '7098778';
imageSets[2] = '5490492,5375565';
imageSets[3] = '8524230,8524228,8524226,8524221,8524155,8524152,8524150,8524145,8524135,8524128,8524124,8524112,8524110,8524108,8524107,8524104,8524103,8524097,8524092,8524088,8524087,8524085,8524083,8524034,8524031,8524000,8523977,8523956,8523855,8523853,7098778,6260879,6260857,6259532,5490592,5490589,5490587,5490585,5490582,5490575,5490557,5490554,5490548,5490543,5490541,5490539,5490537,5490533,5490531,5490528';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 51:
		val = 'http://www12.clikpic.com/asmdublin/images';
		break;
	}
		switch (server_id) {
		case 0:
		val = 'http://www.clikpic.com/asmdublin/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/asmdublin/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/asmdublin/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/asmdublin/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/asmdublin/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/asmdublin/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/asmdublin/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/asmdublin/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/asmdublin/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/asmdublin/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/asmdublin/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/asmdublin/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/asmdublin/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/asmdublin/images';
		break;
	}
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/asmdublin/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/asmdublin/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/asmdublin/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/asmdublin/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/asmdublin/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/asmdublin/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/asmdublin/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/asmdublin/images';
		break;
	}
		switch (server_id) {
		case 53:
		val = 'http://images.clikpic.com/asmdublin/images';
		break;
	}
		switch (server_id) {
		case 52:
		val = 'http://tpc22/clikpic/asmdublin/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/asmdublin/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/asmdublin/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 = 'Absolute School of Modelling Dublin: ' + 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>';
	}
				
	temp += this.fnGetPaymentInfo();
				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>Buy now using PayPal:</p>';
				temp += '<div class="imageinfo" id="imagePrice"><strong>' + this.purchase_instruction + '</strong> &euro;' + (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 += '<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="leef23@gmail.com">';
					temp += '<input type="hidden" name="currency_code" value="EUR">';
					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="leef23@gmail.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;
	}
}

			

