document.write("<style>.mouseover {background:#FFF29F;width:100%;cursor:default;}");
document.write(".mouseout {color:#000000;width:100%;background-color:#ffffff;cursor:default;}");
document.write("ul,li {list-style-type:none;}</style>");
document.write("<div id='divc' style='visibility:hidden;position:absolute;overflow:hidden;z-index:9;border:#B2D0EA 1px solid;border-top:0;background:#fff;'></div>");
document.write("<div id='sbarrow' style='cursor:hand;cursor:pointer;position:absolute;visibility:hidden;' onclick='clkUpdown();'><img id='updown' src='/images/smart01.gif' /></div>");
function setArrowPos()
{
	//右侧箭头
	var tmp=document.getElementById("k");
	var tmp1=document.getElementById("sbarrow");
	var l = tmp.offsetLeft + tmp.offsetWidth - tmp1.offsetWidth - 2;
	var t = tmp.offsetTop + (tmp.offsetHeight - tmp1.offsetHeight) / 2;
	while(tmp=tmp.offsetParent)
	{
		l+=tmp.offsetLeft;
		t+=tmp.offsetTop;
	}
	tmp1.style.left = l + "px";
	tmp1.style.top = t + "px";
	tmp1.style.visibility = "visible";
}
window.onresize=setArrowPos;
setArrowPos();

if(typeof(ext)=="undefined")   
	ext = "";

var l1 = null;	
var g_msg = [];
var oldValue = "";
isFF=(window.navigator.userAgent.toLowerCase().indexOf("firefox")!=-1);
ud=document.getElementById("updown");
var arrclk = false;
function clkUpdown()
{
	if(ud.src.indexOf("01")==-1)
		ud.src="/images/smart01.gif";
	else
	{
		ud.src="/images/smart02.gif";
		if(document.search_fm.k.value != "")
			userInput(document.search_fm.k.value+"||"+document.search_fm.c.value, "k", 0);
		else
			userInput(document.search_fm.k.value+"||"+document.search_fm.c.value, "k", -1);
		arrclk = true;
	}
};

function createAjsComp()
{
	http_request = null;
	if (window.XMLHttpRequest) { // Mozilla, Safari, ...
  	http_request = new XMLHttpRequest();
	} else if (window.ActiveXObject) { // IE
 		http_request = new ActiveXObject("Microsoft.XMLHTTP");
	}
	return http_request;
}

function onSuggest()
{
	if(req.readyState == 4)
	{
		if(req.status == 200)
		{
			if(req.responseText.length <= 1)
			{
				g_msg = [];
			}
			else
			{
				g_msg = req.responseText.split('\n');
				if(isFF)
					g_msg[g_msg.length-1] = g_msg[g_msg.length-1].replace(/\0/g, "");
			}
			jsAutoInstance.handleEvent(g_value, g_id, g_event);
		}
	}	
}

function userInput(fValue,fID,event)
{
	if(event==-1)
	{
		jsAutoInstance.handleEvent("", "k", -1);
		return;
	}
	if(fValue.replace(/\s/g, "") == "")
	{
		jsAutoInstance.handleEvent("", 0, 0);
		return;
	}
	g_event = event.keyCode ? event.keyCode : event.which;
	g_value = fValue;
	g_id = fID;
	
	if(oldValue == fValue)
	{
		jsAutoInstance.handleEvent(g_value, g_id, g_event);
		return;			
	}

	if(l1&&l1.readystate!=0)
	{
		l1.abort();
	}
	req = createAjsComp();
	l1 = req;
	l1.onreadystatechange = onSuggest;
	//var url = "SearchTB.asp?k=" + encodeURI(fValue);
	var url = "/SearchTB.asp?k=" + fValue;
	l1.open("GET", url, true);
	l1.send(null);	
}

function jsAuto(instanceName,objID,fID)
{
	this._msg = [];
	this._x = null;
	this._o = document.getElementById(objID);
	if (!this._o) return;
	this._f = false;
	this._i = instanceName;
	this._r = document.getElementById(fID);
	this._c = -1;
	this._v = null;
	this._e = 0;
	return this;
};

jsAuto.prototype.directionKey=function() { with (this)
{
	var e = g_event;
	var l = _o.childNodes.length - 1;
	if(e==40 && _c < l - 1)
	{
		if(_c>=0) _o.childNodes[_c].className="mouseout";
		_c++;
		_o.childNodes[_c].className="mouseover";
	}
	else if(e==38 && _c >= 0)
	{
		if(_c<l) _o.childNodes[_c].className="mouseout";
		_c--;
			_o.childNodes[_c].className="mouseover";
	}
	else if(e==13)
	{
		if(_c>=0&&_c<l)
		{
			_o.style.visibility = "hidden";
			_r.value = _x[_c];
			_f = false;
			if(isFF)
			{
				for(var ii = 0; ii < document.search_fm.clz.length; ii++)
				{
					if(document.search_fm.clz.item(ii).checked == true)
					{
						location="/Search.asp?c=3&t=&k="+_r.value+"&clz="+document.search_fm.clz.item(ii).value + ext;
						break;
					}
				}
			}
			else
				document.search_fm.submit();		
		}
		
		if(ifFF&&_c == -1)
		{
			_o.style.visibility = "hidden";
			_f = false;
			return;
		}

	}

}};


jsAuto.prototype.domouseover=function(obj)
{
	obj.tagName=="DIV" ? obj.className="mouseover" : obj.parentElement.className="mouseover";
}
jsAuto.prototype.domouseout=function(obj)
{
	obj.tagName=="DIV" ? obj.className="mouseout" : obj.parentElement.className="mouseout";
}
jsAuto.prototype.doclick=function(msg) { with (this)
{
	if(_r)
	{
		_f = false;
		_r.value = msg;
		_o.style.visibility = "hidden";
		document.search_fm.submit();
	}
	else
	{
		return;
	}
}};

jsAuto.prototype.append=function(msg) { with (this)
{
	_i ? "" : _i = eval(_i);
	var div = document.createElement("DIV");

	//bind event to object.
	var re  = new RegExp("(" + _v + ")","i");
	div.style.lineHeight="150%";
	div.className = "mouseout";
	num = msg.substring(0, msg.indexOf(" "));
	var word = msg.substring(msg.indexOf(" ")+1);
	_x.push(word);
	msg = "<li style='line-height:normal;width:300px;height:16px;float:left;text-align:left;padding:2px 0 0 5px;color:#004BCA;'>"+word.replace(re , "<span style='color:#ff0000;'><strong>$1</strong></span>")+"</li><li style='line-height:normal;float:right;padding:2px 5px 0 0;height:16px;color: #009900;'><span style='font-family: Arial;font-size: 11px;'>"+num+"</span> 浏览量</li><br />";
	if (_v) div.innerHTML = msg;
	div.style.fontFamily = "verdana";
	div.onmouseover = function(){_i.domouseover(this)};
	div.onmouseout = function(){_i.domouseout(this)};
	div.onclick = function(){_i.doclick(word)};
	_o.appendChild(div);
	this._o.style.height = parseInt(this._o.style.height) + 19;
}};

jsAuto.prototype.display=function() { with(this)
{
	if((_f&&_v!="")||_e==-1)
	{
		var l = _r.offsetLeft;
		var t = _r.offsetTop + _r.offsetHeight;
		_o.style.width = _r.offsetWidth + "px";
		var tmp=_r;
		while(tmp=tmp.offsetParent)
		{
			l+=tmp.offsetLeft;
			t+=tmp.offsetTop;
		}
		_o.style.left = l + "px";
		_o.style.top = t + "px";
		var helpDiv = document.createElement("DIV");
		helpDiv.innerHTML = "<div style='border-top:#B2D0EA 1px solid;padding-top:5px;'><li style='line-height:normal;height:19px;float:left;padding-left:5px;'><a href=\"javascript:alert(\'智能搜索框是帮助您主动输入搜索关键词贴心功能。具体如下：\\r\\n\\r\\n智能搜索框能随着你在搜索框中输入的每个字词，在下拉框中自动提示浏览次数最多的几组关键词。这时您只需用鼠标点选其中某一条，或者用键盘的上下方向键“↓”“↑”选中某一条，选择后就能自动进行该关键词的搜索。\')\">智能搜索框功能是什么？<\/a></li><li style='line-height:normal;height:19px;float:right;padding-right:5px;'><img src='/images/smart_end.gif' style='cursor:hand;cursor:pointer;'/></li></div>";
		helpDiv.style.fontFamily = "verdana";
		helpDiv.onmouseover = function(){return true};
		helpDiv.onmouseout = function(){return true};
		helpDiv.onclick = function(){return true};			
		_o.appendChild(helpDiv);
		if(_e!=-1)
			_o.style.height = ((_o.childNodes.length-1)*19+26)+"px";
		else
			_o.style.height = "166px";
		_o.style.visibility = "visible";
		ud.src="/images/smart02.gif";
	}
	else
	{
		_o.style.visibility="hidden";
	}
}};
jsAuto.prototype.handleEvent=function(fValue,fID,event) { with (this)
{
	var re;
	var e = event;

	_v = fValue;
	_i = eval(_i);

	if(e==27)//escape
	{
		_o.innerHTML="";
		_o.style.height = "2px";
		_o.style.visibility="hidden";
		ud.src="/images/smart01.gif";
		return;
	}
	if((oldValue==_v)&&(e==38 || e==40 || e==13))
	{
		_i.directionKey();
		oldValue = _v;
		return;
	}
		
	if(e==-1)//推荐
	{
		_o.innerHTML='<iframe marginheight="0" marginwidth="0" frameborder="0" width="'+(_r.offsetWidth-10)+'" height="140" scrolling="no" src="/recommand.asp"></iframe>';
		_e=-1;
		_i.display();
		_e=0;
		return;
	}
	oldValue = _v;	
	_c=-1;
	_x = [];
	_o.innerHTML="";
	_o.style.height = "2";
	
	if(_v == "")
	{
		_o.style.visibility="hidden";
		ud.src="/images/smart01.gif";
		return;
	}

	_f = false;
	for(var i=0; i<g_msg.length; i++)
	{
			_i.append(g_msg[i]);
			_f = true;
	}
	if(!_f)
		ud.src="/images/smart01.gif";
	_i.display();
}};
window.onerror=new Function("return true;");
var jsAutoInstance = new jsAuto("jsAutoInstance","divc","k");

function hideSb()
{
	if(arrclk)
	{
		arrclk=false;
		return;
	}
	jsAutoInstance._o.style.visibility="hidden";
	jsAutoInstance._o.style.height="2px";
	jsAutoInstance._f=false;
	ud.src="/images/smart01.gif";
}
document.onclick=hideSb;


//-->
