
function Dimensions ( habitat ) {
	this.habitat = habitat;
	this.width = 750;
	this.height = 500;
	this.habitat_width = 750;
	this.habitat_height = 500;
	if (this.get()) {
		this.center_media_objects();
	}
}

Dimensions.prototype.center_media_objects = function() {
	var css = this.habitat.css;
	var names = [ "media_obj_5", "media_obj_6", "media_obj_7", "media_obj_8" ];
	for ( var inc = 0; inc < names.length; inc++ ) {
		var name = names[inc];
		var media_object = css.get_element( name );
		if( !media_object ) {
			continue;
		}
		var x = 0;
		for( var element = media_object; element; element = element.offsetParent ) {
			x += element.offsetLeft;
		}
		if( this.habitat_width < this.width ) {
			media_object.style.left = x + this.padding + "px";
		}
	}
};

Dimensions.prototype.get = function() {
	var css = this.habitat.css;
	this.width = css.get_inner_width();
	this.height = css.get_inner_height();
	if ((this.width == 0) || (this.height == 0)) {
		return false;
	}
	this.habitat_width = 750;
	this.habitat_height = 500;
	this.padding = ((this.width > this.habitat_width) ? ((this.width - this.habitat_width) / 2) : 0 );
	return true;
};


