function rotator(div) {
	$(div).cycle({ 
		fx: 'fade', 
		speed: 1000, 
		timeout: 6000,
		next: div
	});
}
function highlight(div,m) {
	$(div + ' ul').each(function(){
		$(this).css('left',Math.round($(this).parent().offset().left) + 'px');
		if ($(this).height()>m) {
			$(this).attr('rel',m);
			$(this).attr('rel2',$(this).height());
		} else {
			$(this).attr('rel',$(this).height());
			$(this).attr('rel2',$(this).height());
		}
		$(this).css('height','0px');
	});	
	$(div + ' li a').hover(function() {
		var jump_menu = $(this).parent().children('ul');
		var offset = jump_menu.attr('rel') + 'px';
		$(this).parent().animate({backgroundColor:'#134E84'},{duration:500,queue:false});
		jump_menu.animate({height:offset},{duration:500,queue:false});
		
		if (jump_menu.attr('rel') == jump_menu.attr('rel2')) {
			jump_menu.scrollTop(0);
		} else if ( Math.round(jump_menu.attr('rel')) + Math.round(jump_menu.scrollTop()) > jump_menu.attr('rel2') ) {
			jump_menu.scrollTop(0);
		}
	}, function() {
		var jump_menu = $(this).parent().children('ul');
		$(this).animate({color:'#416097'},{duration:500,queue:false});
		$(this).parent().animate({backgroundColor:'#134E84'},{duration:500,queue:false});
		jump_menu.animate({height:0 + 'px'},{duration:500,queue:false});
	});
	
	$(div + ' ul').hover(function() {
		var offset = $(this).attr('rel') +'px';
		$(this).animate({height:offset},{duration:500,queue:false});
	}, function () {
		$(this).animate({height:0 + 'px'},{duration:500,queue:false}).css('display','none');
	});

	$(div + ' ul').mousemove(function(e) {
		if ($(this).attr('rel')<$(this).attr('rel2')) {
			var poz=e.pageY - $(this).offset().top;
			var procent=poz/$(this).attr('rel');
			$(div + ' ul').scrollTop( Math.round( procent * ( $(this).attr('rel2')-$(this).attr('rel')) ) );
		} else {
			$(div + ' ul').scrollTop(0);
		}                                                                                                   
	});
	$(div + ' ul a').hover(function() {
		var this_color=$(this).css('color');
		var this_p_color=$(this).parent().css('color');
		$(this).animate({paddingLeft:15 + 'px', color:'#A1D2F2'},{duration:500,queue:false});
		$(this).parent().animate({backgroundColor:'#134E84'},{duration:500,queue:false});
	}, function () {
		$(this).animate({paddingLeft:0 + 'px', color:'#FFFFFF'},{duration:500,queue:false});
		$(this).parent().animate({backgroundColor:'#134E84'},{duration:500,queue:false});
	});
}
