var getPageScroll = function(){
	var sx = window.pageXOffset || document.body.scrollLeft || document.documentElement.scrollLeft;
	var sy = window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop;
	return new Array(sx,sy);
	}
//get the current viewport size
var getViewPortSize = function(){
	var pw = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
	var ph = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
	return new Array(pw,ph);
	}
//get the page size:
var getPageSize = function(){
	var vp = getViewPortSize();
	var pw = document.body.offsetWidth;
	var ph = document.body.offsetHeight;
	//assign viewport size if body size smaller then viewport
	if( vp[0]>pw )
		pw = vp[0];
	if( vp[1]>ph )
		ph = vp[1];
	return new Array(pw,ph);
	}
var adjustPosition = function(top){
	var pageSize = getPageSize();
	var ps = getPageScroll();
	var h = $('#jBox')[0].offsetHeight;
	var w = $('#jBox')[0].offsetWidth;
	var cX = Math.round(pageSize[0]/2)-Math.round(w/2)+ps[0];
	var cY = Math.round(pageSize[1]/2)-Math.round(h/2)+ps[1];
	if( top == 1 )
		$('#jBox').css({left:cX+'px',top:'20px'});
	else
		$('#jBox').css({left:cX+'px'/*,top:cY+'px'*/});
	$('#jOverlay').css({height:getPageSize()[1]+'px'});
	}
var fadeTimeout;
var fadeFunction = function(){
	clearInterval( fadeTimeout );
	if( $('#jOverlay') ){ 
		$('#jOverlay').hide();
		}
	if( $('#jBox') ){
		$('#jBox').hide();
		//new Effect.BlindUp('jBox', { duration: 0.5 });
		}      
	}
//remove the overlay
var removeOverlay = function(){
	fadeTimeout = setInterval(fadeFunction, 1000 );
	}
var createOverlay = function(){
	$('#jOverlay').css({position:'absolute',zIndex:98,left:0,top:0,width:'100%',height:getPageSize()[1]+'px',display:'block'});
	$('#jBox').css({position:'absolute',left:0,top:0,zIndex:99,display:'block'});
	adjustPosition(1);
	$(window).scroll(adjustPosition);
	$(window).resize(adjustPosition);
	}
