﻿

//公用
function $ID(id)
{
	return document.getElementById(id);
}
function $Name(name)
{
	return document.getElementsByName(name);
}
function $Tag(tag)
{
	return document.getElementsByTagName(tag);
}



//Tab切换
function H_ShowTab(id, num)
{
	var tab = $ID(id);
	var tabItems = tab.getElementsByTagName("li");
	for(i = 0; i < tabItems.length; i++)
	{
		var tagBody = $ID(id + "Body" + i);
		if(num == i)
		{
			tagBody.style.display = "block";
			tabItems[i].className = "On";
		}
		else
		{
			tagBody.style.display = "none";
			tabItems[i].className = "nomal";
		}
	}
}

//设置字体大小
function SetFontSize(size) 
{ 
	var zoom=document.all?document.all['Zoom']:document.getElementById('Zoom'); 
	zoom.style.fontSize=size+'px'; 
}

//改变样式
function F_ShowSub(num)
{   
	var tabList = document.getElementById("MainNav").getElementsByTagName("li");
	for(i=0; i<tabList.length; i++)
	{
		if (i==num )
		{ 
			tabList[i].className = "On";
			document.getElementById("SubNav"+i).style.display="block";
		}
		else
		{
			tabList[i].className =""; 
			document.getElementById("SubNav"+i).style.display="none";
		}
	} 
}



/*Tab切换
-id：节点唯一标识
-index：初始索引（从0开始）
-eventType：事件类型（0-鼠标滑动，1-鼠标点击）
-showDelay：渐显时间
-isAuto：是否自动切换
-autoDelay：自动切换时间间隔）*/
function HZ_Tab(id, index, eventType, showDelay, isAuto, autoDelay)
{
	if($("#"+ id + " .tMenu .t").size() == $("#"+ id + " .tBox").size())
	{
		var j;function slide(j){$("#"+ id + " .tMenu .t").removeClass("current");$("#"+ id + " .tMenu .t").eq(j).addClass("current");$("#"+ id + " .tBox").hide();$("#"+ id + " .tBox").eq(j).fadeIn(showDelay);}
		if(index < 0 || index > $("#"+ id + " .tMenu .t").size() - 1){index = 0;}
		$("#"+ id + " .tBox:not(:eq(" + index + "))").hide();
		$("#"+ id + " .tMenu .t:eq(" + index + ")").addClass("current");
		$("#"+ id + " .tMenu .t").each(function(i)
			{if(eventType == 0){$(this).mouseover(function(){slide(i);});}else{$(this).click(function(){slide(i);});}}
		);
		if(isAuto)
		{
			j = index-1; var offset = autoDelay; var timer = null;
			function autoPlay(){n = $("#"+ id + " .tMenu .t").size()-1; j++;if(j > n){j = 0;}slide(j);timer = window.setTimeout(autoPlay, offset);}
			function hookThumb()
			{$("#"+ id + " .tMenu .t").hover(function(){if (timer){clearTimeout(timer);j = $(this).prevAll().filter(".t").length;}},function (){timer = window.setTimeout(autoPlay, offset);this.blur();return false;});$("#"+ id + " .tBox").hover(function(){if (timer){clearTimeout(timer);j = $(this).prevAll().filter(".tBox").length;}},function (){timer = window.setTimeout(autoPlay, offset);this.blur();return false;});}autoPlay();hookThumb();
		}
	}
	else
	{
		alert("ID为[ " + id + " ]的tab个数有误！请检查");
	}
}
