Javascript Get Content Stretch Size

I had a situation like this :

I have a content. The size (width and height) has been known.
Now i want to stretch the content to the screen with some fill rate (for example max 90% of screen size).

I made a javascript code below.

<script type="text/javascript">
function calc() {
	check = get_new_content_dimension(100, 100, 1024, 768, 90);
	console.log('New content size = '+check[0]+' x '+check[1]);

	check = get_new_content_dimension(200, 100, 1024, 768, 90);
	console.log('New content size = '+check[0]+' x '+check[1]);

	check = get_new_content_dimension(100, 200, 1024, 768, 90);
	console.log('New content size = '+check[0]+' x '+check[1]);

	check = get_new_content_dimension(300, 100, 1024, 768, 90);
	console.log('New content size = '+check[0]+' x '+check[1]);

	check = get_new_content_dimension(100, 300, 1024, 768, 90);
	console.log('New content size = '+check[0]+' x '+check[1]);
}

function get_new_content_dimension(content_width, content_height, screen_width, screen_height, fill_rate) {
	console.log('-----------------------------------------');
	console.log('Screen size = '+screen_width+' x '+screen_height);
	console.log('Content size = '+content_width+' x '+content_height);
	max_width = Math.floor(screen_width * fill_rate / 100);
	max_height = Math.floor(screen_height * fill_rate / 100);
	console.log('Max content size = '+max_width+' x '+max_height);

	// Fit width
	ratio_1 = max_width / content_width;
	try_height = ratio_1 * content_height;
	if (try_height > max_height) {
		ratio_2 = max_height / content_height;
		try_height = ratio_2 * content_height;
		try_width = ratio_2 * content_width;
	} else {
		try_width = ratio_1 * content_width;
	}
	var t_return = new Array();
	t_return[0] = Math.floor(try_width);
	t_return[1] = Math.floor(try_height);
	return t_return;
}
</script>

How to Install PECL Memcache in WHM / CentOS

You can run these commands to install PECL memcache (not memcached)

wget http://pecl.php.net/get/memcache-2.2.7.tgz
tar xvfz memcache-2.2.7.tar.gz
cd memcache-2.2.7 (make sure it's memcache and NOT memcached)
phpize
./configure && make
make install

Take note of the php extensions directory that memcache is installed in.
Mine is: /usr/local/lib/php/extensions/no-debug-non-zts-20020429/

Then add this line to your php.ini

extension="/usr/local/lib/php/extensions/no-debug-non-zts-20020429/memcache.so"