﻿


function TrimWhiteSpace(str){
    str = str.replace(/(^\s*)|(\s*$)/g, "");
    return str
}

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 setInnerHtml(obj,value){
    if(document.getElementById(obj))
        document.getElementById(obj).innerHTML = value;
}

function changeTab(lable,showid,total)
{
    for(var i=0;i<total;i++)
    {
        if(document.getElementById(lable+"_content_"+i))
            document.getElementById(lable+"_content_"+i).style.display = "none";
            
        if(document.getElementById(lable+"_img_"+i))
            document.getElementById(lable+"_img_"+i).style.display = "none";

        if(document.getElementById(lable+"_"+i))
        {
            var currentcss = document.getElementById(lable+"_"+i).className;
            if(currentcss.indexOf('H')!=-1)
                currentcss = currentcss.substring(0,currentcss.length-1);
            
            document.getElementById(lable+"_"+i).className = currentcss;    
        }
        
    }
    
     if(document.getElementById(lable+"_img_"+showid))
            document.getElementById(lable+"_img_"+showid).style.display = "block";
            
    if(document.getElementById(lable+"_content_"+showid))
            document.getElementById(lable+"_content_"+showid).style.display = "block";
            
    if(document.getElementById(lable+"_"+showid))
        document.getElementById(lable+"_"+showid).className = document.getElementById(lable+"_"+showid).className + "H";       
}

function changeForexImg(lable,showid,total,imgurl,imgalt)
{
    for(var i=0;i<total;i++)
    {
        if(document.getElementById(lable+"_"+i))
            document.getElementById(lable+"_"+i).className = "menu";
    }
    if(document.getElementById(lable+"_"+showid))
        document.getElementById(lable+"_"+showid).className  = "menuH";  

    document.getElementById("SelectHQ").value = imgurl;
    var codelist = imgurl.split(',')
    document.getElementById(lable).src = "http://202.109.107.114:90/currency?reqtype=4&code1="+codelist[0]+"&code2="+codelist[1];
    document.getElementById(lable).alt = imgalt;  
}

function doFormSubmit(theForm)
{
    document.getElementById(theForm).submit();
}

/*function gourl(url)
{
    document.getElementById("frmzs").action = url;
    document.getElementById("frmzs").submit();
}*/

function changerankling(reporttype)
{
    for(var i=0;i<8;i++)
    {
        var currenturl = document.getElementById("rank81link_"+i).href;
        currenturl = currenturl.substring(0,currenturl.length-2);
        currenturl += reporttype;
        document.getElementById("rank81link_"+i).href = currenturl;
    }
}

function changeRaderTip(tip)
{
    setInnerHtml("radertext","※"+tip+"．");
}

function changeSearch(tip,targetval)
{
   document.getElementById("ajaxinput").value = tip;
   document.getElementById("toptarget").value = targetval;
   document.getElementById("righttarget").value = "index";
   document.getElementById("ajaxinput2").value = "代码/简称/拼音";
}

function yellowpagesubmit()
{
   document.getElementById("frmyellowpage").action = document.getElementById("yellowpagelist").value;
   document.getElementById("frmyellowpage").submit();
}


function stock120_submit(thisForm)
{
    //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 chkForm()
{
    if(document.getElementById("toptarget").value=="bar")
    {
        document.getElementById("topFormSearch").action = encodeURI("http://bar.stockstar.com/s/all.aspx?sn="+(document.getElementById("ajaxinput").value));
        document.getElementById("topFormSearch").submit();
        document.getElementById("topFormSearch").action = "http://quote.stockstar.com/stock/exdir.aspx";
    }else
    {
        document.getElementById("topFormSearch").submit();
        document.getElementById("topFormSearch").action = "http://quote.stockstar.com/stock/exdir.aspx";
    }
    
}

function layer_show(layer_name,action){
    if(action=="show"){
	   if(document.getElementById("ajaxinput").value!="代码/简称/拼音")
	        document.getElementById(layer_name).style.display="none";
	   else
	        document.getElementById(layer_name).style.display="block";
	}else if(action=="hide"){
	   document.getElementById(layer_name).style.display="none";
	}
}

function getCookie(name)        
{
    var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
     if(arr != null) return unescape(arr[2]); return null;
}

function setColor(obj)
{
    var globalquotecolor = getCookie("globalquotecolor");
    if(globalquotecolor!=null&&TrimWhiteSpace(globalquotecolor)=="cn")
    {
        var spanobj = document.getElementById(obj).getElementsByTagName("span");
        for(var i=0;i<spanobj.length;i++)
        {
            if(spanobj[i].className=="font_color_green")
                spanobj[i].className="font_color_red";
            else if(spanobj[i].className=="font_color_red")
                spanobj[i].className="font_color_green";
        }
    }
}

function setTopColor()
{
    var globalquotecolor = getCookie("globalquotecolor");
    if(globalquotecolor!=null&&TrimWhiteSpace(globalquotecolor)=="cn")
    {
        var spanobj = document.getElementById("topquote").getElementsByTagName("span");
        for(var i=2;i<spanobj.length;i++)
        {
            if(spanobj[i].className=="q2 font_color_green")
                spanobj[i].className="q2 font_color_red";
            else if(spanobj[i].className=="q2 font_color_red")
                spanobj[i].className="q2 font_color_green";
        }
    }
}