function show_left_menu(obj){
	var fat_obj = obj.parentNode;
	if(fat_obj.className == "close") fat_obj.className = "";
	else fat_obj.className = "close";
}
function show_sb(obj){			
	obj.getElementsByTagName("ul")[0].style.display = "block";
}
function hidden_sb(obj){
	obj.getElementsByTagName("ul")[0].style.display = "none";
}
function change_class(id,className){
	$(id).className = className;
}
function copyToClipBoard(){
	var clipBoardContent=top.location.href;
	window.clipboardData.setData("Text",clipBoardContent);
	alert("复制地址成功,您可以粘贴（CTRL+V）发送给好友");
}
function GetArgsFromHref(url, name) { 　
	var reg = new RegExp("(^|\\?|&)"+ name +"=([^&]*)(\\s|&|$)", "i");		
	if (reg.test(url)) return RegExp.$2; return "";
}
/* 左导航 */	
function onload_left_menu(){	  	
  //左导航root id
  var ul_id =  new Array("m_wjtd","m_xwzx","m_xzzx","m_kfzq","m_wjzn");
  var xy3_navID = GetArgsFromHref(window.location,"xy3_navID");
  if(xy3_navID!="") $(ul_id[xy3_navID]).className = "open";		 		
  for(var i=0;i<ul_id.length;i++){
	var a_link = $(ul_id[i]).getElementsByTagName("a");				
	for(var j=0;j<a_link.length;j++){					
		if(a_link[j].href.indexOf("?")==-1) a_link[j].href+="?xy3_navID="+i;
		else a_link[j].href+="&xy3_navID="+i;	
	}
  }
}
function dyniframesize(iframeObj) {
	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 show_tab(str,total,now,on_class,off_class){
	for(var i=1;i<=total;i++){
		$(str+i).className=off_class;
	}
	$(str+now).className=on_class;	
}
/* 文章内页 图片切换 */
function change_img(img_id,img_url,img_text){
	$(img_id).src = img_url;
	$(img_id+"_text").innerHTML = img_text;
}
/* 精灵 */
function ghost_larger(){
	$("larger").className="hidden";
	$("smaller").className="";
	$("ghost_in").style.display="block";
}
function ghost_smaller(){
	$("larger").className="";
	$("smaller").className="hidden";
	$("ghost_in").style.display="none";
}
function ghost_close(){
	$("ghost").style.display="none";
}
function ghost_open(){
	ghost_larger();
	$('ghost').style.display='block';		
}
function ax_getansw(){
	var ques = document.getElementById("question").value;
	
	//remove the '#' character
	var re = /\#/g;
	ques = ques.replace(re, '');
	if(ques.length == 0) {
		alert("您好，请先填写问题");
		return ;
	}
	HTTP(function (connection) {
			
			document.getElementById("answer").innerHTML = '正在查询,请稍后...';
			var ques = document.getElementById("question").value;
			var re = /\#/g;
			ques = ques.replace(re, '');
			connection.POST("/php/xy3jl.php", {q:ques});

		}, function (connection){
			if(connection.success){
				var re = /\#(\d{2,})/g;
				connection.result = connection.result.replace(re,"<img src='http://xy3.163.com/emote/$1.gif' alt='' />");
				var re = /\#(\d{1})/g;
				connection.result = connection.result.replace(re,"<img src='http://xy3.163.com/emote/0$1.gif' alt='' />");				
				document.getElementById("answer").innerHTML = connection.result;
								
			}else {
				document.getElementById("answer").innerHTML = "对不起，服务器没有响应，请稍后再试。";
			}
			/* 如果文字数超过190 高度控制为300px 并显示滚动条*/
			/* start */
			if($("answer").innerHTML.length >= 190){
				$("answer").style.height = "300px";
				$("answer").style.overflow = "auto";
			}
			else{
				$("answer").style.height = "auto";
				$("answer").style.overflow = "visible";
			}
			/* end */
		});
}
/* xy3botajax.js */
( function() {

window.ENCODING = 'gb2312';
var string = String.prototype, re_trim = /^[\r\n\s\t]*|[\r\n\s\t]*$/g;

string.trim = function()  {
	return this.replace(re_trim, '');
};
window.trim = function(s) {
	return s.replace(re_trim   , '');
};

window.PLATFORM = document.all? 'IE' : 'GECKO';

if(PLATFORM == 'GECKO') { // GECKO
	
	window.HTTPRequest = function() {
			return new XMLHttpRequest();
	
		}; window.HttpRequest = window.HTTPRequest;
}
else{
	
	window.utf8 = function(data) {
		var glbEncode = [], t, i, j, len;
		utf8_data = data;
		execScript("utf8_data = MidB(utf8_data, 1)+' '", "vbscript");
		t = escape(utf8_data).replace(/%u/g,"").replace(/(.{2})(.{2})/g,"%$2%$1").replace(/%([A-Z].)%(.{2})/g,"@$1$2");
		t = t.split("@");
		i = 0;
		len = t.length;
		while(++i < len){
			j = t[i].substring(0,4);
			if(!glbEncode[j]) {
				utf8_char = eval("0x"+j);
				execScript("utf8_char=Chr(utf8_char)","vbscript");
				glbEncode[j] = escape(utf8_char).substring(1,6);

			}
			t[i] = glbEncode[j] + t[i].substring(4);

		}
		utf8_data = utf8_char = null;
		return unescape(t.join("%")).slice(0,-1);
	};		

	window.HTTPRequest = function() {
			var xmlhttp = null;
			/*@cc_on @*/
			/*@if (@_jscript_version >= 5)
				try	{ xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }
				catch (e) {
					try	{ xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
					catch (E) { xmlhttp = false; } }
			@end @*/
			return xmlhttp;
	
	}; window.HttpRequest = window.HTTPRequest;
}

window.HTTP = function(init, fina) {
	var session = { _http: HTTPRequest() }, obj = session, req = obj._http, cgiv2qstr =
	function(cgiv) {
		var qstr = [], i = 0;
		for(var name in cgiv) qstr[i++] = encodeURIComponent(name) + "=" + encodeURIComponent(cgiv[name]);
		//for(var name in cgiv) qstr[i++] = encodeURIComponent(name) + "=" + cgiv[name];
		return qstr.join("&");
	};

	obj.query = function(method, host, qstr, header, encoding) {
		obj._query = {
			method: method? method : 'GET', host: host,
			qstr: qstr? qstr : '', header: header? header : {},
			encoding: encoding? encoding : ENCODING };
		return obj._query;

	}; // ...
		obj.GET = function(host, cgiv, header, encoding) { return obj.query('GET', host, cgiv? (typeof(cgiv) == 'string'? cgiv : cgiv2qstr(cgiv)) : null, header, encoding); };
		obj.POST = function(host, cgiv, header, encoding) { return obj.query('POST', host, cgiv? (typeof(cgiv) == 'string'? cgiv : cgiv2qstr(cgiv)) : null, header, encoding); };

	obj.send = function() {
		var query = obj._query;

		var init_header = function() {
			req.setRequestHeader("Host", query.host.replace(/^https?:\/{2}([:\[\]\-\w\.]+)\/?.*/, '$1'));

			for(var name in query.header) req.setRequestHeader(name, query.header[name]);
			if(query.encoding != 'utf-8' && PLATFORM == 'GECKO') req.overrideMimeType('text/html;charset=' + query.encoding);
		}

		if(query.method == 'GET') {
			req.open('GET', query.host + (query.qstr == ''? '' : "?" + query.qstr), true);
			init_header();
			req.send(null);
		} else {
			req.open('POST', query.host, true);
			init_header();
			req.setRequestHeader('Content-Length', '' + query.qstr.length);
			req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			req.send(query.qstr);
		}
		return session;
	};

	req.onreadystatechange = function() {
		if(req.readyState == 4) {
			if(req.status == 200) {
				obj.success = true;
				obj.info = req.statusText;

				//if(obj._query.encoding != 'utf-8' && PLATFORM == 'IE') obj.result = utf8(req.responseBody);
				//else obj.result = req.responseText;
				obj.result = req.responseText;
				fina(session);
			} else {
				obj.success = false;
				obj.info = req.statusText;
				fina(session);
			}
		}
	};

	if(init(session) == false) return;

	try { return obj.send() } catch(e) {
		obj.success = false;
		obj.info = e;
		return fina(session);
	}

};
	
} )();