var Stylizer = Class.create();
Stylizer.prototype = {
  el: null,
  initialize: function(el) {
    this.el = $(el);
  },
  /**
   * Set the style of the whole page by changing the class of the BODY element
   * @param integer palette
   * @param string bgcolor (html color)
   */ 
	setPageStyle: function(palette,bgcolor) {
		var currentColor = this.el.getStyle('background-color').parseColor();
		new Effect.Highlight(this.el,{startcolor: currentColor, endcolor: bgcolor, restorecolor: bgcolor, duration: 0.5});
    this.el.className = this.el.className.replace(/palette\d/, 'palette' + Math.floor(palette + 1.0));
  } 
}

/**
 * Global function to be called from SWF
 * @param {palette, bgcolor} params
 */
function setPageStyle(params) {
  var stylizer = new Stylizer(document.getElementsByTagName('BODY')[0]);
  stylizer.setPageStyle(params.palette,params.bgcolor);
}
