

	function PopUpElement(objectName)
	{
		this.animationStarted       = true;
		this.objectNotInitalized    = true;
		this.allowHiding            = true;
		this.backgroundOpacityLimit = 0.6;
		this.backgroundOpacityStep  = 0.0;
		this.foregroundOpacityStep  = 0.0;
		// delay in miliseconds
		this.animationDelay = 20;
		this.animationSteps = 8;

		this.animationDirection;

		this.popUpDiv;
		this.popUpDivBg;
		this.currentElementID;

		this.initalize = function(contentType)
		{
			this.currentElementID = contentType;
			this.popUpDiv = document.getElementById(contentType);
			this.popUpDivBg = document.getElementById("embeded_popup_bg");

			this.objectWasInitalized = false;
		};

		/*
		this.keyPressed = function(event)
		{
			if(this.objectNotInitalized) this.initalize();

			if(event.keyCode==27) this.hide();
		};
		*/

		this.getScrollOffset = function()
		{
			var x, y;
			if (self.pageYOffset)
			{
				// all except Explorer
				x = self.pageXOffset;
				y = self.pageYOffset;
			}
			else if (document.documentElement && document.documentElement.scrollTop)
			{
				// Explorer 6 Strict
				x = document.documentElement.scrollLeft;
				y = document.documentElement.scrollTop;
			}
			else if (document.body)
			{
				// all other Explorers
				x = document.body.scrollLeft;
				y = document.body.scrollTop;
			}

			if (!x) x = 0;
			if (!y) y = 0;

			arrayScrollOffset = new Array(x,y);
			return arrayScrollOffset;
		}

		this.IE6Specific = function()
		{
			if (!(typeof document.body.style.maxHeight == "undefined")) return;

			// to je za IE 6
			this.popUpDiv.style.width = screen.width;
		}

		this.show = function(contentType)
		{
			if(this.objectNotInitalized) this.initalize(contentType);

			var pageWidth = document.body.offsetWidth;
			var pageHeight = document.body.offsetHeight;

			this.IE6Specific();

			// zatemnim ozadje
			this.popUpDivBg.style.opacity = 0.0;
			this.popUpDivBg.style.filter = 'alpha(opacity=0.0)';
			this.popUpDivBg.style.display = "block";
			this.popUpDivBg.style.width = pageWidth + "px";
			this.popUpDivBg.style.height = pageHeight + "px";
			this.popUpDivBg.style.left = "0px";
			this.popUpDivBg.style.top = "0px";

			// postavim na stran div, v katerem se nahaja vsebina
			this.popUpDiv.style.opacity = 0.0;
			this.popUpDiv.style.filter = 'alpha(opacity=0.0)';
			this.popUpDiv.style.display = "block";
			this.popUpDiv.style.left = "0px";
			var offset = this.getScrollOffset();
			var paddingTop = offset[1] + 0.2 * (screen.height - document.getElementById(this.currentElementID + "_content").offsetHeight);
			this.popUpDiv.style.top = paddingTop + "px";

			// izvedem prikaz
			this.animationDirection = "show";
			this.executeAnimation(0, this.animationSteps);
		};

		this.executeAnimation = function(numStep, limitStep)
		{
			if(this.animationStarted)
			{
				this.backgroundOpacityStep = this.backgroundOpacityLimit / limitStep;
				this.foregroundOpacityStep = 1.0 / limitStep;
				this.animationStarted = false;
			}

			if(limitStep >= numStep)
			{
				var whichStep = numStep;
				if(this.animationDirection == "hide") whichStep = limitStep - numStep;

				this.popUpDiv.style.opacity = whichStep *  this.foregroundOpacityStep;
				this.popUpDivBg.style.opacity = whichStep * this.backgroundOpacityStep;

				var foregroundAlpha = 100 * whichStep *  this.foregroundOpacityStep;
				var backgroundAlpha = 100 * whichStep * this.backgroundOpacityStep;

				this.popUpDiv.style.filter = 'alpha(opacity=' + foregroundAlpha + ')';
				this.popUpDivBg.style.filter = 'alpha(opacity=' + backgroundAlpha + ')';

				numStep++;
				setTimeout(objectName + '.executeAnimation(' + numStep + ', ' + limitStep + ')', this.animationDelay);
			}
			else
			{
				// na koncu pa vsebino še odstranim
				if(this.animationDirection == "hide") this.hideExecute();

				this.animationStarted = true;
				return;
			}
		}

		this.hide = function()
		{
			if(this.objectNotInitalized) this.initalize(this.currentElementID);

			if(this.allowHiding)
			{
				this.animationDirection = "hide";

				// video div bg
				this.popUpDivBg.style.opacity = this.backgroundOpacityLimit;
				var alpha = 100.0 * this.backgroundOpacityLimit;
				this.popUpDivBg.style.filter = 'alpha(opacity=' + alpha + ')';

				// še video & td
				this.popUpDiv.style.opacity = 1.0;
				this.popUpDiv.style.filter = 'alpha(opacity=100.0)';

				this.executeAnimation(0, this.animationSteps);
			}
			this.allowHiding = true;
		};

		this.denyHide = function()
		{
			this.allowHiding = false;
		};


		this.hideExecute = function()
		{
			this.popUpDivBg.style.display = "none";
			this.popUpDivBg.style.left = "-1000px";
			this.popUpDivBg.style.top = "-1000px";

			this.popUpDiv.style.display = "none";
			this.popUpDiv.style.left = "-1000px";
			this.popUpDiv.style.top = "-1000px";
		}
	}

