function Showinformation(URL, ORIGINAL_URL, TITLE, TYPE)
{
	if(TYPE == 'info_small')
	{
		jManteigaria.ajaxPrefilter(function( options, original_Options, jqXHR ) {
			options.async = false;
		});
		
		if(jManteigaria("#ms_body_2").is(":visible"))
		{
			jManteigaria('#ms_body_2').css('right', '').animate({width: 'toggle'}, "slow");
		}
		
		setTimeout(function()
		{ 
			api = jManteigaria(".info").jScrollPane(
			{
				verticalDragMinHeight: 6,
				verticalDragMaxHeight: 40,
				horizontalDragMinWidth: 20,
				horizontalDragMaxWidth: 20,
				showArrows: jManteigaria(this).is('.arrow'),
				maintainPosition: false,
				animateScroll: true,
				animateDuration: 100,
				mouseWheelSpeed: 100,
				keyboardSpeed: 920,
				animateSteps: true
			}).data('jsp');
			
			jManteigaria.ajax(
			{
				method: "POST",
				url : URL
			  
			}).done(function( data )
			{
				api.getContentPane().html(data);
				
				if(!jManteigaria('.info *').hasClass('close_button'))
				{
					lang = jManteigaria('html').attr('lang');
				
					lang_type = 'en';
					if(lang == 'pt-pt')
					{
						lang_type = 'pt';
					}	
					
					// Produção
					jManteigaria('<div class="close_button"><a onclick="CloseDiv(\'Manteigaria Silva\', \'https://www.manteigariasilva.pt/'+lang_type+'/\', 119);"></a></div>').prependTo('.info');
					
					// Desenvolvimento
					//jManteigaria('<div class="close_button"><a onclick="CloseDiv(\'Manteigaria Silva\', \'http://www.lavinci.online/projects/manteigaria/index.php/'+lang_type+'/\', 119);"></a></div>').prependTo('.info');
				}	

				if(jManteigaria(".info").is(":visible") == false)
				{
					jManteigaria('.info').animate({width: 'toggle'}, "slow");
				}
				
				document.title = TITLE;
				history.pushState('', '', ORIGINAL_URL);
				
				api.reinitialise();
			});
		}, 500);
	}
	else
	{
		if(jManteigaria('#ms_menu_2').is(":visible"))
		{
			jManteigaria('#ms_menu_2').animate({width: 'toggle'});
		}
		
		if(jManteigaria("#ms_body_2").is(":visible"))
		{
			jManteigaria('#ms_body_2').css('right', '').animate({width: 'toggle'}, "slow");
		}

		setTimeout(function()
		{ 
		
			jManteigaria.ajaxPrefilter(function( options, original_Options, jqXHR ) {
				options.async = true;
			});
			
			api = jManteigaria(".ms_body_article").jScrollPane(
			{
				verticalDragMinHeight: 6,
				verticalDragMaxHeight: 40,
				horizontalDragMinWidth: 20,
				horizontalDragMaxWidth: 20,
				showArrows: jManteigaria(this).is('.arrow'),
				animateScroll: true,
				animateDuration: 1000,
				mouseWheelSpeed: 1000,
				keyboardSpeed: 920,
				animateSteps: true
			}).data('jsp');
							
			jManteigaria.ajax(
			{
				method: "POST",
				url : URL
			  
			}).done(function( data ) 
			{				
				count_mstextodiv = (data.split('ms_texto_div').length-1);
				
				api.getContentPane().html(data);
				setTimeout(function()
				{
					Needscroll();
				}, 1000);

				if(count_mstextodiv < 2)
				{
					jQuery('.jspHorizontalBar').hide();
				}	

				jManteigaria('#ms_body_2').css('right', '0').animate({width: 'toggle'}, "slow");	
				
				document.title = TITLE;
				history.pushState('', '', ORIGINAL_URL);
				
				if(count_mstextodiv > 1)
				{
					api.reinitialise();	
				}
			});
		}, 500);
	}
}

function Needscroll()
{
	jManteigaria('.info').jScrollPane(
	{
		verticalDragMinHeight: 6,
		verticalDragMaxHeight: 40,
		horizontalDragMinWidth: 20,
		horizontalDragMaxWidth: 20,
		showArrows: jManteigaria(this).is('.arrow'),
		animateScroll: true,
		animateDuration: 1000,
		mouseWheelSpeed: 1000,
		keyboardSpeed: 920,
		animateSteps: true
	});
	var api = jManteigaria('.info').data('jsp');

	jManteigaria('.ms_body_article').jScrollPane(
	{
		verticalDragMinHeight: 6,
		verticalDragMaxHeight: 40,
		horizontalDragMinWidth: 20,
		horizontalDragMaxWidth: 20,
		showArrows: jManteigaria(this).is('.arrow'),
		animateScroll: true,
		animateDuration: 1000,
		mouseWheelSpeed: 1000,
		keyboardSpeed: 920,
		animateSteps: true
	});
	
	var api2 = jManteigaria('.ms_body_article').data('jsp');

	var throttleTimeout;
	jManteigaria(window).bind(
		'resize',
		function()
		{
			if (!throttleTimeout) {
				throttleTimeout = setTimeout(
					function()
					{
						api.reinitialise();
						api2.reinitialise();
						throttleTimeout = null;
					},
					50
				);
			}
		}
	);
}

jQuery(function() { 
	
	jQuery('.info-small').on({
		mouseenter: function() {
			
		TYPE = 'info_small';				
		URL = jQuery(this).attr("href") + '?tmpl=component';
		ORIGINAL_URL = jQuery(this).attr("href");
		TITLE = jQuery(this).text().replace(' | ', ' ');				

		jQuery(this).parent().parent().parent().addClass('active');	
		jQuery('dt.level1').not(jQuery(this).parent().parent().parent()).removeClass('active');
		
		Showinformation(URL, ORIGINAL_URL, TITLE, TYPE);
		
		}
	});
});

function CloseDiv(TITLE, ORIGINAL_URL, ITEMID)
{
	if(jManteigaria('#ms_menu_2').is(":visible"))
	{
		jManteigaria('#ms_menu_2').animate({width: 'toggle'});
		jQuery('.off-menu_117 dl dt.off-nav-'+ITEMID+'.active, .off-menu_117 dl dl.level1 dt.off-nav-'+ITEMID+'.active, .off-menu_117 dl dl.level1 dd.off-nav-'+ITEMID+'.active').removeClass('active');
	}
	
	if(jManteigaria("#ms_body_2").is(":visible"))
	{
		jManteigaria('#ms_body_2').css('right', '').animate({width: 'toggle'}, "slow");
		jQuery('.off-menu_117 dl dt.off-nav-'+ITEMID+'.active, .off-menu_117 dl dl.level1 dt.off-nav-'+ITEMID+'.active, .off-menu_117 dl dl.level1 dd.off-nav-'+ITEMID+'.active').removeClass('active');
	}
	
	document.title = TITLE;
	history.pushState('', '', ORIGINAL_URL);
}