function hideContent()
{
	// hide content
	$('#content').animate(
		{
			width: 0
		},
		100,
		function() 
		{
			$('#content').css('display', 'none');
		}
	);
	$('#content').html('');
}

function showContent(text)
{
	// show content
	$('#content').width(0);
	$('#content').css('display', 'block');
	$('#content').animate(
		{
			width: $('#main').width() - 
				depixelize($('#content').css('padding-left')) -
				depixelize($('#content').css('padding-right'))
		},
		500,
		function() 
		{
			$('#content').html(text);
		}
	);
}

function hideMenuTop()
{
	$('#menuTop').css('display', 'none');
}

function showMenuTop()
{
	$('#menuTop').css('display', 'inline');
}

function showFullMenu(id, invokeAction)
{
	$('#fullMenu').css('display', 'inline');
	initLayout();
	$('#fm_' + id).trigger('click');
}

function hideFullMenu()
{
	$('#fullMenu').css('display', 'none');
}

function showContentFrame()
{
	$('#contentFrame').css('display', 'block');
}

function hideContentFrame()
{
	$('#contentFrame').html('');
	$('#contentFrame').css('display', 'none');
}

function showCaptionFrame()
{
	$('#captionFrame').css('display', 'block');
}

function hideCaptionFrame()
{
	$('#captionFrameContentContainer').html('');
	$('#captionFrame').css('display', 'none');
}

function setCaptionFrameText(text)
{
	$('#captionFrameContentContainer').html(convertTextBreaks(text ? text.substring(0, 247) : ''));
}

function setCaptionFramePrintInformation(action, url, mainCategory, subCategory)
{
	var targetURL = url;
	
	// fix for ff6
	if(targetURL.substring(0, 4) == 'http')
	{
		targetURL = url.substring(7, targetURL.length);
	};
	
	$("#printLink").attr('href', action + '?targetURL=' + targetURL + '&mainCategory=' + mainCategory + '&subCategory=' + subCategory);
}

function loadContentFrame(url)
{
	hideCaptionFrame();
	$('#contentFrame').load
	(
	   url
	);	
}

function lockFullMenu()
{
	$('#fullMenu').simpleAccordion('lock');
}

function unlockFullMenu()
{
	$('#fullMenu').simpleAccordion('unlock');
}

function loadFullMenu(id)
{
	// close top menu
	hideMenuTop();

	// fade out	
	hideContent();

	// show full menu
	showFullMenu(id);
	
	// done
	return false;
}

function loadMenuPage(id)
{
	hideContentFrame();
	loadContentFrame('/handler/handle?id=' + id + '&r=' + Math.random());
	
	// done
	return false;
}

function getSelectedPathLocation()
{
	var path = $('#fullMenu').simpleAccordion('getSelectedPath');
	pathComputed = '';
	for (i = 0; i < path.length; i++)
	{
		pathComputed = pathComputed + ((i > 0) ? '/' : '') + getPathElementName(path[i].attr('title'));
	}
	
	return pathComputed;
}

function handleAutoSubmenu(targetMenuStyle, allowedSubmenus)
{
    $('#fullMenu').find('.' + targetMenuStyle).each(
	    function() {
	     $(this).click
	     (
	         function() 
	         {
	 	        children = $(this).parent().find('a');
	 	 	  
	 	       for (i = 0; i < children.length; i++)
	 	       {
	 	          child = $(children[i]);
	 	          found = false;
	 	          for (j = 0; j < allowedSubmenus.length; j++)
	 	          {
	 	        	 if (child.hasClass(allowedSubmenus[j]))
	 	        	 {
	 	        		 found = true;
	 	        		 break;
	 	        	 } 	 
	 	          }
	 	          if (found)         	          
	              {
	 	             id = child[0].id.substr(3, child[0].id.length);
	 	             showFullMenu(id, true);
	 	             break;
	 	          } 
	 	       };
	         }
	      ); 
	   }
    );       
}
