function checkRadioField(field)
{
var checkedIndex = -1;
var rCount=field.length;
if(isNaN(rCount)){if(field.checked)return 0;
else return -1;}
for (i=0;i<rCount;i++){if(field[i].checked)checkedIndex=i;}
return checkedIndex;
}
function validateRadioField(field,filedName,msg)
{
if (checkRadioField(field)==-1)
{
var rCount=field.length;
if(isNaN(rCount)){alert("The options for:\n\n "+filedName+"\n\nmust be selected."+msg);
field.focus();
}else{alert("One of the options for:\n\n "+filedName+"\n\nmust be selected."+msg);
field[0].focus();
}
return (false);
}
return true;
}
function validateSelectField(field,filedName,msg)
{
if(field.selectedIndex==0)
{
if(msg.length==0) alert('Please select one of the options for the field:\n\n'+filedName);
else alert('Please select one of the options '+msg+' for the field:\n\n'+filedName);
field.focus();
return (false);
}
return true;
}
function validateFieldMinMax(field,filedName,min,max,validationList,msg,msgS)
{
var checkStr=field.value;
var allValid=true;
var badC="";
if(min > 0 && field.value=="")
{
alert('Please enter a value for the field:\n\n'+filedName);
field.focus();
return (false);
}
if(min > 0 && field.value.length < min)
{
alert('Please enter at least '+min+' characters in the field:\n\n'+filedName);
field.focus();
return (false);
}
if(max > 0 && field.value.length > max)
{
alert("Please enter at most "+max+' characters in the field:\n\n'+ filedName);
field.focus();
return (false);
}
for(i=0;i<checkStr.length;i++)
{
	ch=checkStr.charAt(i);
	for(j=0;j<validationList.length;j++)
		if (ch==validationList.charAt(j))
			break;
	if (j==validationList.length)
	{
		allValid=false;
		badC=ch;
		break;
	}
}
if (!allValid)
{
	var msg1 = 'Please enter only ';
	var msg2 = ' characters in the field:\n\n'+filedName;
	if(msgS.length==0)
	{
		if(msg.length==0)
			alert(msg1+'letter and digit'+msg2);
		else
			alert(msg1+"letter and digit "+msg+msg2);
	}
	else
		alert("Note!   "+badC+"  is invalid character.\n\n"+msg1+msgS+msg2);
	
	field.focus();
	return (false);
}
else
	return (true);
}