/**
 * show teaser items
 * @author AK
 */

var subItemInfoWraps = $('.subItem-showTeaser .imgInfoWrap');

$('.subItem-showTeaser .imgInfoWrap p.img a')
	.click(function(){ return false })
	.css('cursor', 'default')
;

$('.subItem-showTeaser .imgInfoWrap').hover(function(){
	if ($(this).css('position') == 'static')
		return;
		
	var item = $(this);
	window.clearTimeout(item.data('outTimeoutId'));
				
	var inTimeoutId = window.setTimeout(function(){
		if ($.ppprd.debug.enabled) $.log('in ' + item.parent().parent().attr('id'));
		
		var img = item.find('img');
		var imgHeight = img.height();
	
		img.fadeOut('normal', function(){
			item.parent().parent().addClass('subItem-showTeaser-hover');
			if ($.browser.msie && parseFloat($.browser.version) < 7) {
				item.css('height', imgHeight-1);
			}
			else {
				item.css('minHeight', imgHeight-1);
			}
			$.log('in class: ' + item.parent().parent().attr('class'))
			$.log('in: fadeOut complete');
		});
	}, 175);		
	item.data('inTimeoutId', inTimeoutId);			
}, function(){
	if ($(this).css('position') == 'static')
		return;
	
	var item = $(this);
	window.clearTimeout(item.data('inTimeoutId'));
	
	var outTimeoutId = window.setTimeout(function(){
		if ($.ppprd.debug.enabled) 
			$.log('out ' + item.parent().parent().attr('id'));
		
		var img = item.find('img');
		
		// we're out, cancel possible queued fadeOut
		img.stop({clearQueue: true});
		img.css({opacity: '1'}); // needed to get correct fadeIn behaviour
		
		img.fadeIn('normal', function(){
			$.log('out: fadeIn complete')
		});

		item.parent().parent().removeClass('subItem-showTeaser-hover')
		$.log('out class: ' + item.parent().parent().attr('class'))
		
	}, 375);
	
	item.data('outTimeoutId', outTimeoutId);
});
