//Start***************function IsEmailValid(FormName,ElemName)*******************
<!--
// -----------------------------------------------------------------
// Function    : IsEmailValid
// Language    : JavaScript
// Description : Checks if given email address is of valid syntax
// Copyright   : (c) 2001 eBridge Infomation System Limited.
// -----------------------------------------------------------------
// Ver    Date    Description of modification
// --- ---------- --------------------------------------------------
// 1.0 2001/12/29 Original write : Winson
// -----------------------------------------------------------------
// Source: Javascript Code Library
// -----------------------------------------------------------------
// Usage: IsEmailValid('FormName","ElemName') 

function IsEmailValid(FormName,ElemName)
{
var EmailOk  = true
var Temp     = document.forms[FormName].elements[ElemName]
var AtSym    = Temp.value.indexOf('@')
var Period   = Temp.value.lastIndexOf('.')
var Space    = Temp.value.indexOf(' ')
var Length   = Temp.value.length - 1   // Array is from 0 to length-1

if ((AtSym < 1) ||                     // '@' cannot be in first position
    (Period <= AtSym+1) ||             // Must be atleast one valid char btwn '@' and '.'
    (Period == Length ) ||             // Must be atleast one valid char after '.'
    (Space  != -1))                    // No empty spaces permitted
   {  
      EmailOk = false
      alert('请输入一个合法的Email地址!')
      Temp.focus()
      Temp.select()
   }
return EmailOk
}
// -->
//End***************function IsEmailValid(FormName,ElemName)*********************

//Start***************function IsFormComplete(FormName)*************************
<!--
// -----------------------------------------------------------------
// Function    : IsFormComplete
// Language    : JavaScript
// Description : Checks if all elements in a form have a non-blank value
// Copyright   : (c) 2001 eBridge Infomation System Limited.
// -----------------------------------------------------------------
// Ver    Date    Description of modification
// --- ---------- --------------------------------------------------
// 1.0 2001/12/29 Original write : Winson
// -----------------------------------------------------------------
// Source: Javascript Code Library
// -----------------------------------------------------------------
// Usage: IsFormComplete("theFormName") 

function IsFormComplete(FormName)
{
var x       = 0
var FormOk  = true
TrimFormElements(FormName);
while ((x < document.forms[FormName].elements.length) && (FormOk))
   {
     if (document.forms[FormName].elements[x].value == '')
     { 
        alert('Please enter the '+document.forms[FormName].elements[x].name +' and try again.')
        document.forms[FormName].elements[x].focus()
        FormOk = false 
     }
     x ++
   }
return FormOk
}
// -->
//End*****************function IsFormComplete(FormName)********************

//Start*****************function MD_random(number1, number2)********************
<!--
// -----------------------------------------------------------------
// Function    : MD_random
// Language    : JavaScript
// Description : This function returns a random integer between two numbers. 
// Copyright   : (c) 2001 eBridge Infomation System Limited.
// -----------------------------------------------------------------
// Ver    Date    Description of modification
// --- ---------- --------------------------------------------------
// 1.0 2001/12/29 Original write : Winson
// -----------------------------------------------------------------
// Source: Javascript Code Library
// -----------------------------------------------------------------
// Usage: MD_random(number1, number2) returns a random integer between the values specified.

function MD_random(r1, r2) {
  if (r2 > r1) return (Math.round(Math.random()*(r2-r1))+r1);
  else return (Math.round(Math.random()*(r1-r2))+r2);
}
// -->
//End*****************function MD_random(number1, number2)********************

//Start*****************function WM_setCookie(), WM_readCookie(), WM_killCookie()******************
<!--
// -----------------------------------------------------------------
// Function    : WM_setCookie(), WM_readCookie(), WM_killCookie()
// Language    : JavaScript
// Description : A set of functions that eases the pain of using cookies.
// Copyright   : (c) 2001 eBridge Infomation System Limited.
// -----------------------------------------------------------------
// Ver    Date    Description of modification
// --- ---------- --------------------------------------------------
// 1.0 2001/12/29 Original write : Winson
// -----------------------------------------------------------------
// Source: Javascript Code Library
// -----------------------------------------------------------------
// Usage: MD_random(number1, number2) returns a random integer between the values specified.

// This next little bit of code tests whether the user accepts cookies.
var WM_acceptsCookies = false;
if(document.cookie == '') {
    document.cookie = 'WM_acceptsCookies=yes'; // Try to set a cookie.
    if(document.cookie.indexOf('WM_acceptsCookies=yes') != -1) {
	WM_acceptsCookies = true; 
    }// If it succeeds, set variable
} else { // there was already a cookie
  WM_acceptsCookies = true;
}


function WM_setCookie (name, value, hours, path, domain, secure) {
    if (WM_acceptsCookies) { // Don't waste your time if the browser doesn't accept cookies.
	var not_NN2 = (navigator && navigator.appName 
		       && (navigator.appName == 'Netscape') 
		       && navigator.appVersion 
		       && (parseInt(navigator.appVersion) == 2))?false:true;

	if(hours && not_NN2) { // NN2 cannot handle Dates, so skip this part
	    if ( (typeof(hours) == 'string') && Date.parse(hours) ) { // already a Date string
		var numHours = hours;
	    } else if (typeof(hours) == 'number') { // calculate Date from number of hours
		var numHours = (new Date((new Date()).getTime() + hours*3600000)).toGMTString();
	    }
	}
	document.cookie = name + '=' + escape(value) + ((numHours)?(';expires=' + numHours):'') + ((path)?';path=' + path:'') + ((domain)?';domain=' + domain:'') + ((secure && (secure == true))?'; secure':''); // Set the cookie, adding any parameters that were specified.
    }
} // WM_setCookie


function WM_readCookie(name) {
    if(document.cookie == '') { // there's no cookie, so go no further
	return false; 
    } else { // there is a cookie
	var firstChar, lastChar;
	var theBigCookie = document.cookie;
	firstChar = theBigCookie.indexOf(name);	// find the start of 'name'
	var NN2Hack = firstChar + name.length;
	if((firstChar != -1) && (theBigCookie.charAt(NN2Hack) == '=')) { // if you found the cookie
	    firstChar += name.length + 1; // skip 'name' and '='
	    lastChar = theBigCookie.indexOf(';', firstChar); // Find the end of the value string (i.e. the next ';').
	    if(lastChar == -1) lastChar = theBigCookie.length;
	    return unescape(theBigCookie.substring(firstChar, lastChar));
	} else { // If there was no cookie of that name, return false.
	    return false;
	}
    }	
} // WM_readCookie

function WM_killCookie(name, path, domain) {
  var theValue = WM_readCookie(name); // We need the value to kill the cookie
  if(theValue) {
      document.cookie = name + '=' + theValue + '; expires=Fri, 13-Apr-1970 00:00:00 GMT' + ((path)?';path=' + path:'') + ((domain)?';domain=' + domain:''); // set an already-expired cookie
  }
} // WM_killCookie

// -->
//End*****************function WM_setCookie(), WM_readCookie(), WM_killCookie()******************

//Start*****************function IsIPValid (IPvalue)******************
<!-- Begin
// -----------------------------------------------------------------
// Function    : IsIPValid
// Language    : JavaScript
// Description : Checks if given IP address is of valid syntax
// Copyright   : (c) 2001 eBridge Infomation System Limited.
// -----------------------------------------------------------------
// Ver    Date    Description of modification
// --- ---------- --------------------------------------------------
// 1.0 2001/12/29 Original write : Winson
// -----------------------------------------------------------------
// Source: Javascript Code Library
// -----------------------------------------------------------------
// Usage: IsIPValid('IPVALUE') 
function IsIPValid (IPvalue) {
errorString = "";
theName = "IPaddress";

var ipPattern = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;
var ipArray = IPvalue.match(ipPattern); 

if (IPvalue == "0.0.0.0")
	errorString = errorString + theName + ': '+IPvalue+' is a special IP address and cannot be used here.';
else if (IPvalue == "255.255.255.255")
	errorString = errorString + theName + ': '+IPvalue+' is a special IP address and cannot be used here.';
if (ipArray == null)
	errorString = errorString + theName + ': '+IPvalue+' is not a valid IP address.';
else {
	for (i = 0; i < 4; i++) {
	thisSegment = ipArray[i];
if (thisSegment > 255) {
	errorString = errorString + theName + ': '+IPvalue+' is not a valid IP address.';
	i = 4;
}
if ((i == 0) && (thisSegment > 255)) {
	errorString = errorString + theName + ': '+IPvalue+' is a special IP address and cannot be used here.';
	i = 4;
      }
   }
}
	extensionLength = 3;
if (errorString == "")
	//alert ("That is a valid IP address.");
	return true;
else
{
	return false;	
	alert (errorString);
}
}
//  End -->
//End*****************function IsIPValid (IPvalue)******************
//Start*****************function IsTimeValid('TimeStr') ******************
<!-- Begin
// -----------------------------------------------------------------
// Function    : IsTimeValid
// Language    : JavaScript
// Description : Checks if time is in HH:MM:SS AM/PM format. The seconds and AM/PM are optional.
// Copyright   : (c) 2001 eBridge Infomation System Limited.
// -----------------------------------------------------------------
// Ver    Date    Description of modification
// --- ---------- --------------------------------------------------
// 1.0 2001/12/29 Original write : Winson
// -----------------------------------------------------------------
// Source: Javascript Code Library
// -----------------------------------------------------------------
// Usage: IsTimeValid('TimeStr') 

function IsTimeValid(timeStr) {
var timePat = /^(\d{1,2}):(\d{2})(:(\d{2}))?(\s?(AM|am|PM|pm))?$/;

var matchArray = timeStr.match(timePat);
if (matchArray == null) {
alert("Time is not in a valid format.");
return false;
}
hour = matchArray[1];
minute = matchArray[2];
second = matchArray[4];
ampm = matchArray[6];

if (second=="") { second = null; }
if (ampm=="") { ampm = null }

if (hour < 0  || hour > 23) {
alert("Hour must be between 1 and 12. (or 0 and 23 for military time)");
return false;
}
if (hour <= 12 && ampm == null) {
if (confirm("Please indicate which time format you are using.  OK = Standard Time, CANCEL = Military Time")) {
alert("You must specify AM or PM.");
return false;
   }
}
if  (hour > 12 && ampm != null) {
alert("You can't specify AM or PM for military time.");
return false;
}
if (minute < 0 || minute > 59) {
alert ("Minute must be between 0 and 59.");
return false;
}
if (second != null && (second < 0 || second > 59)) {
alert ("Second must be between 0 and 59.");
return false;
}
//alert("The time you have entered is valid");
return true;
}
//  End -->
//End*****************function IsTimeValid('TimeStr') ******************


//Start*****************IsDateValid(ElemName,FormatStyle) ******************
<!-- Begin
// -----------------------------------------------------------------
// Function    : IsDateValid
// Language    : JavaScript
// Description : //check if date is valid,can match format like "yyyy/mm/dd","mm/dd/yyyy","dd/mm/yyyy" 
// Copyright   : (c) 2001 eBridge Infomation System Limited.
// -----------------------------------------------------------------
// Ver    Date    Description of modification
// --- ---------- --------------------------------------------------
// 1.0 2001/12/29 Original write : Winson
// -----------------------------------------------------------------
// Source: Javascript Code Library
// -----------------------------------------------------------------
// Usage: IsDateValid(ElemName,FormatStyle), format="yyyy/mm/dd","mm/dd/yyyy","dd/mm/yyyy" 
function IsLeapYear(year)
//Check if year is leap year
{
 if((year%4==0&&year%100!=0)||(year%400==0))
 {
 return true;
 } 
 return false;
}


function IsDateValid(ElemName,FormatStyle)
//check if date is valid
{

 var regexp,value,index;
 var year,month,day;
 var iyear,imonth,iday;
 var fmt,regfmt,ordfmt;
 var dateArray;

 if(ElemName.value=='')
 {
  ElemName.focus();
  ElemName.select();
  return false;
 }

 if(FormatStyle=='')
 {
  ElemName.focus();
  ElemName.select();
  return false;
 }

 fmt=new Array("yyyy/mm/dd","mm/dd/yyyy","dd/mm/yyyy");
 
 regfmt=new Array("/^([0-9]{4})\\/([0-9]{2})\\/([0-9]{2})$/","/^([0-9]{2})\\/([0-9]{2})\\/([0-9]{4})$/","/^([0-9]{2})\\/([0-9]{2})\\/([0-9]{4})$/");

 ordfmt=new Array("123","312","321");
 FormatStyle=FormatStyle.toLowerCase();

 for(index=0;index<fmt.length;index++)
 {
  
  if(FormatStyle==fmt[index])
  { 
   eval('regexp='+regfmt[index]+';');

   iyear=parseInt(ordfmt[index].charAt(0));
   imonth=parseInt(ordfmt[index].charAt(1));
   iday=parseInt(ordfmt[index].charAt(2));
   
   break;
  }
 }

 if(index==fmt.length)
 {
  alert("Date Format Not Supported!");
  ElemName.focus();
  ElemName.select();
  return false;
 }

 if(regexp.test(ElemName.value)){
  //alert("Date is matched with Format!");
  dateArray=ElemName.value.match(regexp);

  year=dateArray[iyear];
  month=dateArray[imonth];
  day=dateArray[iday];

  //alert("The Date you have filled is:\nYear:"+year+"\nMonth:"+month+"\nDay:"+day);
/*  
  if(year<2001)
  {
   alert("Year must be greater than 2001!");
   ElemName.focus();
   ElemName.select();
   return false;
  }
*/
  if(month<0||month>12)
  {
   alert("Month must range from 1 to 12!");
   ElemName.focus();
   ElemName.select();   
   return false;
  }

  if(day<0||day>31)
  {
   alert("Day must range from 1 to 31!");
   ElemName.focus();
   ElemName.select();   
   return false;
  }
  else
  { 
   if(month==2)
   { 
    if(IsLeapYear(year)&&day>29)
    {
     alert("In Month 2,Day must range from 1 to 29!");
     ElemName.focus();
     ElemName.select();     
     return false;
    }
    if(!IsLeapYear(year)&&day>28)
    {
     alert("In Month 2,Day must range from 1 to 28!");
      ElemName.focus();
      ElemName.select();     
     return false;
    }
   }
   if((month==4||month==6||month==9||month==11)&&(day>30))
   {
    alert("In this Month ,Day must range from 1 to 30!");
    ElemName.focus();
    ElemName.select();    
    return false;
   }
  }
 }
 else
 {
  alert("Date isn't matched with Format!\nDate Format:"+FormatStyle);
  ElemName.focus();
  ElemName.select();
  return false;
 }
 return true;
}
// End -->
//End*****************IsDateValid(ElemName,FormatStyle) ******************


//Start***************function NumInputOnly()*******************
<!--
// -----------------------------------------------------------------
// Function    : NumInputOnly
// Language    : JavaScript
// Description : Number Input only
// Copyright   : (c) 2001 eBridge Infomation System Limited.
// -----------------------------------------------------------------
// Ver    Date    Description of modification
// --- ---------- --------------------------------------------------
// 1.0 2001/12/31 Original write : Winson
// -----------------------------------------------------------------
// Source: Javascript Code Library
// -----------------------------------------------------------------
// Usage: onkeypress="javascript:NumInputOnly()

function NumInputOnly()
{
if(event.keyCode>57||event.keyCode<48)
event.keyCode=0;
}
// -->
//End***************function TrimFormElements(FormName)*********************

//Start***************function TrimFormElements(FormName)*******************
<!--
// -----------------------------------------------------------------
// Function    : TrimFormElements(FormName)
// Language    : JavaScript
// Description : Trim Form Elements' Space
// Copyright   : (c) 2002 eBridge Infomation System Limited.
// -----------------------------------------------------------------
// Ver    Date    Description of modification
// --- ---------- --------------------------------------------------
// 1.0 2002/01/12 Original write : Winson
// -----------------------------------------------------------------
// Source: Javascript Code Library
// -----------------------------------------------------------------
// Usage: TrimFormElements(FormName)

	function TrimFormElements(FormName){
		var x       = 0
		while (x < document.forms[FormName].elements.length)
		   {
		   document.forms[FormName].elements[x].value = document.forms[FormName].elements[x].value.replace(/(^\s*)|(\s*$)/g, "");
		   x ++
		   }
		return;
	}

// -->
//End***************function TrimFormElements(FormName)*********************

//Start***************function reverse(str)*******************
<!--
// -----------------------------------------------------------------
// Function    : Treverse(str)
// Language    : JavaScript
// Description : reverse string
// Copyright   : (c) 2002 eBridge Infomation System Limited.
// -----------------------------------------------------------------
// Ver    Date    Description of modification
// --- ---------- --------------------------------------------------
// 1.0 2002/01/12 Original write : Winson
// -----------------------------------------------------------------
// Source: Javascript Code Library
// -----------------------------------------------------------------
// Usage: TrimFormElements(FormName)
function reverse(str) {
	text = "";
	for (i = 0; i <= str.length; i++)
	text = str.substring(i, i+1) + text;
	return text;
}
// -->
//End***************function reverse(str)*********************

<!--
// -----------------------------------------------------------------
//判断是否是钱的形式
function isMoney(pObj,errMsg){
 var obj = eval(pObj);
 strRef = "1234567890.";
 if(!isEmpty(pObj,errMsg)) return false;
 for (i=0;i<obj.value.length;i++) {
  tempChar= obj.value.substring(i,i+1);
  if (strRef.indexOf(tempChar,0)==-1) {
   if (errMsg == null || errMsg =="")
    alert("数据不符合要求,请检查");
   else
    alert(errMsg);   
   if(obj.type=="text") 
    obj.focus(); 
   return false; 
  }else{
   tempLen=obj.value.indexOf(".");
   if(tempLen!=-1){
    strLen=obj.value.substring(tempLen+1,obj.value.length);
    if(strLen.length>2){
     if (errMsg == null || errMsg =="")
      alert("数据不符合要求,请检查");
     else
      alert(errMsg);   
     if(obj.type=="text") 
     obj.focus(); 
     return false; 
    }
   }
  }
 }
 return true;
}


