function IsAlphaNumeric (strData)
{
	var nStrLength;
	nStrLength =  strData.length;
	for(i=0; i<nStrLength; i++)
	{
		if( ! ( ((strData.charAt(i) >= '0') && (strData.charAt(i) <= '9')) ||
				((strData.charAt(i) >= 'a') && (strData.charAt(i) <= 'z')) ||
				((strData.charAt(i) >= 'A') && (strData.charAt(i) <= 'Z')) ) )
		{
			return false;
		}
	}
	return true;
}

function IsNumeric(sText)

{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }
   
function IsInteger (str)
{
	for(i=0; i<str.length; i++)
	{
		if( ! ((str.charAt(i) >= '0') && (str.charAt(i) <= '9')) )
		{
			return false;
		}
	}
	return true;
}

/////////////////////////////////////////////////////////////////////
//	Function Name	:	IsPhoneNo()
//	Parameters		:	strValue - phone_no
//	Return Value	:	Boolean - true - valid
//								  false - invalid
//	Description		:	This function validates phone number.
//						Phone No can be either 10 digit number or 12 digits with 2 dashes
//						e.x. 1111111111 or 111-111-1111
////////////////////////////////////////////////////////////////////

function IsPhoneNo(strValue)
{
		var strLastDigits, strFirst3, strMid3, strHyphen1, strHyphen2				
		if((strValue.length != 12) && (strValue.length != 10))
		{
			return false;
		}
		
		strFirst3 = strValue.substring(0,3)
		if (!IsInteger(strFirst3))
		{
			return false;
		}
		
		if(strValue.length == 12) 
		{
			strHyphen1 = strValue.substring(3,4)		
			if ( strHyphen1 != "-")
			{
				return false;
			}
			strHyphen2 = strValue.substring(7,8)
			if ( strHyphen2 != "-")
			{
				return false;
			}
			strMid3 = strValue.substring(4,7)
			strLastDigits = strValue.substring(8,12)
		}
		else  //if Length is 10
		{
			strMid3 = strValue.substring(3,6)
			strLastDigits = strValue.substring(6,10)		
		}
		
		if (!IsInteger(strMid3))
		{
			return false;
		}
		
		if ((!IsInteger(strLastDigits)) || (strLastDigits.length != 4))
		{
			return false;
		}
		
		return true;
}
/////////////////////////////////////////////////////////////////////
//	Function Name	:	IsEmail()
//	Parameters		:	str - Email
//	Return Value	:	Boolean - true - valid
//								  false - invalid
//	Description		:	This function validates Email addresses.
////////////////////////////////////////////////////////////////////

function IsEmail(str)
{
	var strAtFound, strDotFound, bValid;
	var intIndex
	intIndex = 0;
	for(j=0; j<str.length; j++)
	{
		if( (str.charAt(j) == '.') || (str.charAt(j) == '@'))
		{
			if (str.charAt(j) == '@' &&	strAtFound == "Y" )		 
			{
				bValid = false;
				break;
			}
			if (str.charAt(j) == '.' &&	strAtFound == "Y" )
			{
				if( intIndex != 2) //To ensure that atleast one character exists after '.'
				{
					if(! ((j + 1) < str.length))   
						return false;
					intIndex++;
				}
				
				strDotFound = "Y";
			}
			else
				if (str.charAt(j) == '@')
				{
					if(! j > 0 ) // To ensure that atleast one character exists Before '@'
						return false;
					strAtFound = "Y";
				}				
			if( intIndex != 2) 
			{
				if( Checkprecededfollowed(str,j) == false)
				{
					bValid = false;
					break;
				}
				else
				{
					bValid = true;
				}	
			}
			else //once checking is over for @ and two dots exit 
				return true;
			
		}
	}
	if (strDotFound == "Y" && strAtFound == "Y" && bValid == true)
		return true;
	else
		return false;
}
function Checkprecededfollowed(str,intPos)
{
	
	if ( IsAlphaNumeric(str.charAt(intPos - 1)) && IsAlphaNumeric(str.charAt(intPos + 1)))
	{
		return true;				
	}
	else
	{
		return false;
	}	
}

/////////////////////////////////////////////////////////////////////////////
//	Function Name	:	IsDateMMYYYY
//	Parameters		:	none
//	Return Value	:	none
//	Description		:	This function  validates date Valid Format = MM/YYYY
//	Last Done By	:	Gaurav Yadav : Min Year is 1753				
////////////////////////////////////////////////////////////////////////////

function IsDateMMYYYY( strDate )
{
	var theLength = strDate.length
	if ( theLength < 6 || theLength > 7 )
		return false ;
	
	if ( theLength == 7 )
	{
		var theYear = strDate.substring(3,7) ;
		var theMonth = strDate.substring(0,2) ;
		if ( theMonth > 12 || theMonth < 1) 
			return false ;
		if ( theYear < 1753) 
			return false ;

		if ( strDate.charAt(2) != '/' ) 
			return false ;
		
	}
	if ( theLength == 6 )
	{
		var theYear = strDate.substring(3,6) ;
		var theMonth = strDate.substring(0,1) ;
		if ( theYear < 1753) 
			return false ;
		if ( theMonth > 12 || theMonth < 1) 
				return false ;
		
		if ( strDate.charAt(1) != '/' ) 
				return false ;
	}
	for( i = 0 ; i < theLength ; i++ )
	{
		if (!(( strDate.charAt(i) >= '0' && strDate.charAt(i) <= '9')||(strDate.charAt(i) == '/')))
		{
				return false ;
		}
	}
			
return true ;
}



/////////////////////////////////////////////////////////////////////
//	Function Name	:	IsEmpty
//	Parameters		:	checkstring		: String to be validated
//	Return Value	:	Boolean  blank or null - True
//								 non-blank     - False
//	Description		:	This function  checks whether the string is 
//                      empty or null.
////////////////////////////////////////////////////////////////////

function IsEmpty(checkString)
{
    count = 0;         // COUNTER FOR LOOPING THROUGH STRING
    var first_char = 0;
    if (checkString != null)
    {
		for (i = 0; i < checkString.length; i++) 
		{
		    ch = checkString.substring(i, i+1);
		    if ((ch == " " ) && (first_char == 0))
		    {
		        continue;
		    }
		    else
		    {
				first_char = 1;
				break;
		    }
		}
    }
	if (first_char == 0)
	{
		return true;
	}
	else
	{
		return false;
	}
}

/////////////////////////////////////////////////////////////////////
//	Function Name	:	TrimSpaces
//	Parameters		:	checkString	: String containing integers and spaces.
//	Return Value	:	String
//	Description		:	This function trims all spaces in the given string.
//						Caution :Use this function for integer values.
////////////////////////////////////////////////////////////////////

function TrimSpaces(checkString)
{
    newString = "";    // REVISED/CORRECTED STRING

    for (i = 0; i < checkString.length; i++) 
    {
        ch = checkString.substring(i, i+1);
        if (ch != " " ) 
        {
            newString += ch;
        }
    }

        return newString;
}



/////////////////////////////////////////////////////////////////////////
// Script Tag Removed since it gives an error while running the scripts//
/////////////////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////////////////////////
//	The following block containing various functions used in Date Cheking
//  is added by KEDARJ on 30.07.1999.
//  The main function is isValidDate(dateString) which takes the string
//  containing date as an input parameter for its validation.
////////////////////////////////////////////////////////////////////////



// Global variable defaultEmptyOK defines default return value 
// for many functions when they are passed the empty string. 
// By default, they will return defaultEmptyOK.
//
// defaultEmptyOK is false, which means that by default, 
// these functions will do "strict" validation.  Function
// isInt, for example, will only return true if it is
// passed a string containing an integer; if it is passed
// the empty string, it will return false.
//
// You can change this default behavior globally (for all 
// functions which use defaultEmptyOK) by changing the value
// of defaultEmptyOK.
//
// Most of these functions have an optional argument emptyOK
// which allows you to override the default behavior for 
// the duration of a function call.
//
// This functionality is useful because it is possible to
// say "if the user puts anything in this field, it must
// be an integer (or a phone number, or a string, etc.), 
// but it's OK to leave the field empty too."
// This is the case for fields which are optional but which
// must have a certain kind of content if filled in.

var defaultEmptyOK = false




// Attempting to make this library run on Navigator 2.0,
// so I'm supplying this array creation routine as per
// JavaScript 1.0 documentation.  If you're using 
// Navigator 3.0 or later, you don't need to do this;
// you can use the Array constructor instead.

function makeArray(n) {
//*** BUG: If I put this line in, I get two error messages:
//(1) Window.length can't be set by assignment
//(2) daysInMonth has no property indexed by 4
//If I leave it out, the code works fine.
//   this.length = n;
   for (var i = 1; i <= n; i++) {
      this[i] = 0
   } 
   return this
}



/*var daysInMonth = makeArray(12);
daysInMonth[1] = 31;
daysInMonth[2] = 29;   // must programmatically check this
daysInMonth[3] = 31;
daysInMonth[4] = 30;
daysInMonth[5] = 31;
daysInMonth[6] = 30;
daysInMonth[7] = 31;
daysInMonth[8] = 31;
daysInMonth[9] = 30;
daysInMonth[10] = 31;
daysInMonth[11] = 30;
daysInMonth[12] = 31;

*/

var daysInMonth = new Array(13)
{
daysInMonth[1] = 31;
daysInMonth[2] = 29;   // must programmatically check this
daysInMonth[3] = 31;
daysInMonth[4] = 30;
daysInMonth[5] = 31;
daysInMonth[6] = 30;
daysInMonth[7] = 31;
daysInMonth[8] = 31;
daysInMonth[9] = 30;
daysInMonth[10] = 31;
daysInMonth[11] = 30;
daysInMonth[12] = 31;
}


// BOI, followed by one or more digits, followed by EOI.
//kedar var reInteger = /^\d+$/


//kedar Function to check for an integer
function fnIsInteger(s)
{
	for (var i = 0; i < s.length; i++)
	{
	if ((s.charAt(i) == 0) || (s.charAt(i) == 1) || 
		(s.charAt(i) == 2) || (s.charAt(i) == 3) ||
		(s.charAt(i) == 4) || (s.charAt(i) == 5) ||
		(s.charAt(i) == 6) || (s.charAt(i) == 7) ||
		(s.charAt(i) == 8) || (s.charAt(i) == 9))
		{
			//alert ("inloop>> " + i + "   charat>> " + s.charAt(i));
			continue;
		}
	else 
		{
			//alert ("returning false for fnIsInteger");
			return false;
		}
	}
	//alert ("returning true for fnIsInteger");
	return true;
}




// BOI, followed by an optional + or -, followed by one or more digits, 
// followed by EOI.
//kedar var reSignedInteger = /^(\+|-)?\d+$/ 

//kedar Function to check for a signed integer
function fnIsSignedInteger(s)
{
	if ((s.charAt(0) == "+") || (s.charAt(0) == "-")) 
	{
		var s1 = s.substring(1, s.length);
	}
	else
	{
		s1 = s;
	}		
	//alert ("s1>> " + s1);
	
	if (fnIsInteger(s1)) return true;
	else return false;
}	


// Check whether string s is empty.

function isitEmpty(s)
{   return ((s == null) || (s.length == 0))
}



// isSignedInteger (STRING s [, BOOLEAN emptyOK])
// 
// Returns true if all characters are numbers; 
// first character is allowed to be + or - as well.
//
// Does not accept floating point, exponential notation, etc.
//
// We don't use parseInt because that would accept a string
// with trailing non-numeric characters.
//
// For explanation of optional argument emptyOK,
// see comments of function isInt.
//
// EXAMPLE FUNCTION CALL:          RESULT:
// isSignedInteger ("5")           true 
// isSignedInteger ("")            defaultEmptyOK
// isSignedInteger ("-5")          true
// isSignedInteger ("+5")          true
// isSignedInteger ("", false)     false
// isSignedInteger ("", true)      true

function isSignedInteger (s)

{   if (isitEmpty(s)) 
       if (isSignedInteger.arguments.length == 1) return defaultEmptyOK;
       else return (isSignedInteger.arguments[1] == true);

    
    else {
       //kedar return reSignedInteger.test(s)
       return fnIsSignedInteger(s);
    }
}


// isNonnegativeInteger (STRING s [, BOOLEAN emptyOK])
// 
// Returns true if string s is an integer >= 0.
//
// For explanation of optional argument emptyOK,
// see comments of function isInt.

function isNonnegativeInteger (s)
{   var secondArg = defaultEmptyOK;

    if (isNonnegativeInteger.arguments.length > 1)
        secondArg = isNonnegativeInteger.arguments[1];

    // The next line is a bit byzantine.  What it means is:
    // a) s must be a signed integer, AND
    // b) one of the following must be true:
    //    i)  s is empty and we are supposed to return true for
    //        empty strings
    //    ii) this is a number >= 0

    return (isSignedInteger(s, secondArg)
         && ( (isitEmpty(s) && secondArg)  || (parseInt (s) >= 0) ) );
}


// isYear (STRING s [, BOOLEAN emptyOK])
// 
// isYear returns true if string s is a valid 
// Year number.  Must be 2 or 4 digits only.
// 
// For Year 2000 compliance, you are advised
// to use 4-digit year numbers everywhere.
//
// And yes, this function is not Year 10000 compliant, but 
// because I am giving you 8003 years of advance notice,
// I don't feel very guilty about this ...
//
// For B.C. compliance, write your own function. ;->
//
// For explanation of optional argument emptyOK,
// see comments of function isInt.

function isYear (s)
{   if (isitEmpty(s)) 
       if (isYear.arguments.length == 1) return defaultEmptyOK;
       else return (isYear.arguments[1] == true);
    if (!isNonnegativeInteger(s)) return false;
    //kedar return ((s.length == 2) || (s.length == 4));
    //return ((s.length == 4));
    
    if (s.length == 4)
    {
		if ((s.charAt(0) == "+") || (s.charAt(0) == "-")) return false;
		else return true;
	}	
    else return false;
}



// isInt (STRING s [, BOOLEAN emptyOK])
// 
// Returns true if all characters in string s are numbers.
//
// Accepts non-signed integers only. Does not accept floating 
// point, exponential notation, etc.
//
// We don't use parseInt because that would accept a string
// with trailing non-numeric characters.
//
// By default, returns defaultEmptyOK if s is empty.
// There is an optional second argument called emptyOK.
// emptyOK is used to override for a single function call
//      the default behavior which is specified globally by
//      defaultEmptyOK.
// If emptyOK is false (or any value other than true), 
//      the function will return false if s is empty.
// If emptyOK is true, the function will return true if s is empty.
//
// EXAMPLE FUNCTION CALL:     RESULT:
// isInt ("5")            true 
// isInt ("")             defaultEmptyOK
// isInt ("-5")           false
// isInt ("", true)       true
// isInt ("", false)      false
// isInt ("5", false)     true

function isInt (s)

{   var i;

    if (isitEmpty(s)) 
       if (isInt.arguments.length == 1) return defaultEmptyOK;
       else return (isInt.arguments[1] == true);

    //kedar return reInteger.test(s)
    return fnIsInteger(s);
}



// isIntegerInRange (STRING s, INTEGER a, INTEGER b [, BOOLEAN emptyOK])
// 
// isIntegerInRange returns true if string s is an integer 
// within the range of integer arguments a and b, inclusive.
// 
// For explanation of optional argument emptyOK,
// see comments of function isInt.


function isIntegerInRange (s, a, b)
{   if (isitEmpty(s)) 
       if (isIntegerInRange.arguments.length == 1) return defaultEmptyOK;
       else return (isIntegerInRange.arguments[1] == true);

    // Catch non-integer strings to avoid creating a NaN below,
    // which isn't available on JavaScript 1.0 for Windows.
    if (!isInt(s, false)) return false;
    
    // Now, explicitly change the type to integer via parseInt
    // so that the comparison code below will work both on 
    // JavaScript 1.2 (which typechecks in equality comparisons)
    // and JavaScript 1.1 and before (which doesn't).
    var num = parseInt (s);
    return ((num >= a) && (num <= b));
}



// isMonth (STRING s [, BOOLEAN emptyOK])
// 
// isMonth returns true if string s is a valid 
// month number between 1 and 12.
//
// For explanation of optional argument emptyOK,
// see comments of function isInt.

function isMonth (s)
{   if (isitEmpty(s)) 
       if (isMonth.arguments.length == 1) return defaultEmptyOK;
       else return (isMonth.arguments[1] == true);
    return isIntegerInRange (s, 1, 12);
}



// isDay (STRING s [, BOOLEAN emptyOK])
// 
// isDay returns true if string s is a valid 
// day number between 1 and 31.
// 
// For explanation of optional argument emptyOK,
// see comments of function isInt.

function isDay (s)
{   if (isitEmpty(s)) 
       if (isDay.arguments.length == 1) return defaultEmptyOK;
       else return (isDay.arguments[1] == true);   
    return isIntegerInRange (s, 1, 31);
}




// daysInFebruary (INTEGER year)
// 
// Given integer argument year,
// returns number of days in February of that year.

function daysInFebruary (year)
{   // February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (  ((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0) ) ) ? 29 : 28 );
}




// isDate (STRING year, STRING month, STRING day)
//
// isDate returns true if string arguments year, month, and day 
// form a valid date.
// 

function isDate (year, month, day)
{   // catch invalid years (not 2- or 4-digit) and invalid months and days.
    //if (! (isYear(year, false) && isMonth(month, false) && isDay(day, false))) return false;
	
	if (IsEmpty(month) == true)
	{
		return -1;
	}
	
	if (IsEmpty(day) == true)
	{
		return -1;
	}

	// to eliminate the starting character 0
	if (month.length > 1)
	{
		if (month.charAt(0) == '0')
		{
			month = month.charAt(1)
		}
	}

	// to eliminate the starting character 0	
	if (day.length > 1)
	{
		if (day.charAt(0) == '0')
		{
			day = day.charAt(1)
		}
	}

	var retIsYear, retIsMonth, retIsDay
	retIsYear = isYear(year, false);
	retIsMonth = isMonth(month, false);
	retIsDay = isDay(day, false);
	//alert (retIsYear + "  " + retIsMonth + "  " + retIsDay);
	if (! (retIsYear && retIsMonth && retIsDay))
	{
		if (retIsMonth == false) return -1;
		if (retIsDay == false) return -2;
		if (retIsYear == false) return -3;
	}	
	
	
    // Explicitly change type to integer to make code work in both
    // JavaScript 1.1 and JavaScript 1.2.
    var intYear = parseInt(year);
    var intMonth = parseInt(month);
    var intDay = parseInt(day);

	// Year cannot be lessthan 1755.
	if (intYear <= 1755) return -6;

    // catch invalid days, except for February
    //if (intDay > daysInMonth[intMonth]) return false; 
	if (intDay > daysInMonth[intMonth]) return -4;
	
    //if ((intMonth == 2) && (intDay > daysInFebruary(intYear))) return false;
	if ((intMonth == 2) && (intDay > daysInFebruary(intYear))) return -5;
	
    //return true;
    return 0;
}





//Function to check the date validity at client-side.
//This function takes a string as an input parameter and checks it for the 
//validity of the date format 'mm/dd/yyyy'. It first divides the string into
//three substrings containing month, day and year, on the basis of a 
//separator '/'. Then it internally uses a function isDate to check for the 
//validity of this date.
//This function returns an integer. Following are the returning values.
// 	 1	indicates EMPTY STRING passed to the function
//	 0 indicates VALID DATE
//	-1 indicates INVALID MONTH
//	-2 indicates INVALID DAY
//	-3 indicates INVALID YEAR
//	-4 indicates INVALID DAYS FOR THE MONTH
//	-5 indicates INVALID DAYS FOR FEBRUARY


function isValidDate(s)
{
	if ( IsEmpty(s) == true) 
	{
		return 1;
	}
	var inputdt = s;
	var inputmm, inputdd, inputyy;
	var firstSlashAt, secondSlashAt;
	var isFirstSlashFound = "NO", isSecondSlashFound = "NO";
	
	for( var i = 0; i < inputdt.length; i++)
	{
		if (inputdt.charAt(i) == "/" && isFirstSlashFound == "NO")
		{
			inputmm = inputdt.substring(0, i);
			firstSlashAt = i;
			isFirstSlashFound = "YES";
			continue;
		}
			
		if (inputdt.charAt(i) == "/" && isFirstSlashFound == "YES" && isSecondSlashFound == "NO")
		{
			inputdd = inputdt.substring(firstSlashAt+1, i);
			secondSlashAt = i;
			isSecondSlashFound = "YES";
			inputyy = inputdt.substring(secondSlashAt+1, inputdt.length);
			//alert ("mm>> " + inputmm);
			//alert ("dd>> " + inputdd) ;
			//alert ("yy>> " + inputyy) ;
			break;
		}	
	}
//	alert (inputmm + "/" + inputdd + "/" + inputyy);


var returnVal
returnVal = isDate(inputyy, inputmm, inputdd);
//alert ("returnVal>> " + returnVal);

return returnVal;

/*
if (returnVal == 0)
{
	alert ("Valid Date");
	return;
}	
else if (returnVal == -1)
{
	alert("Invalid Month");
	return;
}
else if (returnVal == -2)
{
	alert ("Invalid Day");
	return;
}
else if ( returnVal == -3)
{
	alert ("Invalid Year");
	return;
}			
else if ( returnVal == -4)
{
	alert ("Invalid Days For the month");
	return;
}			
else if ( returnVal == -5)
{
	alert ("Invalid Days For February");
	return;
}			
*/

}



/////////////////////////////////////////////////////////////////////////
// End of block of functions used for date validation function isValidDate.
////////////////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////////////////////
//	Function Name	:	ConfirmDelete()
//	Parameters		:	
//	Return Value	:	Boolean - true - valid
//								  false - invalid
//	Description		:	This function confirms a delete step
////////////////////////////////////////////////////////////////////

function ConfirmDelete()
{
	if (confirm ("Do you want to delete")) 
		return true;
	else
		return false;
}

/////////////////////////////////////////////////////////////////////
//	Function Name	:	IsQuotePresent()
//	Parameters		:	str		: String to be checked.
//	Return Value	:	Boolean - true - valid string
//								  false - invalid string
//	Description		:	This function checks whether the string pas a 
//						quote present in it or not
/////////////////////////////////////////////////////////////////////

function IsQuotePresent(str)
{
	for(i=0; i<str.length; i++)
	{
		if (str.charAt(i) == '"' )
		{
			return true;
		}
	}
	
	return false;
	
}

/////////////////////////////////////////////////////////////////
// Function Name	: IsFormatMatch()
// Description		: This script contains Format Check function
// Parameters		: strFormat	- Format. & strValue - Value to be checked for the format
// Author			: Vijayalakshmi
// Creation Date	: 10/08/1999
// Date Modified	Modified by     Comment
// 13/08/1999       vijayalakshmi   changed the Format check for character D in format
//									enetered - Now where ever D is present in format
//								    It will be checked for DD/MM/YYYY format in value
// 18/08/1999       vijayalakshmi   To make the function generic
//23/08/1999        VIJAYALAKSHMI	To change switch staetment as it does not work in Netscape 3.0
/////////////////////////////////////////////////////////////////
function IsFormatMatch(strFormat, strValue)
{
  var strReturn;
  if(IsEmpty(strFormat) || IsEmpty(strValue))
  {
    return strReturn;
  }
  if(strFormat == "D")
  { 
    if(!isValidDate(strValue)== 0)
    {
        strReturn = "The value should be a date in MM/DD/YYYY format";
        return strReturn;
    }   
    return strReturn;      
  }
  if(strFormat == "Y")       
  {
	if (! (strValue == "Y" || strValue == "N" || strValue == "y" || strValue == "n"))
	{
	   strReturn =  "please enter the value in the format "  + strFormat;
	   return strReturn;
	}
	return strReturn;
  }
  else
  { 
    var nValLen = 0;
    for (nCnt = 0; nCnt < strFormat.length ; nCnt++ ,nValLen++)
    {                 
        if(strFormat.charAt(nCnt) == "9")
        {
			if(! isIntegerInRange(strValue.charAt(nValLen), 0, 9)) 
			{
			   strReturn ="please enter the value in the format "  + strFormat;
			   return strReturn;
			}
		 	
        }
        else
        {
            if(strFormat.charAt(nCnt) == "A")
            {
              if (!((strValue.charAt(nValLen) >= 'a'&& strValue.charAt(nValLen) <= 'z')  || (strValue.charAt(nValLen) >= 'A' && strValue.charAt(nValLen) <= 'Z')))
              {
                  strReturn = "please enter the value in the format "  + strFormat;
                  return strReturn;
              }
            }
            else
            {  
  				if(strFormat.charAt(nCnt) == "X")
		  		{
		  		  //No check required - User can enter anything
		  	    }
		  	    else
		  	    {
		  		    if(strFormat.charAt(nCnt) == "D")		
		  		    {
		  			    var inputdt = strValue.substring(nValLen,strValue.length);
		  			    var inputmm, inputdd, inputyy;
		  				var firstSlashAt, secondSlashAt;
		  				var isFirstSlashFound = "NO", isSecondSlashFound = "NO";
		  				for( var nDtLen = 0; nDtLen < inputdt.length; nDtLen++)
		  				{
		  					if (inputdt.charAt(nDtLen) == "/" && isFirstSlashFound == "NO")
		  					{
		  						inputmm = inputdt.substring(0, nDtLen);
		  						firstSlashAt = nDtLen;
		  						isFirstSlashFound = "YES";
		  						continue;
		  					}
		  					if (inputdt.charAt(nDtLen) == "/" && isFirstSlashFound == "YES" && isSecondSlashFound == "NO")
		  					{
		  						inputdd = inputdt.substring(firstSlashAt+1, nDtLen);
		  						secondSlashAt = nDtLen;
		  						isSecondSlashFound = "YES";
		  						if (inputdt.length <  (nDtLen + 5))
		  						{
		  						  strReturn = "please enter the value in the format "  + strFormat;
		  						  return strReturn;
		  						}
		  						inputyy = inputdt.substring(secondSlashAt+1, secondSlashAt+5);
		  						//nCnt = nCnt + nDtLen + 5;
		  						nValLen = nValLen + nDtLen + 4;  
		  						break;
		  					}	
		  				}
		  				if(! isDate(inputyy, inputmm, inputdd) == 0)
		  				{
		  				       strReturn = "please enter the value in the format "  + strFormat;
		  				       return strReturn;
		  				}
		  			}
		  			else
		  			{	
		  			    if (strValue.charAt(nValLen) != strFormat.charAt(nCnt))
		  			    {
		  			        strReturn = "please enter the value in the format "  + strFormat;
		  			        return strReturn;
		  			    }
		  			}
		  		}
		  	}
		}	
    }
   }     
        if (strValue.length != nValLen)
        {
             strReturn = "please enter the value in the format "  + strFormat;
             return strReturn;
		}		
      
   return strReturn;
 }

/////////////////////////////////////////////////////////////////////
//	Function Name	:	IsDecimal()
//	Parameters		:	str - string	
//	Return Value	:	Boolean - true - valid
//								  false - invalid
//	Description		:	This function validates whether the input is numeric.
////////////////////////////////////////////////////////////////////
 
function IsDecimal(str)
{
var dotcount = 0;
	for(i=0; i<str.length; i++)
	{
	
		if(  ((str.charAt(i) >= '0') && (str.charAt(i) <= '9')) ||
			  (str.charAt(i) == '.'))
		{
			if (str.charAt(i) == '.') 
			{
				dotcount = dotcount + 1;
			}
			if (dotcount > 1)
				return false;
		}
		else 
			return false;
	}
	
	return true;
}


////////////////////////////////////////////////////////////////////////////////////
//	Function Name	:	IsAddress()
//	Parameters		:	Objects for address1,street_num,street_name,
//						suite,city,state_province,zip_code
//	Return Value	:	Boolean - true - valid
//								  false - invalid
//	Description		:	This function validates whether the addresses are validated.
////////////////////////////////////////////////////////////////////////////////////
function IsAddress(objadd,objstreetnum,objstreetname,objsuite,objcity,objstateprovince,objzipcode)
{
	var address = new Array(7);
	address[1] = new FillArray(objadd,"Address");
	address[2] = new FillArray(objstreetnum,"street num");
	address[3] = new FillArray(objstreetname,"street name");
	address[4] = new FillArray(objsuite,"suite");
	address[5] = new FillArray(objcity,"city");
	address[6] = new FillArray(objstateprovince,"state province");
	address[7] = new FillArray(objzipcode,"zip code");
	
	
	for (var i = 1 ; i<= 7 ; i++)
	{
		
		
		 if (i==2 || i==3)
		 {
			
			if (IsEmpty(address[i].obj.value))
			{
				alert(address[i].name + " cannot be empty");
				address[i].obj.focus();
				return false;
			}
		 }	
		
		if (IsQuotePresent(address[i].obj.value))
		{
			alert(address[i].name + " cannot have quotes");
			address[i].obj.focus();
			return false;
		}
		
	}	// End For loop
	
		if ((IsEmpty(address[5].obj.value)) &&  (IsEmpty(address[6].obj.value)))
		{
				
				if (IsEmpty(address[7].obj.value))
				{
					alert(address[7].name + " cannot be empty");
					address[7].obj.focus();
					return false;
				}
		}
		
		// Checking Zip code is an empty and one of other two is empty
		if (IsEmpty(address[7].obj.value))
		{
			if (IsEmpty(address[5].obj.value))
			 {	
				alert(address[5].name + " cannot be empty");
				address[5].obj.focus();
				return false;
			}
			if (IsEmpty(address[6].obj.value))
			{
					alert("Enter The state province ");
					address[6].obj.focus();
					return false;
			}
		}
		// Checking Zip code is an integer.
		//if (!(IsInteger(TrimSpaces(address[7].obj.value))))
		//{
		//		alert(address[7].name + " should be numeric");
		//		address[7].obj.focus();
		//		return false;
		//}
		
	return true;
}

function FillArray(obj , name)
{
	this.obj = obj;
	this.name = name;
}

/////////////////////////////////////////////////////////////////////
//	Function Name	:	checkCardNumWithMod10()
//	Parameters		:	cardnum - string	
//	Return Value	:	Boolean - true - valid
//				  false - invalid
//	Description	:	This function does a modulo 10 check on credit card number
////////////////////////////////////////////////////////////////////

function checkCardNumWithMod10(cardNum) {
var i;
var cc = new Array(16);
var checksum = 0;
var validcc;

// assign each digit of the card number to a space in the array
for (i = 0; i < cardNum.length; i++) {
  cc[i] = Math.floor(cardNum.substring(i, i+1));
}

// walk through every other digit doing our magic
// if the card number is sixteen digits then start at the
// first digit (position 0), otherwise start from the
// second (position 1)
for (i = (cardNum.length % 2); i < cardNum.length; i+=2) {
  var a = cc[i] * 2;
  if (a >= 10) {
   var aStr = a.toString();
   var b = aStr.substring(0,1);
   var c = aStr.substring(1,2);
   cc[i] = Math.floor(b) + Math.floor(c);
  } else {
   cc[i] = a;
  }
}

// add up all of the digits in the array
for (i = 0; i < cardNum.length; i++) {
  checksum += Math.floor(cc[i]);
}

// if the checksum is evenly divisble by 10
// then this is a valid card number
validcc = ((checksum % 10) == 0);

return validcc;
}

/////////////////////////////////////////////////////////////////////
//	Function Name	:	cleanCardNum()
//	Parameters		:	cardnum - string	
//	Return Value	:	newcard
//	Description	:	This function checks if card contains any special characters.
////////////////////////////////////////////////////////////////////

function cleanCardNum(cardNum) {
var i;
var ch;
var newCard = "";

// walk through the string character by character to build
// a new string with numbers only
i = 0;
while (i < cardNum.length) {
  // get the current character
  ch = cardNum.substring(i, i+1);
  if ((ch >= "0") && (ch <= "9")) {
   // if the current character is a digit then add it
   // to the numbers-only string we're building
   newCard += ch;
  } else {
   // not a digit, so check if its a dash or a space
   if ((ch != " ") && (ch != "-")) {
    // not a dash or a space so fail
    alert("The card number contains invalid characters.");
    return "";
   }
  }
  i++;
}

// we got here if we didn't fail, so return what we built
return newCard;
}

/////////////////////////////////////////////////////////////////////
//	Function Name	:	checkCard()
//	Parameters		:cardtype-string
//				cardnum - string	
//	Return Value	:	Boolean - True - Valid
//					  false - invalid
//	Description	:	This function validates credit card number for the type.
////////////////////////////////////////////////////////////////////

function checkCard(cardType, cardNum) {
var validCard;
var cardLength;
var cardLengthOK;
var cardStart;
var cardStartOK;

// check if the card type is valid
//if ((cardType != "BA") && (cardType != "IK") && (cardType != "AX") && (cardType != "DS") && (cardType != "DC") && (cardType != "CB"))
//{
// alert("Please select a valid card type.");
//  return false;
//}

// clean up any spaces or dashes in the card number
validCard = cleanCardNum(cardNum);
if (validCard != "") {
  // check the first digit to see if it matches the card type
	cardStart = validCard.substring(0,1); 
	var firstDigit = cardNum.substring(0,1);
	var secndDigit = cardNum.substring(1,2);
	var length = validCard.length;
	cardStartOK = ((cardType == "BA" && (firstDigit == 4 && (length == 16 || length == 13))) ||	(cardType == "IK" && (firstDigit ==5 && (secndDigit <= 5 && secndDigit >= 1) && length == 16)) || (cardType == "AX" && (firstDigit == 3 && (secndDigit == 4 || secndDigit == 7) && length == 15)) || (cardType == "DC" && (firstDigit == 3 && (secndDigit == 0 || secndDigit == 6 || secndDigit == 8) && length == 14)) || (cardType == "CB" && (firstDigit == 3 && (secndDigit == 0 || secndDigit == 6 || secndDigit == 8) && length == 14)) || (cardType == "DS" && (substring(0,4) == "6011" && length == 16)));	    
	if (!(cardStartOK)) {
	// card number's first digit doesn't match card type
	alert("Please make sure the card number you've entered matched the card type you selected and you have entered all the the digit's of the card number.");
	return false;
	}
  // card number seems OK so do the Mod10
  if (checkCardNumWithMod10(validCard)) 
  {
   return true;
  }
  else 
  {
   alert("Please make sure you've entered your card number correctly.");
   return false;
  }
} 
else 
{
  return false;
}
}

/////////////////////////////////////////////////////////////////////
//	Function Name	:loginNMchk()
//	Parameters		:alphanumeric
//				cardnum - string	
//	Return Value	:	Boolean - True - Valid
//					  false - invalid
//	Description	:	This function validates credit card number for the type.
//	Author		:	Arvind	
////////////////////////////////////////////////////////////////////
function LoginNmChk(StrObj) //Alpha numeric, ".", "_", "-" are allowed
{
	varflag = true;
	StrVal = StrObj.value;

	for(i=0; i < StrVal.length; i++)
	{
		if (!(((StrVal.charCodeAt(i) > 64) && (StrVal.charCodeAt(i) < 91)) ||
			 ((StrVal.charCodeAt(i) > 96) && (StrVal.charCodeAt(i) < 123)) ||
			 ((StrVal.charCodeAt(i) > 47) && (StrVal.charCodeAt(i) < 58)) ||
			 (StrVal.charCodeAt(i) == 95)||
			 (StrVal.charCodeAt(i) == 45)||
			 (StrVal.charCodeAt(i) == 46)))
		{
			return true;
			break;
		}
	}
}

/////////////////////////////////////////////////////////////////////
//	Function Name	: ChkSpclChrs
//	Parameters		: alphanumeric
//	Return Value	: String
//	Description		: This function validates special character
//	Author			: Arvind	
////////////////////////////////////////////////////////////////////

function ChkSpclChrs(StrVal)
{
	varflag = false;
	for(i=0; i < StrVal.length; i++)
	{

		if (!(((StrVal.charCodeAt(i) > 64) && (StrVal.charCodeAt(i) < 91)) ||
			 ((StrVal.charCodeAt(i) > 96) && (StrVal.charCodeAt(i) < 123)) ||
			 ((StrVal.charCodeAt(i) > 47) && (StrVal.charCodeAt(i) < 58)) ||
			 ((StrVal.charCodeAt(i) == 95))	))
		{
			varflag = true;
			break;
		}
	}
	return varflag;
}

/////////////////////////////////////////////////////////////////////
//	Function Name	: ChkSpclChrs2
//	Parameters		: alphanumeric
//	Return Value	: String
//	Description		: This function validates special character and allow space
//	Author			: Bheem Raj	
////////////////////////////////////////////////////////////////////

function ChkSpclChrs2(StrVal)
{
	varflag = false;
	for(i=0; i < StrVal.length; i++)
	{

		if (!(((StrVal.charCodeAt(i) > 64) && (StrVal.charCodeAt(i) < 91)) ||
			 ((StrVal.charCodeAt(i) > 96) && (StrVal.charCodeAt(i) < 123)) ||
			 ((StrVal.charCodeAt(i) > 47) && (StrVal.charCodeAt(i) < 58)) ||
			 ((StrVal.charCodeAt(i) == 95))||
			 ((StrVal.charCodeAt(i) == 32))	))
		{
			varflag = true;
			break;
		}
	}
	return varflag;
}
/////////////////////////////////////////////////////////////////////
//	Function Name	: NewPhone
//	Parameters		: numeric and "-"
//	Return Value	: String
//	Description		: This function validates special character and allow space,",","-","_","&"
//	Author		: Bheem Raj	dtd. 7-12-2002 (
////////////////////////////////////////////////////////////////////


function NewPhone(s)   
{
	for (var i = 0; i < s.length; i++)
	{
	if ((s.charAt(i) == 0) || (s.charAt(i) == 1) || 
		(s.charAt(i) == 2) || (s.charAt(i) == 3) ||
		(s.charAt(i) == 4) || (s.charAt(i) == 5) ||
		(s.charAt(i) == 6) || (s.charAt(i) == 7) ||
		(s.charAt(i) == 8) ||(s.charAt(i) == 9)||
		(s.charCodeAt(i) == 43)||(s.charCodeAt(i) == 45))
		{
			//alert ("inloop>> " + i + "   charat>> " + s.charAt(i));
			continue;
		}
	else 
		{

			//alert ("returning false for fnIsInteger");
			return false;
		}
	}
	//alert ("returning true for fnIsInteger");
	return true;
}
/////////////////////////////////////////////////////////////////////
//	Function Name	: ChkSearch
//	Parameters		: alphanumeric
//	Return Value	: String
//	Description		: This function validates special character and allow space,",","-","_","&"
//	Author			: Bheem Raj	
////////////////////////////////////////////////////////////////////

function ChkSearch(StrVal)
{
	varflag = false;
	for(i=0; i < StrVal.length; i++)
	{

		if (!(((StrVal.charCodeAt(i) > 64) && (StrVal.charCodeAt(i) < 91)) ||
			 ((StrVal.charCodeAt(i) > 96) && (StrVal.charCodeAt(i) < 123)) ||
			 ((StrVal.charCodeAt(i) > 47) && (StrVal.charCodeAt(i) < 58)) ||
			 ((StrVal.charCodeAt(i) == 95))||
			 ((StrVal.charCodeAt(i) == 32))||
   			((StrVal.charCodeAt(i) == 44)) ||
			((StrVal.charCodeAt(i) == 45)) ||
			((StrVal.charCodeAt(i) == 47)) ||
			((StrVal.charCodeAt(i) == 38)) ||
			((StrVal.charCodeAt(i) == 95))	))
		{
			varflag = true;
			break;
		}
	}
	return varflag;
}

/////////////////////////////////////////////////////////////////////
//	Application of functions
////////////////////////////////////////////////////////////////////

function SelectChk(varNo)
{
	if (varNo==0)
		document.ExistingBuyer.usertype[0].checked=true;
	else if (varNo==1)
		document.ExistingBuyer.usertype[1].checked=true;
	else if (varNo==2)
		if (document.ExistingBuyer.SuperUser.checked==true)
			document.ExistingBuyer.SuperUser.checked=false;
		else
			document.ExistingBuyer.SuperUser.checked=true;
}

function SelectSubUser()
{
	if (document.ExistingBuyer.SuperUser.checked==true)
		document.ExistingBuyer.SuperUser.checked=false;
	else
		document.ExistingBuyer.SuperUser.checked=true;
}


/////////////////////////////////////////////////////////////////////
//	Function Name	: Allication of function
//	Parameters		: Radio button value
//	Return Value	: String
//	Description		: This function validates alternate selection of radio buttons
//	Author			: Arvind	
////////////////////////////////////////////////////////////////////

function validateInput()
{
	if (document.ExistingBuyer.Login.value == '')
	{
		alert("Please enter your Login Name!");
		document.ExistingBuyer.Login.focus();
		//return false;
	}
	else if (LoginNmChk(document.ExistingBuyer.Login) == true)
	{
		alert("Special Characters are not allowed for Login Name!");
		document.ExistingBuyer.Login.focus();
		//return false;
	}
	else if (document.ExistingBuyer.Password.value == '')
	{
		alert("Please enter your Password!");
		document.ExistingBuyer.Password.focus();
		//return false;
	}
	else if (ChkSpclChrs(document.ExistingBuyer.Password.value) == true)
	{
		alert("Special Characters are not allowed for Password!");
		document.ExistingBuyer.Password.focus();
		//return false;
	}
	else
	{
		document.ExistingBuyer.action = "LoginValidate.asp";
		document.ExistingBuyer.method = "post";
		document.ExistingBuyer.submit();
		//return true;
	}
}

