function setPagesDimentions()
{
	var width = $(window).width();
	var height = $(window).height();
	
	if (height < 800) height = 800;
	
	$(".bg-image img").width(width).height(height-13);
}

$(window).resize(function()
{
	setPagesDimentions();
});

$(document).ready(function()
{
	setPagesDimentions();
	
	$('.slider').jcarousel({
        scroll: 1				  
	});
	
	$(document).scroll(function()
	{
		var topOffset = $(window).scrollTop();
		var windowSize = $(window).height();
		var totalHeight = 0;
				
		$(".navigation a").each(function()
		{
			
			var thisItem = $(this);
			var itemOffset = $(thisItem.attr("href")).offset().top;
			var itemHeight = $(thisItem.attr("href")).height();
						
			if (itemOffset - itemHeight/2 < topOffset)
			{
				$(".navigation li.selected").removeClass("selected");
				thisItem.parent().addClass("selected");
			}
		});			
	});
});


$(document).ready(function()
{
	$('a[href*=#]').click(function()
	{
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
		&& location.hostname == this.hostname)
		{
			var $target = $(this.hash);
			$target = $target.length && $target
			|| $('[name=' + this.hash.slice(1) +']');
			if ($target.length)
			{
				var targetOffset = $target.offset().top;
				$('html,body')
					.animate({scrollTop: targetOffset}, 1000);
				return false;
			}
		}
	});
});
