﻿/*创建json对象*/
function json(){
         this.Year=0,
         this.Unit="00000000-0000-0000-0000-000000000000",
         this.unitflag=0,
         this.unittype="00000000-0000-0000-0000-000000000000",
         this.Units=[],
         this.Cate=-1,
         this.Cates=[],
         this.Name="",
         this.EnName="",
         this.Code="",
         this.City="",
         this.UseState=-1,
         this.WorkState=-1,
         this.SPECTYPE="",
         this.lowerValue=0,
         this.highValue=0,
         this.MANUFACTURE="",
         this.COUNTRYCODE="00000000-0000-0000-0000-000000000000",
         this.PRODUCINGAREA="",
         this.FUNCTIONFEATURES="",
         this.ALIAS="",
         this.HasCMA=0,
         this.IsSpecial=-1,
         this.IsShare=-1,
         this.IsMisssion=-1,
         this.IsService=-1,
         this.tags=[], 
         this.states=[4],
         this.Sort=[],
         this.orginalSort=["HName","ClassCode","VALUERMB","PurchaseDate","AuditingDate","UPDATEDATE"],
         this.auditStartDate="",
         this.auditEndDate="",
         this.isGather=-1,
         this.UnitName=null,
         this.UnitBuildCode=0
};


/*用户名称：下一步*/
function Next1(id)
{
    var userid=document.getElementById(id).value;
    if(userid==""||userid==null)
    {
        alert("请输入用户名称！");
    }else{
         var isExites=ForgotOldPassword.CheckIsExitsUser(userid).value;
         if(isExites==true)
         {
            document.getElementById("div2").style.display="none";
            document.getElementById("div3").style.display="block";
        }else
        {
           alert('用户名无效！');
        }
    }
}
/*密码问题：下一步*/
function Next2(id,id1)
{
    var question=document.getElementById(id).value;
    var answer=document.getElementById(id1).value;
    if(question==""||question==null)
    {
        alert("请输入密码保护问题！");
    }else if(answer==""||answer==null){
        alert("请输入密码保护问题答案！");
        
    }else
    {
        var isExites=ForgotOldPassword.CheckQuestionAndAnswer(question,answer).value;
        if(isExites==true)
        {
            document.getElementById("div3").style.display="none";
            document.getElementById("div4").style.display="block";
        }
        else{
            alert("请检查密码保护问题和答案是否与注册时填写相同！");
        }
    }
}

/*json对象转换成字符串*/
var JSON = function(sJSON){
    this.objType = (typeof sJSON);
    this.self = [];
(function(s,o){for(var i in o){o.hasOwnProperty(i)&&(s[i]=o[i],s.self[i]=o[i])};})(this,(this.objType=='string')?eval('0,'+sJSON):sJSON);
}
JSON.prototype = {
    toString:function(){
        return this.getString();
    },
    valueOf:function(){
        return this.getString();
    },
    getString:function(){
        var sA = [];
        (function(o){
            var oo = null;
              sA.push('{');
                for(var i in o)
                {
                    if(o.hasOwnProperty(i) && i!='prototype')
                    {
                        oo = o[i];
                        if(oo instanceof Array)
                        {
                            sA.push('"'+i+'":[');
                            for(var b in oo){
                                if(oo.hasOwnProperty(b) && b!='prototype')
                                {
                                    sA.push('"'+oo[b]+'",');
                                    if(typeof oo[b]=='object') arguments.callee(oo[b]);
                                }
                            }
                            sA.push('],');
                            continue;
                        }else if(typeof(oo)=="string")
                            sA.push('"'+i+'":"'+oo+'",');
                       
                        else{
                            sA.push('"'+i+'":'+oo+',');
                        } 
                        if(typeof oo=='object') arguments.callee(oo);
                    }
                }
                sA.push('},');
        
        })(this.self);
        return sA.slice(0).join('').replace(/\[object object\],/ig,'').replace(/,\}/g,'}').replace(/,\]/g,']').replace('Sort','sort').replace('{},','').slice(0,-1);
    },
    push:function(sName,sValue){
        this.self[sName] = sValue;
        this[sName] = sValue;
    }
}
 
 
 

/*打开新页面*/
function openPage(str)
{
    if(str!=null&&str!="")
       window.open(str,"");
}

/*新闻法规*/
function searchNewLaws(_inputId,href)
{
    var varValue=document.getElementById(_inputId).value;
    var url= "Laws/SearchResult.aspx?SearchText=";
    if(href!=""&&href!=null)
        url=href+varValue;
    else
    {
        url=url+varValue;
    }  
    openPage(encodeURI(url));
}
/*搜索仪器*/
function searchInstrument(id)
{
   var searchContent="";
  
   var j=new json();
   var url="";
   if(id=="Search_lnkbtnSearchInstrument1")
   {
       searchContent=document.getElementById("keyword").value; //搜索内容
       if(document.getElementById("instrumentSearchTypeFirst").checked==true)
       {
            j.Name=encodeURI(searchContent).toLowerCase();
           
            url="http://www.csts.net.cn/Foreground/instrument/InstrumentList.aspx?json="+new JSON(j);
           
       }else if(document.getElementById("instrumentSearchTypeSecond").checked==true)
       {
       
            j.Code=encodeURI(searchContent);
            url="http://www.csts.net.cn/Foreground/instrument/InstrumentList.aspx?json="+new JSON(j);
       
       }else if(document.getElementById("instrumentSearchTypeThird").checked==true)
       {
            j.UnitName=encodeURI(searchContent);
            url="http://www.csts.net.cn/Foreground/instrument/InstrumentList.aspx?json="+new JSON(j);
       } 
       else if(document.getElementById("instrumentSearchTypeFour").checked==true)
       {
            j.City=encodeURI(searchContent);
            url="http://www.csts.net.cn/Foreground/instrument/InstrumentList.aspx?json="+new JSON(j);
       } 
   }
   if(id=="Search_lnkbtnSearchInstrument2")
   {
         searchContent=document.getElementById("keyword1").value;
         url="http://www.csts.net.cn/Subcenter/unitList.aspx?SearchText="+encodeURI(searchContent);
   }
   if(id=="Search_lnkbtnSearchInstrument4")
   {
         searchContent=document.getElementById("Search_lnkbtnSearchInstrument4").value;
         url="http://www.csts.net.cn/Subcenter/unitList.aspx?SearchText="+encodeURI(searchContent);
   }
   if(id=="Search_lnkbtnSearchInstrument3")
   {
       searchContent=document.getElementById("Search_lnkbtnSearchInstrument3").value; //搜索内容
       if(document.getElementById("instrumentSearchTypeFirst02").checked==true)
       {
            j.Name=encodeURI(searchContent).toLowerCase();
             
            url="http://www.csts.net.cn/Foreground/instrument/InstrumentList.aspx?json="+new JSON(j);
           
       }else if(document.getElementById("instrumentSearchTypeSecond02").checked==true)
       {
       
            j.Code=encodeURI(searchContent);
            url="http://www.csts.net.cn/Foreground/instrument/InstrumentList.aspx?json="+new JSON(j);
       
       }else if(document.getElementById("instrumentSearchTypeThird02").checked==true)
       {
            j.UnitName=encodeURI(searchContent);
            url="http://www.csts.net.cn/Foreground/instrument/InstrumentList.aspx?json="+new JSON(j);
       } 
       else if(document.getElementById("instrumentSearchTypeFour02").checked==true)
       {
            j.City=encodeURI(searchContent);
            url="http://www.csts.net.cn/Foreground/instrument/InstrumentList.aspx?json="+new JSON(j);
       } 
   
   }
   openPage(url);
}
/*搜索专家*/
function searchExpert(id)
{
    $(id).value="";

}
function changeHotinstruUrl()
{
    var hotinstru=document.getElementById("hotinstru");
    try{
        if(hotinstru!=null)
        {
            var j=new json();
            j.Sort.push("rollcall");
            hotinstru.href=hotinstru.href+"?json="+new JSON(j)+"&sortIndex=5";
        }
    
    }catch(err)
    {
    
    }

}
window.onload=changeHotinstruUrl;



