﻿$(document).ready(function() {

	$('html').css({overflowY: 'scroll'});

	var temp = new Image();
	temp.src = $('#content').css('backgroundImage').replace(/url\("(.*)"\)/g,'$1');
	$(temp).load(function() {
		$('#content').css('height', Math.ceil($('#content').height()/this.height)*this.height+'px');
	});
	if($('.tease_text').length != 0) {
		heights = new Array();
		max = 0;
		heights[0] = $($('.tease_text').get(0)).height();
		heights[1] = $($('.tease_text').get(1)).height();
		heights[2] = $($('.tease_text').get(2)).height();
		
		for (j = 0; j < heights.length; j++ ) {
			if(heights[j] > max) max = heights[j];
		}
		$($('.tease_text').get(0)).css('height', max+'px');
		$($('.tease_text').get(1)).css('height', max+'px');
		$($('.tease_text').get(2)).css('height', max+'px');
	}

	$('a.lightbox').lightBox({
		boxShadow: '0 0 4px #777',
		overlayBgColor: 'none',
		overlayOpacity: 1,
		imageBtnClose: 'schließen',
		imageBtnPrev: '',
		imageBtnNext: '',
		btnNext: 'weiter &#x25B6;',
		btnPrev: '&#x25C0; zurück',
		containerResizeSpeed: 10,
		txtImage: 'Bild',
		txtOf: 'von'
	});

	$('.wp-content-wrap a').filter(':has(img)').lightBox({
		boxShadow: '0 0 4px #777',
		overlayBgColor: 'none',
		overlayOpacity: 1,
		imageBtnClose: 'schließen',
		imageBtnPrev: '',
		imageBtnNext: '',
		btnNext: 'weiter &#x25B6;',
		btnPrev: '&#x25C0; zurück',
		containerResizeSpeed: 10,
		txtImage: 'Bild',
		txtOf: 'von'
	});
	
	$('a.extern').click(function(e) {
		e.preventDefault();
		window.open(this.href);
	});

	
	$('.wp-content-wrap img').each(function(index, element) {
		width = $(this).attr('width');
		height = $(this).attr('height');
		if(width > 382) {
			multiplicator = 382/width;
			$(this).attr('width', Math.floor(width*multiplicator));
			$(this).attr('height', Math.floor(height*multiplicator));
		}
	});
});