stringtest=/^[a-zA-Z. ]{1,}$/;
emptytest = /^[ ]{1,}$/;
alphatest = /^[a-zA-Z0-9_]{1,}$/;
floattest = /^[0-9.+-]{1,}$/;
inttest = /^[0-9+-]{1,}$/;
currencytest = /^[0-9.,+-]{1,}$/;

function LTrim(str)
/*
   PURPOSE: Remove leading blanks from our string.
   IN: str - the string we want to LTrim
*/
{
   var whitespace = new String(" \t\n\r");

   var s = new String(str);

   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(str)
/*
   PURPOSE: Remove trailing blanks from our string.
   IN: str - the string we want to RTrim

*/
{
   // 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(str);

   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(obj)
/*
   PURPOSE: Remove trailing and leading blanks from our string.
   IN: str - the string we want to Trim

   RETVAL: A Trimmed string!
*/
{
	str=obj.value
    obj.value=RTrim(LTrim(str));
}

//----------------------------------------------------------------------------------------------------------------
function NumericValidate(e)
{
	e = e || window.event;	
	if (e.keyCode>=48 && e.keyCode<=57) 
	{
		return true;
	}
	else
	{
		return false;
	}
}

function SpecialCharValidation()
{// for `(96) &(38) "(34) '(39) 
				code=eval(event.keyCode)				
				if (code==96 || code==38 || code==34 || code==39)
				{event.keyCode=0;}
}

function PassportValidation()
{// for `(96) &(38) "(34) '(39) Space(32)
				code=eval(event.keyCode)				
				if (code==96 || code==38 || code==34 || code==39 || code==32)
				{event.keyCode=0;}
}

function PptValidation()
{
	code=eval(event.keyCode)		
	//alert(code);
		
	 if ((code >= 65 && code <= 90) || (code >= 97 && code <= 122) || (code >= 48 && code <= 57))
	 {}else
	 {
		event.keyCode=0;
	 }
}

function RefNoValidation()
{
	code=eval(event.keyCode)		
	//alert(code);
		
	 if ((code >= 65 && code <= 90) || (code >= 97 && code <= 122) || (code >= 48 && code <= 57) || (code == 47))
	 {}else
	 {
		event.keyCode=0;
	 }
}

function SpecialCharValidationprov()
{
    code=eval(event.keyCode)				
	if ((code >= 65 && code <= 90) || (code >= 97 && code <= 122) || (code >= 48 && code <= 57) || (code == 92) || (code == 32)|| (code == 45) || (code == 47))
	{}
	else{event.keyCode=0;}
}

function NameValidation()
{
		code=eval(event.keyCode)				
		if ((code >= 65 && code <= 90) || (code >= 97 && code <= 122) ||(code == 32))
		{}
		else
		{event.keyCode=0;}
}

function textCounter(obj,maxchar)
{
  if(obj.value.length > maxchar)
  {
    alert("Contents cannot exceed more than " + maxchar);
    obj.focus();
    return false;
  }
  else{return true;}
}
function AcceptNumerics()
{
	// for `(96) &(38) "(34) '(39) 
	code=eval(event.keyCode);						
	if (code<48 || code>57)
	{
	event.keyCode=0;
	}
}

function isEmailAddr(email)
{
  var result  = false;
  var theStr  = new String(email)
  var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

  if (filter.test(theStr))
  {result = true;}
  return result;
}

function OnKeyPressCheckNumeric(strField,e)
{
	//	Allow backspace  & tab keys
	if ((window.event.keyCode == 8) || (window.event.keyCode == 9) )
		return true;
	e= e || window.event		
		if ((e.keyCode>=48 && e.keyCode<=57) || (e.keyCode>=96 && e.keyCode<=105))
		{		
			return true;			
		}
		else
		{
			strField.value=strField.value.substring(0,strField.value.length-1);
			return;
		}
}
//----------------------------------------------------------------------------------------------------------------
function formatSSN(strField,mask,maxlen){
     var oLen = strField.value.length; 
	 var oLenIndex = oLen -1;
	 // Escape for backspace & tab keys
	if((window.event.keyCode == 8) || (window.event.keyCode == 9))
		return true;
	if(mask.charAt(oLenIndex) == '9')
	{
		var Unicodeval = strField.value.charCodeAt(oLenIndex);
		if(Unicodeval < 48 || Unicodeval > 57)
		{
			strField.value = strField.value.substring(0,oLenIndex);
			return;
		}
	}
	if(oLen < maxlen)
	{
		for(i=oLen;i<maxlen; i++)
		{
			if(mask.charAt(i) != '9' && mask.charAt(i) != 'X')
				strField.value += mask.substring(i,i+1);
			else
				break;
		}
	}
}

//----------------------------------------------------------------------------------------------------------------
	function checkValidEmail(obj)
	{
		if(!isEmailAddr(obj.value))
		{obj.value = "";return false;}
	}
	
	function isEmailAddr(email)
	{
			var result  = false;
			var theStr  = new String(email)
			var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

	  	   if (filter.test(theStr))
		   {result = true;}
			return result;
	}
			 
	function isEmail(objTxt)
	{
		var emailtest = /^[a-zA-Z0-9_.@-]{1,}$/;
		var emailString = objTxt.value;
		if(emailtest.test(emailString))
		{
			var iAt = emailString.indexOf('@');
			var iDot = emailString.indexOf('.');
			var iDot2 = emailString.lastIndexOf('.');
			iDot=(iDot==iDot2)?iDot:iDot2;

			if(iAt>0 && iDot>0 && (emailString.length-(iDot+1)==2 || emailString.length-(iDot+1)==3))
			{
				return true;
			}
			else
			{
				alert("Invalid Email, '@' or '.' missing. e.g abc@yahoomail.com"); 
				return false;
			}
		}
		else
		{
			alert("Wrong User name or Domain name in email address");
			return false;
		}
	}

//----------------------------------------------------------------------------------------------------------------

function fnUCase(obj)
{
	var strText = new String(obj.value);
	strText = strText.replace("'", "");
	strText = strText.replace("\"", "");
		
	var newstrText = new String();
	newstrText = strText.toUpperCase();
	obj.value = newstrText;
	return;
}

// Checking for trim
function isBlank(str)
{
	if (str.length == 0)
		return false;
		
	for (var i = 0; i < str.length; i++)
	{
		var ch = str.substring(i, i + 1);
		if(ch != " ")
		{
			return true;
		}
	}
	return false;
}


function IsNumeric(strString)
{
   var strValidChars = "0123456789.-";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   for (i = 0; i < strString.length && blnResult == true; i++)
   {
      strChar = strString.charAt(i);
      if(strValidChars.indexOf(strChar) == -1)
      {blnResult = false;}
   }

   return blnResult;
}

function CalculateFees(nodd)
{
   var totalddfees = 0;
			    
   var txtTotDDAmt = document.getElementById("RepBank__ctl" + (nodd + 1) + "_txtTotDDAmt");
   var txtPayment  = document.getElementById("txtPayment");
   var txtCash     = document.getElementById("txtCash");
			    
   for(h = 1 ; h <= nodd ; h++)
   {
       var txtAmount = document.getElementById("RepBank__ctl" + h + "_txtAmount");
		   
	   if(txtAmount.value == ""){txtAmount.value = 0;}
				   
	   totalddfees += parseInt(txtAmount.value);
  }
				
  if(nodd > 0 ){txtTotDDAmt.value = totalddfees;}
  if(txtCash.value == ""){txtCash.value = 0;}
  txtPayment.value = parseInt(txtCash.value) + totalddfees;
}
