$(function() {
	setupZoom();
	$('#lblockImages .iw').cycle({
		speed: 4000,
		timeout: 5000
	});
	
	$('.sponsorencycle').cycle({
		speed: 1200,
		timeout: 3000,
		fx: 'scrollVert'
	});
	
	
	equalHeight($('#main, #left, #right'));
	
	
	equalHeight($('.startpagina_blok2, .startpagina_blok3'));
	equalHeight($('.startpagina_blok4, .startpagina_blok5'));
	
	equalHeight($('#content ul.sponsorenoverzicht li.sponsor'));
	
	
	attachTooltips();
	
	
	$('.sponsoren a').click(function() {
		document.location.href = '/sponsoren/';
		return false;
	});
	
	$('.startpagina_blok').each(function (){
		var imgObj = $(this).find('img')[0];
		var link = $(this).find('a').attr('href');
		if (typeof(imgObj) != 'undefined' && typeof(link) != 'undefined') {
			$(imgObj).css('cursor','pointer').click(function() {
				document.location.href = link;
			});
		}
	});
});

function equalHeight(group) {
    tallest = 0;
    group.each(function() {
        thisHeight = $(this).height();
        if(thisHeight > tallest) {
            tallest = thisHeight;
        }
    });
    group.height(tallest);
}

function attachTooltips() {
	$('.tooltip_trigger').each(function() {
		var tooltip_name = this.id.replace('link_','');
		var tooltip_trigger_object = this;

		$('#tooltip_' + tooltip_name).css({
			'display':'block',
			'opacity':0,
			'marginTop': 0
		});
		

		$(this).mouseover(function() {
			$('#tooltip_' + tooltip_name).stop().animate({
				'opacity':1,
				'marginTop': 10
			}, 350);
		});
		
		$(this).mouseleave(function() {
			$('#tooltip_' + tooltip_name).stop().animate({
				'opacity':0,
				'marginTop': 0
			}, 350);
		});
	});
}

