﻿//声明XMLHttpRequest对象
var xmlHttp;

//得到股票详细信息
function getstockinfo(stockcode)
{	
	if(stockcode.length==6){
	createXMLHTTP();//创建XMLHttpRequest对象
    //var url="ajaxadd.asp?Name="+userName+"&Event=Check";
	var url="http://sms.gueasy.com/StockInfoAction.do?method=getStockinfo&stockcode="+stockcode;
    xmlHttp.open("GET",url,true);
    xmlHttp.onreadystatechange=getInfo;
    xmlHttp.send(null);
	}else{
	document.getElementById("stocksname").innerHTML="数据读取中...";
	}
    
}

function createXMLHTTP()
{
    if(window.XMLHttpRequest)
    {
        xmlHttp=new XMLHttpRequest();//mozilla浏览器
    }
    else if(window.ActiveXObject)
    {
        try
        {
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");//IE老版本
        }
        catch(e)
        {}
        try
        {
            xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");//IE新版本
        }
        catch(e)
        {}
        if(!xmlHttp)
        {
            window.alert("不能创建XMLHttpRequest对象实例！");
            return false;
        }
    }
}

//股票详细信息回调函数
function getInfo(stockcode)
{
	if(stockcode.length==6){
		if(xmlHttp.readyState==4)//判断对象状态
		{
			if(xmlHttp.status==200)//信息成功返回，开始处理信息
			{
					//document.getElementById("imgName").src="images/false.gif";
					//让注册按钮失效
					document.getElementById("stocksname").innerHTML=xmlHttp.responseText; 
					document.getElementById("stocksname1").value=xmlHttp.responseText;
			}
		}
		else
		{
			document.getElementById("stocksname").innerHTML="证券代码不存在";
			
		}
	}else{
		document.getElementById("stocksname").innerHTML="数据读取中...";
	}
}

//得到证券名称
function getsimplestockinfo(stockcode)
{	
	if(stockcode.length==6){
	
	createXMLHTTP();
    var url="http://passport.gueasy.com/stockinfo?stockcode="+stockcode;
    xmlHttp.open("GET",url,true);
    xmlHttp.onreadystatechange=simpleStockInfo;
    xmlHttp.send(null);
	}else{
		document.getElementById("stocksname").innerHTML="数据读取中...";
	}
}

function sends(mobile)
{	
	var partten = /^1[3,5,8]{1}\d{9}$/;
	if(mobile.length==11&&partten.test(mobile)){
	
	createXMLHTTP();
    var url="http://passport.gueasy.com/sends?mobile="+mobile;
    xmlHttp.open("GET",url,true);
    xmlHttp.onreadystatechange=sendmsg;
    xmlHttp.send(null);
	}else{
		alert('手机号码不能为空或者格式不正确，请确认后重试!');
	}
}
function sendmsg()
{	
	 if(xmlHttp.readyState==4)//判断对象状态
    {
        if(xmlHttp.status==200)//信息成功返回，开始处理信息
        {
                //document.getElementById("imgName").src="images/false.gif";
                //让注册按钮失效				
			alert(xmlHttp.responseText);
	 
        }
    }
	
}

//证券名称回调函数
function simpleStockInfo()
{
    if(xmlHttp.readyState==4)//判断对象状态
    {
        if(xmlHttp.status==200)//信息成功返回，开始处理信息
        {
                //document.getElementById("imgName").src="images/false.gif";
                //让注册按钮失效
				if(xmlHttp.responseText!="【】"){
					document.getElementById("stocksname").innerHTML=xmlHttp.responseText;
					
					
					//alert(oo("stockname1").value);
				}else{
					document.getElementById("stocksname").innerHTML="证券代码不存在";
				}
				 
        }
    }
	else
	{
		document.getElementById("stocksname").innerHTML="证券代码不存在";
		
    }
}

function oo(obj){
	return typeof(obj)!="string"?obj:document.getElementById(obj)
}





//得到涨停和跌停价格
function getupdowninfo(stockcode)
{
	
    var url="http://sms.gueasy.com/StockInfoAction.do?method=getUpDown&stockcode="+stockcode;
    xmlHttp.open("GET",url,true);
    xmlHttp.onreadystatechange=updownInfo;
    xmlHttp.send(null);
}

//涨停和跌停价格回调函数
function updownInfo()
{
    if(xmlHttp.readyState==4)//判断对象状态
    {
        if(xmlHttp.status==200)//信息成功返回，开始处理信息
        {
                //document.getElementById("imgName").src="images/false.gif";
                //让注册按钮失效
				document.getElementById("updowninfo").innerHTML=xmlHttp.responseText; 
        }
    }
	
}

//得到股票当前价格
function getprice(stockcode)
{
	
    var url="http://sms.gueasy.com/StockInfoAction.do?method=getPrice&stockcode="+stockcode;
    xmlHttp.open("GET",url,true);
    xmlHttp.onreadystatechange=priceInfo;
    xmlHttp.send(null);
}

//股票当前价格回调函数
function priceInfo()
{
    if(xmlHttp.readyState==4)//判断对象状态
    {
        if(xmlHttp.status==200)//信息成功返回，开始处理信息
        {
                //document.getElementById("imgName").src="images/false.gif";
                //让注册按钮失效
				document.getElementById("updown").value=xmlHttp.responseText; 
        }
    }
	
}