var BGTweener = new Class({
        Implements: [Options],
        options: {
                el: "el",
                "tween": {
                        "duration": "2000",
			"transition": 'linear'
                },
                firstColor: "#000000",
                secColor: "#ffffff",
                delay1: 100,
                delay2: 3000
        },
        initialize: function(options) {
                this.setOptions(options);
                this.el = $(this.options.el);
                this.el.set("tween",this.options.tween);
                this.el.setStyle("background-color",this.options.secColor);
                this.timer = null;
                this.toSecColor();
        },
        toSecColor: function() {
                this.el.tween("background-color",this.options.secColor).get("tween").chain(function() {
                    $clear(this.timer);
                    this.timer = this.toFirstColor.delay(this.options.delay1,this);
                }.bind(this));
        },
        toFirstColor: function() {
                this.el.tween("background-color",this.options.firstColor).get("tween").chain(function() {
                    $clear(this.timer);
                    this.timer = this.toSecColor.delay(this.options.delay2,this);
                }.bind(this));
        }
});
window.addEvent('domready', function() {

	var rc = $random(0,359);
	var GColor1 = $HSB(rc, 100, 70).rgbToHex();
	var GColor2 = $HSB(rc, 30, 70).rgbToHex();
	$$('body').setStyle("background-color",GColor1);
	/*
	var BGTween = new BGTweener({
		el: $(document.body),
		firstColor: GColor1,
		secColor: GColor2,
		delay1: '1000',
		delay2: '5000'
	});
	*/
	
});