<!--
var whitespace = " \t\n\r"
var zeros = "0\t\n\r"
var i
var optionChecked = ""


function autoTab(control, controllen, nextcontrol)
{
var digits = control.value.length +1
if (digits <= controllen)
	{
	control.focus()
	}
	else
	{
	nextcontrol.focus()
	}
} // end function autoTab


function checkPhone(areacode, midthree, lastfour)

{
// check phone is entered with correct length

if (!isWhitespace(areacode.value))
	{
	if(!checkLen(areacode, "3") || !checkLen(midthree, "3") || !checkLen(lastfour, "4"))
		{
		alert("Please correct the phone number")
		areacode.focus()
		areacode.select()
		return false	
		}


	// check phone is numeric


	if (!isNum(areacode.value) || !isNum(midthree.value) || !isNum(lastfour.value))
		{
		alert("Please correct the phone number")
		areacode.focus()
		areacode.select()
		return false
		}

	// check phone greater than zero

	if (isZeros(areacode.value) || isZeros(midthree.value) || isZeros(lastfour.value))
		{
		alert("Please correct the phone number");
		areacode.focus();
		areacode.select();
		return false;
		} 

	}

} // end checkPhone


function checkEmail(control)
{

if (!isWhitespace(control.value) && (control.value.indexOf("@",0) == "-1" || control.value.indexOf(".",0) == -1))
	{
	alert("Please enter a valid email")
	control.focus()
	control.select()	
	return false
	}

} // end checkEmail


function validateZip5(control)

{

	// check Zip code is entered with correct length

	if (isWhitespace(control.value) || !checkLen(control, "5"))
		{
		alert("Zip code must have 5 digits");
		control.focus();
		control.select();
		return false;
		}

	// check Zip code is numeric

	if (!isNum(control.value))
		{
	alert("This field must be numeric")
	control.focus()
	control.select()
	return false
		}

	// check Zip code is greater than 0

	if (isZeros(control.value))
		{
		alert("Zip code must be greater than 0");
		control.focus();
		control.select();
		return false;
		} 

} //end function validateZip5


function checkNum(control)

{

if (!isNum(control.value))
	{
	alert("This field must be numeric")
	control.focus()
	control.select()
	return false
	}

} // end checkNum
	

function checkZero(control)

{

if (isZeros(control.value))
	{
	alert("This field must be greater than 0")
	control.focus()
	control.select()	
	return false
	}

} // end checkZero
	

function checkRequiredEntry(control,controlname)
{

if (isWhitespace(control.value)) 
	{
	alert("Please complete " + controlname)
	control.focus()
	control.select()
	return false
	}

}// end checkRequiredEntry


function checkOptions(control, controlname)
{

for (i=0; i<control.length; i++)
	{
	if (control[i].checked)
		{
		optionChecked = control[i].value
		}
	}

if (isWhitespace(optionChecked))
	{
	alert("Please select a " + controlname)
	return false
	}
	else
	{
	return true
	}

}// end checkOptions


function RemoveBad(strTemp) 
{ 


    strTemp = strTemp.replace(/\<|\>|\"|\'|\%|\;|\(|\)|\&|\+|\*|\!|\#|\$|\^|\_|\=|\~|\{|\}|\[|\]|\:/g,""); 

//  strTemp = strTemp.replace(/\<|\>|\"|\'|\%|\;|\(|\)|\&|\+|\*|\!|\#|\$|\^|\_|\=|\~|\{|\}|\[|\]|\?|\:/g,""); 
    return strTemp;

}// end RemoveBad


// called sub functions


function isInteger(num)
{   
    for (i = 0; i < num.length; i++)
    {   
        var charNum = num.charAt(i);
        if (!(charNum >= 0 && charNum <= 9))
			{
			return true
			}
	}
}

function isNum(num)
{
	if (isInteger(num))
		{
		return false
		}
	return true
}

function isWhitespace(infield)
	{ 
  
	for (i = 0; i < infield.length; i++)
		{   
		var fieldchar = infield.charAt(i);
		if (whitespace.indexOf(fieldchar) == -1)
			{
			return false
			}
		}
	return true 
	}

function isZeros(infield)
	{ 
  
	for (i = 0; i < infield.length; i++)
		{   
		var fieldchar = infield.charAt(i);
		if (zeros.indexOf(fieldchar) == -1)
			{
			return false;
			}
		}
	return true 
	}


function checkLen(control, controllen)

{

if(control.value.length != controllen)
	{
	return false
	}
	else
	{
	return true
	}

} // end checkLen

//-->
