﻿function isNotNull(n)
{

    for(i=0;i<n.length;i++)
    {
       if(n[i].value.length<1)
       {
          alert("不能为空!请输入!");
          n[i].focus();
        return false;
        }
    }
        return true;
}
function isNumber(n)
{

       if(isNaN(n))
       {
         // alert("请输入数字!");


        return false;
        }
  
        return true;

}

    function isEmail(theStr)
    {

         for(i=0;i<theStr.length;i++)
         {
            var atIndex = theStr[i].value.indexOf ('@');
            var dotIndex = theStr[i].value.indexOf ('.', atIndex);
            var flag = true;
            var theSub = theStr[i].value.substring (0, dotIndex + 1);
            if ((atIndex < 1) || (atIndex != theStr[i].value.lastIndexOf ('@')) || (dotIndex < atIndex + 2) || (theStr[i].value.length <= theSub.length))
            {
               alert("请正确输入Email!");
               theStr[i].select();
               flag = false;
            }
            else
            {
             flag = true;
            }
            return (flag);
          }
    }

    function isDelete()
    {
        if(confirm("真的要删除?"))
        {
         return true;
        }
      return false;
    }

    function checkLength (txt,size)
    {
    aMatch = txt.value.match(/[^\x00-\x80]/g);
    txtLength=txt.value.length + (! aMatch ? 0 : aMatch.length);
    if(txtLength>size)
    {
      alert("输入内容过长!");
       txt.focus();
       return false;
      }
     return true;
    }






function checkFormData(names)
{



           for(i=0;i<names.length;i++)
           {

                 na=names[i];
                txt=na[0];type=na[1];maxsize=na[2];notnull=na[3];


                if(txt.type=="text" || txt.type=="textarea")
                {

                 if(notnull)
                 {

                        if(txt.value.length==undefined || txt.value.length==null || txt.value.length<1)
                        {
                          alert("不能为空!");
                          txt.focus();
                          return false;
                        }

                   }





                   if(type=="n")
                   {
                              if(isNaN(txt.value))
                              {
                                alert("请输入数字!");
                                txt.select();
                                 return false;
                              }
                    }
                    else if(type=="e")
                    {
                           var atIndex = txt.value.indexOf ('@');
                           var dotIndex = txt.value.indexOf ('.', atIndex);

                           var theSub = txt.value.substring (0, dotIndex + 1);
                           if ((atIndex < 1) || (atIndex != txt.value.lastIndexOf ('@')) || (dotIndex < atIndex + 2) || (txt.value.length <= theSub.length))
                           {
                             alert("请正确输入Email!");
                             txt.select();
                             return false;
                            }
                    }


                     aMatch = txt.value.match(/[^\x00-\x80]/g);
                     txtLength=txt.value.length + (! aMatch ? 0 : aMatch.length);
                     if(txtLength>maxsize)
                     {
                        alert("输入内容过长!(最多输入"+maxsize+"个字符!每个汉字两个字符!)");
                        txt.select();
                        return false;
                      }
                  }
                  else
                  {

                         if(type=="ck")
                         {
                          var n=0;
                          for(j=0;j<txt.length;j++)
                          {
                                if(txt[j].checked==true)
                                {
                                   n=n+1;
                                }
                          }
                          if(n<maxsize)
                          {
                              alert("请只少选择"+maxsize+"个选项!");
                              return false;
                          }
                         }

                  }




           }
              return true;

    }




           function   Vector()
  {
          this.data   =   new   Array();
          this.add   =   Vector_add;
          this.remove   =   Vector_remove;
          this.get   =   Vector_elementAt;
          this.set   =   Vector_setElementAt;
          this.insert   =   Vector_insert;
          this.contains   =   Vector_contains;
          this.length   =   Vector_length;
          this.toString   =   Vector_toString;
  }

  function   Vector_add(   item   )
  {
          this.data[   this.data.length   ]   =   item;
  }

  function   Vector_remove(   index   )
  {
          var   data   =   this.data;
          data[   index   ]   =   null;
          var   tmpdata   =   new   Array();
          var   newindex   =   0;
          for(   var   i   =   0;   i   <   data.length;   i++   )
          {
                  if(   data[   i   ]   !=   null   )
                  {
                          tmpdata[   newindex   ]   =   data[   i   ];
                          newindex++;
                  }
          }
          this.data   =   tmpdata;
  }

  function   Vector_removeItem(   item   )
  {
          var   data   =   this.data;
          var   tmpdata   =   new   Array();
          var   newindex   =   0;
          for(   var   i   =   0;   i   <   data.length;   i++   )
          {
                  if(   data[   i   ]   !=   item   )
                  {
                          tmpdata[   newindex   ]   =   data[   i   ];
                  }
                  newindex++;
          }
          this.data   =   tmpdata;
  }

  function   Vector_elementAt(   index   )
  {
          return   this.data[   index   ];
  }

  function   Vector_setElementAt(   index,   item   )
  {
          this.data[   index   ]   =   item;
  }

  function   Vector_insert(   index,   item   )
  {
          if(   index   ==   this.data.length   )
          {
                  this.add(   item   );
                  return;
          }
          var   data   =   this.data;
          var   tmpdata   =   new   Array();
          var   newindex   =   0;
          for(   var   i   =   0;   i   <   data.length;   i++   )
          {
                  if(   i   ==   index   )
                  {
                          tmpdata[   i   ]   =   item;
                          newindex++;
                  }
                  tmpdata[   newindex   ]   =   data[   i   ];
                  newindex++;
          }
          this.data   =   tmpdata;
  }

  function   Vector_contains(   item   )
  {
          for(   var   i   =   0;   i   <   this.data.length;   i++   )
          {
                  if(   this.data[i]   ==   item   )
                  {
                          return   true;
                  }
          }
          return   false;
  }

  function   Vector_length()
  {
          return   this.data.length;
  }

  function   Vector_toString()
  {
          var   dataString   =   "[   ";
          var   data   =   this.data;
          for(   var   i   =   0;   i   <   data.length;   i++   )
          {
                  dataString   +=   data[i]   +   "   ";
          }
          dataString   +=   "]";
          return   dataString;
  }
