﻿
var xmlHttp;
 function createXMLHttpRequest()
 {
    if(window.ActiveXObject)
    {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else if(window.XMLHttpRequest)
    {
        xmlHttp = new XMLHttpRequest();
    }
}

function  clearvalue(contro)
 {
	 var nowvalue=document.getElementById(contro).value;
	 if(nowvalue=="您的手机号码")
	 {
	 document.getElementById(contro).value="";
	 }
 }
 function setvalue(contro)
 {
	 var nowvalue=document.getElementById(contro).value;
	 if (nowvalue==""&&nowvalue!="您的手机号码")
	 {
		 document.getElementById(contro).value="您的手机号码";
	 }
 }
 function sendMyTel(teltextbox,mycome,mybutton)
 {
	 var mytel=document.getElementById(teltextbox).value;
	// var mycode=document.getElementById(mycodeinput).value;
	var mycode="";
	 if (mytel==""||mytel=="您的手机号码")
	 {
		 alert("请认真输入您的手机号码！");
	 }
	 else
	 {		
	 		if (isNaN(mytel))
			{
				alert("手机号请输入数字！");
			}
			else
			{
				if(mytel.length<11||mytel.length>12)
				{
					alert("手机号格式不正确！");
				}
				else
				{
					document.getElementById(mybutton).disabled = true
	 	   			createXMLHttpRequest();
           			var url= "/js/acceptTel.asp?mytel="+mytel+"&mycome="+mycome+"&rnd="+Math.random();
          			 xmlHttp.open("GET",url,true);
           			xmlHttp.onreadystatechange=sendTelsave;
           			xmlHttp.send(null);
		   			document.getElementById(mybutton).disabled = false;
		   			document.getElementById(teltextbox).value="您的手机号码";
				}
			}
	 }
 }
 function sendTelsave()
{
    if(xmlHttp.readyState==4)
    {
        if(xmlHttp.status==200)
        {
             var ResultString=xmlHttp.responseText;
             if(ResultString=="true")
             {
                 alert("您的电话已经已经成功提交！我公司会尽快与您联系。");

             }
        }
     }
 }

 function pageX(elem)
 {
        return elem.offsetParent?(elem.offsetLeft+pageX(elem.offsetParent)):elem.offsetLeft;
}

　　//获取当前的Y坐标值
function pageY(elem)
{
        return elem.offsetParent?(elem.offsetTop+pageY(elem.offsetParent)):elem.offsetTop;
}

//如果该input Text标签的width:200px;height:20px; 则它的下面弹出层divshow 的位置应该设为

function showpagekey(inp,keyword)
{
    if ((navigator.userAgent.indexOf('MSIE') >= 0) && (navigator.userAgent.indexOf('Opera') < 0))
    {
        //判断如果是ie浏览器则显示关键字检索框
	    var divshow=document.getElementById("newscontentkeyword");
        divshow.style.left=pageX(inp)+70;
        divshow.style.top=pageY(inp);
        Seachkey(keyword);
        divshow.style.display="block";   
       
    }
           
}
function Seachkey(keyword)
 {
	
	 	   createXMLHttpRequest();
           var url= "/js/SearchKeylistNews.ashx?Keyword="+encodeURI(keyword)+"&rnd="+Math.random();
           xmlHttp.open("GET",url,true);
           xmlHttp.onreadystatechange=SeachkeySend;
           xmlHttp.send(null);

 }
function SeachkeySend()
{
    if(xmlHttp.readyState==4)
    {
        if(xmlHttp.status==200)
        {
             var ResultString=xmlHttp.responseText;
             if(ResultString=="false")
             {
                 document.getElementById("newscontentkeyword").innerHTML="加载信息失败...";
                 
             }
             else
             {
                document.getElementById("newscontentkeyword").innerHTML=ResultString;
             
             }
            
        }
        else
        {
            document.getElementById("newscontentkeyword").innerHTML="正在加载信息...";
            
        }
     }
 }
 function closesearchdiv()
 {
    document.getElementById("newscontentkeyword").style.display="none";
 }
 function submitsearch()
 {
    var keyword=document.getElementById("SearchControl1$TextBoxSearchKey").value;
    var tp=document.getElementById("SearchControl1$DropDownListSearchType").value;
    if(keyword=="")
    {
        alert("请输入查询关键字！");
    }
    else
    {
        window.open ('http://so.001919.com/index.html?tp='+tp+'&keyword='+encodeURI(keyword));
    }
 }
  function neiSearch(keyinput,typeinput)
 {
    var keyword=document.getElementById(keyinput).value;
    var stypes=document.getElementById(typeinput).value;
    if(keyword=="")
    {
        alert("请输入关键字！");
    }
    else
    {
        if(keyword!="关键字")
        {
            window.open('http://so.001919.com/index.aspx?tp='+encodeURI(stypes)+'&keyword='+encodeURI(keyword));
        }
    }
 }
  function neiSearch1(keyinput)
 {
    var keyword=document.getElementById(keyinput).value;
     if(keyword=="")
    {
        alert("请输入关键字！");
    }
    else
    {
        if(keyword!="关键字")
        {
            window.open('http://so.001919.com/index.aspx?tp='+encodeURI("股票资讯")+'&keyword='+encodeURI(keyword));
        }
    }
 }
 function indexuserLogin()
 {
    var username=document.getElementById("TextBoxUserName").value;
    var password=document.getElementById("TextBoxPassWord").value;
   var logincheck=true;
    if(username=="")
    {
        alert("用户名不能为空！");
        return false
    }
    if(password=="")
    {
     alert("密码不能为空！");
      return false;
    }
    if(logincheck)
    {
         createXMLHttpRequest();
           var url= "/js/UserLogin.ashx?UserName="+encodeURI(username)+"&Password="+encodeURI(password)+"&rnd="+Math.random();
           xmlHttp.open("GET",url,true);
           xmlHttp.onreadystatechange=LoginSubmit;
           xmlHttp.send(null);
    }
    
 }
 function LoginSubmit()
{
    var nologinHtml="<li>用户名：</li>";
    nologinHtml+="<li><input name=\"TextBoxUserName\" type=\"text\" id=\"TextBoxUserName\" class=\"jcp_bb\" />";
    nologinHtml+="</li><li>密码：</li><li><input name=\"TextBoxPassWord\" type=\"password\" id=\"TextBoxPassWord\" class=\"jcp_bb\" /></li>";
    nologinHtml+="<li><input type=\"button\" name=\"\" value=\"登陆\" class=\"jcp_login\" onclick=\"indexuserLogin();\" /></li>";
    nologinHtml+="<li><a href=\"http://user.001919.com/UserReg.aspx\" target=\"_blank\">快速注册</a></li><li>|</li><li><a href=\"http://user.001919.com/ForgotPass.aspx\" target=\"_blank\">找回密码</a></li>";
    if(xmlHttp.readyState==4)
    {
        if(xmlHttp.status==200)
        {
             var ResultString=xmlHttp.responseText;
             if(ResultString=="0")
             {
                // document.getElementById("userLoginUl").innerHTML="<li><img src=\"images/loading_small.gif\"  /></li><li>加载信息失败...</li>";
                alert("用户名不能为空！");
             }
             else if(ResultString=="1")
             {
                alert("密码不能为空！");
             }
               else if(ResultString=="2")
             {
                alert("用户名不存在！");
             }
               else if(ResultString=="3")
             {
                alert("密码错误！");
             }
               else if(ResultString=="4")
             {
                alert("登录错误！");
             }
             else
             {
               // alert(ResultString);
                document.getElementById("userLoginUl").innerHTML=ResultString;
             }
        }
        else
        {
            document.getElementById("userLoginUl").innerHTML="<li><img src=\"images/loading_small.gif\"  /></li><li>正在登陆...</li>";
        }
     }
 }
