jQuery.obiTzp = function(flash, width, height, steps, forceShow) {
	settings = {
		fadeSpeed: 'normal',
		cookieCount: 'obi_tzp_c',
		cookie: 'obi_tzp',
		cookiePath : { path: '/' }
	}

	if (forceShow) {
		buildOverlay(flash, width, height);
	} else {
		if ($.cookie(settings.cookie) != null) {
			if ($.cookie(settings.cookieCount) == null) {
				$.cookie(settings.cookieCount, 1, settings.cookiePath);
			} else {
				$.cookie(settings.cookieCount, parseInt($.cookie(settings.cookieCount)) + 1, settings.cookiePath);
			}

			var current = $.cookie(settings.cookieCount);
			for (var i = 0; i < steps.length; i++) {
				if (parseInt(steps[i]) == current) {
					$.cookie(settings.cookie, i + 1, settings.cookiePath);
					buildOverlay(flash, width, height);
				}
			}
		}
	}

	function buildOverlay(flash, width, height) {
		backgroundDiv = "<div class='overlay' style='background: #000;position: absolute;top:0;left:0;z-index:9500;width:100%;'></div>";
		$('body').append(backgroundDiv);
		$('div.overlay').css('height', $(document).height()).bind('click', function() {
			close();
		});

		$('div.overlay').css('opacity', 0).fadeTo(settings.fadeSpeed, 0.5, function() {
			$('div.overlay').append("<div class='overlay_flash'><div id='overlay_flash'></div></div>");
			$('div.overlay_flash').attr('style', 'width:' + width + 'px;height:' + height + 'px;');
			$('div.overlay_flash').css('opacity', 0).fadeIn(settings.fadeSpeed, function() {
				$('div.overlay_flash').attr('style', 'position:absolute;left:' + ($(document).width() - width) / 2 + 'px;top:100px;');
				swfobject.embedSWF(flash, 'overlay_flash', width, height, '9.0.0');
			});
		});
	};

	function close() {
		$('div.overlay').css('opacity', 0.5).fadeOut(settings.fadeSpeed);
		$('div.overlay').empty().remove();
	}
};

	// for flash
	function tzpSetCookie(name, value, settings) {
		$.cookie(name, value, settings);
	}

	// for flash
	function tzpGetCookie(name) {
		return $.cookie(name);
	}

	// for flash
	function tzpDeleteCookie(name) {
		$.cookie(name, null);
	}

	function test() {
		alert('aaaa');
	}

	// opens the flash action layer
	function tzpOpenLayer(forceShow) {
		// OBI version/link
		$.obiTzp('/de/flash/tzp.swf', 934, 340, [3, 7, 9, 11], forceShow);

		// local version
		//$.obiTzp('tzp.swf', 934, 340, [3, 7, 9, 11], forceShow);
	}

	// loads the flash Layer when a user clicks on the teaser
	function tzpLoadTeaser() {
		if (tzpGetCookie('obi_tzp')==null) {
			tzpSetCookie('obi_tzp', '0', { path: '/' });
		}
		tzpOpenLayer(true);
	};

	// initialize the script
	$(document).ready(function() {
		tzpOpenLayer(false);
	});
