document.viewport = {
  getDimensions: function() {
    var dimensions = { };
	var width,height;
	if (self.innerHeight) // all except Explorer
	{
		width = self.innerWidth;
		height = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
		// Explorer 6 Strict Mode
	{
		width = document.documentElement.clientWidth;
		height = document.documentElement.clientHeight;
	}
	else if (document.body) // other Explorers
	{
		width = document.body.clientWidth;
		height = document.body.clientHeight;
	}
	dimensions['width'] = width;
	dimensions['height'] = height;
    return dimensions;
  },

  getWidth: function() {
    return this.getDimensions().width;
  },

  getHeight: function() {
    return this.getDimensions().height;
  },

  getScrollOffsets: function() {
    return Element._returnOffset(
      window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft,
      window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop);
  }
};




Element.Methods.show = function (element)
{
	if($(element).hasClassName('hidden'))
	{
		$(element).removeClassName('hidden');
	}
	$(element).style.display = '';
	return $(element);
}

Element.Methods.visible = function(element) {
    if($(element).hasClassName('hidden'))
	{
		return false;
	}
	return $(element).style.display != 'none';
}

Element.Methods.getPaddingHeight = function(element) {
	var paddingTop = $(element).getStyle('padding-top');
	paddingTop = (paddingTop == null) ? 0 : parseInt(paddingTop);
	
	var paddingBottom = $(element).getStyle('padding-bottom');
	paddingBottom = (paddingBottom == null) ? 0 : parseInt(paddingBottom);

	return paddingTop + paddingBottom;
}

Element.Methods.getPaddingWidth = function(element) {
	var paddingLeft = $(element).getStyle('padding-left');
	paddingLeft = (paddingLeft == null) ? 0 : parseInt(paddingLeft);
	
	var paddingRight = $(element).getStyle('padding-right');
	paddingRight = (paddingRight == null) ? 0 : parseInt(paddingRight);

	return paddingLeft + paddingRight;
}


Element.Methods.getSurroundingAreaWidth = function(element) {

	var marginLeft = $(element).getStyle('margin-left');
	marginLeft = (marginLeft == null) ? 0 : parseInt(marginLeft);	
	
	var borderLeftWidth = $(element).getStyle('border-left-width');
	borderLeftWidth = (borderLeftWidth == null || isNaN(borderLeftWidth)) ? 0 : parseInt(borderLeftWidth);		
	
	var padding = $(element).getPaddingWidth();
		
	var borderRightWidth = $(element).getStyle('border-right-width');
	borderRightWidth = (borderRightWidth == null  || isNaN(borderRightWidth)) ? 0 : parseInt(borderRightWidth);
	
	var marginRight = $(element).getStyle('margin-right');
	marginRight = (marginRight == null) ? 0 : parseInt(marginRight);
	
	return marginLeft + borderLeftWidth + padding + borderRightWidth + marginRight;
}

Element.Methods.getSurroundingAreaHeight = function(element) {

	var marginTop = $(element).getStyle('margin-top');
	marginTop = (marginTop == null) ? 0 : parseInt(marginTop);	

	var borderTopWidth = $(element).getStyle('border-top-width');
	
	borderTopWidth = borderTopWidth == null ? 0 : (parseInt(borderTopWidth) ? parseInt(borderTopWidth) : 0);		
	
	var padding = $(element).getPaddingHeight();
	
	var borderBottomWidth = $(element).getStyle('border-bottom-width');
	borderBottomWidth = (borderBottomWidth == null || isNaN(borderBottomWidth)) ? 0 : parseInt(borderBottomWidth);
	
	var marginBottom = $(element).getStyle('margin-bottom');
	marginBottom = (marginBottom == null) ? 0 : parseInt(marginBottom);
	
	return marginTop + borderTopWidth + padding + borderBottomWidth + marginBottom;
}

Element.Methods.getTotalWidth = function(element) {
	if(element.visible())
	{
		var adjustWidth = 0;
		if(Prototype.Browser.IE)
		{
//			adjustWidth = $(element).getPaddingWidth();
		}
		return parseInt(element.getStyle('width')) + element.getSurroundingAreaWidth() - adjustWidth;
	}
	return 0;
}

Element.Methods.getTotalHeight = function(element) {
	if(element.visible())
	{
		var adjustHeight = 0;
		if(Prototype.Browser.IE)
		{
//			adjustHeight = $(element).getPaddingHeight();
		}
		return parseInt(element.getStyle('height')) + element.getSurroundingAreaHeight() - adjustHeight;
	}
	return 0;
}


Element.addMethods();


