(function($) {
    $(function(){
	    var maxTableSize = 472;			// apply overflow is exceeds this size
	    var floatTableSize = 315;		// float if table is less than this size
	    var floatDirection = "left";	// float direction for all tables
	    var floatWrapHTML;

	    // setup float direction HTML
	    (floatDirection == "left") ? floatWrapHTML = '<div class="tableLeft"></div>' : floatWrapHTML = '<div class="tableRight"></div>';

	    $('.storytext table').each(function() {
		    // if table width is greater than column width then add a div of tableFull to hide and give scroll bars
		    if($(this).width() > maxTableSize) $(this).wrap('<div class="tableFull"></div>');

		    // if table width is less than floatTableSize then float it according to defined alignment
		    if($(this).width() <= floatTableSize) $(this).wrap(floatWrapHTML);
	    });
    });
})(jQuery);
