﻿// JScript 文件

function openWindow(url,width,height)
{
    var w =(screen.width-width)/2;
    var h = (screen.height-height)/2;
    window.open(url,"_blank","height="+ height +"px,width="+ width +"px, top="+ h +", left="+ w +", toolbar=no, menubar=no, scrollbars=yes, resizable=no,location=no, status=no");
}

 //最大化打开窗口，并且只显示标题
   function OpenMaxWindow(url)
  {
     var height=screen.availHeight-30;
     var width=screen.availWidth-10;
     window.open(url,'_blank','height='+height+',width='+width+',top=0,left=0,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no, status=no');
  } 

function ValidatorTrim(s) {
    var m = s.match(/^\s*(\S+(\s+\S+)*)\s*$/);
    return (m == null) ? "" : m[1];
}

function clickxtgs(id,width,height)
{
   var strurl = "../InstantInfo.aspx?Type=1&id="+id;
   openWindow(strurl,width,height);
}

function clickshgs(id,width,height)
{
   var strurl = "ContentView.aspx?type=1&id="+id;
   openWindow(strurl,width,height);
}

function clickxzzx(id,width,height)
{
   var strurl = "ContentView.aspx?type=2&id="+id;
   openWindow(strurl,width,height);
}


function moreshgs(width,height)
{
   var strurl = "MoreInfoView.aspx?type=1";
   openWindow(strurl,width,height);
}

function morexzzx(width,height)
{
   var strurl = "MoreInfoView.aspx?type=2";
   openWindow(strurl,width,height);
}

function Locus(width,height)
{
   var id = document.getElementById("txtSCMC").value;
   var strurl = "Search/Locus.aspx?SCMC="+escape(id);
   openWindow(strurl,width,height);

}

function Merchandise(width,height)
{
   var id = document.getElementById("txtpm").value;
   var strurl = "Search/Merchandise.aspx?PM="+escape(id);
   openWindow(strurl,width,height);

}

function DealNo(width,height)
{
   var id = document.getElementById("txtjyh").value;
   var strurl = "Search/DealNo.aspx?JYH="+id;
   openWindow(strurl,width,height);

}

function VoucherNo(width,height)
{
   var id = document.getElementById("txtSaleID").value;
   if (ValidatorTrim(id).length == 0)
   {
        alert('请输入上市凭证号！');
        return;
   }
   var strurl = "Search/VoucherNo.aspx?SaleID="+id;
   openWindow(strurl,width,height);

}

function KPQK(width,height)
{
   var strurl = "Search/Kpqk.aspx";
   openWindow(strurl,width,height);

}

function GridViewSelectRow()
{
   var strKey = "hfPrimaryKey";
   var  hfPrimaryKey =  document.getElementById(strKey);
   if(hfPrimaryKey==null)
   {
      return false;
   }
   if (hfPrimaryKey!=null) 
   {
      if (hfPrimaryKey.value=="")
      {
         alert('请选择一条记录！');
         return false;
      }
   }
}

function strBytes(str) 
{ 
    var len; 
    var i; 
    len = 0; 
    for (i=0;i<str.length;i++) 
    { 
        if (str.charCodeAt(i)>255) len+=2; else len++; 
    } 
    return len; 
} 

function CheckTextBox()
{
	//服务器控件检查
    if(!Page_ClientValidate())
    {
        return false; 
    }
    
    for(var i=1;i<=document.all.zjcount.value;i++)
    {
        if(document.getElementById( ContentPlaceHolder1Prex +"zj_jj_"+i))
          {
              var file=document.getElementById( ContentPlaceHolder1Prex +"zjclFileUpload_"+i).value;
		      var text=file;
		      file=file.substr(file.lastIndexOf("\\")+1);
		      var errmessage="";
		      if (text!=""&&/.JPG$|.jpeg$|.BMP$|.png$|.MP3$|.wma$|.ra$|.rm$|.rmvb$|.mpg$|.mpeg$|.wmv$|.TXT$|.htm$|.html$|.PDF$|.DOC$|.DOCX$|.WPS$/i.test(text) == false)
		      {
  		   	    errmessage="证据文件格式不对。";
		      }
		      if(strBytes(file)>40)
		      {	
		  	    errmessage="证据"+i+"上传的文件名称过长!最大长度不能超过40个字节,一个中文为两个字节,其它为一个字节！";	
	    	  }
		      if(errmessage!="")
		      {
		        alert(errmessage);
			    document.getElementById( ContentPlaceHolder1Prex +"zjclFileUpload_"+i).focus();
			    document.getElementById( ContentPlaceHolder1Prex +"zjclFileUpload_"+i).select();
			    return false;
		      }			
		      if(strBytes(document.getElementById( ContentPlaceHolder1Prex +"zj_jj_"+i).value)>240)
		      {
			    alert("证据简介"+i+"内容过多!最大长度不能超过240个字节,一个中文为两个字节,其它为一个字节！");
			    document.getElementById( ContentPlaceHolder1Prex +"zj_jj_"+i).focus();
			    document.getElementById( ContentPlaceHolder1Prex +"zj_jj_"+i).select();
			    return false;
		      }					
          }
    }
}

