
<!-- hide from non-js browsers

// bust out of frames... (commented out on 5 April 2002)
/*if (top.location != self.location) {
  top.location = self.location;
}*/

// function for links in popup windows to load in parent window...
function go(url) {
  opener.location.href = url;
}

// generic popup window...
function popUp(URL, name, Width, Height, Left, Top) {
    popwin=open(URL,name,'width=' + Width + ',height=' + Height + ',left=' + Left + ',top=' + Top + ',status=no,location=no,toolbar=no,menubar=no,resizable=yes,scrollbars=yes');
    popwin.focus();
	if (popwin.opener == null) popwin.opener = self; // we can use opener in popUp JS functions
}

// generic popup window...
function openViewlet(URL, Width, Height ) {
    popwin=open(URL,'Viewlet','width=' + Width + ',height=' + Height + ',left=100,top=100,status=no,location=no,toolbar=no,menubar=no,resizable=yes,scrollbars=yes');
    popwin.focus();
	if (popwin.opener == null) popwin.opener = self; // we can use opener in popUp JS functions
}
// medium popup window...
function popWin(URL, name) {
 popwin=open(URL,name,'width=400,height=400,left=200,top=150,status=no,location=no,toolbar=no,menubar=yes,resizable=yes,scrollbars=yes');
 popwin.focus();
 if (popwin.opener == null) popwin.opener = self; // we can use opener in popUp JS functions
}

// large popup window...
function popWin1(URL, name) {
 popwin=open(URL,name,'width=640,height=400,left=100,top=100,status=no,location=no,toolbar=yes,menubar=yes,resizable=yes,scrollbars=yes');
 popwin.focus();
 if (popwin.opener == null) popwin.opener = self; // we can use opener in popUp JS functions
}
// small popup window...
function popWin2(URL, name) {
 popwin=open(URL,name,'width=300,height=150,left=200,top=150,status=no,location=no,toolbar=no,menubar=no,resizable=yes,scrollbars=yes');
 popwin.focus();
 if (popwin.opener == null) popwin.opener = self; // we can use opener in popUp JS functions
}
// "WebCT is down for maintenance" alert for Tuesdays 5:30 - 7:30am...
function WebCTmaintenance() {
  now = new Date()
  if ((now.getDay() == 2) && (now.getHours() >= 0) && (now.getHours() <= 7.5)) {
  alert("Reminder: WebCT may be down for maintenance each Tuesday morning from 5:30am - 7:30am,\n which may prevent you from logging in at the next page.")
  }
  return true
}

// rollover image for "Log into WebCT"...
if (document.images) {
 loginOver = new Image
 loginOff = new Image
 loginOver.src = "/images/CIT_WebCT_login.gif"
 loginOff.src = "/images/CIT_WebCT_login1.gif"
} else {
 loginOver = ""
 loginOff = ""
 document.login = ""
}

// validation for search box...
function validateSearchBox(searchForm) {
 if (searchForm.search_query.value == "") {
  alert("You must enter a keyword to perform the search.")
  searchForm.search_query.focus()
  return false
 }
 return true
}


// check for valid email address...
function validEmail(email) {
 invalidChars = "/:,;<>#!"     // Specify invalid characters for email address field
 if (email == "") {            // Email address cannot be empty
  return false
 }
 for (i=0; i<invalidChars.length; i++) {     // Does the email address contain invalid characters?
  badChar = invalidChars.charAt(i)
  if (email.indexOf(badChar,0) > -1) {
   return false
  }
 }
 atPos = email.indexOf("@",1)       // There must be one "@" symbol
 if (atPos == -1) {
  return false
 }
 if (email.indexOf("@",atPos+1) > -1) {        // There must not be more than one "@" symbol
  return false
 }
 periodPos = email.indexOf(".",atPos)        // There must be at least one "." after the "@"
 if (periodPos == -1) {
  return false
 }
 if (periodPos+3 > email.length) {        // There must be at least 2 characters after the "."
  return false
 }
 return true
} // end check for valid email address

// check for valid campus phone number...
function validPhone(phone) {
 invalidChars = "/:;<>?!@#$%^&*abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"     // Specify invalid characters for phone # field
 if (phone == "") {            // Phone $ cannot be empty
  return false
 }
 for (i=0; i<invalidChars.length; i++) {     // Does the phone # contain invalid characters?
  badChar = invalidChars.charAt(i)
  if (phone.indexOf(badChar,0) > -1) {
   return false
  }
 }
 if (phone.length < 4) {        // There must be at least 4 characters in the phone #
  return false
 }
 return true
}


// "Not found" form validation...
function validateNotFound(notFoundForm) {
 // check for Name...
 if (notFoundForm.email.value != "") {
  if (!validEmail(notFoundForm.email.value)) {
   alert("You must enter a valid email address");
   notFoundForm.email.focus()
   notFoundForm.email.select()
   return false
  }
 }
 return true
}


// Class registration form validation...
function validateClassRegistration(classRegForm) {
 // check for Name...
 if (classRegForm.name.value == "") {
  alert("You must enter a name");
  classRegForm.name.focus()
  return false
 }
 // check for valid email...
 if (!validEmail(classRegForm.email.value)) {
   alert("You must enter a valid email address");
   classRegForm.email.focus()
   classRegForm.email.select()
   return false
 }
 // check for phone number...
 if (classRegForm.phone.value == "") {
  alert("You must enter a phone number.");
  classRegForm.phone.focus()
  return false
 }
 // check for status...
 statusChoice = classRegForm.status.selectedIndex
 if (classRegForm.status.options[statusChoice].value == "") {
  alert("You must select your status on campus: faculty, staff, or student.");
  classRegForm.status.focus()
  return false
 }
 // check for school...
 schoolChoice = classRegForm.school.selectedIndex
 if (classRegForm.school.options[schoolChoice].value == "") {
  alert("You must select your school or choose 'other' and specify a department.");
  classRegForm.school.focus()
  return false
 }
 // check for department if school = 'other'...
 if (classRegForm.school.options[schoolChoice].value == "other") {
  if (classRegForm.department.value == "") {
   alert("You must specify a department.")
   classRegForm.department.focus()
   return false
  }
 }
 // check for class date...
 classDate = classRegForm.class_date.selectedIndex
 if (classRegForm.class_date.options[classDate].value == "") {
  alert("You must select a date for the class you wish to enroll in.");
  classRegForm.class_date.focus()
  return false
 }
 // if all is well...
 return true
} // end class registration form validation


// "Contact Us" form validation...
function validateContactUs(contactUs) {
 // check for First Name...
 if ((contactUs.FirstName) && (contactUs.FirstName.value == "")) {
  alert("You must enter a first name");
  contactUs.FirstName.focus()
  return false
 }
 // check for Last Name...
 if ((contactUs.LastName) && (contactUs.LastName.value == "")) {
  alert("You must enter a last name");
  contactUs.LastName.focus()
  return false
 }
 // check for valid email...
 if (!validEmail(contactUs.email.value)) {
   alert("You must enter a valid email address");
   contactUs.email.focus();
   contactUs.email.select();
   return false
 }
 if (contactUs.email.value != contactUs.email_v2.value) {
   alert("You must verify your email address exactly");
   contactUs.email_v2.focus();
   contactUs.email_v2.select();
   return false
 }
 // a status must be chosen...
 if (contactUs.status) {
   statusChoice = contactUs.status.selectedIndex;
   if (contactUs.status.options[statusChoice].value == "") {
     alert("You must select a status.");
     contactUs.status.focus();
     return false
   }
 }
  // a school must be chosen...
 if (contactUs.school) {
   schoolChoice = contactUs.school.selectedIndex;
   if (contactUs.school.options[schoolChoice].value == "") {
     alert("You must select a school.");
     contactUs.status.focus();
     return false
   }
 
   // IF school is set to Other, then a department must be specified...
   if ((contactUs.school.options[schoolChoice].value == "other") && (contactUs.department.value == "")) {
     alert("With no school specified, you must enter a department");
     contactUs.department.focus()
     return false
   }
 }
 if (contactUs.category) {
   // a category must be chosen...
   categoryChoice = contactUs.category.selectedIndex
   if (contactUs.category.options[categoryChoice].value == "") {
     alert("You must select a category.");
     contactUs.category.focus()
     return false
   }
 }
 // check for question/comments...
 if ((contactUs.comments) && (contactUs.comments.value == "")) {
   alert("You must enter a description of your question or comments.");
   contactUs.comments.focus()
   return false
 }
 return true
} // end "Contact Us" form validation


// Problem tracking system Email form validation...
function validateProblemEmail(EmailForm) {
 // check for valid email...
 if (!validEmail(EmailForm.Email.value)) {
   alert("You must enter a valid email address");
   EmailForm.Email.focus()
   return false
 }
 if (EmailForm.Email.value != EmailForm.vEmail.value) {
   alert("The email addresses do not match.  Please verify your email address.");
   EmailForm.vEmail.focus()
   return false
 }
 return true
} // end PTS Email form validation


// Problem tracking system "Report a WebCT Problem" form validation...
function validateWebCTProblem(WebCTform) {
 // check for Name...
 /*
 if (WebCTform.Name.value == "") {
  alert("You must enter a name");
  WebCTform.Name.focus()
  return false
 }
 */
 if (WebCTform.FirstName.value == "") {
  alert("You must enter a first name");
  WebCTform.FirstName.focus()
  return false
 }
 if (WebCTform.LastName.value == "") {
  alert("You must enter a last name");
  WebCTform.LastName.focus()
  return false
 }
 // check for valid email...
 if (!validEmail(WebCTform.Email.value)) {
   alert("You must enter a valid email address");
   WebCTform.Email.focus()
   WebCTform.Email.select()
   return false
 }
 // check for date...
 if (WebCTform.Date.value == "") {
  alert("You must enter a date");
  WebCTform.Date.focus()
  return false
 }
 // check for time...
 if (WebCTform.Time.value == "") {
  alert("You must enter a time");
  WebCTform.Time.focus()
  return false
 }
 // a location must be chosen...
 locationChoice = WebCTform.Location.selectedIndex
 if (WebCTform.Location.options[locationChoice].value == "") {
  alert("You must select a location.");
  WebCTform.Location.focus()
  return false
 }
 // must fill in "other" details if location="other"
 if (WebCTform.Location.value == "other") {
  if (WebCTform.other_location.value == "") {
   alert("Since you have selected other as your location, you must specify the exact location.");
   return false
  }
 }
 // check for problem summary...
 if (WebCTform.Summary.value == "") {
  alert("You must fill in a summary of the problem.");
  WebCTform.Summary.focus()
  return false
 }
 // check for problem details...
 if (WebCTform.Problem.value == "") {
  alert("You must elaborate the details of the problem.");
  WebCTform.Problem.focus()
  return false
 }
 return true
} // end Problem Tracking System "Report a WebCT Problem" form validation


// validation for CIT News database insert form...
function validateCITnewsInsert(newsForm) {
 if (newsForm.News_Link.value == "") {
  alert("You must enter a News Link.")
  newsForm.News_Link.focus()
  return false
 }
 if (newsForm.News_Title.value == "") {
  alert("You must enter a News Title.")
  newsForm.News_Title.focus()
  return false
 }
 if (newsForm.News_Body.value == "") {
  alert("You must enter a News Body.")
  newsForm.News_Body.focus()
  return false
 }
 return true
} // end validation for CIT News database insert form


// validation for CIT News database email form...
function validateCITnewsEmail(mailForm) {
 if (mailForm.cc.value != "") {
  if (!validEmail(mailForm.cc.value)) {
   alert("You must enter a valid Cc: email address")
   mailForm.cc.focus()
   mailForm.cc.select()
   return false
  }
 }
 if (mailForm.bcc.value != "") {
  if (!validEmail(mailForm.bcc.value)) {
   alert("You must enter a valid Bcc: email address")
   mailForm.bcc.focus()
   mailForm.bcc.select()
   return false
  }
 }
 return true
} // end validation for CIT News database email form


// validation for CIT Mailing List subscription form...
function validateCITlistManage(listForm) {
 if (listForm.name.value == "") {
  alert("You must enter a name.")
  listForm.name.focus()
  return false
 }
 if (!validEmail(listForm.email.value)) {
   alert("You must enter a valid email address")
   listForm.email.focus()
   listForm.email.select()
   return false
 }
 return true
} // end validation for CIT Mailing List subscription form


// Consultation Database Email form validation...
function validateConsultEmail(EmailForm) {
 // check for valid email...
 if (EmailForm.listEmail.value == "") {
  if (!validEmail(EmailForm.Email.value)) {
   alert("You must enter a valid email address");
   EmailForm.Email.focus()
   return false
  }
  if (EmailForm.Email.value != EmailForm.vEmail.value) {
   alert("The email addresses do not match.  Please verify your email address.");
   EmailForm.vEmail.focus()
   return false
  }
 }
 return true
} // end Consultation Email form validation


// "Consultation Database Insert" form validation...
function validateConsultation(Consultform) {
 // check for Name...
 if (Consultform.Name.value == "") {
  alert("You must enter the Patron's name")
  Consultform.Name.focus()
  return false
 }
 // check for valid email...
 if (!validEmail(Consultform.Email.value)) {
   alert("You must enter a valid email address")
   Consultform.Email.focus()
   return false
 }
 // check for status...
 statusChoice = Consultform.Status.selectedIndex
 if (Consultform.Status.options[statusChoice].value == "") {
  alert("You must select a status for the client.")
  Consultform.Status.focus()
  return false
 }
 // check for school...
 schoolChoice = Consultform.School.selectedIndex
 if (Consultform.School.options[schoolChoice].value == "") {
  alert("You must select a school or choose 'other' and specify a department.")
  Consultform.School.focus()
  return false
 }
 // check for department if school = 'other'...
 schoolChoice = Consultform.School.selectedIndex
 if (Consultform.School.options[schoolChoice].value == "Other") {
  if (Consultform.Department.value == "") {
   alert("You must specify a department.")
   Consultform.Department.focus()
   return false
  }
 }
 // check for date...
 if (Consultform.Consult_Date.value == "") {
  alert("You must enter a consultation date.")
  Consultform.Consult_Date.focus()
  return false
 }
 re = /^\d\d\d\d-\d\d-\d\d$/
 if (re.test(Consultform.Consult_Date.value)) { return true
 } else { 
   alert("You must enter a correctly formatted date, such as 2002-01-01 for 1 Jan 2002.")
   Consultform.Consult_Date.focus()
   return false
 }
 // check for time...
 if (Consultform.Consult_Time.value == "") {
  alert("You must enter a consultation time");
  Consultform.Consult_Time.focus()
  return false
 }
 // a location must be chosen...
 locationChoice = Consultform.Location.selectedIndex
 if (Consultform.Location.options[locationChoice].value == "") {
  alert("You must select a location.");
  Consultform.Location.focus()
  return false
 }
 // must fill in "other" details if location="other"
 if (Consultform.Location.value == "other") {
  if (Consultform.other_location.value == "") {
   alert("Since you have selected 'other' as your location, you must specify the location.");
   return false
  }
 }
 // check for time spent...
 if (Consultform.Time_Spent.value == "") {
  alert("You must enter the time committed to the consultation");
  Consultform.Time_Spent.focus()
  return false
 }
 re = /^\d+$/
 if (re.test(Consultform.Time_Spent.value)) { return true 
 } else { 
   alert("You must enter only numbers for the amount of time spent, in minutes.");
   Consultform.Time_Spent.focus()
   return false
 }
 // check for summary...
 if (Consultform.Summary.value == "") {
  alert("You must enter a summary of the consultation");
  Consultform.Summary.focus()
  return false
 }
 // check for consult details...
 if (Consultform.Details.value == "") {
  alert("You must enter the details of the consultation.");
  Consultform.Details.focus()
  return false
 }
 return true
} // end "Consultation Database Insert" form validation

// validation for CIT Lab door code request form...
function validateCodeRequest(codeForm) {
 if (codeForm.FirstName.value == "") {
  alert("You must enter a first name.")
  codeForm.FirstName.focus()
  return false
 }
 if (codeForm.LastName.value == "") {
  alert("You must enter a last name.")
  codeForm.LastName.focus()
  return false
 }
 // check for status...
 statusChoice = codeForm.Status.selectedIndex
 if (codeForm.Status.options[statusChoice].value == "") {
  alert("You must select a status.")
  codeForm.Status.focus()
  return false
 }
 // check for Position if status=other...
 statusChoice = codeForm.Status.selectedIndex
 if (codeForm.Status.options[statusChoice].value == "other") {
  if (codeForm.Position.value == "") {
   alert("You must specify a position.")
   codeForm.Position.focus()
   return false
  }
 }
 // check for school...
 schoolChoice = codeForm.School.selectedIndex
 if (codeForm.School.options[schoolChoice].value == "") {
  alert("You must select a school or choose 'other' and specify a department.")
  codeForm.School.focus()
  return false
 }
 // check for department if school = 'other'...
 schoolChoice = codeForm.School.selectedIndex
 if (codeForm.School.options[schoolChoice].value == "other") {
  if (codeForm.Department.value == "") {
   alert("You must specify a department.")
   codeForm.Department.focus()
   return false
  }
 }
 if (!validEmail(codeForm.Email.value)) {
   alert("You must enter a valid email address")
   codeForm.Email.focus()
   return false
 }
 if (codeForm.Email.value != codeForm.vEmail.value) {
   alert("The email addresses do not match.  Please verify your email address.");
   codeForm.vEmail.focus()
   return false
 }
 if ((codeForm.Phone.value == "") || (!validPhone(codeForm.Phone.value))) {
  alert("You must enter a valid phone number.")
  codeForm.Phone.focus()
  return false
 }
 // check for department if school = 'other'...
 statusChoice = codeForm.Status.selectedIndex
 if ((codeForm.Status.options[statusChoice].value == "Staff") || (codeForm.Status.options[statusChoice].value == "Student")) {
  if (codeForm.Faculty_Sponsor.value == "") {
   alert("You must enter a faculty sponsor.")
   codeForm.Faculty_Sponsor.focus()
   return false
  }
  if (codeForm.Sponsor_Email.value == "") {
   alert("You must enter the sponsor's email address.")
   codeForm.Sponsor_Email.focus()
   return false
  }
 }
 return true
} // end validation for CIT Lab door code request form

// This function checks and unchecks boxes on a form
// Pass the Checkbox group name as the function argument...
// <input type="checkbox" name="my_checkbox_list" value="1">Value 1<br>
// <input type="checkbox" name="my_checkbox_list" value="2">Value 2<br>
// <input type=button name="CheckAll"   value="Check All"
	//onClick="checkAll(document.myform.my_checkbox_list)">
function checkAll(field)
{
for (i = 0; i < field.length; i++)
	field[i].checked = true ;
} // end checkAll function

// This function unchecks boxes on a form
// Pass the Checkbox group name as the function argument...
// <input type="checkbox" name="my_checkbox_list[]" value="1">Value 1<br>
// <input type="checkbox" name="my_checkbox_list[]" value="2">Value 2<br>
// <input type=button name="UnCheckAll" value="Uncheck All"
	//onClick="uncheckAll(document.getElementsByName('my_checkbox_list[]'))">
function uncheckAll(field)
{
for (i = 0; i < field.length; i++)
	field[i].checked = false ;
} // end uncheckAll function

// this function is used by setDateTime
function ensureDoubleDigit(input_value) {
  var new_value = input_value;
  if (new_value < 10) {
    new_value = "0" + new_value;
  }
  return new_value;
}

// This function places the date and time (YYY-DD-MM hr:mn:sc) into a form field
// Pass the form field name as the function argument...
// <input type="hidden" name="my_date_field" value="">
// <input type="text" name="my_date_field" value="">
// <input type=button name="SetDate" value="Date Stamp"
	//onClick="setDateTime(document.my_form_name.my_date_field[1])">
function setDateTime(formfield) {
  now_date = new Date();
  if (now_date.getYear() < 2000) {
  now_yyyy = (1900 + now_date.getYear());
  } else {
    now_yyyy = (now_date.getYear());
  }
  now_mm = ensureDoubleDigit((1 + now_date.getMonth()));
  now_dd = ensureDoubleDigit(now_date.getDate());
  now_hr = ensureDoubleDigit(now_date.getHours());
  now_mn = ensureDoubleDigit(now_date.getMinutes());
  now_sc = ensureDoubleDigit(now_date.getSeconds());
  formfield.value = ""+now_yyyy+"-"+now_mm+"-"+now_dd+" "+now_hr+":"+now_mn+":"+now_sc;
} // end function setDateTime

// This function places the date only (YYY-DD-MM) into a form field
// Pass the form field name as the function argument...
// <input type="hidden" name="my_date_field" value="">
// <input type="text" name="my_date_field" value="">
// <input type=button name="SetDate" value="Date Stamp"
	//onClick="setDateStamp(document.my_form_name.my_date_field[1])">
function setDateStamp(formfield) {
  now_date = new Date();
  if (now_date.getYear() < 2000) {
  now_yyyy = (1900 + now_date.getYear());
  } else {
    now_yyyy = (now_date.getYear());
  }
  now_mm = ensureDoubleDigit((1 + now_date.getMonth()));
  now_dd = ensureDoubleDigit(now_date.getDate());

  formfield.value = ""+now_yyyy+"-"+now_mm+"-"+now_dd;
} // end function setDateStamp

// This function places the date and time (YYY-DD-MM hr:mn:sc) into a form field
// Pass the form field name as the function argument...
// <input type="hidden" name="my_date_field" value="">
// <input type="text" name="my_date_field" value="">
// <input type=button name="SetDate" value="Date Stamp"
	//onClick="setDateTime(document.my_form_name.my_date_field[1])">
function setTimeStamp(formfield) {
  now_date = new Date();
  if (now_date.getYear() < 2000) {
  now_yyyy = (1900 + now_date.getYear());
  } else {
    now_yyyy = (now_date.getYear());
  }
  now_mm = ensureDoubleDigit((1 + now_date.getMonth()));
  now_dd = ensureDoubleDigit(now_date.getDate());
  now_hr = ensureDoubleDigit(now_date.getHours());
  now_mn = ensureDoubleDigit(now_date.getMinutes());
  now_sc = ensureDoubleDigit(now_date.getSeconds());
  formfield.value = ""+now_hr+":"+now_mn+":"+now_sc;
} // end function setTimeStamp

// end hide from non-js browsers -->
