// JScript 文件
//声明XMLHttpRequest对象
var waitPricetime;
var oldcode = "";

function search()
{
	waitPricetime=window.setTimeout("sea();",1000);
} 
    
function sea()
{   
   if(waitPricetime != null){clearTimeout(waitPricetime);}
   var value=document.getElementById('txtCodeS').value;
   if(value=="")
   {
       document.getElementById('divStockResult').style.visibility="hidden";
       return;
   }
   if(oldcode == value){return;}
   document.getElementById('divStockResult').innerHTML="";
  
   url="/vip/StockLive/Aj/stockcode.aspx?key="+value;
   var SubXmlHttp=createXMLHTTP();//创建XMLHttpRequest对象 
   SubXmlHttp.open("GET",url,true); 
   SubXmlHttp.onreadystatechange=function()
   {
	if(SubXmlHttp.readyState==4)//判断对象状态
		{    
			if(SubXmlHttp.status==200)//信息成功返回，开始处理信息
			{
				var result = SubXmlHttp.responseText;
				if(result != ""){
					var divPopCal = document.getElementById('divStockResult');
					divPopCal.innerHTML=result;
					var popCtrl = document.getElementById('txtCodeS');
					var oTmp = popCtrl;
					var x = oTmp.offsetLeft;
					var y = oTmp.offsetTop;
					while(oTmp.offsetParent) {
						oTmp = oTmp.offsetParent;
						x += oTmp.offsetLeft;
						y += oTmp.offsetTop;
					}
					with (divPopCal.style) {left = x; top = y+popCtrl.offsetHeight+1;visibility = 'visible';}
				}
				else{
					document.getElementById('divStockResult').style.visibility="hidden";
				}
				if(waitPricetime != null){clearTimeout(waitPricetime);}
			}
		}
      
   }
   SubXmlHttp.send(null);
   
   oldcode = value;
}
function createXMLHTTP()
{
  var SubXmlHttp;
 if(window.XMLHttpRequest) { 
  SubXmlHttp = new XMLHttpRequest();
  if (SubXmlHttp.overrideMimeType) {SubXmlHttp.overrideMimeType("text/html");}
 }
 else if (window.ActiveXObject) { 
  try {SubXmlHttp = new ActiveXObject("Msxml2.XMLHTTP");}
  catch (e) { try {SubXmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}}
 }
 if (!SubXmlHttp) { window.alert("can't create XMLHttpRequest object.");return null; }
 return  SubXmlHttp;
}

//返回坐标
function fGetXY(aTag){
var oTmp = aTag;
var pt = new Point(0,0);
do {
pt.x += oTmp.offsetLeft;
pt.y += oTmp.offsetTop;
oTmp = oTmp.offsetParent;
} while(oTmp.tagName!="BODY");
return pt;
}

function select(a)
{  
   document.getElementById('divStockResult').style.visibility="hidden";
   document.getElementById('txtCodeS').value=a.getAttribute("codeid");
   document.getElementById('txtMarket').value=a.getAttribute("marketid");
   document.form1.submit();
}

function up(a)
{
   a.className="divCodeIDs_hover";
}

function out(a)
{  
   a.className="divCodeIDs";
}

function checkStock()
{ 
   if(document.form1.txtCodeS.value=="" || document.form1.txtCodeS.value=="代码/名称/拼音" || document.form1.txtCodeS.value=="请输入查询词"){
		document.form1.txtCodeS.value="请输入查询词";
		document.form1.txtCodeS.focus();
		return false;
	}
	var str=document.form1.txtCodeS.value;
	var i;
	for(i=0;i<str.length;i++)
	{
		if ((str.charCodeAt(i)< 48) || str.charCodeAt(i)>=58 )
		{
			document.form1.action = "http://stock.678678.com/stockerror.aspx";
		}
	}
	return true;
}

