function isEmail(elm) {
  	var str = elm.value; // email string
		if (str == "" || str == null ) {
			alert("Please enter an email.");
			elm.focus();
  		elm.select();
			return false;
		} // checking for empty email.
		var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
  	var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid
  	if (!reg1.test(str) && reg2.test(str)) { // if syntax is valid
    			return true;
  		}
  	alert("\"" + str + "\" is an invalid e-mail!"); 
  		elm.focus();
  		elm.select();
  		return false;
}

function isFilled(elm) {
		//alert("I am in isFilled");
		if (elm.value == "" || elm.value == null)	{
            var newid = elm.id.replace("_"," ");
			alert("Please fill in the " + newid + " field.");
			elm.focus();
			elm.select();
			return false;
		}
		else {
			return true;
		}
}
	
function isPhone(elm) {
		var pattern = /[0-9]{3}-[0-9]{3}-[0-9]{4}/;
		if (pattern.test(elm.value)) {
			return true;
			}
			alert("Please enter the phone number in the following format: 123-456-7890");
			elm.focus();
			elm.select();
			return false;
}
	
function isInt(elm) {
		var pattern = /[^0-9]/;
		if (pattern.test(elm.value)) {
			alert("Please enter numbers only. Do not enter '$' ',' or other symbols.");
			elm.focus();
			elm.select();
			return false;
			}
			return true;
}

function isRadioChecked(elm) {    
    myOption = -1;
    //alert(myOption);
    for (i=elm.length-1; i > -1; i--) {
        if (elm[i].checked) {            
            myOption = i;
            i = -1;
            //alert(elm[myOption].value);
         }
    }
    if (myOption == -1) {
        alert("You must select a " + elm[0].id);
        elm[0].focus();
        return false;
    } else {
        return true;
    }
}
function isSelectChecked(elm) {
    //alert(elm.selectedIndex);
    //alert(elm.selectedIndex.value);
    if (elm.selectedIndex == '0') {
            var newid = elm.id.replace("_"," ");
            alert("Please choose one of the options for " + newid);
			//elm.focus();
			//elm.select();
			return false;
		}
		else {
			return true;
		}		
}

function isCheckBoxwithOther(elm1, elm2) {
    myOption = -1;
    for (i=elm1.length-1; i > -1; i--) {
        if (elm1[i].checked) {            
            myOption = i;
            i = -1;
            //alert(elm[myOption].value);
         }
    }
    if (myOption == -1) {
        if (elm2.value == "" || elm2.value == null)	{
			alert("Please fill in the " + elm1[0].id + " field.");
			elm1[0].focus();
			return false;
		}
		else {
			return true;
		}
    } else {
        return true;
    }
}






















