function Size( width, height, aspectRatio )
{
	this.getValidDimension = function( dimension )
	{
		var validDimension = 0;
		
		if ( dimension != null && typeof dimension == "number" && dimension > 0 )
		{
			validDimension = dimension;
		}
	
		return validDimension;
	}
	
	this.multiplyBy = function( number )
	{
		if ( number == null && typeof number == "number" )
		{
			this.width *= number;
			this.height *= number;
		}
	}
	
	this.toString = function( )
	{
		return "( " + this.width + " x " + this.height + " )";
	}
	
	this.getWidth = function( )
	{
		return this.width;
	}
	
	this.getHeight = function( )
	{
		return this.height;
	}
	
	this.canContain = function( size )
	{
		return this.width >= size.width && this.height >= size.height;
	}
	
	this.getAspectRatio = function( )
	{
		var aspectRatio = null;

		if ( this.height != 0 )
		{
			aspectRatio = this.width / this.height;
		}
		
		return aspectRatio;
	}
	
	this.getArea = function( )
	{
		return this.getWidth( ) * this.getHeight( );
	}
	
	
	var twoOrMoreNulls = ( width == null && height == null ) || ( height == null && aspectRatio == null ) || ( aspectRatio == null && width == null );
		
	if ( twoOrMoreNulls || width == 0 || height == 0 || ( aspectRatio != null && aspectRatio == 0 ) )
	{
		this.width = 0;
		this.height = 0;
	}
	else if ( aspectRatio == null )
	{
		this.width = width;
		this.height = height;
	}
	else if ( width == null || ( height != null && ( width / height > aspectRatio ) ) )
	{
		this.height = height;
		this.width = this.height * aspectRatio;
	}
	else
	{
		this.width = width;
		this.height = this.width / aspectRatio;
	}
	
	this.width = this.getValidDimension( this.width );
	this.height = this.getValidDimension( this.height );
}

Size.union = function( sizeA, sizeB, aspectRatio )
{
	return new Size( Math.max( sizeA.width, sizeB.width ), Math.max( sizeA.height, sizeB.height ), aspectRatio );
}


Size.intersection = function( sizeA, sizeB, aspectRatio )
{
	return new Size( Math.min( sizeA.width, sizeB.width ), Math.min( sizeA.height, sizeB.height ), aspectRatio );
}



