// JavaScript Document

function SwitchNewsTag_s(id,num,count)
{
	ClearTagClass_s(id,count);
	document.getElementById("tagname_" + id + num).className = "tagf";
	document.getElementById(id + num).className ="hexunShow";
	
}
function ClearTagClass_s(id,count)
{
	for(i=1;i<=count;i++)
	{
		document.getElementById("tagname_" + id + i).className = "tagn";
		document.getElementById(id + i).className ="hexunHidden";
	}
}
function SwitchNewsTag2(id,num,count)
{
	ClearTagClass2(id,count);
	document.getElementById("tagname_" + id + num).className = "tagf2";
	document.getElementById(id + num).className ="hexunShow";
}
function ClearTagClass2(id,count)
{
	for(i=1;i<=count;i++)
	{
		document.getElementById("tagname_" + id + i).className = "tagn2";
		document.getElementById(id + i).className = "hexunHidden";
	}
}
//适合每个单元格个一个背景（效果在IT频道右侧‘股票行情’）
function show_menu2(StockCode,menu_id,menu_sub,menu1,menu2,menu3,menu4,menu5,menu6)
{
	  for(var i=1;i<7;i++)
	  {
	       if(document.getElementById("menuContent_"+menu_id+"_"+i)!=null)
	       {
	            document.getElementById("menuContent_"+menu_id+"_"+i).style.display="none";
		   }
		   if(document.getElementById("menuId_"+menu_id+i)!=null)
		   {
		        document.getElementById("menuId_"+menu_id+i).className=""
		   }
      }
	  

	if(document.getElementById("menuContent_"+menu_id+"_"+menu_sub)!=null)
	{
	    document.getElementById("menuContent_"+menu_id+"_"+menu_sub).style.display="block";
	}
	
	var aa=new Array("",menu1,menu2,menu3,menu4,menu5,menu6);
	for (var j=1; j<7;j++)
	{
		if(document.getElementById("menuId_"+menu_id+"_"+j)!=null)
		{
		    document.getElementById("menuId_"+menu_id+"_"+j).className=aa[j];	
	    }  
	}
	document.getElementById("kuangjia").src="../FrmStockSmallPicture.aspx?PType=smallPicture&StockCode="+StockCode;
    var url="../FrmStockSmallPicture.aspx?PType=smallPicture&ReturnSort=IsArray&StockCode="+StockCode;
    StockAjax(url);

}
function ChangeSmallPic(StockCode)
{
    document.getElementById("kuangjia").src="../FrmStockSmallPicture.aspx?PType=smallPicture&StockCode="+StockCode;
    var url="../FrmStockSmallPicture.aspx?PType=smallPicture&ReturnSort=IsArray&StockCode="+StockCode;
    StockAjax(url);
}

function Changetag(ID)
{
    var num=ID.substr(3,1);
    for(i=1;i<=2;i++)
    {
        var tagID="tag"+i;
        var NewsListID="NewsList"+i;
        var NewsListCurID="NewsList"+num;
        
        if(ID==tagID)
        {
            document.getElementById(ID).className="this_title";
        }
        else
        {
            document.getElementById(tagID).className="that_title";
        }
        
        if(NewsListCurID==NewsListID)
        {
            document.getElementById(NewsListCurID).style.display="block";
        }
        else
        {
            document.getElementById(NewsListID).style.display="none";
        }
    }
}
function StockAjax(url)
{
        function createXmlHttpRequest()
        {
	        if(window.ActiveXObject)
	        {
		        return new ActiveXObject("Msxml2.XMLHTTP");
		     }
	        else if(window.XMLHttpRequest)
	        {
		        return new XMLHttpRequest();
		     }
        }
        function callback()
        {  
            if(xmlHttp.readyState==4)
	            if(xmlHttp.status==200)
	            {
	                var GP=document.getElementById("gupiao");
	                var returnStr=xmlHttp.responseText;
	                document.getElementById("returnText1").innerHTML=returnStr.split("|")[0];
	                document.getElementById("returnText2").innerHTML=returnStr.split("|")[1];
	                document.getElementById("returnText3").innerHTML=returnStr.split("|")[2];
	                var number=document.getElementById("returnText3").innerHTML;
	                
	                var ss=number.substring(0,number.length-1);
	                var bb=ss/100; 
	                if(bb>0)
	                {
	                    GP.src="web/images/sheng.gif";
	                }
	                else
	                {
	                    GP.src="web/images/jiang.gif";                  
	                }

	                
	            }	             
        }
        var xmlHttp=createXmlHttpRequest();    
		xmlHttp.onreadystatechange=function(){callback();}
		xmlHttp.open("post",url,true);
		xmlHttp.send(null);
}
function openWindow()
{
    var stockcode=document.getElementById("textfield4").value;
    if(stockcode=="")
    {
        window.alert("请填写股票号码！");
        return false;
    }
    else
    {
        if(stockcode.toLowerCase().substring(0,2)!="sz" && stockcode.toLowerCase().substring(0,2)!="sh")
        {
            if(stockcode.toLowerCase().substring(0,1)!="0" && stockcode.toLowerCase().substring(0,1)!="2" && stockcode.toLowerCase().substring(0,1)!="6" && stockcode.toLowerCase().substring(0,1)!="9")
            {
                window.alert("股票号码有错误，请重新填写！");
                return false;
            }
            else
            {
                 window.showModalDialog("web/FrmStock-Picture.aspx?StockCode="+stockcode,"","dialogWidth=655px;dialogHeight=440px;center=1;help=0;resizable=0;status=0;scroll=0");
            }
        }
        else
        {
            if(stockcode.toLowerCase().substring(2,3)!="0" && stockcode.toLowerCase().substring(2,3)!="2" && stockcode.toLowerCase().substring(2,3)!="6" && stockcode.toLowerCase().substring(2,3)!="9")
            {
                 window.alert("股票号码有错误，请重新填写！");
                return false;
            }
            else
            {
                 window.showModalDialog("web/FrmStock-Picture.aspx?StockCode="+stockcode,"","dialogWidth=655px;dialogHeight=440px;center=1;help=0;resizable=0;status=0;scroll=0");
            }
        }
    }
}
function ctlent(eventobject)
{
    if((event.ctrlKey&&window.event.keyCode==13)||window.event.keyCode==13)
    {
        openWindow();
    }
}

function openWindowNews()
{
    var stockcode=document.getElementById("textfield4").value;
    if(stockcode=="")
    {
        window.alert("请填写股票号码！");
        return false;
    }
    else
    {
        if(stockcode.toLowerCase().substring(0,2)!="sz" && stockcode.toLowerCase().substring(0,2)!="sh")
        {
            if(stockcode.toLowerCase().substring(0,1)!="0" && stockcode.toLowerCase().substring(0,1)!="2" && stockcode.toLowerCase().substring(0,1)!="6" && stockcode.toLowerCase().substring(0,1)!="9")
            {
                window.alert("股票号码有错误，请重新填写！");
                return false;
            }
            else
            {
                 window.showModalDialog("FrmStock-Picture.aspx?StockCode="+stockcode,"","dialogWidth=655px;dialogHeight=440px;center=1;help=0;resizable=0;status=0;scroll=0");
            }
        }
        else
        {
            if(stockcode.toLowerCase().substring(2,3)!="0" && stockcode.toLowerCase().substring(2,3)!="2" && stockcode.toLowerCase().substring(2,3)!="6" && stockcode.toLowerCase().substring(2,3)!="9")
            {
                 window.alert("股票号码有错误，请重新填写！");
                return false;
            }
            else
            {
                 window.showModalDialog("FrmStock-Picture.aspx?StockCode="+stockcode,"","dialogWidth=655px;dialogHeight=440px;center=1;help=0;resizable=0;status=0;scroll=0");
            }
        }
    }
}

