$(document).ready(function()
{
	// MENU TIMEOUT  
	var timeM = null;
	$('#main-menu ul li.main').bind('mouseenter', function (){
    	$('#main-menu ul li.main').removeClass('hover');
			$(this).addClass('hover');
			clearTimeout(timeM);
  });
	$('#main-menu ul li.main:not(.active)').bind('mouseleave', function(){
    	var elem = $(this);
    	timeM = setTimeout(function(){ elem.removeClass('hover');}, 600);   	
    });
	
	// ACCORDION
	$('.most-wanted').accordion({header: '.heading'});
	
	// SHOW EXTENDED-FORM
	$('.extended-search').css('display', 'none');
	$('.open-close .open').removeClass('hidden');
	$('.open-close .open').click(function(){
		$('.extended-search').css('display', 'block');
		$(this).addClass('hidden');	
		$(this).parent().each(function(){
			$('.close', this).removeClass('hidden');
		});
		return false;
	});
	$('.open-close .close').click(function(){
		$('.extended-search').css('display', 'none');
		$(this).addClass('hidden');	
		$(this).parent().each(function(){
			$('.open', this).removeClass('hidden');
		});
		return false;
	});
	
	// VERTICAL ALIGN
	$('.winegrowing-detail #annot-box .img-box').each(function(){ 
     var imgBoxH = $(this).height();
     $('img', this).each(function (){
       $(this).bind('load', function(){
        var imgH = $(this).height(); 
        $(this).css('margin-top', (imgBoxH - imgH) / 2 + 'px');
       }).attr('src', this.src);
     });     
  });
	  
});



