function fadeInit(mc) {
	if (actionDone == 1) {
		var fade = new Fade(mc, "#fff", "#ff6", 15, 50, 1, 3, true);
		fade.init();
	}
	common_init();
}
fadeID = 0;
function Fade(id, startColour, endColour, count, speed, delay, repeat, hideAfterDone, callback) {
	this.id = id;
	this.startColour = startColour;
	this.endColour = endColour;
	this.oldcount = count;
	this.count = count;
	this.speed = speed;
	this.delay = delay;
	this.playonce = 0;
	this.repeat = repeat;
	this.obj = $(id);
	this.colour = new Array();
	this.steps = 0;
	this.hideAfterDone = hideAfterDone;
	this.callback = callback;
}
Fade.prototype.init = function() {
	clearTimeout(fadeID);
	first = this.parseColour(this.startColour, 'hex');
	last = this.parseColour(this.endColour, 'hex');
	this.colour = new Array();
	this.colour[this.count] = this.startColour;
	for (i=0; i<this.count; i++) {
		temp = "rgb(";
		temp += parseInt(first[0]+(last[0]-first[0])/this.count*i);
		temp += ",";
		temp += parseInt(first[1]+(last[1]-first[1])/this.count*i);
		temp += ",";
		temp += parseInt(first[2]+(last[2]-first[2])/this.count*i);
		temp += ")";
		this.colour[this.count-i] = temp;
	}
	this.colour[0] = this.endColour;
	var thisObj = this;
	fadeID = setTimeout(function () {
		thisObj.fade();
	}, this.delay);
};
Fade.prototype.fade = function() {
	if (this.count>=0) {
		this.obj.style.backgroundColor = this.colour[this.count--];
		var thisObj = this;
		fadeID = setTimeout(function () {
			thisObj.fade();
		}, this.speed);
	} else {
		this.playonce++;
		if (this.playonce<this.repeat) {
			var tmp = this.endColour
			this.endColour = this.startColour
			this.startColour = tmp;
			this.count = this.oldcount;
			this.init();
		} else {
			if (this.hideAfterDone) {
				displayObj(this.id, false);
				fixFooter();
			}
			if (this.callback) {
				window[this.callback]();
			}
		}
	}
};
Fade.prototype.parseColour = function(colour, t) {
	var m = 1;
	var col = colour.replace(/[\#rgb\(]*/,'');
	if (t == 'hex') {
		if (col.length == 3) {
			a = col.substr(0, 1);
			b = col.substr(1, 1);
			c = col.substr(2, 1);
			col = a+a+b+b+c+c;
		}
		var num = new Array(col.substr(0, 2), col.substr(2, 2), col.substr(4, 2));
		var base = 16;
	} else {
		var num = col.split(',');
		var base = 10;
	}
	if (t == 'rgbp') {
		m = 2.55;
	}
	var ret = new Array(parseInt(num[0], base)*m, parseInt(num[1], base)*m, parseInt(num[2], base)*m);
	return (ret);
};