function XYcoordinate(x, y) {
	this.x = (isNaN(x)) ? x : 0;
	this.y = (isNaN(y)) ? y : 0;
	this.xmouse = 0;
	this.ymouse = 0;
	this.xoffset = 0;
	this.yoffset = 0;
	this.stageW = 0;
	this.stageH = 0;
	this.objW = 0;
	this.objH = 0;
}
	
XYcoordinate.prototype.calculateXY = function(target) {
	var parent = target;
	while (parent) {
		this.x += parent.offsetLeft;
		this.y += parent.offsetTop;
		parent = parent.offsetParent;
	}
}
	
XYcoordinate.prototype.mouseXY = function(event) {
	// Win IE
	if (!event) event = window.event;
		
	if (event.pageX) {
		this.xmouse = event.pageX;
		this.ymouse = event.pageY;
	} else {
		this.xmouse = event.clientX;
		this.ymouse = event.clientY;
	}
}
	
XYcoordinate.prototype.mouseOffset = function(target, event) {
	this.calculateXY(target);
	this.mouseXY(event);
		
	this.xoffset = this.xmouse - this.x;
	this.yoffset = this.ymouse - this.y;
}

XYcoordinate.prototype.getStageW = function() {
	if(window.innerWidth) return window.innerWidth; // Mozilla, Opera, NN4
 	if(document.documentElement && document.documentElement.clientWidth){ // �ȉ� IE
		return document.documentElement.clientWidth;
	} else if (document.body && document.body.clientWidth) {
		return document.body.clientWidth;
	}	
}

XYcoordinate.prototype.getStageH = function() {	
	if(window.innerHeight) return window.innerHeight; // Mozilla, Opera, NN4
	if(document.documentElement && document.documentElement.clientHeight){ // �ȉ� IE
		return document.documentElement.clientHeight;
	} else if (document.body && document.body.clientHeight) {
		return document.body.clientHeight;
	}
}

XYcoordinate.prototype.getStageScroll = function() {
	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}
	
	return yScroll;
}

XYcoordinate.prototype.getStageSize = function() {
	var w, h;
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	this.stageW = this.getStageW();
	this.stageH = this.getStageH();
	
	if (xScroll > this.stageW) {
		this.stageW = xScroll;
	}
	if (yScroll > this.stageH) {
		this.stageH = yScroll;
	}
	
}

XYcoordinate.prototype.getSize = function(obj) {
	var w, h;
	
	w = obj.offsetWidth;
	h = obj.offsetHeight;
	
	this.objW = w;
	this.objH = h;
}

XYcoordinate.prototype.getScrollPosX = function() {
    if (typeof window.pageXOffset != 'undefined') {
        return window.pageXOffset;
    }
    else if (typeof document.documentElement.scrollLeft != 'undefined' && document.documentElement.scrollLeft > 0) {
        return document.documentElement.scrollLeft;
    }
    else if (typeof document.body.scrollLeft != 'undefined') {
        return document.body.scrollLeft;
    }
    return 0;
}

XYcoordinate.prototype.getScrollPosY = function() {
    if (typeof window.pageYOffset != 'undefined') {
        return window.pageYOffset;
    }
    else if (typeof document.documentElement.scrollTop != 'undefined' && document.documentElement.scrollTop > 0) {
        return document.documentElement.scrollTop;
    }
    else if (typeof document.body.scrollTop != 'undefined') {
        return document.body.scrollTop;
    }
    return 0;
}


function replaceXY(obj1, obj2) {
	var coordObj = new XYcoordinate(obj1.offsetLeft, obj1.offsetTop);
	coordObj.calculateXY(obj1);
				
	obj2.style['left'] = coordObj.x + "px";
	obj2.style['top'] = coordObj.y + "px";
}