	function PictureSlide(Pictures, SlideBar, Preview)
	{
		this.Pictures = Pictures || null;
		this.SlideBar = SlideBar || null;
		this.Preview = Preview || null;

		this.ClickSpeed = 6;
		this.SlideSpeed = 0.1;

		this.AjaxLoad = true;
		this.NewRightPictures = -2600; // Mitte bei 240
		this.NewLeftPictures = -1300;

		this.PictureHeight = "60px";
		this.PictureWidth = "65px";

		this.PreloadPics = null;
	}
	PictureSlide.prototype =
	{
		"Pointer" : null,
		"CurrentSpeed" : null,
		"Interval" : null,
		"runAjax" : false,
		"initSlide" : function()
		{
			var Object = this;

			setEvent(this.SlideBar, "mousemove", function(e) { Object.SlideMousemove(e); }, false);
			setEvent(this.SlideBar, "mouseout", function(e) { Object.StopSlide(e); }, true);
			//this.SlideBar.addEventListener("click", function(e) { Object.test(e); }, false);
		},
		"initInterval" : function()
		{
			var Object = this;
			//alert('as');
			this.Interval = window.setInterval(function(e){ Object.GetNewImages.GetOneImage("custom"); }, 25000);
			setEvent("GalleryBox", "mouseover", function(e) { Object.StopInterval(e); }, true);
			setEvent("GalleryBox", "mouseout", function(e) { Object.Interval = window.setInterval(function(e){ Object.GetNewImages.GetOneImage("custom"); }, 25000); }, true);
		},
		"StopInterval" : function(e)
		{
			clearInterval(this.Interval);
			this.Interval = null;
		},
		"initButton" : function(Left, Right)
		{
			var Object = this;

			setEvent(Left, "click", function(e) { Object.GetNewImages.GetOneImage(); }, true);
			setEvent(Right, "click", function(e) { Object.GetNewImages.GetOneImage(); }, true);
		},
		"GetNewImages" : {
			"toggleImage" : 1,
			"ChangeImage" : function(src,MediaID)
			{
				var img1 = document.getElementById("GalleryImageOne");
				var img2 = document.getElementById("GalleryImageTwo");
				if(this.toggleImage == 0)
				{
				//	alert(img1);
					img1.childNodes[0].src = src;
					img1.href = "/modules/CwEvent/eventmedia.php?mid=" + MediaID;
					this.toggleImage = 1;
					setTimeout("Pic.GetNewImages.MakeTransperent(0, true)",100);
				}
				else
				{
					//alert(img2);
					img2.childNodes[0].src = src;
					img2.href = "/modules/CwEvent/eventmedia.php?mid=" + MediaID;
					this.toggleImage = 0;
					setTimeout("Pic.GetNewImages.MakeTransperent(10, false)",100);
				}
			},
			"MakeTransperent" : function(i, Direction)
			{
				var img1 = document.getElementById("GalleryImageOne");
				var img2 = document.getElementById("GalleryImageTwo");
				//alert(i);
				img1.childNodes[0].style.filter = "alpha(opacity=" + (i*10) + ")";
				img1.childNodes[0].style.MozOpacity = 0.0 + i/10;
				img1.childNodes[0].style.opacity = 0.0 + i/10;
				img2.childNodes[0].style.filter = "alpha(opacity=" + 100-(i*10) + ")";
				img2.childNodes[0].style.MozOpacity = 0.0 + (10-i)/10;
				img2.childNodes[0].style.opacity = 0.0 + (10-i)/10;

				img1.style.display = "";
				img2.style.display = "";

				if(Direction)
				{
					i++;
				}
				else
				{
					i--;
				}
				if(i<=10 && i>=0)
				{
					setTimeout("Pic.GetNewImages.MakeTransperent(" + i + ", " + Direction + ")",100);
				}
				else
				{
					if(Direction)
					{
						img2.style.display = "none";
					}
					else
					{
						img1.style.display = "none";
					}
				}
			},
			"GetOneImage" : function(type)
			{
					jS.queue.pB.set({"name":"gallery","php":["Gallery", "GetOneImage"]});
					//jS.req();
			},
			"ResponseGetOneImage" : function(Response, MediaIDs)
			{
				this.ChangeImage(Response[0], MediaIDs[0]);
			}
		},
		"initPreview" : function(type)
		{

			jS.queue.pB.set({"name":"gallery","php":["Gallery", "GetPreview"]});
			//jS.req();
		},
		"ResponseInitPreview" : function(images, MediaIDs)
		{
			var Object = this;
			var left = null;
			this.PreloadPics = images;

			for(var i=0;i<this.PreloadPics.length;i++)
			{
				left = ((Math.round(this.PreloadPics.length/2)-i)*parseInt(this.PictureWidth))*-1;
				var span = this.NewImg(this.PreloadPics[i], left, MediaIDs[i]);

				$c(this.Pictures).appendChild(span);
				delete span;
			}
			$c(this.Pictures).style.left = (Math.round(this.PreloadPics.length/2)*-1)+"px";
		},
		"GetParentNodeById" : function(Element, ElementID, BackSteps)
		{
			var BackSteps = BackSteps || 5;
			for(var i=0;i<BackSteps;i++)
			{
				if(Element && Element.id == ElementID)
				{
					return Element;
				}
				Element = Element.parentNode;
			}
			return false;
		},
		"SlideMousemove" : function(e)
		{
			//var ele = this.GetParentNodeById($evT(e), "GalleryBox", 10);

			//this.SlideBar.style.width ~ 208 ueberarbeiten ...
			this.CurrentSpeed = Math.round(((parseInt(208)/2)-($evPx(e)-$e("GalleryBox").offsetLeft-$e("GalleryList").offsetLeft))*this.SlideSpeed); //($evPx(e) - this.SlideBar.offsetLeft)

			//this.Preview.innerHTML = $evT(e).id;
			if(this.CurrentSpeed != 0 && this.Pointer == null)
			{
				this.Slide();
			}
			else if(this.CurrentSpeed == 0)
			{
				this.StopSlide();
			}
		},
		"SlideMousedown" : function(Direction)
		{
			this.CurrentSpeed = this.ClickSpeed*Direction;

			if(this.Pointer == null)
			{
				this.Slide();
			}
		},
		"Slide" : function()
		{
			var Object = this;

			this.AjaxReload();
			$c(this.Pictures).style.left = (parseInt($c(this.Pictures).style.left)+this.CurrentSpeed)+"px";
			this.Pointer = window.setTimeout(function() { Object.Slide(); }, 100);
		},
		"NewImg" : function(src, left, mediaID)
		{
			var Object = this;
			//alert(left);
			var div = document.createElement("div");
			//div.setAttribute("className", "GalleryListPic");
			div.className = "GalleryListPic";
			div.style.left = left+"px";

			//var a = document.createElement("a");
			//a.setAttribute("href", "bullu");

			var img = document.createElement("img");
			img.setAttribute("src", src);
			img.mediaID = mediaID;
			setEvent("click", function(e) { Object.GetNewImages.ChangeImage($evT(e).src, $evT(e).mediaID); }, true, img);

			//a.appendChild(img);
			div.appendChild(img);
			return div;
		},
		"firstChild" : function(type, parent)
		{
			for(var i=0;i<10;i++)
			{
				if(parent.childNodes[i].tagName && parent.childNodes[i].tagName.toLowerCase() == type.toLowerCase())
				{
					return parent.childNodes[i];
				}
			}
		},
		"lastChild" : function(type, parent)
		{
			for(var i=parent.childNodes.length-1;i>0;i--)
			{
				if(parent.childNodes[i].tagName && parent.childNodes[i].tagName.toLowerCase() == type.toLowerCase())
				{
					return parent.childNodes[i];
				}
			}
		},
		"AjaxSide" : null,
		"AjaxReload" : function()
		{
			if(this.AjaxLoad == false)
			{
				return;
			}
			var span = null;
			var left = parseInt(this.firstChild("div", $c(this.Pictures)).style.left)+parseInt($c(this.Pictures).style.left);
			//$c(this.Preview).innerHTML = left + " > " +  this.NewLeftPictures + "<br>" + left + " < " + this.NewRightPictures;

			if(left > this.NewLeftPictures)
			{
				this.AjaxSide = "left";
				this.RequestAjaxReload();
			}
			else if(left <this.NewRightPictures)
			{
				this.AjaxSide = "right";
				this.RequestAjaxReload();
			}
		},
		"RequestAjaxReload" : function()
		{
			jS.queue.pB.set({"Name":"ajaxReload","php":["Gallery","GetAjaxReload"]});
			jS.req();
		},
		"ResponseAjaxReload" : function(imgs, MediaIDs)
		{
			var left = parseInt(this.firstChild("div", $c(this.Pictures)).style.left)+parseInt($c(this.Pictures).style.left);
			if(this.AjaxSide == "left")
			{
				for(var i=0;i<imgs.length;i++)
				{
					if(left > this.NewLeftPictures)
					{
						span = this.NewImg(imgs[i], parseInt(this.firstChild("div", $c(this.Pictures)).style.left)-parseInt(this.PictureWidth), MediaIDs[i]);
						$c(this.Pictures).insertBefore(span, $c(this.Pictures).firstChild);
						$c(this.Pictures).removeChild($c(this.Pictures).lastChild);
						left = parseInt(this.firstChild("div", $c(this.Pictures)).style.left)+parseInt($c(this.Pictures).style.left);
					}
				}
			}
			else if(this.AjaxSide == "right")
			{
				for(var i=0;i<imgs.length;i++)
				{
					if(left <this.NewRightPictures)
					{
						span = this.NewImg(imgs[i], parseInt(this.lastChild("div", $c(this.Pictures)).style.left)+parseInt(this.PictureWidth), MediaIDs[i]);
						$c(this.Pictures).appendChild(span);
						$c(this.Pictures).removeChild($c(this.Pictures).firstChild);
						left = parseInt(this.firstChild("div", $c(this.Pictures)).style.left)+parseInt($c(this.Pictures).style.left);
					}
				}
			}
		},
		"StopSlide" : function(e)
		{
			clearTimeout(this.Pointer); // UEBERARBEITEN >>>>>><<<<<<< ...
			this.Pointer = null;
		}
	};
