
var pb_htmlUtils = Class.create({
	
	toIntPx: function(value){
		// TODO Hacer que tenga en cuenta la unidad en la que está y devuelva el equivalente en píxeles
		value = parseInt(value);
		if (isNaN(value)){
			value = 0;
		}
		
		return value;
	},
	
	getRealWidth: function(node){
		var borderLeft = this.toIntPx(node.style.borderLeftWidth);
		var borderRight = this.toIntPx(node.style.borderRightWidth);
		var paddingLeft = this.toIntPx(node.style.paddingLeft);
		var paddingRight = this.toIntPx(node.style.paddingRight);
		var width = this.toIntPx(node.offsetWidth);
		return borderLeft + borderRight + paddingLeft + paddingRight + width;
	},
	
	getRealHeight: function(node){
		var borderTop = this.toIntPx(node.style.borderTopWidth);
		var borderBottom = this.toIntPx(node.style.borderBottomWidth);
		var paddingTop = this.toIntPx(node.style.paddingTop);
		var paddingBottom = this.toIntPx(node.style.paddingBottom);
		var height = this.toIntPx(node.offsetHeight);
		return borderTop + borderBottom + paddingTop + paddingBottom + height;
	},
	
	getPositionInPage: function(node){
		var resultX = 0;
		var resultY = 0;
		
		while (node != null) {
			resultX += node.offsetLeft;
			resultY += node.offsetTop;
			node = node.offsetParent;
		}
		
		return new Array(resultX,resultY);
	},
	
	getXPosInPage: function(node){
		var result = 0;

		while (node != null) {
			result += node.offsetLeft;
			node = node.offsetParent;
		}
		
		return result;
	},

	getYPosInPage: function(node){
		var result = 0;

		while (node != null) {
			result += node.offsetTop;
			node = node.offsetParent;
		}
		
		return result;		
	}
});
