// JavaScript Document

Drupal.behaviors.mccloud = function () {
	function mccloud_scale_to_fit() {
		var pageWidth = screen.width - 16;
		var itemWidth = this.width;
		if (itemWidth > pageWidth) {
			var factor = pageWidth / itemWidth;
			this.height = this.height * factor;
			this.width = itemWidth * factor;
		}
	}
	
	jQuery('img:not(.resize-processed)').each(mccloud_scale_to_fit).addClass('resize-processed');
	jQuery('object:not(.resize-processed)').each(mccloud_scale_to_fit).addClass('resize-processed');
}
