  var ie = document.all?1:0;
  
  function HMError(strEType,strError,strOther,strEN) {
    strError = unescape(strError).replace(/\+/g," ");
    strError = strError.replace(/\\n/g,"\n");
    switch(strEType) {
      case "A":	// alert -> OK button only
        alert(strError);
        break;
      case "M":	// new windows 
        if (ie)
          DoModal(strOther,strEN);
        else
          DoFakeModal(strOther,strEN);
        break;
      case "C":	// comfirm -> OK and Cancel buttons
        return(confirm(strError));
        break;
    }
  }
  
  function DoModal(strOther,strEN) {
    rv = window.showModalDialog("url","","dialogWidth:360px;dialogHeight:217px;help:0;scroll:0;status:0;");
    if (rv.help)
      CallPaneHelp(rv.help);
    if (rv.url) {
      if (strOther=="attach")
        DoSaveMSG();
      Else
        location.href=rv.url;
    }
  }
  
  function DoFakeModal(strOther,strEN) {
    ErrOther = strOther;
    window.open("url", "newwin", "resizable=no,width=360,height=217");
  }

  function strltrim(str) {
    return str.replace(/^\s+/,'');
  }

  function strrtrim(str) {
    return str.replace(/\s+$/,'');
  }

  function checkLogin(e) {
    ok = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
    if(ok.indexOf(e.charAt(0))<10) { 
      return (false);
    }
    for(i=0; i < e.length ;i++) {
      if(ok.indexOf(e.charAt(i))<0) { 
        return (false);
      }	
    }
    return (-1);
  } 

  function checkEmail(e) {
    ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";
    for(i=0; i < e.length ;i++) {
      if(ok.indexOf(e.charAt(i))<0) { 
        return (false);
      }	
    } 

    if (document.images) {
      re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
      re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
      if (!e.match(re) && e.match(re_two)) {
        return (-1);		
      } 
    }
}

  function confirmDeleteData(str, url) {
    if(HMError("C", str,"","")) {
      document.location = url;
    }
  }
 function openwincenter(url,winname,x,y)
{
        var sx = screen.width;
        var sy = screen.height;
        var wx = (sx/2) - (x /2);
        var wy = (sy/2) - (y/2) - 50;
        winwindow = window.open(url,winname,"width=" + x + ",height=" + y +",menubar=0,resizable=0,scrollbars=0,status=0,titlebar=0,toolbar=0,left=0,top=0,left=" + wx + ",top=" + wy)
}

 function openwincenterbar(url,winname,x,y)
{
        var sx = screen.width;
        var sy = screen.height;
        var wx = (sx/2) - (x /2);
        var wy = (sy/2) - (y/2) - 50;
        winwindow = window.open(url,winname,"width=" + x + ",height=" + y +",menubar=0,resizable=0,scrollbars=1,status=0,titlebar=0,toolbar=0,left=0,top=0,left=" + wx + ",top=" + wy)
}

