function deTag(s) {
	var tag = /<([^>]*)>/g;
	return s.replace(tag, '').replace(/&nbsp;/g, ' ');
}
function carouselMouseOver(o) {
	window.status= deTag(o.innerHTML);
	// identify the visible twin of this tag and carousel it
	oTwin = getObject(o.id + "_twin");
	if (oTwin != undefined) carousel(oTwin);
	// carousel(o);
	return true;
}

function linkMouseOut() {
	window.status='' ;
	return true;
}

var CAROUSEL = new Array();

function carousel(o) {
	if (o.carouselIndex == undefined) {
		// this is first time o has been carouseled; add it to the array of CAROUSEL items
		o.carouselIndex = CAROUSEL.length;
		o.caption = deTag(o.innerHTML);
		//alert(o.carouselIndex + ": set caption to " + o.caption);
		CAROUSEL[o.carouselIndex] = o;
	}
	else if (o.rotating) return; // don't carousel if already doing so
	window.status= o.caption;
	o.rotating = true;
	o.count = 0;
	o.carouselId = setInterval("rotateCarousel(" + o.carouselIndex + ")", 100);
}

function rotateCarousel(i) {
	var o = CAROUSEL[i];
	o.innerHTML = carouselText(o.innerHTML);
	if (o.caption == deTag(o.innerHTML)) 
	{
		clearInterval(o.carouselId);
		o.rotating = false;
		return;
	}
	if ((o.count++ > 40 && o.count < 60) || deTag(o.innerHTML).substr(0,4) == o.caption.substr(0,4)) 
	{
		//alert('[' + o.caption + '][' + deTag(o.innerHTML) + ']');
		clearInterval(o.carouselId);
		o.rotating = false;
	}
}
function carouselText(s) {
	// abcde => bcdea  <tag>abc</tag>de ==> <tag>bc</tag>de<tag>a</tag>
	if (s.length == 0) return;
	s = s.replace(/&nbsp;/g, ' ');
	var tag = /^<([^>]*)>([^>]*)<([^>]*)>(.*)/
	var result = s.match(tag);
	if (result == null) {
		s = s.substr(1) + s.substr(0,1);
	} else {
		if (result[2].length == 1)
			s = result[4] + '<' + result[1] + '>' + result[2] + '<' + result[3] + '>';
		else
			s = '<' + result[1] + '>' + result[2].substr(1) + '<' + result[3] + '>' + result[4] + '<' + result[1] + '>' + result[2].substr(0,1) + '<' + result[3] + '>';
	}
	return s.replace(/ /g, '&nbsp;');
}

