var t1Close
function opdiv(b1,b2){
var opid = document.getElementById(b1);
var allHD = opid.parentNode.parentNode.getElementsByTagName("div");
var $allHDa = $("#nav2  .a01");
$allHDa.css({'background':'','color':'#ffffff'})
for (i=0;i<allHD.length;i++){
allHD[i].style.display = "none";
}
clearTimeout(t1Close);
opid.style.display = "";
var pa = document.getElementById(b2);
pa.style.backgroundColor = "#ffffff";
pa.style.color = "#004C78";
//alert(opid.offsetWidth);
opid.style.left= - (opid.offsetWidth-110)/2;
//alert(opid.style.display);
//if (opid.style.display == "none"){
//$(opid).show("slow");
//alert(opid.style.display);
//}
}
function hddiv(b1,b2){
clearTimeout(t1Close);
var opid = document.getElementById(b1);
var pa = document.getElementById(b2);

t1Close = setTimeout(function(){opid.style.display = "none";pa.style.backgroundColor = "";pa.style.color = "#ffffff";},500);
}

$(function(){
	var itemIndex = 0;
	var itemlen = $(".wrapLeft > .items").length;
	$(".panel").click(function(){
		if( !$(".wrapLeft > .items").is(":animated") ){
			var $p = $(".wrapLeft .current").parent().parent();
			var orgIndex = $(".wrapLeft > .items").index($p);
			var $items = $(this).parent().parent();
			var len = $(".wrapLeft > .items").length;
			var index = $(".wrapLeft > .items").index($items);
			var offsetLeft = $items.position().left;
			var realLeft = index * 34;
			if( index>orgIndex ){
				for(var i=orgIndex;i<=index;i++){
					$(".items").eq(i).animate({"left":i*34},1000);//$(".items").eq(i).css("left",i*24);
				}
			}else{
				for(var j=(index+1);j<len;j++){
					$(".items").eq(j).animate({"left":(j*34+520)},1000);//$(".items").eq(j).css("left",j*24+268);
				}
			}
			$(this).addClass("current").parent().parent().siblings().find("a").removeClass("current");
			itemIndex = index;
			setText(itemIndex+1);
		}
		return false;
	}).focus(function(){
		$(this).blur();
	});

	$(".wrapLeft").hover(function(){
		if(times){clearTimeout(times); }
	},function(){
		setTimes(itemIndex);
	});

	
	function setTimes(itemIndex) {
		$(".panel").eq(itemIndex).click();
		itemIndex++;
		if( itemIndex > (itemlen-1)){
			itemIndex = 0 ;
		}
		times = setTimeout( function(){
			setTimes(itemIndex);
		}, 5000 );
	}

	function setText(itemIndex) {
		$("#txt").text(itemIndex);
	}

	setTimes(itemIndex);
});
