// JavaScript Document

		function validation(oFormName)
		{
			var isSubmit=true;
			var msgs='';
			var AlertCount=0;
			var elements=document.forms[oFormName].elements;
			
			for(element=0;element<elements.length;element++)
			{
				var current=document.forms[oFormName].elements[element];
				while((current = current.parentElement)  && current.tagName !="TD");
					objecjTD=current;
				
				var msg=objecjTD.previousSibling.innerHTML;
				var objectvalue=document.forms[oFormName].elements[element].value;
				var objectclass=document.forms[oFormName].elements[element].className;
				var objecttype=document.forms[oFormName].elements[element].type;
				
				
				if (objectclass.indexOf('required')>-1 && isEmpty(objectvalue) && objecttype=='text')
				{
					
					AlertCount+=1;
					msgs=msgs+AlertCount+') '+msg+' required.'+'<Br/>';
					isSubmit=false;
				
				}
				if (objectclass.indexOf('required')>-1 && isEmpty(objectvalue) && objecttype=='password')
				{
					
					AlertCount+=1;
					msgs=msgs+AlertCount+') '+msg+' required.'+'<Br/>';
					isSubmit=false;
				
				}			
				if (objectclass.indexOf('required')>-1 && objecttype=='select-one')
				{
					
					if (document.forms[oFormName].elements[element].selectedIndex==0)
					{
						AlertCount+=1;
						msgs=msgs+AlertCount+') '+'Please select '+msg+'<Br/>';
						isSubmit=false;
					}
				}
					
				if (objectclass.indexOf('email')>-1 && !isEmail(objectvalue) && !isEmpty(objectvalue) && objecttype=='text')
				{
					AlertCount+=1;
					msgs=msgs+AlertCount+') '+'Enter Valid '+msg+'<Br/>';
					isSubmit=false;
				}
					
				if (objectclass.indexOf('url')>-1 && !isUrl(objectvalue) && !isEmpty(objectvalue) && objecttype=='text')
				{	
					AlertCount+=1;
					msgs=msgs+AlertCount+') '+'Enter Valid '+msg+'<Br/>';
					isSubmit=false;
				}
					
				if (objectclass.indexOf('date')>-1 && !isDate(objectvalue) && !isEmpty(objectvalue) && objecttype=='text')
				{
					AlertCount+=1;
					msgs=msgs+AlertCount+') '+'Enter Valid '+msg+'<Br/>';
					isSubmit=false;	
				}
				
				if (objectclass.indexOf('currency')>-1 && !isCurrency(objectvalue) && !isEmpty(objectvalue) && objecttype=='text')
				{
					AlertCount+=1;
					msgs=msgs+AlertCount+') '+'Enter Valid '+msg+'<Br/>';
					isSubmit=false;	
				}
				
				if (objectclass.indexOf('numeric')>-1 && !isNumeric(objectvalue) && !isEmpty(objectvalue) && objecttype=='text')
				{
					AlertCount+=1;
					msgs=msgs+AlertCount+') '+'Enter Valid '+msg+'<Br/>';
					isSubmit=false;	
				}
				
				if (objectclass.indexOf('integer')>-1 && !isInteger(objectvalue) && !isEmpty(objectvalue) && objecttype=='text')
				{
					AlertCount+=1;
					msgs=msgs+AlertCount+') '+'Enter Valid '+msg+'<Br/>';
					isSubmit=false;	
				}
				
				if (objectclass.indexOf('usphone')>-1 && !isUSPhone(objectvalue) && !isEmpty(objectvalue) && objecttype=='text')
				{
					AlertCount+=1;
					msgs=msgs+AlertCount+') '+'Enter Valid '+msg+'<Br/>';
					isSubmit=false;	
				}
				
				if (objectclass.indexOf('uszip')>-1 && !isUSZip(objectvalue) && !isEmpty(objectvalue) && objecttype=='text')
				{
					AlertCount+=1;
					msgs=msgs+AlertCount+') '+'Enter Valid '+msg+'<Br/>';
					isSubmit=false;	
				}
			}
			if (!isSubmit)
			{
				OpenModelPopup(msgs)
				return false;
			}//alert(msgs);
			else
			{
				//Code By Kalpa document.forms[oFormName].action Not owrking for this one	
				return true;
				//document.getElementById(oFormName).submit();
				//document.oFormName.submit();
			}
		}
		
		
	function trimAll( strValue ) {
	/************************************************
	DESCRIPTION: Removes leading and trailing spaces.
	
	PARAMETERS: Source string from which spaces will
	  be removed;
	
	RETURNS: Source string with whitespaces removed.
	*************************************************/
	 var objRegExp = /^(\s*)$/;
	
		//check for all spaces
		if(objRegExp.test(strValue)) {
		   strValue = strValue.replace(objRegExp, '');
		   if( strValue.length == 0)
			  return strValue;
		}
	
	   //check for leading & trailing spaces
	   objRegExp = /^(\s*)([\W\w]*)(\b\s*$)/;
	   if(objRegExp.test(strValue)) {
		   //remove leading and trailing whitespace characters
		   strValue = strValue.replace(objRegExp, '$2');
		}
	  return strValue;
	}
	
	function isEmpty( strValue ) {
	/************************************************
	DESCRIPTION: Validates that a string is not all
	  blank (whitespace) characters.
	
	PARAMETERS:
	   strValue - String to be tested for validity
	
	RETURNS:
	   True if valid, otherwise false.
	*************************************************/
	   var strTemp = strValue;
	   strTemp = trimAll(strTemp);
	   if(strTemp.length > 0){
		 return false;
	   }
	   return true;
	}
	
	function isInteger( strValue ) {
	/************************************************
	DESCRIPTION: Validates that a string contains only
		valid integer number.
	
	PARAMETERS:
	   strValue - String to be tested for validity
	
	RETURNS:
	   True if valid, otherwise false.
	**************************************************/
	  var objRegExp  = /(^-?\d\d*$)/;
	
	  //check for integer characters
	  return objRegExp.test(strValue);
	}
	
	function  isNumeric( strValue ) {
	/*****************************************************************
	DESCRIPTION: Validates that a string contains only valid numbers.
	
	PARAMETERS:
	   strValue - String to be tested for validity
	
	RETURNS:
	   True if valid, otherwise false.
	******************************************************************/
	  var objRegExp  =  /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;
	
	  //check for numeric characters
	  return objRegExp.test(strValue);
	}
	
	function  isCurrency( strValue ) {
	/*****************************************************************
	DESCRIPTION: Validates that a string contains only valid currency format.
	
	PARAMETERS:
	   strValue - String to be tested for validity
	
	RETURNS:
	   True if valid, otherwise false.
	******************************************************************/
	  var objRegExp  =  /^\s*\d+\.\d{2}\s*$/;
	
	  //check for numeric characters
	  return objRegExp.test(strValue);
	}
	
	function  isEmail( strValue ) {
	/*****************************************************************
	DESCRIPTION: Validates that a string contains a
	valid email pattern.
	
	PARAMETERS:
	strValue - String to be tested for validity
	
	RETURNS:
	True if valid, otherwise false.
	
	REMARKS: Accounts for email with country appended
	does not validate that email contains valid URL
	type (.com, .gov, etc.) or valid country suffix.
	******************************************************************/
	 // var objRegExp  = /(^[a-z]([a-z_\.]*)@([a-z_\.]*)([.][a-z]{3})$)|(^[a-z]([a-z_\.]*)@([a-z_\.]*)(\.[a-z]{3})(\.[a-z]{2})*$)/i;

	  var objRegExp  =  /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*\.(\w{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))$/
	
	  //check for numeric characters
	  return objRegExp.test(strValue);
	}
	
	function  isUrl( strValue ) {
	/*****************************************************************
	DESCRIPTION: Validates that a string contains only valid currency format.
	
	PARAMETERS:
	   strValue - String to be tested for validity
	
	RETURNS:
	   True if valid, otherwise false.
	******************************************************************/
	  var objRegExp  =  /http:\/\/[A-Za-z0-9\.-]{3,}\.[A-Za-z]{3}/;
	
	  //check for numeric characters
	  return objRegExp.test(strValue);
	}
	
	function  isDate( strValue ) {
	/*****************************************************************
	DESCRIPTION: Validates that a string contains only
    valid dates with 2 digit month, 2 digit day,
    4 digit year. Date separator can be ., -, or /.
    Uses combination of regular expressions and
    string parsing to validate date.
    Ex. mm/dd/yyyy or mm-dd-yyyy or mm.dd.yyyy

	PARAMETERS:
	   strValue - String to be tested for validity
	
	RETURNS:
	   True if valid, otherwise false.
	
	REMARKS:
	   Avoids some of the limitations of the Date.parse()
	   method such as the date separator character.
	******************************************************************/
	  var objRegExp  =  /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$/;
	
	  //check for numeric characters
	  return objRegExp.test(strValue);
	}

	function isUSPhone( strValue ) {
	/************************************************
	DESCRIPTION: Validates that a string contains valid
	  US phone pattern.
	  Ex. (999) 999-9999 or (999)999-9999
	
	PARAMETERS:
	   strValue - String to be tested for validity
	
	RETURNS:
	   True if valid, otherwise false.
	*************************************************/
	  var objRegExp  = /^\([1-9]\d{2}\)\s?\d{3}\-\d{4}$/;
	
	  //check for valid us phone with or without space between
	  //area code
	  return objRegExp.test(strValue);
	}
	
	function isUSZip( strValue ) {
	/************************************************
	DESCRIPTION: Validates that a string a United
	  States zip code in 5 digit format or zip+4
	  format. 99999 or 99999-9999
	
	PARAMETERS:
	   strValue - String to be tested for validity
	
	RETURNS:
	   True if valid, otherwise false.
	
	*************************************************/
	var objRegExp  = /(^\d{5}$)|(^\d{5}-\d{4}$)/;
	
	  //check for valid US Zipcode
	  return objRegExp.test(strValue);
	}






