//CheckEmail
//Function validates a string passed in as an email, returns False if Valid Email
function checkEmail (strng) {
var error="";
if (strng == "") {
 return true;
}
    var emailFilter=/^[^@]+@[^@.]+\.[^@]*\w\w$/ ;
    if (!(emailFilter.test(strng))) { 
       return true;
    }
    else {
//test email for illegal characters
       var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/ ;
         if (strng.match(illegalChars)) {
          return true;
       }
    }
return false;    
}

//removeSpaces
//Removes Spaces from a passed string
function removeSpaces(string) {
	var tstring = "";
	string = '' + string;
	splitstring = string.split(" ");
	for(i = 0; i < splitstring.length; i++)
	tstring += splitstring[i];
	return tstring;
}

//checkPhone
//Checks phone number - strip out delimiters and check for 10 digits, returns false if valid phone number
function checkPhone (strng) {
var error = "";
if (strng == "") {
 return true;
}
var stripped = strng.replace(/[\(\)\.\-\ ]/g, '');
    if (isNaN(parseInt(stripped))) {
       return true;
  
    }
    if (!(stripped.length >= 10)) {
     return true;
    } 
return false;
}

//Checks Zip Code - returns false if valid Zip Code
function checkZip (strng) {
var error = "";
if (strng == "") {
 return true;
}
var stripped = strng.replace(/[\(\)\.\-\ ]/g, '');
    if (isNaN(parseInt(stripped))) {
       return true;
  
    }
    if (!(stripped.length == 5)) {
     return true;
    } 
return false;
}

//IsNumber
//Validates a string to see if it only contains integers
//Returns True if strng only conatins integers
function IsNumber (strng) {
 if (strng == "") { return false; }
 var stripped = strng.replace(/[\(\)\.\-\ ]/g, '');
 if (isNaN(parseInt(stripped))) { return false; }
 return true;
}


//isEmpty
//Returns False if a passed in string is Not Empty
function isEmpty(strng) {
var error = "";
  if (strng.length == 0) {
     return true;
  }
return false;	  
}

//ValidateDropDown
//Validates a drop down - determines if the passed in string is not equal to "null"
function ValidateDropDown(strng) {
if(strng == "null") { return true; }
else { return false; }
}

//Generic Error Message
//Display a generic error message to ask for help
function genericErrorMessage() { alert ("A problem occurred on our end, please e-mail the T-STEM Center at tstem@ttu.edu about this issue so we can fix it."); }

//toggleDisplay
//Toggles a div to either be hidden or shown
function toggleDisplay(id)
{ if (document.getElementById(id).style.display== '') {document.getElementById(id).style.display='none';}
  else {document.getElementById(id).style.display='';} }