if (typeof window.console === 'undefined') {
	window.console = {
		log: function() {
			void(0);
		}
	};
}

function changeImage() {
	var images = new Array();
	images[0] = 'url(img/galleries/teaserpic_1.jpg) no-repeat';
	images[1] = 'url(img/galleries/teaserpic_2.jpg) no-repeat';
	images[2] = 'url(img/galleries/teaserpic_3.jpg) no-repeat';
	images[3] = 'url(img/galleries/teaserpic_4.jpg) no-repeat';
	images[4] = 'url(img/galleries/teaserpic_5.jpg) no-repeat';
	
	var messages_rand = Math.ceil(Math.random() * 4);
	var current_image = images[messages_rand];

	$('#homePage .teaser')
		.fadeTo(100, 0.5, function() {
			$(this).css('background', current_image);
			$(this).fadeTo(100, 1.0);
		})
	;
}

jQuery(function($) {
	var currContentHeight = 0;
	var maxContentHeight = 0;
	var currTitleHeight = 0;
	var maxTitleHeight = 0;
	var rowLeveler = $('.rowLeveler');
	rowLeveler.each(function() {
		var titleLeveler = $(this).find('.titleLeveler');
		titleLeveler.each(function() {
			currTitleHeight = $(this).height();
			//console.log(this, 'title height:', currTitleHeight, 'px');
			if (currTitleHeight > maxTitleHeight) {
				maxTitleHeight = currTitleHeight;
			}
		});
		titleLeveler.height(maxTitleHeight);
		//console.log('Setting all above objects\' title height to:', maxTitleHeight, 'px');
		currTitleHeight = 0;
		maxTitleHeight = 0;
		
		var contentLeveler = $(this).find('.contentLeveler');
		contentLeveler.each(function() {
			currContentHeight = $(this).height();
			//console.log(this, 'content height:', currContentHeight, 'px');
			if (currContentHeight > maxContentHeight) {
				maxContentHeight = currContentHeight;
			}
		});
		contentLeveler.height(maxContentHeight);
		//console.log('Setting all above objects\' content height to:', maxContentHeight, 'px');
		currContentHeight = 0;
		maxContentHeight = 0;
	});
	
	$('.target_blank')
		.attr('target', '_blank')
	;
	
	$('.submitCheck')
		.attr('value', '1')
	;
	
	$('a.inputButton')
		.click(function() {
			$(this).parents('form')
				.submit()
			;
		})
	;
	
	$("#galleryCarousel")
		.jcarousel({
	        scroll: 2,
	        animation: 800
		})
	;
	
	setInterval("changeImage()", 5000);
	
});
