function SwitchImage(sImage, sNewImage) { 
  document.images[sImage].src = sNewImage;
}

function contactwindow(ct){
  var x;
  x = ct;
  msgWindow = window.open(x,'Contact','top=150,left=200,width=500,height=400,resizable=yes'); 
}

function repwindow(pn){
  var x;
  x = pn;
  msgWindow = window.open(x,'jav','top=100,left=200,width=350,height=400,resizable=yes,scrollbars=yes'); 
}

function adminwindow(pn){
  var x;
  x = pn;
  msgWindow = window.open(x,'Admin','top=100,left=200,width=750,height=400,resizable=yes,scrollbars=yes'); 
}

function closepopup() {
  if (!msgWindow.closed)
      msgWindow.close();
}

function cal(newloc){
  window.location=newloc;
}

function closewin(){
  window.close();
}

function omenu(x){
  window.location=x;
}

function isLeadingSpace(field, errorString){
  var lc = field.value.charAt(0);
  if ((lc == ' ') || (lc == '\n')) {
    alert(errorString);
    field.focus();
    return (true);
  }
  return (false);
}

function isBlank(field, errorString){
  for (i=0; i < field.value.length; i++){
    var c = field.value.charAt(i);
    if ((c == ' ') || (c == '\n') || (c == '')) {
      alert(errorString);
      field.focus();
      return (true);
    }
  }
  return (false);
}

function isEmpty(field, errorString){
  if ((field.value == null) || (field.value.length == 0)){
    alert(errorString);
    field.focus();
    return (true);
  }
  return (false);
}

function isEmpty2(field){
  if ((field.value == null) || (field.value.length == 0)){
    return (true);
  }
  return (false);
}

function isWholeNumber(field, errorString){
  for (i=0; i < field.value.length; i++)
    if(isNaN(field.value)){
      alert(errorString);
      field.focus();
      return (false);
    }
  return (true);
}

function isNumeric(field, errorString){
  var ValidChars = '0123456789.';
  var Char;
  for (i = 0; i < field.value.length; i++){ 
    Char = field.value.charAt(i); 
    if (ValidChars.indexOf(Char) == -1){
      alert(errorString);
      field.focus();
      return (false);
    }
  }
  return (true);
}

function isNumeric2(field){
  var ValidChars = '0123456789.';
  var Char;
  for (i = 0; i < field.value.length; i++){ 
    Char = field.value.charAt(i); 
    if (ValidChars.indexOf(Char) == -1){
      return (false);
    }
  }
  return (true);
}

function isDate(field, errorString){
  var DtFormat = 'MM/DD/YYYY'
  if(field.value.indexOf("/") == -1){
    alert(errorString+DtFormat);
    field.focus();
    return (false);
  }
  var enteredDate = field.value.split("/")
  var enteredMonth = enteredDate[0];
  var enteredDay = enteredDate[1];
  var enteredYear = enteredDate[2];
  
  // Check that entered values are numeric.
  if(isNaN(enteredDay) || isNaN(enteredMonth) || isNaN(enteredYear)){
    alert(errorString+DtFormat);
    field.focus();
    return (false);
  }
  // Check that entered values are valid months, days, and years.
  var date2 = new Date(enteredMonth+'/'+enteredDay+'/'+enteredYear)
  var day2 = date2.getDate();
  var month2 = date2.getMonth()+1;
  var year2 = date2.getFullYear();
  if(enteredDay == day2 && enteredMonth == month2 && enteredYear == year2){
    return (true);
  }
  else{
    alert(errorString+DtFormat);
    field.focus();
    return (false);
  }
}

function isEmail(field, errorString){
  var email = ((field.value.indexOf("@") != -1) && (field.value.indexOf(".") != -1)); 
  if (!email){
    alert(errorString);
    field.focus();
    return (false);
  }
  return (true);
}

function isPhoneNum(field, errorString){
  var numcount = 0;
  for (i=0; i < field.value.length; i++){
    if ((field.value.charAt(i) >= "0") && (field.value.charAt(i) <= "9")){
      numcount = numcount + 1;
    }
  }
  if (numcount < 10){
    alert(errorString);
    field.focus();
    return (false);
  }
  return (true);
}

function ValidateCommuteCal()
{
  var errString = "You must enter a valid commute type as listed below the calendar.";
  var Carpool = "C";
  var Walk = "W";
  var Bike = "B";
  var Transit = "T";
  var Vanpool = "V";
  var numDays = formObj.eomDays.value;
  for (i=0; i < numDays; i++)
    if ((formObj.CommuteBy(i).value != null) && (formObj.CommuteBy(i).value.length != 0)){
      if (formObj.CommuteBy(i).value.toUpperCase() == " "){
        (formObj.CommuteBy(i).value.toUpperCase() = "")
      }
      if ((formObj.CommuteBy(i).value.toUpperCase() != Carpool) && 
          (formObj.CommuteBy(i).value.toUpperCase() != Walk) && 
          (formObj.CommuteBy(i).value.toUpperCase() != Bike) && 
          (formObj.CommuteBy(i).value.toUpperCase() != Transit) && 
          (formObj.CommuteBy(i).value.toUpperCase() != Vanpool)){
        alert(errString);
        formObj.CommuteBy(i).focus();
        return(false);
      }
    }
  return(true);
}

//----------------------------------------
	//strip non integer characters from a string.  Just send it a string - depends on "isCharInteger"
	function integerStripString(s)
	{
		var newString =""
		for (i = 0; i < s.length; i++)
		{
			var c = s.charAt(i)
			if (isCharInteger(c, i))
			{
				newString=newString+c
			}else{
				//do nothing
			}	
		}
		return newString;
	}
	
	
	//checks to see if an entire string is an integer
	function isStringInteger(s)
	{   var i;
		for (i = 0; i < s.length; i++)
		{   
			// Check that current character is number, or that the negative sign is in the right place.
			var c = s.charAt(i);
			if (!isCharInteger(c, i)) return false;
		}
		 // All characters are numbers and the negative sign is in the right place.
		return true;
	}
	
	function isCharInteger(c, i)
	//checks if a character is an integer, based off of the character, and its position in the string (IE "-" can only exist at the begining of an integer).
	{
		if (i == null)
		{
			i=0
		}
		 if ((((c < "0") || (c > "9")) && (c != "-")) || ((c == "-") && (i !=0 )))
		 {
			return false;
		 }
	return true;
	}

