//下拉菜单
function menufix() {
	var sfEls=document.getElementById("jieqi_menu");
	if(sfEls) sfEls=sfEls.getElementsByTagName("li");
	if(sfEls){
		for(var i=0; i<sfEls.length; i++){
			sfEls[i].onmouseover=function(){ this.className="sfhover"; }
			sfEls[i].onmouseout=function(){ this.className="nohover"; }
			sfEls[i].onmousedown=function(){ this.className="sfhover"; }
			sfEls[i].onmouseup=function(){ this.className="sfhover"; }
		}
	}
}
if (document.all){
	window.attachEvent('onload',menufix);
}else{
	window.addEventListener('load',menufix,false);
}

//浮动提示框（显示title内容）
var tipname = "tips";
var tiptag = "a,label,div,img,span"; 
var tipx = 0;
var tipy = 15;
var tipobj = null;

function tipinit() {
	var tipNameSpaceURI = "http://www.w3.org/1999/xhtml";
	if(!tipContainerID){ var tipContainerID = tipname;}
	var tipContainer = document.getElementById(tipContainerID);

	if(!tipContainer) {
	  tipContainer = document.createElementNS ? document.createElementNS(tipNameSpaceURI, "div") : document.createElement("div");
		tipContainer.setAttribute("id", tipContainerID);
	  document.getElementsByTagName("body").item(0).appendChild(tipContainer);
	}

	if (!document.getElementById) return;
	tipobj = document.getElementById(tipname);
	if(tipobj) document.onmousemove = function(evt){tipmove(evt)};

	var a, sTitle, elements;
	
	var elementList = tiptag.split(",");
	for(var j = 0; j < elementList.length; j++)
	{	
		elements = document.getElementsByTagName(elementList[j]);
		if(elements)
		{
			for (var i = 0; i < elements.length; i ++)
			{
				a = elements[i];
				sTitle = a.getAttribute("title");				
				if(sTitle && typeof(a.onmouseover) != "function" && typeof(a.onmouseout) != "function")
				{
					a.setAttribute("tiptitle", sTitle);
					a.removeAttribute("title");
					a.removeAttribute("alt");
					a.onmouseover = function() {tipshow(this.getAttribute('tiptitle'))};
					a.onmouseout = function() {tiphide()};
				}
			}
		}
	}
}

function tipmove(evt) {
	if(tipobj.style.display == "block"){
		var x=0, y=0;
		if (document.all) {
			x = (document.documentElement && document.documentElement.scrollLeft) ? document.documentElement.scrollLeft : document.body.scrollLeft;
			y = (document.documentElement && document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop;
			x += window.event.clientX;
			y += window.event.clientY;
		} else {
			x = evt.pageX;
			y = evt.pageY;
		}
		tipobj.style.left = (x + tipx) + "px";
		tipobj.style.top = (y + tipy) + "px";
	}
}

function tipshow(text) {
	if (!tipobj) return;
	tipobj.innerHTML = text;
	tipobj.style.display = "block";
}

function tiphide() {
	if (!tipobj) return;
	tipobj.innerHTML = "";
	tipobj.style.display = "none";
}

if (document.all){
	window.attachEvent('onload',tipinit);
}else{
	window.addEventListener('load',tipinit,false);
} 

//tab效果
function selecttab(obj){
	var n = 0;
	var tabs = obj.parentNode.parentNode.getElementsByTagName("li"); 
	for(i=0; i<tabs.length; i++){
		tmp = tabs[i].getElementsByTagName("a")[0];
		if(tmp == obj){
			tmp.className="selected";
			n=i;
		}else{
			tmp.className="";
		}
 	}
	var contents = obj.parentNode.parentNode.parentNode.parentNode.getElementsByTagName("div")[1].getElementsByTagName("div");
	for(i=0; i<contents.length; i++){
		contents[i].style.display = i==n ? "block" : "none";   
 	}
}

//173hk效果文件
 function Leftrank(num){
 for(var id = 1;id<=2;id++)
 {
	 var Tab="left_rankings_top"+id;
 if(id==num)
 {
	document.getElementById(Tab).className="left_rankings_top_on";
 }
 else
 {
	document.getElementById(Tab).className="left_rankings_top_off"; 
 } 
	 
 var Main="left_rankings_content"+id;
 if(id==num)
 {
	document.getElementById(Main).className="left_rankings_content viewon";
 }
 else
 {
	document.getElementById(Main).className="left_rankings_content viewoff"; 
 }
 }
 }
 
 
 // 最新更新及小说排行榜 Tab
 function Tabnum(num){
 for(var id = 1;id<=2;id++)
 {
 var Main="bottom_rank_main"+id;
 if(id==num)
 {
	document.getElementById(Main).className="bottom_rank_main viewon";
 }
 else
 {
	document.getElementById(Main).className="bottom_rank_main viewoff"; 
 }
 
 var Tab="bottom_rank_tab"+id;
 if(id==num)
 {
	document.getElementById(Tab).className="bottom_rank_tabon";
 }
 else
 {
	document.getElementById(Tab).className="bottom_rank_taboff"; 
 }
 }
 }

// 周,月点击榜Tab
  function clickrank(num){
 for(var id = 1;id<=2;id++)
 {
	 var Tab="all_visit"+id;
 if(id==num)
 {
	document.getElementById(Tab).className="all_visit_clickon";
 }
 else
 {
	document.getElementById(Tab).className="all_visit_clickoff"; 
 } 
 var Main="all_visit_content"+id;
 if(id==num)
 {
	document.getElementById(Main).className="all_visit_content viewon";
 }
 else
 {
	document.getElementById(Main).className="all_visit_content viewoff"; 
 }
 }
 }
 
 // 周点击榜图文
  function pic_titlenum(num,id,event){
    var obj = document.getElementById(id).getElementsByTagName("li");
    event = event || window.event;
	if (event.type == "mouseover") {
        for(var i = 0; i < obj.length; i++)
              {
                  if(obj[i] == num)
				{
					obj[i].className = "light";
		
				}
				else
				{
					obj[i].className = "li";
					
				}

 }
 }
 }

// 总收藏总推荐Tab
  function allclickrank(num){
 for(var id = 1;id<=2;id++)
 {
	 var Tab="goodnum_allvote"+id;
 if(id==num)
 {
	document.getElementById(Tab).className="all_visit_clickon";
 }
 else
 {
	document.getElementById(Tab).className="all_visit_clickoff"; 
 } 
 var Main="goodnum_allvote_content"+id;
 if(id==num)
 {
	document.getElementById(Main).className="goodnum_allvote_content viewon";
 }
 else
 {
	document.getElementById(Main).className="goodnum_allvote_content viewoff"; 
 }
 }
 }
//封面推荐Tab
var now_content=0;
var total_content=4;
var way=1;
var start_content=Math.round(Math.random()*(total_content-1))+1; 
function content_mouse(num){
now_content=num;
for (var i=1;i<=total_content;i++){
document.getElementById('divhl0'+i).style.display='none';
document.getElementById('slide0'+i).className='cover_commend';
}
document.getElementById('divhl0'+num).style.display='block';
document.getElementById('slide0'+num).className='cover_commend_light';
}						
function change_content(){							
for (var i=1;i<=total_content;i++){
document.getElementById('divhl0'+i).style.display='none';
}
document.getElementById('divhl0'+now_content).style.display='block';
if (way) now_content++;
else now_content--;
if(now_content>total_content) {now_content=total_content-1;way=0;}
else if(now_content==0) {now_content=1;way=1;}
theTimer2=setTimeout('change_content()', timeout2);
} 
// 经管励志 Tab
 function business(num){
 for(var id = 1;id<=2;id++)
 {
 var Main="business_main"+id;
 if(id==num)
 {
	document.getElementById(Main).className="business_main viewon";
 }
 else
 {
	document.getElementById(Main).className="business_main viewoff"; 
 }
 
 var Tab="business_tab"+id;
 if(id==num)
 {
	document.getElementById(Tab).className="business_tabon";
 }
 else
 {
	document.getElementById(Tab).className="business_taboff"; 
 }
 }
 } 
 function favorite(){
	var sURL = window.location.href;
	var sTitle = document.title;
    var ua = navigator.userAgent.toLowerCase();
	if(ua.indexOf("msie 8")>-1){
		external.AddToFavoritesBar(sURL,sTitle,'slice');//IE8
	}else{
		try {
			window.external.addFavorite(sURL, sTitle);
		} catch(e) {
			try {
				window.sidebar.addPanel(sTitle, sURL, "");//firefox
			} catch(e) {
				alert("加入收藏失败，请使用Ctrl+D进行添加");
			}
		}
	}
}


