var tags = new Array();
var trans = 0;
var last = -1;
var lastF = 1;

function startCloud() {
	var cb = document.getElementById('cloudBase');
	if (cb) {
		var tmp = cb.innerHTML;
		tags = tmp.split(';');
		cb.innerHTML = '';
		for (var i = 1; i <= 3; i++) {
			var ct = document.createElement('span');
			ct.setAttribute('id', 'cloudText_'+i);
			if (document.all) {
				ct.setAttribute('className', 'cloudText');
			}
			else {
				ct.setAttribute('class', 'cloudText');
			}
			randomStyle(ct);
			cb.appendChild(ct);
		}
		cloudChange(1);
	}
}

function cloudChange(id) {
	var ct = document.getElementById('cloudText_'+id);

	randomStyle(ct);

	window.setTimeout('getIn('+id+')', 100);
}

function randomStyle(ct) {
	var rand;
	do {
		rand = parseInt( Math.random() * (tags.length) );
	}
	while (rand == last);
	last = rand;

	var tmp =  1 + parseInt( Math.random() * 3 ) ;
	if (tmp == 1) {
		ct.style.textAlign = 'left';
	}
	else if (tmp == 2) {
		ct.style.textAlign = 'right';
	}
	else {
		ct.style.textAlign = 'center';
	}
	ct.style.fontSize = (14 + parseInt( Math.random() * 7 )) + 'px';

	ct.innerHTML = tags[rand];
}

function getOut(id) {
	trans--;

	if (id == -1) {
		do {
			id =  1 + parseInt( Math.random() * 3 ) ;
		}
		while (lastF == id);
		lastF = id;
	}

	var ct = document.getElementById('cloudText_'+id);
	ct.style.opacity = trans/10;
	ct.style.filter = 'alpha(opacity='+trans*10+')';
	if (trans==0) {
		cloudChange(id);
	}
	else {
		window.setTimeout('getOut('+id+')', 100);
	}
}

function getIn(id) {
	trans++;

	var ct = document.getElementById('cloudText_'+id);
	ct.style.opacity = trans/10;
	ct.style.filter = 'alpha(opacity='+trans*10+')';
	if (trans==10) {
		window.setTimeout('getOut(-1)', 500);
	}
	else {
		window.setTimeout('getIn('+id+')', 100);
	}
}

