var viewWidth, viewHeight, bodyWidth, bodyHeight;

function setdim() { bodyHeight = $(document).height();
	bodyWidth = $(document).width();
	
	if (self.innerHeight) // all except Explorer
	{
		viewWidth = self.innerWidth;
		viewHeight = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight) {
		viewWidth = document.documentElement.clientWidth;
		viewHeight = document.documentElement.clientHeight;
	}
	else if (document.body) {
		viewWidth = document.body.clientWidth;
		viewHeight = document.body.clientHeight;
	}
	
	bodyHeight = document.height || document.body.offsetHeight;
	if (bodyHeight < viewHeight) {
		bodyHeight = viewHeight;
	}
	
	$('#dim').css('height', bodyHeight);
	$('#dim').css('width', viewWidth);
	
	$('#popup').css('height', viewHeight);
	$('#popup').css('width', viewWidth);
}

$("#nav").bind("mouseenter",function(){
	$('#dim').show();
	$('#dim').css('opacity', 0).fadeTo('fast', 0.8);
}).bind("mouseleave",function(){
	$('#dim').css('opacity', 0.8).fadeTo('fast', 0, hidedim);
});

setdim();

$(window).resize(function(){
  setdim();
});

function hidedim() {
	$('#dim').hide();	
}