/*

	LIST OF FUNCTIONS:
		LTrim
		RTrim
		Trim
		IsPercentage
		IsNumeric
		IsDigit
		IsPhone
		IsDate
		IsDate1
		Round	
		DateCompare
		Show
		Hide
		DateCompare1
		IsEmail
		IsPwdLetter
		IsPwdNum
		IsPwdChars
		IsPwdLength
		Is3ConsecutiveChars
		confirmCard
		verify_ccard
		validChar
		validLen
		validAlphaNumber
		validInteger
		validDecimal
		cmdGet
		validPostalCode
		validTime

		
*/

/*
	This script contains several useful functions that can be used to validate
	fields of a form before submission. (DSG)
*/


function LTrim(strInput) {
	var whitespace = new String(" \t\n\r");
    var s = new String(strInput);

    if (whitespace.indexOf(s.charAt(0)) != -1) {
			// We have a string with leading blank(s)...
        var j=0, i = s.length;
			// Iterate from the far left of string until we don't have any more whitespace...
        while (j < i && whitespace.indexOf(s.charAt(j)) != -1) j++;
			// Get the substring from the first non-whitespace character to the end of the string...
        s = s.substring(j, i);
	}
    return s;
}


function RTrim(strInput) {
	// We don't want to trip JUST spaces, but also tabs,
    // line feeds, etc.  Add anything else you want to
    // "trim" here in Whitespace

    var whitespace = new String(" \t\n\r");
    var s = new String(strInput);
    if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
			// We have a string with trailing blank(s)...
		var i = s.length - 1;       // Get length of string
			// Iterate from the far right of string until we don't have any more whitespace...
        while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1) i--;
            // Get the substring from the front of the string to where the last non-whitespace character is...
        s = s.substring(0, i+1);
	}
	return s;
}



function Trim(strInput) {
	return RTrim(LTrim(strInput));
}



function IsPercentage(strInput) {
	var strDigits = "0123456789.";
	var bolAllDigits = true;

	var strCheck = strInput;
	for (i = 0;  i < strCheck.length;  i++) {
		ch = strCheck.charAt(i);
		for (j = 0;  j < strDigits.length;  j++) {
			if (ch == strDigits.charAt(j)) {
				break;
			}
		}
		if (j == strDigits.length) {
			bolAllDigits = false;
			break;
		}
	}
	if (!bolAllDigits) {
		return(1);
	}

    if (((strCheck / strCheck) != 1) && (strCheck != 0)) {
		return(1);
	}

	if (parseInt(strCheck) > 100 && strCheck != 0) {
		return(1);
	}

	return(0);
}



function IsNumeric(strInput) {
	var strDigits = "0123456789.";
	var bolAllDigits = true;

	var strCheck = strInput;
	for (i = 0;  i < strCheck.length;  i++) {
		ch = strCheck.charAt(i);
		for (j = 0;  j < strDigits.length;  j++) {
			if (ch == strDigits.charAt(j)) {
				break;
			}
		}
		if (j == strDigits.length) {
			bolAllDigits = false;
			break;
		}
	}
	if (!bolAllDigits) {
		return(1);
	}

    if (((strCheck / strCheck) != 1) && (strCheck != 0)) {
		return(1);
	}
	return(0);
}

function IsInteger(strInput) {
	var strDigits = "0123456789-";
	var bolAllDigits = true;

	var strCheck = strInput;
	for (i = 0;  i < strCheck.length;  i++) {
		ch = strCheck.charAt(i);
		for (j = 0;  j < strDigits.length;  j++) {
			if (ch == strDigits.charAt(j)) {
				break;
			}
		}
		if (j == strDigits.length) {
			bolAllDigits = false;
			break;
		}
	}
	if (!bolAllDigits) {
		return false;
	}

    if (((strCheck / strCheck) != 1) && (strCheck != 0)) {
		return  false;
	}
	return true;
}

function IsDigit(strInput) {
	var strDigits = "0123456789";
	var bolAllDigits = true;

	var strCheck = strInput;
	for (i = 0;  i < strCheck.length;  i++) {
		ch = strCheck.charAt(i);
		for (j = 0;  j < strDigits.length;  j++) {
			if (ch == strDigits.charAt(j)) {
				break;
			}
		}
		if (j == strDigits.length) {
			bolAllDigits = false;
			break;
		}
	}
	if (!bolAllDigits) {
		return(1);
	}
	return(0);
}


function IsPhone(strInput) {
	if (strInput.length > 0) {
		if (strInput.length < 10) {
			return(1);
		}
		else {
			if (IsDigit(strInput) != 0) {
				return (1);
			}
		}
	}
	return (0);
}



/* ---------------------------------------------------------------------------
	This function checks whether or not the string argument is a valid date.
	Return codes are:
		0 = Valid
		1 = Invalid format (MM/DD/YYYY)
		2 = Invalid characters entered
		3 = Invalid month entered
		4 = Invalid day entered
   ----------------------------------------------------------------------------- */

function IsDate(strInput) {
	var strDigits = "0123456789/";
	var bolAllDigits = true;
	var bolDelimitorCheck = true;
	var strMonth = "";
	var strDay = "";
	var strLeapYear = "";
	var intLeapYear = 0;
	var strCheck = strInput;

	if (strCheck.length < 10) {
		return (1);
	}  
    var strYear = strCheck.charAt(6) + strCheck.charAt(7) + strCheck.charAt(8) + strCheck.charAt(9);
	for (i = 0;  i < strCheck.length;  i++) {
		ch = strCheck.charAt(i);
		for (j = 0;  j < strDigits.length;  j++) {
			if (ch == strDigits.charAt(j)) {
				break;
			}
		}
		if (j == strDigits.length) {
			bolAllDigits = false;
			break;
		}
		if ( ((i == 2) && (ch != strDigits.charAt(10))) || ((i == 5) && (ch != strDigits.charAt(10))) ) {
			bolDelimitorCheck = false;
			break;
		}
		if ( i == 2 && ch == strDigits.charAt(10) ) {
			strMonth = strCheck.charAt(0) + strCheck.charAt(1);
			if (strMonth < "01" || strMonth > "12") {
				return(1);
			}
		}
  		if ( i == 5 && ch == strDigits.charAt(10) ) {
			strDay = strCheck.charAt(3) + strCheck.charAt(4);
			if (strDay < "01" || strDay > "31") {
				return(1);
			}
			if (strMonth == "01" && strDay > "31") {
				return(1);
			}
			if (strMonth == "02" ) {
				strLeapYear = strYear / "4";
				intLeapYear = parseInt(strLeapYear);
				intLeapYear = strLeapYear - intLeapYear;
				if (intLeapYear == 0) {
					/* leap year */
					if (strDay > "29") {
						return(1);
					}
				}
				else {
					if (strDay > "28") {
						return(1);
					}
				}	
			}
			if (strMonth == "03" && strDay > "31") {
				return(1);
			}
			if (strMonth == "04" && strDay > "30") {
				return(1);
			}
			if (strMonth == "05" && strDay > "31") {
				return(1);
			}
			if (strMonth == "06" && strDay > "30") {
				return(1);
			}
			if (strMonth == "07" && strDay > "31") {
				return(1);
			}	
			if (strMonth == "08" && strDay > "31") {
				return(1);
			}
			if (strMonth == "09" && strDay > "30") {
				return(1);
			}
			if (strMonth == "10" && strDay > "31") {
				return(1);
			}
			if (strMonth == "11" && strDay > "30") {
				return(1);
			}
			if (strMonth == "12" && strDay > "31") {
				return(1);
			}
		}
	}
	if (!bolDelimitorCheck){
		return(1);
	}
	if (!bolAllDigits) {
		return(1);
	}

	return(0);
}


function IsDate1(vexpmonth, vexpyear) {
	var strDigits = "0123456789/";
	var bolAllDigits = true;
	var bolDelimitorCheck = true;
	var strMonth = "";
	var strDay = "";
	var strLeapYear = "";
	var intLeapYear = 0;
	var strCheck = vexpmonth[vexpmonth.selectedIndex].value + "/" + "01" + "/" + vexpyear.value;

	if (strCheck.length < 10) {
		return (1);
	}  
    var strYear = strCheck.charAt(6) + strCheck.charAt(7) + strCheck.charAt(8) + strCheck.charAt(9);
	for (i = 0;  i < strCheck.length;  i++) {
		ch = strCheck.charAt(i);
		for (j = 0;  j < strDigits.length;  j++) {
			if (ch == strDigits.charAt(j)) {
				break;
			}
		}
		if (j == strDigits.length) {
			bolAllDigits = false;
			break;
		}
		if ( ((i == 2) && (ch != strDigits.charAt(10))) || ((i == 5) && (ch != strDigits.charAt(10))) ) {
			bolDelimitorCheck = false;
			break;
		}
		if ( i == 2 && ch == strDigits.charAt(10) ) {
			strMonth = strCheck.charAt(0) + strCheck.charAt(1);
			if (strMonth < "01" || strMonth > "12") {
				return(1);
			}
		}
  		if ( i == 5 && ch == strDigits.charAt(10) ) {
			strDay = strCheck.charAt(3) + strCheck.charAt(4);
			if (strDay < "01" || strDay > "31") {
				return(1);
			}
			if (strMonth == "01" && strDay > "31") {
				return(1);
			}
			if (strMonth == "02" ) {
				strLeapYear = strYear / "4";
				intLeapYear = parseInt(strLeapYear);
				intLeapYear = strLeapYear - intLeapYear;
				if (intLeapYear == 0) {
					/* leap year */
					if (strDay > "29") {
						return(1);
					}
				}
				else {
					if (strDay > "28") {
						return(1);
					}
				}	
			}
			if (strMonth == "03" && strDay > "31") {
				return(1);
			}
			if (strMonth == "04" && strDay > "30") {
				return(1);
			}
			if (strMonth == "05" && strDay > "31") {
				return(1);
			}
			if (strMonth == "06" && strDay > "30") {
				return(1);
			}
			if (strMonth == "07" && strDay > "31") {
				return(1);
			}	
			if (strMonth == "08" && strDay > "31") {
				return(1);
			}
			if (strMonth == "09" && strDay > "30") {
				return(1);
			}
			if (strMonth == "10" && strDay > "31") {
				return(1);
			}
			if (strMonth == "11" && strDay > "30") {
				return(1);
			}
			if (strMonth == "12" && strDay > "31") {
				return(1);
			}
		}
	}
	if (!bolDelimitorCheck){
		return(1);
	}
	if (!bolAllDigits) {
		return(1);
	}

	return(0);
}


function Round(number,X) {
// rounds number to X decimal places, defaults to 2
    X = (!X ? 2 : X);
    return Math.round(number*Math.pow(10,X))/Math.pow(10,X);
}


function DateCompare(strDateFrom,strDateTo) {
	var strDate1 = "";
	var strDate2 = "";
	if (strDateFrom.length == 10) {
		strDate1 = strDateFrom.substring(6,10) + strDateFrom.substring(0,2) + strDateFrom.substring(3,5);
	}
	else {
		if (strDateFrom == "") {
			strDate1 = "";
		}
		else {
			return(1);
		}
	}
	if (strDateTo.length == 10) {
		strDate2 = strDateTo.substring(6,10) + strDateTo.substring(0,2) + strDateTo.substring(3,5);
	}
	else {
		if (strDateTo == "") {
			strDate2 = "";
		}
		else {
			return(1);
		}
	}
	if (strDate1 == "" || strDate2 == "") {
		return (0);
	}
	else {
		if (strDate1 > strDate2) {
			return(1);
		}
		else {
			return(0);
		}
	}
}


function DateCompare1(vtoday, vexpmonth, vexpyear) {
	var strDate1 = "";
	var strDate2 = "";
	var strDateFrom = vtoday.value;
        var strDateTo = vexpmonth[vexpmonth.selectedIndex].value + "/" + "01" + "/" + vexpyear.value;
	if (strDateFrom.length == 10) {
		strDate1 = strDateFrom.substring(6,10) + strDateFrom.substring(0,2) + strDateFrom.substring(3,5);
	}
	else {
		if (strDateFrom == "") {
			strDate1 = "";
		}
		else {
			return(1);
		}
	}
	if (strDateTo.length == 10) {
		strDate2 = strDateTo.substring(6,10) + strDateTo.substring(0,2) + strDateTo.substring(3,5);
	}
	else {
		if (strDateTo == "") {
			strDate2 = "";
		}
		else {
			return(1);
		}
	}
	if (strDate1 == "" || strDate2 == "") {
		return (0);
	}
	else {
		if (strDate1 > strDate2) {
			return(1);
		}
		else {
			return(0);
		}
	}
}


<!-- Begin
function IsEmail(emailStr) {
/* The following pattern is used to check if the entered e-mail address
   fits the user@domain format.  It also is used to separate the username
   from the domain. */
var emailPat=/^(.+)@(.+)$/
/* The following string represents the pattern for matching all special
   characters.  We don't want to allow special characters in the address. 
   These characters include ( ) < > @ , ; : \ " . [ ]    */
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
/* The following string represents the range of characters allowed in a 
   username or domainname.  It really states which chars aren't allowed. */
var validChars="\[^\\s" + specialChars + "\]"
/* The following pattern applies if the "user" is a quoted string (in
   which case, there are no rules about which characters are allowed
   and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
   is a legal e-mail address. */
var quotedUser="(\"[^\"]*\")"
/* The following pattern applies for domains that are IP addresses,
   rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
   e-mail address. NOTE: The square brackets are required. */
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
/* The following string represents an atom (basically a series of
   non-special characters.) */
var atom=validChars + '+'
/* The following string represents one word in the typical username.
   For example, in eugenia.protopopescu@somewhere.com, eugenia and protopopescu are words.
   Basically, a word is either an atom or quoted string. */
var word="(" + atom + "|" + quotedUser + ")"
// The following pattern describes the structure of the user
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
/* The following pattern describes the structure of a normal symbolic
   domain, as opposed to ipDomainPat, shown above. */
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")


/* Finally, let's start trying to figure out if the supplied address is
   valid. */

/* Begin with the coarse pattern to simply break up user@domain into
   different pieces that are easy to analyze. */
var matchArray=emailStr.match(emailPat)
if (matchArray==null) {
  /* Too many/few @'s or something; basically, this address doesn't
     even fit the general mould of a valid e-mail address. */
	alert("Invalid Email Address. (check @ and .'s)")
	return false
}
var user=matchArray[1]
var domain=matchArray[2]

// See if "user" is valid 
if (user.match(userPat)==null) {
    // user is not valid
    alert("Invalid UserName.")
    return false
}

/* if the e-mail address is at an IP address (as opposed to a symbolic
   host name) make sure the IP address is valid. */
var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) {
    // this is an IP address
	  for (var i=1;i<=4;i++) {
	    if (IPArray[i]>255) {
	        alert("Invalid IP_Email.")
		return false
	    }
    }
    return true
}

// Domain is symbolic name
var domainArray=domain.match(domainPat)
if (domainArray==null) {
	alert("Invalid Domain Name in Email.")
    return false
}

/* domain name seems valid, but now make sure that it ends in a
   three-letter word (like com, edu, gov) or a two-letter word,
   representing country (uk, nl), and that there's a hostname preceding 
   the domain or country. */

/* Now we need to break up the domain to get a count of how many atoms
   it consists of. */
var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 || 
    domArr[domArr.length-1].length>4) {
   // the address must end in a two letter or three letter word.
   alert("Email Address must end in a four letter domain (.info), three letter domain (.com), or two letter country (.ca).")
   return false
}

// Make sure there's a host name preceding the domain.
if (len<2) {
   var errStr="Email Address missing HostName."
   alert(errStr)
   return false
}

// If we've gotten this far, everything's valid!
return true;
}
//  End -->


function show(object) {
    if (document.layers && document.layers[object])
        document.layers[object].visibility = 'visible';
    else if (document.all)
        document.all[object].style.visibility = 'visible';
}

function hide(object) {
    if (document.layers && document.layers[object])
        document.layers[object].visibility = 'hidden';
    else if (document.all)
        document.all[object].style.visibility = 'hidden';
}

function MM_dragLayer(objNS,objIE,hL,hT,hW,hH,toFront,dropBack,cU,cD,cL,cR,targL,targT,tol,strJS) { //v1.2
  var i,j,aLayer,retVal,curDrag=null,NS=(navigator.appName=='Netscape'), curLeft, curTop;
  if (!document.all && !document.layers) return false;
  retVal = true; if(!NS) event.returnValue = true;
  if (MM_dragLayer.arguments.length > 1) {
    curDrag = eval((NS)?objNS:objIE); if (!curDrag) return false;
    if (!document.allLayers) {
      document.allLayers = new Array();
      with (document) {
        if (NS) {
          for (i=0; i<layers.length; i++) allLayers[i]=layers[i];
          for (i=0; i<allLayers.length; i++) {
            if (allLayers[i].document && allLayers[i].document.layers)
              for (j=0; j<allLayers[i].document.layers.length; j++)
                allLayers[allLayers.length] = allLayers[i].document.layers[j];
        } } else {
          for (i=0; i<all.length; i++)
            if (all[i].style != null && all[i].style.position)
              allLayers[allLayers.length] = all[i];
    } } }
    curDrag.MM_dragOk=true; curDrag.MM_targL=targL; curDrag.MM_targT=targT;
    curDrag.MM_tol=Math.pow(tol,2); curDrag.MM_hLeft=hL; curDrag.MM_hTop=hT;
    curDrag.MM_hWidth=hW; curDrag.MM_hHeight=hH; curDrag.MM_toFront=toFront;
    curDrag.MM_dropBack=dropBack; curDrag.MM_strJS=strJS;
    curDrag.MM_oldZ = (NS)?curDrag.zIndex:curDrag.style.zIndex;
    curLeft= (NS)?curDrag.left:curDrag.style.pixelLeft; curDrag.MM_startL = curLeft;
    curTop = (NS)?curDrag.top:curDrag.style.pixelTop; curDrag.MM_startT = curTop;
    curDrag.MM_bL=(cL<0)?null:curLeft-cL; curDrag.MM_bT=(cU<0)?null:curTop -cU;
    curDrag.MM_bR=(cR<0)?null:curLeft+cR; curDrag.MM_bB=(cD<0)?null:curTop +cD;
    curDrag.MM_LEFTRIGHT=0; curDrag.MM_UPDOWN=0; curDrag.MM_SNAPPED=false; //use in your JS!
    document.onmousedown = MM_dragLayer; document.onmouseup = MM_dragLayer;
    if (NS) document.captureEvents(Event.MOUSEDOWN|Event.MOUSEUP);
  } else {
    var theEvent = ((NS)?objNS.type:event.type);
    if (theEvent == 'mousedown') {
      var aLayer, maxDragZ=null;
      var mouseX = (NS)?objNS.pageX : event.clientX + document.body.scrollLeft;
      var mouseY = (NS)?objNS.pageY : event.clientY + document.body.scrollTop;
      document.MM_maxZ = 0;
      for (i=0; i<document.allLayers.length; i++) {
        aLayer = document.allLayers[i];
        var aLayerZ = (NS)?aLayer.zIndex:aLayer.style.zIndex;
        if (aLayerZ > document.MM_maxZ) document.MM_maxZ = aLayerZ;
        var isVisible = (((NS)?aLayer.visibility:aLayer.style.visibility).indexOf('hid') == -1);
        if (aLayer.MM_dragOk != null && isVisible) with (aLayer) {
          var parentL=0; var parentT=0;
          if (!NS) { 
            parentLayer = aLayer.parentElement;
            while (parentLayer != null && parentLayer.style.position) {
              parentL += parentLayer.offsetLeft;
              parentT += parentLayer.offsetTop;
              parentLayer = parentLayer.parentElement;
          } }
          var tmpX=mouseX-(((NS)?pageX:style.pixelLeft+parentL)+MM_hLeft);
          var tmpY=mouseY-(((NS)?pageY:style.pixelTop +parentT)+MM_hTop);
          var tmpW = MM_hWidth;  if (tmpW <= 0) tmpW += ((NS)?clip.width :offsetWidth);
          var tmpH = MM_hHeight; if (tmpH <= 0) tmpH += ((NS)?clip.height:offsetHeight);
          if ((0 <= tmpX && tmpX < tmpW && 0 <= tmpY && tmpY < tmpH) &&
             (maxDragZ == null || maxDragZ <= aLayerZ)) {
            curDrag = aLayer; maxDragZ = aLayerZ;
      } } }
      if (curDrag) {
        document.onmousemove = MM_dragLayer; 
        if (NS) document.captureEvents(Event.MOUSEMOVE);
        curLeft = (NS)?curDrag.left:curDrag.style.pixelLeft;
        curTop = (NS)?curDrag.top:curDrag.style.pixelTop;
        MM_oldX = mouseX - curLeft; MM_oldY = mouseY - curTop;
        document.MM_curDrag = curDrag;  curDrag.MM_SNAPPED=false;
        if(curDrag.MM_toFront) {
          eval('curDrag.'+((NS)?'':'style.')+'zIndex=document.MM_maxZ+1');
          if (!curDrag.MM_dropBack) document.MM_maxZ++;
        }
        retVal = false; if(!NS) event.returnValue = false;
    } } else if (theEvent == 'mousemove') {
      if (document.MM_curDrag) with (document.MM_curDrag) {
        var mouseX = (NS)?objNS.pageX : event.clientX + document.body.scrollLeft;
        var mouseY = (NS)?objNS.pageY : event.clientY + document.body.scrollTop;
        newLeft = mouseX-MM_oldX; newTop  = mouseY-MM_oldY;
        if (MM_bL!=null) newLeft = Math.max(newLeft,MM_bL);
        if (MM_bR!=null) newLeft = Math.min(newLeft,MM_bR);
        if (MM_bT!=null) newTop  = Math.max(newTop ,MM_bT);
        if (MM_bB!=null) newTop  = Math.min(newTop ,MM_bB);
        MM_LEFTRIGHT = newLeft-MM_startL; MM_UPDOWN = newTop-MM_startT;
        if (NS) {left = newLeft; top = newTop;}
        else {style.pixelLeft = newLeft; style.pixelTop = newTop;}
        retVal = false; if(!NS) event.returnValue = false;
    } } else if (theEvent == 'mouseup') {
      document.onmousemove = null;
      if (NS) document.releaseEvents(Event.MOUSEMOVE);
      if (NS) document.captureEvents(Event.MOUSEDOWN); //for mac NS
      if (document.MM_curDrag) with (document.MM_curDrag) {
        if (typeof MM_targL !='number' || typeof MM_targT != 'number') eval(MM_strJS);
        else if ((Math.pow(MM_targL-((NS)?left:style.pixelLeft),2)+
                  Math.pow(MM_targT-((NS)?top:style.pixelTop),2))<=MM_tol) {
          if (NS) {left = MM_targL; top = MM_targT;}
          else {style.pixelLeft = MM_targL; style.pixelTop = MM_targT;}
          eval(MM_strJS);  MM_SNAPPED = true;
          MM_LEFTRIGHT = MM_startL-MM_targL; MM_UPDOWN = MM_startT-MM_targT;
        }
        if(MM_dropBack) {if (NS) zIndex = MM_oldZ; else style.zIndex = MM_oldZ;}
        retVal = false; if(!NS) event.returnValue = false;
      } 
      document.MM_curDrag = null;
    }
    if (NS) document.routeEvent(objNS);
  }
  return retVal;
}

//following functions are used to check password

//pwd must contain letter
function IsPwdLetter(strInput) {
	var pwdPat = /[A-Za-z]/;
	var matchArray = strInput.match(pwdPat);
	if (matchArray == null) {
		return(1);
	}
	return(0);
}

//pwd must contain number
function IsPwdNum(strInput) {
	var pwdPat = /[0-9]/;
	var matchArray = strInput.match(pwdPat);
	if (matchArray == null) {
		return(0);
	}
	return(1);
}
//pwd can't contain special chars
function IsPwdChars(strInput) {
	var pwdPat = /[^A-Za-z0-9]/;
	var matchArray = strInput.match(pwdPat);
	if (matchArray != null) {
		return(0);
	}
	return(1);
}

function IsPwdLength(strInput){
	var i=strInput.length;
	if ((i<6) || (i>20)) {
		return(0);
	}
	return(1);
}

//pwd doen't allow 3 consecutive chars
function Is3ConsecutiveChars(strInput){
	var Len=strInput.length;
	for (i=0; i<Len; i++){
		var code1=strInput.charCodeAt(i);
		var code2=strInput.charCodeAt(i+1);
		var code3=strInput.charCodeAt(i+2);
		if ((code1==code2) && (code1==code3)) {
			return(0);
		}
	}
	return(1);
}


//replace special chars
function ReplaceSpecialChars(strInput){
	var strText=strInput;
	strText=strText.replace(/"/,"'");
	strText=strText.replace(/=/,"equal");
	strText=strText.replace(/{</,"(");
	strText=strText.replace(/}>/,")");
	return;
}


//ConfirmCard is used to validate credit card number
function confirmCard(card1, card2, cardtype)
{
        errorStrings = new Array(
                "Hee Hee.  No error here!", //0
                "Check sum failed", //1
                "Check sum failed", //2
                "Check sum failed", //3
                "Check sum failed", //4
                "Check sum failed", //5
                "Check sum failed", //6
                "Check sum failed", //7
                "Check sum failed", //8
                "Check sum failed", //9
                "Number of digits must be greater than 12", //10
                "Master Card prefix must be 51-55", //11
                "Visa prefix must be 4", //12
                "American Express prefix must be 34 or 37", //13
                "Discover prefix must be 6011", //14
                "Diner's Club/Carte Blanche prefix must be 36, 38, or 300-305", //15
                "enRoute prefix must be 2014 or 2149", //16
                "JCB prefix must be 3, 2131 or 1800", //17
                "Why are you reading my source?", //18
                "Are you just a glutton for punishment?", //19
                "Insert comment here.", //20
                "Number of digits must be 16 for Master Card", //21
                "Number of digits must be 13 or 16 for Visa", //22
                "Number of digits must be 15 for American Express", //23
                "Number of digits must be 16 for Discover ", //24
                "Number of digits must be 14 for Diner's Club/Carte Blanche", //25
                "Number of digits must be 15 for enRoute", //26
                "Number of digits must be 16 for JCB with prefix of 3", //27
                "Number of digits must be 15 for JCB with prefix of 2131 or 1800") //28

			if((reason = verify_ccard(card1.value + card2.value, cardtype[cardtype.selectedIndex].value)) == 0)
			{
			        //alert("Valid Card Number!");
			        return true;
			}
			else
			{
			        //alert("Card Number Invalid.  Reason number = " + reason + " Reason = " + errorStrings[reason]);
			        return false;
			}
		
		
}

function verify_ccard(inNumber, type)
{// returns 0 if valid, positive number if invalid.
        total = 1*0;
        tmp = 1*0;

        number = "";

        // make sure there are only numbers in the string...
        for(i = 0; i < inNumber.length; i++)
        {
		if(inNumber.charAt(i) >= "0" && inNumber.charAt(i) <= "9")
                {
                        number = number + inNumber.charAt(i);
                }
        }

        if(number.length < 13) return 10; // too short for anything

        first = "" + number.charAt(0);
        second = "" + number.charAt(1);
        third = "" + number.charAt(2);
        firstTwo = first + second;
        firstFour = firstTwo + third + number.charAt(3);

        if(type == "MC")
        {
                if(first != "5" || second < "1" || second > "5")
                        return 11;// invalid Mastercard prefix
                if(number.length != 16)
                        return 21;
        }
        else if(type == "VISA")
        {
                if(first != "4")
                        return 12;// invalid Visa prefix
                if(number.length != 13 && number.length != 16)
                        return 22;
        }
        else if(type == "AMEX")
        {
                if(first != "3" || (second != "4" && second != "7"))
                        return 13;// invalid American Express Prefix
                if(number.length != 15) 
                        return 23;
        }
        else if(type == "DISC")
        {
                        if(firstFour != "6011")
                                return 14;// invalid prefix.
                        if(number.length != 16)
                                return 24;
        }
        else if(type == "DCCB")
        {
                if(firstTwo != "36"
                        && firstTwo != "38"
                        && (firstTwo != "30" ||
                                (third < "0" || third > "5")))
                {
                        return 15;
                }
                if(number.length != 14)
                        return 25;
        }
        else if(type == "enRoute")
        {
                if(firstFour != "2014"
                        && firstFour != "2149")
                        return 16;// invalid enRoute card
                if(number.length != 15)
                        return 26;
		return 0; // no check sum calculation needed
        }
        else if(type == "JCB")
        {
                if(firstFour != "2131"
                        && firstFour != "1800"
                        && (first != "3") )
                        return 17;
                if(number.length != 16 && first =="3")
                        return 27;
                if(number.length != 15 && first != "3")
                        return 28;
        }
        // now check the credit card suffix and length vs. the type

    
         // do the check sum
        for(loc = number.length - 2; loc >= 0; loc -= 2)
        {
                total += 1 * number.charAt(loc +1);
                tmp = number.charAt(loc) * 2;
		if(tmp > 9) total += 1;
		total += tmp%10;
        }
	if(number.length % 2 > 0)
	total += 1 * number.charAt(0);


        return (total % 10);
}

<!---------------------------------------------------------------->
<!-- validChar: Validation for First & Last Names:              -->
<!--	strValid - string to validate                           -->
<!-- Letters, space, ' and '-' are allowed.						-->
<!-- Otherwise alert "Incorrect format." is displayed.			-->
<!---------------------------------------------------------------->

function validChar(intLength, strValid){
	bolCorrFormat = true;
	
	if (strValid.length > intLength)
		bolCorrFormat = false;
		
	if (strValid.length != 0) {
		for (i=0; i < strValid.length; i++){
			if (!((strValid.charCodeAt(i) >= 97 && strValid.charCodeAt(i) <= 122) ||
			(strValid.charCodeAt(i) >= 65 && strValid.charCodeAt(i) <= 90 ) ||
			strValid.charCodeAt(i) == 45 || strValid.charCodeAt(i) == 32 ||
			strValid.charCodeAt(i) == 39))
				bolCorrFormat = false;
		}
	
		if (!bolCorrFormat)
			alert("Invalid format.");
	}		
	
	return bolCorrFormat;
}

<!---------------------------------------------------------------->
<!-- validLen: Length Validation                                -->
<!---------------------------------------------------------------->

function validLen(intLength, strValid){
	bolCorrFormat = true;
	
	if (strValid.length > intLength)
		bolCorrFormat = false;
		
	if (strValid.length != 0) {
		if (!bolCorrFormat)
			alert("Invalid length.");
	}		
	
	return bolCorrFormat;
}

<!---------------------------------------------------------------->
<!-- validAlphaNumber: Validation for Asset No:					-->
<!--	strValid - string to validate                           -->
<!-- Letters and Numbers are allowed.							-->
<!---------------------------------------------------------------->
function validAlphaNumber(intLength, strValid){
	bolCorrFormat = true;
	
	if (strValid.length > intLength)
		bolCorrFormat = false;
		
	if (strValid.length != 0) {
		for (i=0; i < strValid.length; i++){
			if (!((strValid.charCodeAt(i) >= 97 && strValid.charCodeAt(i) <= 122) ||
				  (strValid.charCodeAt(i) >= 65 && strValid.charCodeAt(i) <= 90 ) ||
				  (strValid.charCodeAt(i) >= 48 && strValid.charCodeAt(i) <= 57)))
			{	
				bolCorrFormat = false;
			}
		}
	}		
	
	return bolCorrFormat;
}


<!--------------------------------------------------------------------->
<!-- validInteger: Checking for integer wiht maximum length function -->              -->
<!-- 	intNum 	 - Maximum length of characters                      -->
<!--	strValid - string to validate                                -->
<!--------------------------------------------------------------------->

function validInteger(intNum, strValid){
	bolCorrFormat = true;
	if (strValid.length != 0) {
		if (strValid.length > intNum){
			bolCorrFormat = false;
		}
		else{
			for (i=0; i < strValid.length; i++){
				if (!(strValid.charCodeAt(i) >= 48 && strValid.charCodeAt(i) <= 57))
					bolCorrFormat = false;
			
			}
//			if (!bolCorrFormat)
//				alert("Value must be numeric.");
		}
	}

	return bolCorrFormat;
}

<!---------------------------------------------------------------->
<!-- validDecimal: Checking for Decimal function                -->
<!--	strValid - string to validate                           -->
<!---------------------------------------------------------------->

function validDecimal(strValid){
	j=0;
	k=0;
	bolCorrFormat = true;
	if (strValid.length != 0) {
		for (i=0; i < strValid.length; i++){
			if (!(strValid.charCodeAt(i) >= 48 && strValid.charCodeAt(i) <= 57))
				j++;
			if ((strValid.charCodeAt(i) == 46))
					k++;
		}
		if (j>1 || (j == 1 && k == 0))
		bolCorrFormat = false;
	}
	
//	if (!bolCorrFormat)
//		alert("Value must be decimal.");
	
	return bolCorrFormat;
}

/*
NAME:		CMDGET
PARAM:		FORMOBJECT, BUTTONOBJECT, DSTURL
*/
function cmdGet(form, btnObj, dstURL){
	
		form.action = dstURL + "?btn_cmd=" + btnObj.name;
		form.method="Post";	
		form.submit();

}

<!--------------------------------------------------------------->
<!-- validPostalCode: Validation of Postal Code in the format: -->
<!--				M2J4H9	 - 6 characters, without space	   -->
<!--				M2J 4H9	 - 6 characters, with space		   -->
<!--				##### - 5 characters, with space		   -->
<!--				strValid - string to be validated		   -->
<!--------------------------------------------------------------->

function validPostalCode(strValid)
{
	bolCorrFormat = true;
	strPost = strValid

	if (strPost.length != 0)
	{
		if (((strPost.charCodeAt(0) >= 65 && strPost.charCodeAt(0) <= 90) || (strPost.charCodeAt(0) >= 97 && strPost.charCodeAt(0) <= 122)))
		{
			if (strPost.length == 7) {
				if (strPost.substring(3,4) != " ")
					bolCorrFormat = false;
				else
					strPost = strValid.substring(0,3) + strValid.substring(4,7);
			}
			if (strPost.length <= 6 && bolCorrFormat) {
				for (i=0; i<strPost.length; i++) {
					if (((i+1)%2) == 1) {
						if (!((strPost.charCodeAt(i) >= 65 && strPost.charCodeAt(i) <= 90) || (strPost.charCodeAt(i) >= 97 && strPost.charCodeAt(i) <= 122)))
							bolCorrFormat = false;
					}
					else {
						if (!(strPost.charCodeAt(i) >= 48 && strPost.charCodeAt(i) <= 57))
							bolCorrFormat = false;
					}
				}
			}
			else if (strPost.length >= 7)
				bolCorrFormat = false;
		}
		else if ((strPost.charCodeAt(0) >= 48 && strPost.charCodeAt(0) <= 57))
		{
			if (strPost.length == 10) {
				if (strPost.substring(5,6) != "-")
					bolCorrFormat = false;
				else
					strPost = strValid.substring(0,5) + strValid.substring(6,10);
			}
			if (strPost.length <= 9 && bolCorrFormat)
				for (i=0; i < strPost.length; i++) {
					if (strPost.charCodeAt(i) < 48 || strPost.charCodeAt(i) > 57)
					{
						bolCorrFormat = false;
					}
				}
			else if (strPost.length >= 10)
				bolCorrFormat = false;
		}
	}	
	return bolCorrFormat;
}
<!--------------------------------------------------------------->
<!-- validPostalCode: Validation of Canada Postal Code in the format: -->
<!--				M2J4H9	 - 6 characters, without space	   -->
<!--				M2J 4H9	 - 6 characters, with space		   -->
<!--				##### - 5 characters, with space		   -->
<!--				strValid - string to be validated		   -->
<!--------------------------------------------------------------->

function validCaPostalCode(strValid)
{
	bolCorrFormat = true;
	strPost = strValid

	if (strPost.length != 0)
	{
		if (((strPost.charCodeAt(0) >= 65 && strPost.charCodeAt(0) <= 90) || (strPost.charCodeAt(0) >= 97 && strPost.charCodeAt(0) <= 122)))
		{
			if (strPost.length == 7) {
				if (strPost.substring(3,4) != " ")
					bolCorrFormat = false;
				else
					strPost = strValid.substring(0,3) + strValid.substring(4,7);
			}
			if (strPost.length <= 6 && bolCorrFormat) {
				for (i=0; i<strPost.length; i++) {
					if (((i+1)%2) == 1) {
						if (!((strPost.charCodeAt(i) >= 65 && strPost.charCodeAt(i) <= 90) || (strPost.charCodeAt(i) >= 97 && strPost.charCodeAt(i) <= 122)))
							bolCorrFormat = false;
					}
					else {
						if (!(strPost.charCodeAt(i) >= 48 && strPost.charCodeAt(i) <= 57))
							bolCorrFormat = false;
					}
				}
			}
			else if (strPost.length >= 7)
				bolCorrFormat = false;
		}
		else 
		{
			
				bolCorrFormat = false;
		}
	}	
	return bolCorrFormat;
}

<!---------------------------------------------------------------->
<!-- validTime: Validation of the Time in the format:           -->
<!-- 	HH:MM                                                   -->
<!--	strValid - string to validate                           -->
<!---------------------------------------------------------------->

function validTime(strValid){
	bolCorrFormat = true;
	if (strValid.length != 0) {
		if (strValid.length != 5 || strValid.charCodeAt(2) != 58 )
			bolCorrFormat = false;
		for (i=0; i < strValid.length; i++){
			if (i != 2 && !(strValid.charCodeAt(i) >= 48 && strValid.charCodeAt(i) <= 57))
				bolCorrFormat = false;	
				
		}
		
		if (bolCorrFormat) {
			intHour = parseInt(strValid.substr(0, 2), 10)
			intMin = parseInt(strValid.substr(3, 2), 10)
			if (intHour > 23 || intMin > 59)
				bolCorrFormat = false;
		}	
	}		
	
	return bolCorrFormat;
}

function DateCompare(strDateFrom,strDateTo) {
	var strDate1 = "";
	var strDate2 = "";
	if (strDateFrom.length == 10) {
		strDate1 = strDateFrom.substring(6,10) + strDateFrom.substring(0,2) + strDateFrom.substring(3,5);
	}
	else {
		if (strDateFrom == "") {
			strDate1 = "";
		}
		else {
			return(1);
		}
	}
	if (strDateTo.length == 10) {
		strDate2 = strDateTo.substring(6,10) + strDateTo.substring(0,2) + strDateTo.substring(3,5);
	}
	else {
		if (strDateTo == "") {
			strDate2 = "";
		}
		else {
			return(1);
		}
	}
	if (strDate1 == "" || strDate2 == "") {
		return (0);
	}
	else {
		if (strDate1 > strDate2) {
			return(1);
		}
		else {
			return(0);
		}
	}
}