function gallery(interval,jump,holder,images,start){
	start = start - 1 || 0;
	this.interval = interval;
	this.jump = jump;
	this.holder = holder;
	this.images = images;
	this.counter = 0;
	this.track = start;
	
	build(this);
	
	function build(obj) {
		obj.holder = document.getElementById(obj.holder);
		obj.images = document.getElementsByName(obj.images);
		prepareImages(obj);
		showGallery(obj);
	}
	
	function prepareImages(obj) {
		if(obj.images.length != 1) {
			backButton = document.createElement("a");
			backButton.href = "#";
			backButton.innerHTML = "&nbsp;&nbsp; &laquo; back &nbsp;&nbsp;";
			backButton.className = "galleryButton";
			backButton.onclick = function() { backButtonEvent(obj); };
			obj.Back = backButton;
			document.getElementById("galleryButtons").appendChild(backButton);
			
			nextButton = document.createElement("a");
			nextButton.href = "#";
			nextButton.innerHTML = "&nbsp;&nbsp; next &raquo; &nbsp;&nbsp;";
			nextButton.className = "galleryButton";
			nextButton.onclick = function() { nextButtonEvent(obj); };
			obj.Next = nextButton;
			document.getElementById("galleryButtons").appendChild(nextButton);
			if (obj.track == obj.images.length - 1) obj.Next.className = "galleryButtonDisabled";
			if (obj.track == 0) obj.Back.className = "galleryButtonDisabled";
		}
		closeButton = document.createElement("a");
		closeButton.href = "#";
		closeButton.innerHTML = "&nbsp;&nbsp; close [<span class='normal'> x </span>] &nbsp;&nbsp;";
		closeButton.className = "galleryButton";
		closeButton.onclick = function() { closeGallery(obj); };
		document.getElementById("galleryButtons").appendChild(closeButton);
		obj.images[obj.track].style.display = "block";
	}
	
	function showGallery(obj) {
		obj.holder.style.opacity = obj.counter/10;
		obj.holder.style.filter = 'alpha(opacity=' + obj.counter*10 + ')';
		obj.holder.style.zIndex = "31";
		obj.animation = window.setInterval( function() {
			obj.holder.style.opacity = obj.counter/10;
			obj.holder.style.filter = 'alpha(opacity=' + obj.counter*10 + ')';
			obj.counter = parseFloat(Number(obj.counter + obj.jump).toPrecision(2));
			if (obj.counter >= 10) {
				obj.holder.style.opacity = obj.counter/10;
				obj.holder.style.filter = 'alpha(opacity=' + obj.counter*10 + ')';
				clearInterval(obj.animation);
				obj.animation = false;
				document.getElementById("main").style.display = "none";
			}
		},obj.interval);
	}
	
	function nextButtonEvent(obj) {
		if (!obj.busy) {
			if (obj.track < obj.images.length - 1) {
				obj.busy = true;
				obj.trans = 10;
				obj.transInt = 10;
				obj.transJump = 1;
				obj.images[obj.track].timer = window.setInterval(function(){fadeOut(obj,"forward")}, obj.transInt);
				
			}
		}
	}
	
	function backButtonEvent(obj) {
		if (!obj.busy) {
			if (obj.track != 0) {
				obj.busy = true;
				obj.trans = 10;
				obj.transInt = 10;
				obj.transJump = 1;
				obj.images[obj.track].timer = window.setInterval(function(){fadeOut(obj,"back")}, obj.transInt);
			}
		}
	}
	
	function fadeOut(obj,action) {
		obj.images[obj.track].style.opacity = obj.trans / 10;
		obj.images[obj.track].style.filter = 'alpha(opacity=' + obj.trans * 10 + ')';
		obj.trans = parseFloat(Number(obj.trans - obj.transJump).toPrecision(2));
		if (obj.trans.valueOf() <= 0) {
			clearInterval(obj.images[obj.track].timer);
			obj.images[obj.track].style.opacity = obj.trans / 10;
			obj.images[obj.track].style.filter = 'alpha(opacity=' + obj.trans * 10 + ')';
			obj.images[obj.track].style.display = "none";
			if (action == "back") {
				obj.track--;
				if (obj.track == 0) obj.Back.className = "galleryButtonDisabled";
				if (obj.Next.className == "galleryButtonDisabled") obj.Next.className = "galleryButton";
			}
			else if (action == "forward") {
				obj.track++;
				if (obj.track == obj.images.length - 1) obj.Next.className = "galleryButtonDisabled";
				if (obj.Back.className == "galleryButtonDisabled") obj.Back.className = "galleryButton";
			}
			obj.images[obj.track].style.opacity = 0 / 10;
			obj.images[obj.track].style.filter = 'alpha(opacity=' + 0 * 10 + ')';
			obj.images[obj.track].style.display = "block";
			obj.images[obj.track].timer = window.setInterval(function(){fadeIn(obj)},obj.transInt);
		}
	}
	
	function fadeIn(obj) {
		obj.images[obj.track].style.opacity = obj.trans / 10;
		obj.images[obj.track].style.filter = 'alpha(opacity=' + obj.trans * 10 + ')';
		obj.trans = parseFloat(Number(obj.trans + obj.transJump).toPrecision(2));
		if (obj.trans >= 10) {
			clearInterval(obj.images[obj.track].timer);
			obj.images[obj.track].style.opacity = obj.trans / 10;
			obj.images[obj.track].style.filter = 'alpha(opacity=' + obj.trans * 10 + ')';
			obj.busy = false;
		}
	}
	
	function closeGallery(obj) {
		for (var i=0; i<obj.images.length; i++) {
			obj.images[i].style.display = "none";
			obj.images[i].style.opacity = 10/10;
			obj.images[i].style.filter = 'alpha(opacity=' + 10*10 + ')';
		};
		document.getElementById("galleryButtons").innerHTML = "";
		document.getElementById("main").style.display = "block";
		obj.holder.style.opacity = 0/10;
		obj.holder.style.filter = 'alpha(opacity=' + 0*10 + ')';
		obj.holder.style.zIndex = "-1";
	}
}
