/*
switch 1.2.1 “on the fly” layout adjustment
requires mootools v1.2 (MIT License)
*/
var sw_std_sizes = new Hash ({
'xx-small': '584',
'x-small': '744',
'small': '968',
'medium': '1096',
'large': '1344',
'x-large': '1384',
'xx-large': '1544'
});
function sw_cssy() {
var sw_class = sw_std_sizes.getValues();
for(var i = sw_class.length - 1; i >= 0; i--) {
if ($$('body').hasClass('xxx-large') == 'true') {
$$('body').removeClass('xxx-large');
}
else if ($$('body').hasClass(sw_std_sizes.keyOf(sw_class[i])) == 'true') {
$$('body').removeClass(sw_std_sizes.keyOf(sw_class[i]));
}
}
};
function swhich()
{//swhich applies a size based class on <body>
sw_cssy();
var sw_width = String(window.getSize().x);
if (sw_std_sizes.keyOf(sw_width) !== null) {
$$('body').addClass(sw_std_sizes.keyOf(sw_width));
}
else {
var sw_width = Number(sw_width);
var sw_size = sw_std_sizes.getValues();
var i = 0;
while (i < sw_size.length) {
var sw_comp = Number(sw_size[i]);
if (sw_width > 1544) {
$$('body').addClass('xxx-large');
}
else if (sw_width <= sw_comp) {
$$('body').addClass(sw_std_sizes.keyOf(sw_size[i])); var i = 9;
}
i++;
}
}
};
window.addEvent('domready', function() { swhich(); });
window.addEvent('resize', function() { swhich(); });