$(document).ready(function(){
	$('#menumain div.item').hover(function(){
		$(this).addClass('hover');
	}, function(){
		$(this).removeClass('hover');
	});
	function getH()
	{
		return (window.innerHeight ? window.innerHeight : (document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.offsetHeight));
	}
	function getW()
	{
		return (window.innerWidth ? window.innerWidth : (document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body.offsetWidth));
	}
	function setSpacerSize()
	{
		var h = getH();
		var acth = parseInt($('#wrappermain').height());
		var seth = (h > acth) ? ((h - acth) / 2) : 10;
		$('#spacertop').height(seth);
	}
	setSpacerSize();
	setTimeout(setSpacerSize, 100);
	$(window).resize(setSpacerSize);
	function lbActive(url)
	{
		h = getH();
		w = getW();
		$('#lb').attr('class', 'active').height(getH());
		$('#lbal').show(0).css({'top':(h / 2) - 200, 'left':(w - 54) / 2});
		var img = new Image();
		img.src = url;
		img.onload = function(){
			$('#lbmainimage').attr('src', url);
			left = (w - $('#lbmainimage').width()) / 2;
			left = (left > 10) ? left : 10;
			$('#lbmainimage').css({'top':'50px', 'left': left}).draggable();
			$('#lbal').hide(0);
		}
		/*$('<img />').attr('src', url).load(function(){
			$('#lbmainimage').attr('src', url);
			left = (w - $('#lbmainimage').width()) / 2;
			left = (left > 10) ? left : 10;
			$('#lbmainimage').css({'top':'50px', 'left': left}).draggable();
			$('#lbal').hide(0);
		});*/
	}
	function lbInactive()
	{
		$('#lb').attr('class', 'inactive');
		$('#lbmainimage').css('top', '-100px').attr('src', '');
	}
	$('#lbclose, #lb').click(function(){
		lbInactive();
		return false;
	});
	$('.lb').click(function(){
		lbActive($(this).attr('href'));
		return false;
	});
});
