		function CheckNumeric(fld)
		{
			if (isNaN(fld.value))
			{
				alert('Please enter only numbers');
				fld.value="";
				fld.focus();
			}
		} 

		function CheckLoginName(fld)
		{
			var loginName;
			
			if (fld.value.length >0)
			{
				if((fld.value.length < 6) || (fld.value.length >15))
					{
					alert("Login name should be minimum 6 characters and maximum 15 characters");
					fld.focus();
					return
					}
			
				loginName=fld.value.charAt(0);
				
				if(! (isNaN(loginName)))
				{
					alert("Login Name should not start with Numbers/Empty Space.");
					fld.focus();
					return
				}
				
				
			}
					
		}
		
		function CheckChar(fld)
		{
			if(fld.value.length >0)
			{
			if((fld.value.length < 6) || (fld.value.length >15))
				{
				alert("Password should be minimum 6 characters and maximum 15 characters");
				fld.focus();
				return
				}
			}
		
		}
		
		function CharNumbers()
		{
			w=window.event.keyCode				
			if (w>64 & w<91 | w >96 & w <123 | w>47 & w<58 | w==8 | w==95)
			{
				return
			}				
			else
			{
				alert("Invalid characters.")
				window.event.keyCode=null
			}
		}
		
		function ValidateText(TextBoxControl) 
		{	var Text=TextBoxControl.value; 
			var reg = /^[\w]{0,100}$/g;
			if (reg.test(Text)<1)   
			{   alert('Special characters not allowed.'); 
				TextBoxControl.focus();   
			}  
		} 
		
		function CheckFeeAmount(txtfld)
		{			
			var totalamount, amount, Miscellaneous, CurrentDue, Fine;
			totalamount = document.forms[0].elements['txtPayAmtValidate'].value;
			Miscellaneous = document.forms[0].elements['hdnMiscellaneous'].value;
			CurrentDue = document.forms[0].elements['hdnCurrentDue'].value;
			Fine = document.forms[0].elements['hdnFineAmount'].value;
			PayAmount =  document.forms[0].elements['txtPayAmount'].value;
			
			amount = txtfld.value;
			
			for (i=0;i<=amount.length-1; i++ )
			{
				if(amount.charAt(i) == ",")
				{
					amount=amount.replace(',','');
				}
			}


			if (parseFloat(PayAmount) < parseFloat(Fine))
			{
				alert('Amount paid cannot be less than Fine Due amount.' );
				txtfld.focus();			
				return false;
			}

			if ( parseFloat(amount) < 1 )
			{
				alert ("Please enter a valid amount within the range of 1 to 99999999.99");
				return false;	
			}

			if ( parseFloat(amount) > 99999999.99 )
			{
				alert ("Please enter a valid amount within the range of 1 to 99999999.99");
				return false;
			}	
			
			for (i=0;i<=totalamount.length-1; i++ )
			{
				if(totalamount.charAt(i) == ",")
				{
					totalamount=totalamount.replace(',','');
				}
			}
			/*************************/
			
			
			if (document.forms[0].elements['chkMiscellaneous'].checked)
				{
					//if (parseFloat(amount) >  (parseFloat(totalamount)  + parseFloat(Miscellaneous)))
					if (parseFloat(amount) <  (parseFloat(Miscellaneous)  + parseFloat(Fine)))
					{
						alert('Amount paid cannot be less than the miscellaneous and fine amount.' );
						return false;
					}
				}
			
			if (window.Form1.cmbPayOptions.value=='Total')
			{
				if (document.forms[0].elements['chkMiscellaneous'].checked)
				{
					//if (parseFloat(amount) >  (parseFloat(totalamount)  + parseFloat(Miscellaneous)))
					if (parseFloat(amount) >  parseFloat(totalamount))
					{
						alert('Amount paid cannot be greater than Total Due amount and miscellaneous.' );
						return false;
					}
				}
				else if (parseFloat(amount) >  (parseFloat(totalamount) - parseFloat(Miscellaneous)))
				{
					alert('Amount paid cannot be greater than Total Due amount.' );
					return false;
				}
			}
			
			if (window.Form1.cmbPayOptions.value!='Total')
			{
			//	alert(PayAmount);
				if (document.forms[0].elements['chkMiscellaneous'].checked)
				{
					if (parseFloat(amount) >  (parseFloat(CurrentDue) + parseFloat(Fine)   + parseFloat(Miscellaneous)))
					{
						alert('Amount paid cannot be greater than Current Due amount and miscellaneous.' );
						return false;
					}
				}
				else
				{
					if (parseFloat(amount) >  (parseFloat(CurrentDue) + parseFloat(Fine)))
					{
						alert('Amount paid cannot be greater than Current Due amount.' );
						return false;
					}
				}
			}
			
			/*************************/
			if (parseFloat(amount) > parseFloat(totalamount) )
			{
				alert('Amount paid cannot be greater than Total Due amount.' );
				txtfld.focus();			
				return false;
			}
			
			
			
			//return false;
		}
		
		function CheckPayOption()
		{			
			var totalamount, amount, CurrentDue, Miscellaneous, Fine, PayAmount;
			totalamount = document.forms[0].elements['txtPayAmtValidate'].value;
			amount = document.forms[0].elements['hdnTotalAmount'].value;
			
			PayAmount =  document.forms[0].elements['txtPayAmount'].value;
			CurrentDue = document.forms[0].elements['hdnCurrentDue'].value;
			Miscellaneous = document.forms[0].elements['hdnMiscellaneous'].value;
			Fine = document.forms[0].elements['hdnFineAmount'].value;
			
			if (window.Form1.cmbPayOptions.value=='Total')
			{
				if (document.forms[0].elements['chkMiscellaneous'].checked)
				{
					document.forms[0].elements['txtPayAmount'].value = BRS(amount) ;// + parseFloat(Miscellaneous);
				}
				else
				{
					var diff = parseFloat(amount) - parseFloat(Miscellaneous);
					var val;
					try
					{
					//if the diff doesnt contain '.' then it throws up error, so why in exceptin adding'.00'
						val = BRS(diff);
					}
					catch(ex)
					{
						val = BRS(diff + '.00');
					}
					document.forms[0].elements['txtPayAmount'].value =  val;//(parseFloat(amount) - parseFloat(Miscellaneous));
				}
			}
			
			if (window.Form1.cmbPayOptions.value!='Total')
			{
				if (document.forms[0].elements['chkMiscellaneous'].checked)
				{
				
					var add = parseFloat(CurrentDue) + parseFloat(Fine);
					var val;
					

					try
					{
					//if the diff doesnt contain '.' then it throws up error, so why in exceptin adding'.00'
						val = BRS(add);
					}
					catch(ex)
					{
						val = BRS(add + '.00');
					}	
					document.forms[0].elements['txtPayAmount'].value =val;// parseFloat(CurrentDue) + parseFloat(Fine);// + parseFloat(Miscellaneous);
				}
				else
				{
				
					//var diff = parseFloat(amount) - parseFloat(Miscellaneous);
					var diff =  parseFloat(CurrentDue) + parseFloat(Fine) - parseFloat(Miscellaneous);
					var val;
					try
					{
					//if the diff doesnt contain '.' then it throws up error, so why in exceptin adding'.00'
						val = BRS(diff);
					}
					catch(ex)
					{
						val = BRS(diff + '.00');
					}
					document.forms[0].elements['txtPayAmount'].value = val;// BRS(parseFloat(amount) - parseFloat(Miscellaneous));
				}
			}
		}
		
		function BRS(Str) { // Str a String
  var L = Str.toString().length, P = Str.toString().indexOf('.'), Q
 
  if (P<0) return Str + ".00" // was integer
  if (P==L-2) return Str + "0" // was tenths
  if (P==L-3) return Str // was hundredths
  if (Str.charAt(0)=="-") return "-" + BRS(Str.substring(1)) // NEG
  Q = Str.substring(P+3) // tail
  if (Q<"5") return Str.substring(0, P+3)
  if (Q>"5") return BRS(String(0.0125 + +Str.substring(0, P+3)))
  // past here, a Bankers' decision is needed

  Q = Str.charCodeAt(P+2) % 2  ? +0.001 : -0.001
  alert(Str + 'its here');
  return BRS(String(Q + +Str)) }
		
	