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;
  }
  return [ scrOfX, scrOfY ];
}
function registerCenteredDiv(prop){
	prop = getCommonProperty(prop,{
		id:"",
		minWidth:30,
		minHeight:30,
		maxWidth:300,
		maxHeight:300
	});	
	var addDiv = document.getElementById(prop.id);
	if(addDiv){
		var r = addDiv.getBoundingClientRect();
		addDiv.minWidth = prop.minWidth;
		addDiv.minHeight = prop.minHeight;
		
		if(prop.maxWidth == "none"){
			addDiv.maxWidth = r.right - r.left;
			addDiv.maxHeight = r.bottom - r.top;
		}
		else{
			addDiv.maxWidth = prop.maxWidth;
			addDiv.maxHeight = prop.maxHeight;
		}
		
		addDiv.style.position = "absolute";   
		
		addDiv.resizeToCenter=function(){
			var w = document.body.offsetWidth? document.body.offsetWidth : window.innerWidth;
			var h = screen.height ? screen.height : document.body.offsetHeight;
			var s = getScrollXY();
			var r = this.getBoundingClientRect();
			this.style.left = (w-(r.right-r.left))/2 +"px";
    		this.style.top = (h-(r.bottom-r.top)+s[1]*2)/2 - 90 +"px";
		}
		addDiv.onBeforeOpen = function(){
			myFxMask.start();	
		}
		addDiv.onBeforeClose = function(){
			myFxMask.stop();
		}
		addDiv.openOrClose = function(){
			if(this.style.display == "block"){
				this.onBeforeClose();
				this.style.display = "none";
			}
			else{
				this.onBeforeOpen();
				var w = document.body.offsetWidth? document.body.offsetWidth : window.innerWidth;
				var h = document.body.offsetHeight ? document.body.offsetHeight : window.innerHeight;
				this.style.left = (w-this.minWidth)/2 +"px";
				this.style.top = (h-this.minHeight)/2 +"px";
				this.style.height = this.minWidth + "px"; 
				this.style.width = this.minHeight + "px";
				this.style.display = "block";
				var temp = this.style.overflow; 
				this.style.overflow = "hidden";
				resize(addDiv,"none",this.maxHeight,function(){ 
					resize(addDiv,addDiv.maxWidth,"none",function(){
						addDiv.style.overflow = temp;		  
					},"center");
				},"center");   
			}
		}	
	}
	return addDiv;
}
