

(
	function() {
		Presentation = {
			initialiseLightbox: function() {
			 return;
				$('#thumbnails .thumbnail').each(function(index, ele) { 
					var jE = $(ele);
					jE.click(function(eve) { 
						var fileName = eve.target.src.replace('_thumb', '');
						
						var image = new Image();
						image.src = fileName;
						
						var showItem = $('<div id="bignailWrap"></div>');
						var showImage = $('<div id="slideTitle"><div id="slideSelector"><img src="' + fileName + '" /></div><div>');
						showItem.append(showImage);
						 
						$('body').append(showItem);
						
						showItem.click(function(eve2) {
							showItem.fadeOut(100, function() { 
								showItem.remove();
							});
						});
						
						showImage.fadeIn(100);
						window.setTimeout(showItem.center, 100);
						
						return false;
					});
				});
			},
			
			centre: function() {
				Presentation.lightBox.center();	
			},
			
			preloader: new Array(),
			
			preloaderIndex: 0,
			
			fetchPreloader: function() {
			return;
				if(Presentation.preloaderIndex < Presentation.preloader.length) {
					var preloadImage = new Image();
					preloadImage.onload = function() {
						Presentation.fetchPreloader();
					}
					preloadImage.src = Presentation.preloader[Presentation.preloaderIndex];
					
					Presentation.preloaderIndex++;
				}
			},
			
			Start: function() {
				Presentation.index = 0;
				
				/* $('#header_insertedObject').hide(); */
				Presentation.lightBack = $('<div id="fuzz"></div>');
				$('body').append(Presentation.lightBack);
				
				Presentation.lightBox = $('<div id="bignailWrap"></div>');
				$('body').append(Presentation.lightBox);
				
				Presentation.showImage();		 
				return false;
			},
			
			showImage: function() {
				var fileName = LightboxSlides[Presentation.index];
				var image = new Image();
				image.src = fileName;
				
				var html = new Array();				
				html.push('<div id="slideTitle">');
				
								
				try {
					html.push('<h1>');
					html.push($('h1:visible').html());
					html.push('</h1>');
				} catch (e) {
					// no heading
	 
				}
				
				html.push('<div id="slideSelector" style="width:730px;">');			
				
				html.push('<a style="color: red; float:right;" id="close" href="#" onclick="Presentation.close(); return false;">X</a>');
				
				
				html.push('<a href="#" onclick="Presentation.moveImage(-1); return false;" class="' + selected + '">');
				html.push('&lt;&lt; Previous');
				html.push('</a>');
				
				for(var i = 0; i < LightboxSlides.length; i++) {
					var selected = (i == Presentation.index) ? ' selected ' : '';
					html.push('<a href="#" onclick="Presentation.switchImage(' + i + '); return false;" class="' + selected + '">');
					html.push((i+1).toString());
					html.push('</a>');
				}
				
				html.push('<a href="#" onclick="Presentation.moveImage(1); return false;" class="' + selected + '">');
				html.push($('div#translateThisNxt').html() + ' &gt;&gt;');
				html.push('</a>');
				
				
				/*
				html.push('<a style="color: red; float:right;" id="close" href="#" onclick="Presentation.close(); return false;">X</a>');
				*/
				
				html.push('</div>');
				
				html.push('	<img src="' + fileName + '" onclick="Presentation.close();" onload="Presentation.centre();" />');
								
				html.push('</div>');	
			 
				Presentation.internalBox = $(html.join(''));				
				Presentation.lightBox.append(Presentation.internalBox);
			
				Presentation.timer = window.setTimeout(Presentation.showNextImage, 10000);
			},
			
			showNextImage: function() {
				Presentation.internalBox.remove();
				
				Presentation.index++;
				if(Presentation.index >= LightboxSlides.length) { 
					Presentation.index = 0;
				}
				
				Presentation.showImage();				
			},
			
			switchImage: function(nextImage) {
				if(Presentation.timer != null) {
					window.clearTimeout(Presentation.timer);
				}
				
				Presentation.internalBox.remove();				
				Presentation.index = nextImage;
				Presentation.showImage();
			},
			
			moveImage: function(plusMinus) {
				if(Presentation.timer != null) {
					window.clearTimeout(Presentation.timer);
				}
				
				Presentation.internalBox.remove();				
				Presentation.index+= plusMinus;
				
				if(Presentation.index < 0) {
					Presentation.index = LightboxSlides.length - 1;
				}
				
				if(Presentation.index >= LightboxSlides.length) { 
					Presentation.index = 0;
				}
				
				Presentation.showImage();			
			},
			
			close: function() {
				if(Presentation.timer != null) {
					window.clearTimeout(Presentation.timer);
				}
				
				Presentation.internalBox.remove();
				Presentation.lightBack.remove();
			},
			
			jQueryPlugins: function() {
				jQuery.fn.center = function () {
					this.css("position","absolute");
					this.css("top", ( $(window).height() - this.height() ) / 2+$(window).scrollTop() + "px");
					this.css("left", ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + "px");
					return this;
				}
			}
		};
	}
)();



addLoader(Presentation.initialiseLightbox);
addLoader(Presentation.jQueryPlugins);
addLoader(Presentation.fetchPreloader);
