function rect(x, y, width, height){
	this.width=(!width)?0:width; 
	this.height=(!height)?0:height;
	this.x=(!x)?0:x; 
	this.y=(!y)?0:y;
}
function BlockToRect(obj){
	var x = FindPosX(obj);
	var y = FindPosY(obj);
	var width = parseInt(GetCssProp(obj, "width"));
	var height = parseInt(GetCssProp(obj, "height"));
	return new rect(x, y, width, height);
}

function SetObjDim(obj, rectangle){
	with(obj.style){
		top = rectangle.y + 'px'; 
		left = rectangle.x + 'px';
		height = rectangle.height + 'px';
		width = rectangle.width + 'px';
	}
}
function XyFetch(e){
	if(e){ 
		if(e.pageX){
			return new rect(e.pageX, e.pageY);
		}
		else{
			return new rect(e.clientX + document.body.scrollLeft - 2, e.clientY + document.body.scrollTop - 2);
		}
	}
}

function FindPosX(obj){
	var curleft = 0;
	if(obj.offsetParent){
		while(obj.offsetParent){
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if(obj.x){
		curleft += obj.x;
	}
	return curleft;
}
function FindPosY(obj){
	var curtop = 0;
	if(obj.offsetParent){
		while(obj.offsetParent){
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if(obj.y)
		curtop += obj.y;
	return curtop;
}

function GetCssProp(el, cssproperty){
	if(window.getComputedStyle){
		return elstyle = window.getComputedStyle(el, "").getPropertyValue(cssproperty);
	}	
	else if(el.currentStyle){
		return el.currentStyle[cssproperty];
	}
}