$(document).ready(function(){
	if($('a.object').length>0) {
		var zCounter = 20;
		var objCount = $('a.object').length;
		$('a.object').each(function(){
			$(this).parent().css('z-index', zCounter);
			$(this).css('z-index', zCounter+objCount);
			$('img', this).css('z-index', zCounter+objCount+objCount);
			$('.info', this).css('z-index', zCounter+objCount+objCount+objCount);
			zCounter++;
		});

		$('a.object').click(function(){
			if($(this).attr('secondClick')=='1') {
				$(this).attr('secondClick', '0');
				$('.info', this).hide();
				return true;
			} else {
				var thisObj = this;
				$(this).attr('secondClick', '1');
				window.setTimeout(function(){
					$(thisObj).attr('secondClick', '0');
				}, 500);
			}

			if($('.info:visible', this).length>0) {
				$('.info', this).fadeOut(200);
			} else {
				// $('a.object .info').fadeOut(200); // Diese Zeile rauskommentieren wenn mehrere Popups gleichzeitig sichtbar sein sollen

				if(!$(this).attr('rePositioned')) {
					var pos = $(this).position();
					$(this).attr('rePositioned', 1);
					$('.info', this).css('left', pos.left+parseInt($('.info', this).css('left')));
					$('.info', this).css('top',  pos.top +parseInt($('.info', this).css('top')));
				}

				$('.info', this).fadeIn(200);
			}
			return false;
		});
	}

	$('a.showInfo').click(function(){
		var url = $(this).attr('href');
		$('.productInfo').hide();
		$(url+'.productInfo').show();
		return false;
	});
});

