'****************************************************************
'*   	            CommonFuns_NoEnc.vbs                        *
'*     Copyright (c) Netmarch Company 2000-2002                 *
'*                   All rights reserved                        *
'****************************************************************

'**********************Description*******************************
'* Main function detail	: 中国吴江项目中VbS Function定义文件    *
'* Author				: Jemmy_liu             *
'* Date					: 2003-09-16            *
'* Version				: 1.0                   *
'****************************************************************
 Const NMC_EMPTY_DATA_ELEMENT = "请输入完整的日期！"
 Const NMC_INVALID_DATA_ELEMENT = "请输入正确的日期格式！"
 Dim nmm_strProjectName:nmm_strProjectName="中国昆山宾馆"

Function CheckTextIsValid(FrmName,ElementName,ErrString)
  If trim(GetValue(FrmName,ElementName)) = "" Then
    NMMessageDlg "warning","请输入"&ErrString&"！"
    GetFocus FrmName,ElementName
    CheckTextIsValid = False
	Exit Function
  End IF
  CheckTextIsValid = True
End Function

Function GetValue(FrmName,ElementsName)
  GetValue = Eval("Document."&FrmName&"."&ElementsName&".Value")
End Function

Function NMMessageDlg(Dlgtype,DlgMsg)
  Dim nmm_DlgTypeNum
  nmm_DlgTypeNum = 1
  IF LCase(Trim(Dlgtype)) = "infor" Then
	nmm_DlgTypeNum = 64
  End IF
  IF LCase(Trim(Dlgtype)) = "error" Then
	nmm_DlgTypeNum = 16
  End IF
  IF LCase(Trim(Dlgtype)) = "warning" Then
	nmm_DlgTypeNum = 48
  End IF
  IF LCase(Trim(Dlgtype)) = "ok" Then
	nmm_DlgTypeNum = 6
  End IF
  IF LCase(Trim(Dlgtype)) = "conform" Or LCase(Trim(Dlgtype)) = "confirm"   Then
	nmm_DlgTypeNum = 292
  End IF
  nmm_DlgTypeNum = CInt(nmm_DlgTypeNum)
  NMMessageDlg = Msgbox (DlgMsg, nmm_DlgTypeNum, nmm_strProjectName)	
End Function

Function GetFocus(FrmName,ElementsName)
  GetFocus = Eval("Document."&FrmName&"."&ElementsName&".Focus()")
End Function

function GetEditorContent(frmName)
  GetEditorContent = Eval("Document."&FrmName&".getFinishContent()")
End function
'Author: Tom tao
'Version: 1.0
'Date: 2002-12-23
'showMessageDlg(nmm_strDlgType,nmm_strDlgMsg)
'Function:弹出对话框的各种类型
'Para:
      'nmm_strDlgType :弹出对话框类型.值为infor,error,warning,conform
      'nmm_strDlgMsg :弹出对话框时,显示的信息
'Return:
  			'Normal:
  			'Abnormal:
     
function showMessageDlg(nmm_strDlgType,nmm_strDlgMsg)
	Dim nmm_intDlgTypeNum
	nmm_intDlgTypeNum = 1

	if Trim(nmm_strDlgType) = "infor" Then
		nmm_intDlgTypeNum = 64
	End if

	if Trim(nmm_strDlgType) = "error" Then
		nmm_intDlgTypeNum = 16
	End if
			
	if Trim(nmm_strDlgType) = "warning" Then
		nmm_intDlgTypeNum = 48
	End if

	if Trim(nmm_strDlgType) = "conform" Then
		nmm_intDlgTypeNum = 292
	End if

	nmm_intDlgTypeNum = CInt(nmm_intDlgTypeNum)
	showMessageDlg = Msgbox (nmm_strDlgMsg, nmm_intDlgTypeNum,"中国吴江")	
End function

'***********************************************************************************
'Author		: Frank Kong
'Version	: 1.0
'Date		: 2003/05/27
'Name		: IsValidEmail(email)
'Function	: 检测邮件地址是否合法
'Para		: 
'			  email 邮件地址
'Return		: 
'	Normal	: true: 合法
'			: false:非法
'			  
'***********************************************************************************
function IsValidEmail(email)
dim nmm_arrNames, nmm_strName, nmm_intCounter, nmm_strTemp
'Check for valid syntax in an email address.
IsValidEmail = true
nmm_arrNames = Split(email, "@")
if UBound(nmm_arrNames) <> 1 then
  IsValidEmail = false
  exit function
end if
for each nmm_strName in nmm_arrNames
  if Len(nmm_strName) <= 0 then
    IsValidEmail = false
    exit function
  end if
  for nmm_intCounter = 1 to Len(nmm_strName)
    nmm_strTemp = Lcase(Mid(nmm_strName, nmm_intCounter, 1))
    if InStr("abcdefghijklmnopqrstuvwxyz_-.", nmm_strTemp) <= 0 and not IsNumeric(nmm_strTemp) then
      IsValidEmail = false
      exit function
    end if
  next
  if Left(nmm_strName, 1) = "." or Right(nmm_strName, 1) = "." then
    IsValidEmail = false
    exit function
  end if
next
if InStr(nmm_arrNames(1), ".") <= 0 then
  IsValidEmail = false
  exit function
end if
nmm_intCounter = Len(nmm_arrNames(1)) - InStrRev(nmm_arrNames(1), ".")
if nmm_intCounter <> 2 and nmm_intCounter <> 3 then
  IsValidEmail = false
  exit function
end if
if InStr(email, "..") > 0 then
  IsValidEmail = false
end if
end function
