function init()
{
  var obj1 = document.getElementById('PriceID');
  if (obj1) obj1.src="cpbj.asp";
  var obj2 = document.getElementById('newsID');
  if (obj2) obj2.src="jtdt.asp";
  GetCookie();
  var strURL = location.href;
  strURL = strURL.toLowerCase(); 
  if (strURL.indexOf("upc")>0)
  {  document.getElementById('upc').style.display="block";}
  else
  {  document.getElementById('sdkj').style.display="block";}
}
function checkuserstate()
{
 if (login==0)
 {
  document.getElementById("div0").style.display="block";
  document.getElementById("div1").style.display="none";
  document.getElementById("UserNick").innerHTML="";
  document.getElementById("addimgid").src="addIMG.asp?"+Math.random();
 }
 else
 {
  document.getElementById("div0").style.display="none";
  document.getElementById("div1").style.display="block";
  document.getElementById("UserNick").innerHTML=nick;
  document.getElementById("addimgid").src="";
 }
}
function GetCookie()
{  login = 0;
   var CookieString = document.cookie;
   if (CookieString !="")
   { var n1=CookieString.indexOf("SiteUser");
     var n2 = CookieString.indexOf("addnum");
     var temp = CookieString.substring(n1,n2);
     var CookieSet = temp.split("&");
     var SetSize = CookieSet.length;
     if (SetSize >0 )
     {
        for (i=0;i<SetSize;i++)
        {
            if (CookieSet[i].indexOf("SiteUser") >-1)
            {  var UserName = CookieSet[i].split("=")[1];login = 1;nick=decodecookie(UserName); break;}
         }
      }
   }
   checkuserstate();
}
function decodecookie(str) 
{ var strarr; 
  var strrtn=""; 
  strarr=str.split("x"); 
  for (var i=strarr.length-1;i>=0;i--) 
　{ strrtn+=String.fromCharCode(eval(strarr[i])); }
　return strrtn; 
}

function SetURL(n)
{
  var url="LookNews.asp?ID="+n;
  window.open(url,"news")
  return false;
}

function opennew(c,Nwidth,N2,Nsc)
{var Nheight=N2; 
 if (Nheight>520){Nheight=screen.availHeight-30;}
 if (! newWindow || newWindow.closed)
  {var rbb="toolbar=0,resizable,scrollbars="+Nsc+",dependent=0,width="+Nwidth+",height="+Nheight;
   newWindow = window.open(c,"showPresult",rbb);
   newWindow.moveTo(0,0);
  }
  else
  {
    newWindow.focus();
  }
  return false;
}
function setFavorite(strURL)
{
  window.external.addFavorite(strURL,'石大科技集团')
}

function Downloads(str)
{
 var url
 url=replace(str,"http","ftp")
 url=replace(url,"/sdkj/","/")
 window.open(url);
 return false;
}
function replace(str,replace_what,replace_with)
{
var ndx=str.indexOf(replace_what);
var delta=replace_with.length - replace_what.length;
while(ndx >= 0)
{
str=str.substring(0,ndx)+replace_with+str.substring(ndx+replace_what.length);
ndx=str.indexOf(replace_what,ndx+delta+1);
}
return str;
}

function checklogin()
{
 var theForm=document.frm1;
  if (checkempty(theForm.nick.value)==false)
  {
    alert("请您输入用户名！");
    theForm.nick.focus();
    return false;
  }
  if (checkempty(theForm.pwd.value)==false)
  {  
     alert ("请您输入密码！");
     theForm.pwd.focus();
     return false;
  } 
  if (checkempty(theForm.addtionnum.value)==false) 
  {  
     alert ("请输入附加码！");
     theForm.addtionnum.focus();
     return false;
  }
 if (login==1)
 {alert("您已经登陆");}
 else
 {
  theForm.submit();
 }
 theForm.addtionnum.value="";
 theForm.pwd.value="";
 return false;
}

function checkout()
{
 if (login==1)
 {
  var theForm=document.frm2;
  theForm.submit();
 }
  return false;
}
function Complete(UserName)
{
 msg="——————————————————\n\n登陆成功，可以浏览全部信息。\n\n——————————————————";
 login=1;
 nick=UserName;
// alert(msg);
 checkuserstate();
}
function Complete1()
{ login=0;
 checkuserstate();
}

function OpenMIS(){
var winheight;
var winwidth;
    winheight=screen.availHeight-30;
    winwidth=screen.availWidth-10;
var gourl="/NetOA/manger/control.asp";
var msg="toolbar=0,directories=0,menubar=0,status=0,scrollbars=1,width="+winwidth+",height="+winheight+",resizable=0";
if (! newWindow1 || newWindow1.closed)
 {newWindow1=window.open(gourl,"MIS1",msg);
  newWindow1.moveTo(0,0);
 }
newWindow1.focus();
return false;
}

function openAD(n)
{
   var gourl = "/NetOA/News/special/index.asp?ID=" + n;
   window.open(gourl);
}