$(document).ready(function(){
	setupVariablePageWidth();
});


/*
 * Set up variable page widths
 */
var setupVariablePageWidth = function(){
	var _body = $('body.variable-page');
	var _classes = ['page-width-narrow','page-width-std','page-width-wide'];
	var _curr_width = 0;
	
	if( $(".newline4").length )//winnowing thresholds
		var _thresholds = [1170,1350];
	else //box thresholds
		var _thresholds = [1170,1590];
	
	if (_body.length) {
		$(window).resize(function() {
			// Get the new page width
			var w = $(this).width();
			//Check if we've crossed a threshold
			if (w > _thresholds[1] && _curr_width <= _thresholds[1]) {
				// Wide page
				_body.removeClass(_classes[0]+' '+_classes[1]).addClass(_classes[2]);
			} else if (w >= _thresholds[0] && w <= _thresholds[1] && (_curr_width < _thresholds[0] || _curr_width > _thresholds[1])) {
				// Standard width page
				_body.removeClass(_classes[0]+' '+_classes[2]).addClass(_classes[1]);
			} else if (w < _thresholds[0] && (_curr_width >= _thresholds[0] || _curr_width == 0)) {
				// Narrow page
				_body.removeClass(_classes[1]+' '+_classes[2]).addClass(_classes[0]);
			}
			//Update the current page width variable
			_curr_width = w;
		});
		// Trigger the resize event on page load
		$(window).trigger('resize');
	}
}