function checkRadio(objradio, strcomment)
{
var flagcheck = 0;

	for (var i = 0; i < objradio.length; i++) 
	{
		if (objradio[i].checked == true)
		{
			flagcheck = 1;
		}
	}	
	
	if (flagcheck == 0)
	{
		strmsg = strmsg + "\n" + strcomment;
	}

	return(flagcheck);	
}

function checkCheckbox(formname, strStartName, intStartNum, intEndNum, intMinAnswers, intMaxAnswers, strcomment)
{
var flagcheck = 0;
var intCountAnswers = 0;

	for (var i = intStartNum; i <= intEndNum; i++) 
	{
		if (eval("formname." + strStartName + i + ".checked"))
		{
			++intCountAnswers;
		}
	}	

	if ((intCountAnswers >= intMinAnswers) && (intCountAnswers <= intMaxAnswers))
	{
		flagcheck = 1;
	}
	
	if (flagcheck == 0)
	{
		strmsg = strmsg + "\n" + strcomment;
	}

	return(flagcheck);	
}

function digitsOnly(afield, lowerbound, upperbound)
{
var strText, thelength;

	strText = afield.value;
	thelength = strText.length;
	i = 0;
	while (i < thelength)
	{
		reg = /[0-9]/;
		if (reg.test(strText.substr(i,1)) == false)
		{
			strText = strText.substring(0, i) + strText.substring(i+1);
		}
		else
		{
			i = i + 1;
		}
		thelength = strText.length;
	}

	if (strText > "")
	{
		if ((parseFloat(strText) < lowerbound) || (parseFloat(strText) > upperbound))
		{
			strText = "";
		}
	}
	afield.value = strText;
}

function removeQuotes(strValue)
{
	i = strValue.indexOf("\"");
	while (i > -1)
	{
		strValue = strValue.substr(0,i) + strValue.substr(i+1);
		i = strValue.indexOf("\"");
	}
	
	return(strValue);
}

function removeQuotesAddSingle(strValue)
{
	i = strValue.indexOf("\"");
	while (i > -1)
	{
		strValue = strValue.substr(0,i) + "'" + strValue.substr(i+1);
		i = strValue.indexOf("\"");
	}
	
	return(strValue);
}

function removeCRandLF(strValue)
{
	i = strValue.indexOf(String.fromCharCode(13,10));
	while (i > -1)
	{
		strValue = strValue.substr(0,i) + " " + strValue.substr(i+2);
		i = strValue.indexOf(String.fromCharCode(13,10));
	}

	i = strValue.indexOf(String.fromCharCode(10,13));
	while (i > -1)
	{
		strValue = strValue.substr(0,i) + " " + strValue.substr(i+2);
		i = strValue.indexOf(String.fromCharCode(10,13));
	}

	i = strValue.indexOf(String.fromCharCode(10));
	while (i > -1)
	{
		strValue = strValue.substr(0,i) + " " + strValue.substr(i+1);
		i = strValue.indexOf(String.fromCharCode(10));
	}

	i = strValue.indexOf(String.fromCharCode(13));
	while (i > -1)
	{
		strValue = strValue.substr(0,i) + " " + strValue.substr(i+1);
		i = strValue.indexOf(String.fromCharCode(13));
	}
	
	return(strValue);
}

function checkText(objtext, strcomment)
{
var flagcheck = 0;
var strText = "";
var strChar = "";
var x = 0;

	strText = objtext.value;
	if (strText > "")
	{
		strChar = strText.substr(x, 1);
		while ((strChar == " ") && (x < strText.length))
		{
			x = x + 1;
			if (x < strText.length)
			{
				strChar = strText.substr(x, 1);
			}
		}
		
		if (x > 0)
		{
			if (x == strText.length)
			{
				strText = "";
			}
			else
			{
				strText = strText.substr(x);
			}
		}
		
		objtext.value = strText;
		
		if (strText != "")
		{
			flagcheck = 1;
		}
	}
	
	if (flagcheck == 0)
	{
		strmsg = strmsg + "\n" + strcomment;
	}

	return(flagcheck);	
}
function checkEmail(afield, strerror)
{
var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
	if (re.test(afield.value) == false)
	{
		strmsg = strmsg + "\n" + strerror;
	}
}
