$(function() { 

	// Layer
	$('table.wohnungen td a').click(function() { 
		var ziel = $(this).attr('href');
		$.get(ziel, function(resp) { 
			$('<div class="layerbox"></div>')
				.appendTo('body')
				.html(resp);
			$('<a class="layerclose" title="schließen" href="#">x</a>')
				.appendTo('.layerbox')
				.click(function() { 
					$('.layerbox').remove();
					return false;
				});
			$('.layerbox h1:first').wrapInner('<span />');
			
			// Colorbox - Thickbox-Ersatz
			$('a.colorbox').colorbox({
				opacity: 0.6,
				previous: 'zurück',
				next: 'vor',
				current: '{current} von {total}',
				close: 'schließen'
			});
		});
		return false;
	});
	
	// 360° Ansichten-Layer
	$('a.panlink').live('click', function() { 
		if($(this).attr('href') != '#') { 
			var href = $(this).attr('href');
			popup(href);
		};
		return false;
	});
	

	// Tabs
	if($('#contenttabs').length) { 
		$('#contenttabs').eujTabs({ 
			content: 'tabcontent'
		});
	};
	
	// Transparenz der Bilder
	$('table.wohnungen td a img').css({ opacity: 0.6 });
	$('table.wohnungen td a').hover(function() { 
		$(this).find('img').css({ opacity: 1 });		
	}, function() { 
		$(this).find('img').css({ opacity: 0.6 });
	});
	
});


// Standard-JS-PopUp
function popup(url) {
	var leftPos = (screen.width) ? (screen.width - 800) / 2:0;
	var topPos = (screen.height) ? (screen.height - 480) / 2:0;
	var props = "width=800, height=480, left="+leftPos+", top="+topPos+" toolbar=0, personalbar=0, menubar=0, scrollbars=0, resizable=0, status=0";
	newwindow = window.open(url, 'Panorama', props);
	if (window.focus) { 
		newwindow.focus()
	}
	return false;
};
