var _stockcode = new String();
var _mk = new String();
var _security = new String();

var cachemx = new String();
var cachefj = new String();
var cachefz = new String();
var cachesz = new String();
var cachelastvisitstock = new String();
var cachemyvisitcookiestock = new String();

var isFirst = true;
var datatype = 0;

var parentpath = "http://club.pchome.net/";
function createHttpRequest()
{
   var httprequest= false;
    if(window.ActiveXObject)
    {
         var versions = ['Microsoft.XMLHTTP', 'MSXML.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.7.0', 'Msxml2.XMLHTTP.6.0', 'Msxml2.XMLHTTP.5.0', 'Msxml2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP'];
        for(var i=0; i<versions.length; i++) 
        {
            try {
               httprequest= new ActiveXObject(versions[i]);
                if(httprequest) 
                {
                    break;
                }
            } catch(e) {}
        }
    }
    if(window.window.XMLHttpRequest)
    {
       httprequest=new   XMLHttpRequest();
        if(httprequest.overrideMimeType)
        {
           httprequest.overrideMimeType("text/xml");
        }
    }
    
    return httprequest;
}

function getBarUrl(stockcode,markettype,cssname)
{
   if (cssname=="undefined") cssname="";
   return "<a class="+cssname+" href=\"http://bar.stockstar.com/redir1.asp?code=" + stockcode + "&mk=" + markettype + "\">股吧</a>";
}

function getHotStock(gptype,rise)
{
    if(!document.getElementById("dphot"))
        return false;
    
    setInnerHTML("dphot","<img src='http://img.club.pchome.net/html/images/club-loadingIcon.gif'>");
     
    var str = new String();
    var url = parentpath+"quotedata.php?action=hotstock&date="+Date()+"&type="+gptype+"&rise="+rise;
    var obj = createHttpRequest();
    obj.open("GET", url, true);
    obj.onreadystatechange = function(){
       if (obj.readyState == 4)
       {
           if(obj.status == 200){	
               if(obj.responseText.length>2)
               {    
                    var str = obj.responseText.split('|');
                    var tablestr = new String();
                    for(var i=0;i<str.length;i++)
                    {
                        var tmpobj = str[i].split(',');
                        if(tmpobj[1])
                        {
                            if (i%2)
                            {
                            	tablestr += "<ul class='money'>"
                        	}
                       	 	else
                        	{
                        		tablestr += "<ul class='odd money'>"	
                        	}
                        	
                            tablestr += "<li class=a1>"+tmpobj[1]+"</li>&nbsp;";
                        	
                            tablestr += "<li class=a2>"+tmpobj[2]+"</li>&nbsp;";
                            tablestr += "<li class="+getCss(tmpobj[4],0)+">"+tmpobj[4]+"%"+getArrow(tmpobj[4],0)+"</li>&nbsp;</ul>";
                        }
                    }
                   setInnerHTML("dphot",tablestr)
               }
		   }
       }};
   obj.send(null);  
}

function setInnerHTML(obj,strhtml,val,val2)
{
    if(document.getElementById(obj))
    {
    document.getElementById(obj).innerHTML = strhtml;
    if(val)
    {
        if(parseFloat(val)>parseFloat(val2))
            document.getElementById(obj).className = "font_red";
        else if (parseFloat(val)<parseFloat(val2))
            document.getElementById(obj).className = "font_green";
        else
            document.getElementById(obj).className = "";
    }
    }
}

function setStyle(strhtml,val,val2)
{
    var str = new String();
    if(parseFloat(val)>parseFloat(val2))
        str = "<span class=\"font_red\">"+strhtml+"</span>";
    else if (parseFloat(val)<parseFloat(val2))
        str = "<span class=\"font_green\">"+strhtml+"</span>";
    else
        str = strhtml;
    
    return str;
}

function getMyOwnStock()
{
    setInnerHTML("dpzs","<img src='http://img.club.pchome.net/html/images/club-loadingIcon.gif'>");
    var url = parentpath+"quotedata.php?action=myownstock&date="+Date();
    /*if(Boolean(flag)==true)
        url = "../" + url;*/
    var obj = createHttpRequest();
    obj.open("GET", url, true);
    obj.onreadystatechange = function(){
       if (obj.readyState == 4)
       {
           if(obj.status == 200){	
               if(obj.responseText.length>2)
               {    
                    var str = obj.responseText.split('|');
                    var tablestr = new String();
                    for(var i=0;i<str.length;i++)
                    {
                        var tmpobj = str[i].split(',');
                        if(tmpobj[1])
                        {
                            if (i%2)
                            {
                            	tablestr += "<ul class='money'>"
                        	}
                       	 	else
                        	{
                        		tablestr += "<ul class='odd money'>"	
                        	}
                            tablestr += "<li class=a1>"+tmpobj[1];
                            if (i>1)
                            {
                            	tablestr += "<a href=quotedata.php?action=del&code="+tmpobj[0]+"&type="+tmpobj[14]+">[删]</a></li>&nbsp;";
                            }
                        	else
                        	{
                        		tablestr += "</li>&nbsp;";
                        	}
                        	
                            tablestr += "<li class=a2>"+tmpobj[2]+"</li>&nbsp;";
                            tablestr += "<li class="+getCss(tmpobj[4],0)+">"+tmpobj[4]+"%"+getArrow(tmpobj[4],0)+"</li>&nbsp;</ul>";
                        }
                    }
                   setInnerHTML("dpzs",tablestr)
               }
                
		   }
       }};
   obj.send(null);
}

   function stock120_submit()
      {
          var thisForm = document.getElementById("stock120_form");
          
          //联系电话
          if ((thisForm.quote120_phone2.value!="")&&(thisForm.quote120_phone2.value.length<8))
	      {
		     alert ("请正确输入您的联系电话号码。如：13888888888或者021-88888888");
		     thisForm.quote120_phone2.focus();
		     return false;
	      }
	      else if (thisForm.quote120_phone2.value!="")
	      {
             var rex1=/^[1][35]\d{9}$/;
             var rex2=/^([0][^0]\d{1,2}[\-]{0,1}){0,1}[1-9]\d{6,7}$/;
             if(!((rex1.test(thisForm.quote120_phone2.value))||(rex2.test(thisForm.quote120_phone2.value)))){
                alert("请正确输入您的联系电话号码。如：13888888888或者021-88888888");
                thisForm.quote120_phone2.focus();
                return false;
             }
          }else{
             alert ("联系电话不能空。");
		     thisForm.quote120_phone2.focus();
		     return false;
          }
          
          //股票代码
          if ((thisForm.quote120_phone1.value!="")&&(thisForm.quote120_phone1.value.length<5))
	      {
		     alert ("请正确输入股票代码。");
		     thisForm.quote120_phone1.focus();
		     return false;
	      }
	      else if(thisForm.quote120_phone1.value != ""){
		     var rex=/^\d{6}$/;
		     if(!rex.test(thisForm.quote120_phone1.value)){
                alert("请正确输入股票代码。");
                thisForm.quote120_phone1.focus();
                return false;
             }
          }else{
             alert ("股票代码不能空。");
		     thisForm.quote120_phone1.focus();
		     return false;
          }
          
          var quote = thisForm.quote120_phone1.value;
          var mobile = thisForm.quote120_phone2.value;
          
          var content = "quote="+quote+"&mobile="+mobile;
          var url = "http://info.stockstar.com/svideo/sendUserIndex.ashx";
          document.domain = "stockstar.com";
          document.getElementById("iframeProxy").contentWindow.upGgzd(url,content);                      
          return false;
      }
      
      function post_ac(){
          alert("提交成功。");
      }
      
      function post_fa(){
          alert("提交失败。");
      }

function getArrow(val1,val2)
{
    if(parseFloat(val1)>parseFloat(val2))
        return "↑";
    else if(parseFloat(val1)<parseFloat(val2))
        return "↓";
    else
        return "";
}

function getCss(val,val2)
{
    if(parseFloat(val)>parseFloat(val2))
        return "a3";
    else if (parseFloat(val)<parseFloat(val2))
        return "a4";
    else
        return "a5";
}

function refreshStock(){ 
    var dd = new Date();
    if((dd.getHours()<9)||(dd.getHours()>=15))
        return;
    else if((dd.getHours()==9)&&(dd.getMinutes()<15))
        return;
    else if(((dd.getHours()>=11)&&(dd.getMinutes()>=30))&&(dd.getHours()<13))
        return;
    else 
    {
        getMyOwnStock();
        getHotStock(document.getElementById("hottype").options[document.getElementById("hottype").options.selectedIndex].value,document.getElementById("hotrise").options[document.getElementById("hotrise").options.selectedIndex].value);
        isFirst = false;
    }
}

function stoprefreshStock(){
        window.clearInterval(refreshstockobj);
}

function swapObjCss(obj,oldobj)
{
    if(document.getElementById(obj).className == "l_zx_tab1")
    {
        return;
    }

    document.getElementById(oldobj).className = "l_zx_tab2";
   	document.getElementById(obj).className = "l_zx_tab1";
   	var str;
    if(obj=="jqfwg")
        str = cachelastvisitstock;
   	else if(obj=="zxg")  
        str = cachemyvisitcookiestock;
   	else
   	    str = new String();
    setInnerHTML("lastvisitstock",str);
}

function doDPZS()
{
    var oldvalue = document.getElementById("code").value;
	document.getElementById("code").value = document.getElementById("scode").value;
	document.getElementById("target").value = "compquote";
	document.getElementById("frmserach").submit();
	document.getElementById("code").value = oldvalue;
   	document.getElementById("target").value = "RTQuote";
}

function changeDPZSType(stockcode)
{
    document.getElementById("scode").value = stockcode+","+document.getElementById("DPZSType").value;
}

var refreshstockobj = window.setInterval("refreshStock()",1000*60);