var intTC = null;
var tTipTimer;
var bolDirection = true;
function tipSlideShow() {
	var tips = $$('div.tip');	
	if(tips.length > 0) {
		var strFirstID = tips.first().id;
		var strLastID = tips.last().id;
		var strAnimImgSrc = "/__resources/img/Head/mng_anim.gif";
		if(bolDirection) {
			if(intTC == null || intTC == -1 || intTC > tips.length) {
				intTC = 1;
			}
			if(intTC > 0 && intTC < tips.length) {
				var objAnimImg = $(tips[intTC].id).select('img.animbutt')[0];
				$(tips[intTC - 1].id).removeClassName('showtip');
				$(tips[intTC].id).addClassName('showtip');
				objAnimImg.src = strAnimImgSrc;
				intTC = intTC + 1;
			} else {
				var objAnimImg = $(strFirstID).select('img.animbutt')[0];
				$(strLastID).removeClassName('showtip');
				$(strFirstID).addClassName('showtip');
				objAnimImg.src = strAnimImgSrc;
				intTC = 1;
			}
			$('tip-counter-nr').update(intTC+"/"+tips.length);
		} else {
			if(intTC == null || intTC < 0) {
				intTC = tips.length + 1;
			}
			if(intTC > 1 && intTC <= tips.length) {
				var objAnimImg = $(tips[intTC - 2].id).select('img.animbutt')[0];
				$(tips[intTC - 1].id).removeClassName('showtip');
				$(tips[intTC - 2].id).addClassName('showtip');
				objAnimImg.src = strAnimImgSrc;
				intTC = intTC - 1;
			} else {
				var objAnimImg = $(strLastID).select('img.animbutt')[0];
				$(strFirstID).removeClassName('showtip');
				$(strLastID).addClassName('showtip');
				objAnimImg.src = strAnimImgSrc;
				intTC = tips.length;
			}
			$('tip-counter-nr').update(intTC+"/"+tips.length);
		}
	}
}
function controlTip(strCommand) {
	if (strCommand == 'stop') {
		window.clearInterval(tTipTimer);
		$('tip-stop-img').addClassName('display-none');
		$('tip-start-img').removeClassName('display-none');
	} 
	if(strCommand == 'start') {
		bolDirection = true;
		window.clearInterval(tTipTimer);
		$('tip-start-img').addClassName('display-none');
		$('tip-stop-img').removeClassName('display-none');
		tipSlideShow();
		tTipTimer = window.setInterval("tipSlideShow()", 45000);
	} 
	else if(strCommand == 'next') {
		bolDirection = true;
		window.clearInterval(tTipTimer);
		$('tip-stop-img').addClassName('display-none');
		$('tip-start-img').removeClassName('display-none');
		tipSlideShow();
	} 
	else if(strCommand == 'prior') {
		bolDirection = false;
		window.clearInterval(tTipTimer);
		$('tip-stop-img').addClassName('display-none');
		$('tip-start-img').removeClassName('display-none');
		tipSlideShow();
	}
}