//used+++
function trim(text){
// Erase blank in the most left and most right sections of a string
  var i,j;
  for(i=0; text.charAt(i)==" " && i<text.length; i++){}
  if(i==text.length) return "";
  for(j=text.length-1; text.charAt(j)==" " && j>-1; j--){}
  return text.substring(i,j+1);
}

function BlankRadio(obj, n, msg)
{
temp=false
for(i=0; i<n; i++)
{
if (obj[i].checked)
{
temp=true
}
}
if (!temp)
{
alert(msg);
obj[0].focus();
return false;
}
return true;
}

//used+++
//check to see if fields are filled
function Blank(obj,msg) {
   if (trim(obj.value)=="") {
      alert(msg);
	  obj.focus();
	  return false;
      }
   return true;
}

//used+++
//check if one of the choices is selected in combo
function checkCombo(obj,msg) {
   if (obj.value==0) {
      alert(msg);
	  obj.focus();
	  return false;
      }
document.myForm.actions.value="view";
   return true;
}

//used+++
//check if textboxes are blank
function checkTextBox(obj,msg) {
   if (trim(obj.value)=="") {
      alert(msg);
	  obj.focus();
	  return false;
      }
document.myForm.actions.value="add";
   return true;
}


//check for valid email
function Check_EMail(obj,msg) {
var x = obj.value;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9])+$/;
	if (!filter.test(x)) 
{
alert(msg);
obj.focus();
return false;
}
return true;
}

//check the string consist of all integers
function IsChar(obj,message){
   if(isNaN(obj.value)==true){
		alert(message);
	    obj.focus();
		return false;
     }
return true;
}

//used+++
function CheckLength(obj, minchar, msg){  
   if (obj.value.length<minchar) {
       alert(msg);
	   obj.focus();
	   return false;   
} 
return true;
}


//used+++
function IsDateValid(obj){
var sDate, sMonth, sYear, sSymbol1, sSymbol2, sym;

sMonth = obj.value.substring(0,2);
sDate=obj.value.substring(3,5);
sYear=obj.value.substring(6,8);
sSymbol1=obj.value.substring(2,3);
sSymbol2=obj.value.substring(5,6);
sym="/";

if (sSymbol1 != sym || sSymbol2 != sym){
alert("Date should consist " + sym + " symbol");
obj.focus();
return false;
}

if((isNaN(sDate)) || (isNaN(sMonth)) || (isNaN(sYear))){
alert("Only integers allowed");
obj.focus();
return false;
}
return true;
}