//********************************************************
//Function for trimming blank spaces.
//argument:textbox
//use:restricts users from entering blank space.
function Trim(TRIM_VALUE){
if(TRIM_VALUE.length < 1){
return"";
}
TRIM_VALUE = RTrim(TRIM_VALUE);
TRIM_VALUE = LTrim(TRIM_VALUE);
if(TRIM_VALUE==""){
return "";
}
else{
return TRIM_VALUE;
}
} //End Function

function RTrim(VALUE){
var w_space = String.fromCharCode(32);
var v_length = VALUE.length;
var strTemp = "";
if(v_length < 0){
return"";
}
var iTemp = v_length -1;

while(iTemp > -1){
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(0,iTemp +1);
break;
}
iTemp = iTemp-1;

} //End While
return strTemp;

} //End Function

function LTrim(VALUE){
var w_space = String.fromCharCode(32);
if(v_length < 1){
return"";
}
var v_length = VALUE.length;
var strTemp = "";

var iTemp = 0;

while(iTemp < v_length){
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(iTemp,v_length);
break;
}
iTemp = iTemp + 1;
} //End While
return strTemp;
} //End Function

//********************************************************************
//function for checking whether textbox is blank.

function istbblank()
		{
		if (Trim(document.Form1.elements("TextBox1").value)=="")
			{
			alert("Name field cannot be blank")
			return false
			}
		
		}
		
//********************************************************************
//function for checking whether textbox is blank.
//arguments:control-which control ie textbox to be checked;msg-messsage to be shown to the user.

function istbblank1(control,msg)
		{
			if(Trim(document.Form1.elements(control).value)=="")
			{
			alert(msg)
			document.Form1.elements(control).focus();
			return false
			}
		}


//********************************************************************
//function for checking whether typed in charecters are numeric.
//arguments:controlvalue-textbox
//use:dosen't allow user to enter numeric charecters. 

		function isnumeric(e,obj,controlvalue)
	{
		var str=e.keyCode;
		str=parseInt(str);
  if(str<48 || str>57  ) 
 		{
	 		 
e.keyCode=0;
	 alert("Please enter numeric charecters only")
	 document.Form1.elements(controlvalue).focus()
 	
		}
			
  	}	
  	
 //********************************************************************
//function for checking whether typed in charecters are numeric.
//arguments:control-textbox
//use:dosen't allow user to enter numeric charecters and also more than two digits.ex:age
 	
  	function isage(e,obj,control)
		{
		
		var str=e.keyCode;
	 	str=parseInt(str);
  if(str<48 || str>57  ) 
	 		{
	 		 
 e.keyCode=0;
 	 alert("Please enter numeric charecters only")
 	 document.Form1.elements(control).focus()
 	
 	
			}
			else if(document.Form1.elements(control).value.length>1)
			{
			
			e.keyCode=0;
		alert("Please enter a valid age.")
		document.Form1.elements(control).focus()
		
			}
    	}
    	
    	
 //********************************************************************
//function for checking whether typed in charecters are numeric.
//arguments:control-textbox
//use:dosen't allow user to enter numeric charecters except "-".ex.0495-2306211
 	
    	function istelnum(e,obj,control)
		{
		var str=e.keyCode;
	 	str=parseInt(str);
  if((str<48 && str!=45) || str>57) 
	 	{
 e.keyCode=0;
 	 alert("Please enter numeric charecters only")
 	document.Form1.elements(control).focus()
 }
    	}
    	
    	
 //********************************************************************
//function for checking whether the value is a proper email address.
//arguments:control-textbox
//use: allow user to enter proper e-mail address only ex.lloydtgeorge@gmail.com
 	function isemail(control)
 	{
 	if(!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.Form1.elements(control).value))
		{
		alert("Please enter a valid email id")
		
		document.Form1.elements(control).focus()
		return false
		}
 	
 	}	
    
    	
    