$(function(){
	$('.thumbnails img').each(function(i, elem){
		var link = $('<a></a>');
		link.attr('rel', 'thumbnails');
		link.attr('href', $(elem).attr('src'));
		link.addClass('thumbnail');
		$(elem).replaceWith(link);

		link.append($(elem).clone());

	});
	$('.thumbnails a.thumbnail').fancybox({autoScale: true, overlayShow: true, centerOnScroll: true, margin: '15px'});

	// Classic popup links
	$('a.popup').fancybox({autoScale: true, overlayShow: true, centerOnScroll: true, margin: '15px'});
});

/*************************************************
 * Legacy code
 */

function openPopUp(url,windowname){
	//alert("popup");
	popUpWeite=fensterweite()-40;
	popUpHoehe=fensterhoehe();
	leftMargin=(fensterweite()-popUpWeite)/2;
	topMargin=(fensterhoehe()-popUpHoehe)/2+20;
	fenster=window.open(url, windowname, "right=10,width="+popUpWeite+",height="+popUpHoehe+",scroll=no,status=yes,scrollbars=no,resizable=yes,left="+leftMargin+",top="+topMargin);
	fenster.focus();
	return false;
}

function fensterweite() {
	if (window.innerWidth) {
		return window.innerWidth;
	} else if (document.body && document.body.offsetWidth) {
		return document.body.offsetWidth;
	} else {
		return 0;
	}
}

function fensterhoehe() {
	if (window.innerHeight) {
		return window.innerHeight;
	} else if (document.body && document.body.offsetHeight) {
		return document.body.offsetHeight;
	} else {
		return 0;
	}
}


