/* 以前旧版js Start */
function ajaxurl(adDiv){
	var baseurl = "http://xyq.163.com/" + (adDiv || "");
	return baseurl;	
	}
function getajax(){
	var xmlhttp = false;
	if(window.ActiveXObject){
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else if(window.XMLHttpRequest){
		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
	}
function sendRequest(url,func,posts){
	ajax = getajax();
	ajax.onreadystatechange = func;
	if(posts==null){ajax.open("GET", url, true);}
	else{
	ajax.open("POST", url, true);
	ajax.setRequestHeader("Content-Length",posts.length); 
	}
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	ajax.send(posts);	
}

/*------------Try函数-------------*/
var Try = {
  these: function() {
    var returnValue;

    for (var i = 0; i < arguments.length; i++) {
      var lambda = arguments[i];
      try {
        returnValue = lambda();
        break;
      } catch (e) {}
    }
    return returnValue;
  }
}

function tryCollectGarbage(){
    return Try.these(
        function() {return CollectGarbage();},
        function() {return false;}
        );
}
function getResult(adDiv,num){
	var $=function(s){return typeof(s)=="string" ? document.getElementById(s) : s;};
	if (ajax.readyState < 4) {
		$("loading").style.visibility = "visible";
	} 
	else if (ajax.readyState == 4) {
		$("loading").style.visibility = "hidden";
		if (ajax.status == 200){
		var result = ajax.responseText;
		if(adDiv=="mhjl"){
			var re = /\#(\d{2})/g;
			result = result.replace(re,"<img src='"+ajaxurl()+"images/emote/$1.gif' alt='' />");
			var re = /\#(\d{1})/g;
			result = result.replace(re,"<img src='"+ajaxurl()+"images/emote/0$1.gif' alt='' />");
						
			$('mhjl_answer').innerHTML = result;
		}
		else if(adDiv=="getrss"){
			$('sub'+num).innerHTML = result;
			}
	}
		else {
			alert("异步加载错误!");
			delete ajax;
			tryCollectGarbage();
		}
	}
}	
function mhjl(){//定义收到服务器的响应后需要执行的JavaScript函数
	var $=function(s){return typeof(s)=="string" ? document.getElementById(s) : s;};
	var q = $("mhjl_ask").value;
	if(q==""){alert("您好，问题不能为空！");return false;}
	//alert(q);
	$('mhjl_answer').innerHTML = "正在查询中，请稍候...";
	var url = ajaxurl("php/mhjl.php");
	var posts = "q="+q;
	function func(){
    	getResult("mhjl");
	};
	sendRequest(url,func,posts);
}
/* 以前旧版js End */


// change menu
//参数(menu前字符,content前字符,总数,当前,打开class,关闭class,是否处理open状态)
function change_menu(menu_str,total_num,now_num,open_className,close_className,not_chk_open){
	var $=function(s){return typeof(s)=="string" ? document.getElementById(s) : s;};
	not_chk_open=(not_chk_open==null)?true:false;
	var menu_className=$(menu_str+now_num).className;
	if(menu_className==open_className && not_chk_open){
		$(menu_str+now_num).className=close_className;
	}
	else if(menu_className==close_className){
		for(var i=1; i<=total_num;i++){
			$(menu_str+i).className=close_className;
		}
		$(menu_str+now_num).className=open_className;
	}
}
// 滚动
var Scroller=function(id){
	//初始化函数 START>>>
	this.init=function(){
		
		this.ele.style.position="absolute";
		this.ele.style.width=(this.options.width*2+8)+"px";
		this.ele.style.left="0";
		this.ele.style.top="0";

		var HTML=this.ele.innerHTML;
		this.ele.innerHTML+=HTML;
		
		var __scroller=this;/*最好少用这种方式*/
		
		this.ele.onmouseover=function(){
			__scroller.stop();
		}
		
		this.ele.onmouseout=function(){
			__scroller.run(this.normal);
		}
		
	}

	this.setOptions=function(ops){
		for (var desc in ops) {
			this.options[desc] = ops[desc];
		}
	}
	
	this.run=function(ops){
		this.stop();
		this.setOptions(ops||{});
		var __scroller=this;
		this.mover=setInterval(function(){__scroller.move();},this.options.speed);
		
	}
	
	this.stop=function(){
		if(this.mover!=null){
			clearInterval(this.mover);
		}		
	}
	
	this.move=function(){
		var pos=parseInt(this.ele.style.left);
		if(this.options.orientation=="left"){
			
			if(Math.abs(pos)-this.options.width>=0){
				this.ele.style.left="-"+this.options.step*2+"px";
			}else{
				this.ele.style.left=(pos-this.options.step)+"px";
			}
			
		}else{
		
			if(pos>=0){
				this.ele.style.left="-"+(this.options.width-this.options.step*2)+"px";
			}else{
				this.ele.style.left=(pos+this.options.step)+"px";
			}
		
		}
	}
	
	//定义基本属性；
	this.options={
		orientation:"left",
		speed:50,
		step:1,
		width:100
	}
	
	this.mover=null;
	this.ele=document.getElementById(id);

	//初始化 START>>>
	this.setOptions(arguments[1]||{});
	this.init();
	this.run();
}
//内页左边导航打开，关闭
function change_obj(obj_id,img_id){
	var $=function(s){return typeof(s)=="string" ? document.getElementById(s) : s;};
	if($(obj_id).style.display =="block"){
		$(obj_id).style.display ="none";
		$(img_id).src = "http://res.nie.netease.com/xyq/gw/08v2/images/"+img_id+".gif";
	}
	else{
		$(obj_id).style.display = "block";
		$(img_id).src = "http://res.nie.netease.com/xyq/gw/08v2/images/"+img_id+"s.gif";
	}
}
//搜索
function onSave(){
	var $=function(s){return typeof(s)=="string" ? document.getElementById(s) : s;};
	var keywords = document.getElementById("searchKeyWords").value;
	if (keywords.length == 0){
		alert("请输入搜索关键字");
	return false;
	}
  	var checkValue;
  	var r = document.getElementsByName("sradio"); 
  	for(var i=0;i<r.length;i++){ 
      if(r[i].checked==true){
          checkValue = r[i].value;
      } 
  	}
  if(checkValue==1){
	$("keyfrom").value = "xyq.163.com";
	$("form_search").action = "http://www.yodao.com/search?ue=utf8&";
  }else if(checkValue==2){
	$("keyfrom").value = "xyq.163.com/news/";
	$("form_search").action = "http://www.yodao.com/search?ue=utf8&";
  }
  else if(checkValue==3){
	$("keyfrom").value = "xyq.163.com/introduce/";
	$("form_search").action = "http://www.yodao.com/search?ue=utf8&";
  }
  else if(checkValue==4){
	$("keyfrom").value = "xyq.163.com/fans/";
	$("form_search").action = "http://www.yodao.com/search?ue=utf8&";
  }
  else if(checkValue==5){
	$("form_search").action = "http://xyq.zhidao.163.com/htdocs/search/search.html#q=" + encodeURIComponent(keywords);;
  }
  $("form_search").submit();
}
// 根据标记名 返回子节点集
// fat: 父级 如果字符串 ? $(fat).childNodes : fat.childNodes;
// childTagName: 子节点标记名
function getChild(fat,childTagName){
	var $=function(s){return typeof(s)=="string" ? document.getElementById(s) : s;};
	var child = (typeof fat == "object") ? fat.childNodes : document.getElementById(fat).childNodes;
	var obj = new Array();
	if(typeof childTagName != "undefined"){
	  childTagName = childTagName.toUpperCase();
	  for(var i=0;i<child.length;i++){
		  if(child[i].tagName == childTagName) obj.push(child[i]);
	  }
	}
	else{
	  for(var i=0;i<child.length;i++){
		  if(typeof child[i] != "undefined") obj.push(child[i]);
	  }
	}
	return obj;
}
function menuOnload(){	
	var $=function(s){return typeof(s)=="string" ? document.getElementById(s) : s;};
	var ul = document.getElementById("menuTree").getElementsByTagName("ul");
	for(var i=0;i<ul.length;i++){
		var fat = ul[i].parentNode;		
		if(ul[i].className!="menuTree-sub"){			
			var a = getChild(fat,"a")[0];		
			a.className=" hasSub";
		}		
		(
			function(){				
				var _self = ul[i];
				var status;
				fat.onmouseover = function(){
					status = "open";
					var _this = this;
					setTimeout(
						function(){
							if(status=="open") {								
								_self.style.display = "block";
							}
						}
						,180
					);
				}
				fat.onmouseout = function(){
					status = "close";
					setTimeout(
						function(){
							if(status=="close") _self.style.display = "none";
						}
						,200
					);
				}
			}
		)();
	}
	
}
//首页 列表 栏目背景色处理
function type_onload(fatID){
	var $=function(s){return typeof(s)=="string" ? document.getElementById(s) : s;};
	var type = $(fatID).getElementsByTagName("span");												
	for(var i=0;i<type.length;i++){
		if(type[i].getAttribute("name")=="type" && type[i].innerHTML!=""){
			if(i%2==0) type[i].className = "typeBg-1";
			else type[i].className = "typeBg-2";
		}
	}
}
//iframe高度自适应
function dyniframesize(iframeObj) {
	var $=function(s){return typeof(s)=="string" ? document.getElementById(s) : s;};
	if (iframeObj && !window.opera) {
		var leftHeight = 573;
		iframeObj.style.display = "block";
		if (iframeObj.contentDocument && iframeObj.contentDocument.body.offsetHeight) {
			if (iframeObj.id=="mainFrame"&& iframeObj.contentDocument.body.offsetHeight < leftHeight) {
				iframeObj.height = leftHeight;
			} else {
				iframeObj.height = iframeObj.contentDocument.body.offsetHeight;
			}
		} else if (iframeObj.Document && iframeObj.Document.body.scrollHeight) {
			if (iframeObj.id=="mainFrame" && iframeObj.Document.body.scrollHeight < leftHeight) {
				iframeObj.height = leftHeight;
			} else {
				iframeObj.height = iframeObj.Document.body.scrollHeight;
			}
		}
	}
}
//首页知道 处理
function index_zhidao(){
	var $=function(s){return typeof(s)=="string" ? document.getElementById(s) : s;};
	var q = $("q_keywords");
	q.value = "请输入关键字";
	q.className ="default";
	q.onclick = function(){
		this.value = "";
		this.className ="";
	}
	
}
	   // 返回最终样式函数，兼容IE和DOM，设置参数：元素对象、样式特性
function getDefaultStyle(obj,attribute){ 
    return obj.currentStyle?obj.currentStyle[attribute]:document.defaultView.getComputedStyle(obj,false)[attribute];
}
	// right bar 
function navBtn(fatID){
	var v=navigator.appVersion.match(/MSIE (\d\.\d)/)?parseInt(navigator.appVersion.match(/MSIE (\d\.\d)/)[1]) : 100;
	if(v>6) return;
	var $=function(s){return typeof(s)=="string" ? document.getElementById(s) : s;};
	var visible=function(o){
		if(o.style.visibility=="hidden") o.style.visibility="visible";
	};
	visible($(fatID));
	if($(fatID).style.position!="absolute")$(fatID).style.position="absolute";
	var plus = 410;
	var timeOut = 80;
	var minHeight = 400;	
  var h = document.documentElement.clientHeight;		
	if( h>minHeight+plus){
		$(fatID).style.top = Math.max(document.documentElement.scrollTop, document.body.scrollTop)+plus+"px";				
	}
	setTimeout('navBtn("'+fatID+'")',timeOut);
}
//滚动函数:mqHorizontal(),20090423
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('d 16=5(7){l N(5(7){d 9=2;e(2){2.$=5(s){l O(s)=="17"?r.18(s):s};2.7=7||{};2.8=$(7.8);2.t=7.t||19;2.u=7.u||1;2.f=7.f;f=(f&&f=="1a")?f:\'4\';2.v=O(7.v)=="5"?7.v:5(){};2.1b=g;2.w=g;2.h=g;2.6=g;2.x=0;2.A=0;2.a=0;2.m=g;2.y=0;2.B=g;2.P=5(o){d o=$(o),c=r.C(o.1c);c.Q=o.Q;c.R=o.R;c.3.S=c.3.T="4";c.3.z="U";j(o.D!="")c.D=o.D+"1d"+(N 1e()).1f();l c};2.V=5(o){d o=9.$(o),c=r.C("W");c.3.1g="1h";c.3.X="1i";l c};2.Y=5(o){d o=9.$(o),b=r.C("W");o.3.Z="E";b.3.Z="E";b.3.X="1j";b.3.z="1k%";b.3.1l="0";b.3.1m="0";o.F.n(b);l b};2.G=5(o){j(o.3.10=="E")o.3.10="G"};8.F.n(h=Y(8.F));h.n(6=V(h));6.n(8);x=h.H;8.3.z="U";8.3.S=8.3.T="4";a=p(8.H||0);w=1n.1o(x/a);2.I=5(){e(2){6.3.z=(A=a*(w+1))+"k";h.3.1p=6.1q+"k"}};1r(i=0;i<w;i++){6.n(P(8))}I.q(2);B=J(5(){e(9){y=p(a)==(a=p(8.H||0))?y+1:0;j(y>11){K(B)};I.q(9)}},11);2.12=5(){e(2){d 4=p(6.3.4||0);j(a+4<=0){6.3.4=(a+4)+"k"}L{6.3.4=(4-u)+"k"}}};2.13=5(){e(2){d 4=p(6.3.4||0);j(4+(A-a)-x>=0){6.3.4=(4-a)+"k"}L{6.3.4=(4+u)+"k"}}};2.M=5(){e(9){G(6);j(f=="4")12.q(9);L 13.q(9)}};2.14=5(){K(9.m)};2.15=5(){e(9){K(m);m=J(M,t)}};2.m=J(M,t);6.1s=14;6.1t=15;v.q(2)}})(7)};',62,92,'||this|style|left|function|stage|opt|con|that|conWidth|grd||var|with|direction|null|ground||if|px|return|mqInt|appendChild||parseInt|call|document||delay|amount|callback|clone_count|grdWidth|_isRended|width|stgWidth|_isRendInt|createElement|id|hidden|parentNode|visible|offsetWidth|rectFix|setInterval|clearInterval|else|marquee|new|typeof|clone|innerHTML|className|styleFloat|cssFloat|auto|buildStage|div|position|buildGround|overflow|visibility|20|mqLeft|mqRight|stop|start|mqHorizontal|string|getElementById|25|right|con_clone|tagName|_clone|Date|getTime|display|block|absolute|relative|100|padding|margin|Math|ceil|height|offsetHeight|for|onmouseover|onmouseout'.split('|'),0,{}));