window.onscroll = scroll
function scroll() {
	doOverlay('overlay');
	doCenter('overlayAdd');
}

function getObj(obj) {
	if ( document.getElementById ) {
		obj = document.getElementById( obj );
	} else if ( document.all ) {
		obj = document.all.item( obj );
	}
	
	return obj
}

function doPlace(obj,left) {
	obj = getObj(obj);
	
  	var winWidth = 0, winHeight = 0;
  	if( typeof( window.innerWidth ) == 'number' ) {
    	//Non-IE
    	winWidth = window.innerWidth;
    	winHeight = window.innerHeight;
  	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    	//IE 6+ in 'standards compliant mode'
    	winWidth = document.documentElement.clientWidth;
    	winHeight = document.documentElement.clientHeight;
  	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
     	//IE 4 compatible
   	 	winWidth = document.body.clientWidth;
		winHeight = document.body.clientHeight;
	}
	
	
	obj.style.left  = ( winWidth - 1000 ) / 2 + left + 'px';
	obj.style.top = (160 + getScrollXY()) + 'px';
	
}

function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  //window.alert( 'Horizontal scrolling = ' + scrOfX + '\nVertical scrolling = ' + scrOfY );
  return scrOfY;
}

function getObj(obj) {
	if ( document.getElementById ) {
		obj = document.getElementById( obj );
	} else if ( document.all ) {
		obj = document.all.item( obj );
	}
	
	return obj
}

function doCenter(obj) {
	obj = getObj(obj);
	
  	var winWidth = 0, winHeight = 0;
  	if( typeof( window.innerWidth ) == 'number' ) {
    	//Non-IE
    	winWidth = window.innerWidth;
    	winHeight = window.innerHeight;
  	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    	//IE 6+ in 'standards compliant mode'
    	winWidth = document.documentElement.clientWidth;
    	winHeight = document.documentElement.clientHeight;
  	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
     	//IE 4 compatible
   	 	winWidth = document.body.clientWidth;
		winHeight = document.body.clientHeight;
	}
	
	obj.style.left  = (winWidth / 2 - obj.offsetWidth / 2) + 'px';
	obj.style.top = (winHeight / 2 - obj.offsetHeight / 2) + getScrollXY() + 'px';
}

function doOverlay(obj) {
	obj = getObj(obj);

  	var winWidth = 0, winHeight = 0;
  	if( typeof( window.innerWidth ) == 'number' ) {
    	//Non-IE
    	winWidth = window.innerWidth;
    	winHeight = window.innerHeight;
  	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    	//IE 6+ in 'standards compliant mode'
    	winWidth = document.documentElement.clientWidth;
    	winHeight = document.documentElement.clientHeight;
  	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
     	//IE 4 compatible
   	 	winWidth = document.body.clientWidth;
		winHeight = document.body.clientHeight;
	}

	obj.style.width  = winWidth + 'px';
	obj.style.height = winHeight + 'px';
	obj.style.top = getScrollXY() + 'px';
}

function showOverlay(toDo, obj, objOver) {
	obj = getObj(obj);
	objOver = getObj(objOver);
	
	obj.style.visibility = toDo;
	objOver.style.visibility = toDo;
}

function insertInfo(obj,info) {
	obj = getObj(obj);
    obj.innerHTML = info;
}
