var sitmapBox = "#sitemap ul:first";
var menuWidth = 0;
var overflow = false;

function onReadySpecific()
{
	
}

function onResizeCheckMenu()
{
	$("#sitemap").css('overflow', 'hidden');
	menuWidth = $("#sitemap").width();
	
	$('body').append('<div class="sitemap_arrow" id="sitemap_right"><a href="#">&gt;</a></div><div class="sitemap_arrow" id="sitemap_left"><a href="#">&lt;</a></div>');
	$('.sitemap_arrow').hide();
	
	//scrollPadding = 40;
	if($('#sitemap ul:first').attr(aWAtt) == undefined)
	{
		overflow = false;
		$('#sitemap ul').each(
			function()
			{
				$(this).attr(aWAtt, 0);
				$(this).width(1000000);
				$(this).find('li').each(
					function()
					{
						calculateActualMenuWidth($(this));
					}
				);
				//$(this).width($(this).attr(aWAtt)*1);
				checkListForArrows($(this));

			}
		);
		$('#sitemap ul:first').width($('#sitemap ul:first').attr(aWAtt)*1);
	}
	else
	{
		overflow = false;
		$('#sitemap ul').each(
			function()
			{
				checkListForArrows($(this));
			}
		);
	}
}

function checkListForArrows(ul)
{
	var listWidth = ul.attr(aWAtt)*1;
	var listHolderWidth = $('#'+div_id).width() - 350;
	if(listWidth > listHolderWidth)
	{
		overflow = true;
		//$(this).css('left', 0);
		$("#sitemap").width(listHolderWidth-30);
		$('#sitemap_right a').mousedown(function(){startTween(this, -1, ul);});
		$('#sitemap_left a').mousedown(function(){startTween(this, 1, ul);});
		$('.sitemap_arrow').show();
	}
	else if(!overflow)
	{
		$("#sitemap").width(listHolderWidth);
	}
}

function calculateActualMenuWidth(li)
{
	var currentCountWidth = li.parent('ul').attr(aWAtt)*1;
	currentCountWidth += li.width()+((li.css('margin-right')).replace('px', '')*1);
	li.parent('ul').attr(aWAtt, currentCountWidth);
}

function onResizeBodySpecific()
{	
	onResizeCheckMenu();
	var skh = $('#sticky_gallery_nav').height();
	if(skh != null && bodyHeight == $('#body').height() && skh > 0)
	{
		bodyHeight = $('#body').height() - skh - 9 - scrollPadding;
	}
}

function onResizeGalleryItemSpecific(fimg)
{
		
}