var len, tab;
var timeFrame = 3000;
cTip = 1;

function setHover(a){
	var o, t;
	t = a.className.replace("bhti0", "").replace("hover", "");
	if (t != cTip){
		o = $('.bhti0'+cTip+'hover');
		o.attr("class", o.attr("class").replace("hover", ""));
		showBanner(a);
		a.className += 'hover';
		cTip = t;
	}
}
function showBanner(a){
	var t;
	t = a.className.replace("bhti0", "").replace("hover", "");
	if (t != cTip){
		document.getElementById("bhti0"+cTip+"banner").style.display = 'none';
		document.getElementById("bhti0"+t+"banner").style.display = 'block';
	}
}

$(document).ready(function(){
	var o;
	o = $('.bhtips > div');
	len = o.length;
	o.each(function(){
		var href = $(this).find(".bhti-title a").attr("href");
		$(this).bind("click", function(){
			window.location = href;
		});
	});
	tabsStart(timeFrame, cTip+1);
});

function setAutoHover(i, tm){
	var o1, o2;

	if (i != cTip)
	{
		o1 = $('.bhti0'+cTip+'hover');
		o2 = $('.bhti0'+i);
		o1.attr("class", o1.attr("class").replace("hover", ""));
		o2.attr("class", o2.attr("class")+"hover");
		showBannerAuto(i);

		cTip = parseInt(i);
		
		if (tm != undefined){
			tab = setTimeout(function(){
				setAutoHover((cTip+1 <= len) ? cTip+1 : 1, tm);
			}, tm);
		}
	}
}
function showBannerAuto(i){
	var o1, o2;
	if (i != cTip){
		document.getElementById('bhti0'+cTip+'banner').style.display = 'none';
		document.getElementById('bhti0'+i+'banner').style.display = 'block';
	}
}
function mouseHover(o){
	var i = o.className.replace("bhti0", "").replace("hover", "");
	if( i != cTip )
	{
		tabsStop();
		setAutoHover(i);
	}
}
function tabsStart(t, frInd){
	tab = setTimeout(function(){
		setAutoHover(frInd, t);
	}, t);
}
function tabsStop(){
	clearTimeout(tab);
} 
