/*  Mike Woolsey 
 *  April 26 2010
 *  Intelliresponse is a "knowledge engine" app purchased by the Admission 
 *  office.
 *  Site visitors type a question into a text field that is passed to 
 *  the intelliresponse server. This script appears on the future students 
 *  landing page.
 *--------------------------------------------------------------------------*/


var defaultStr = 'Type your question here';
 
function isBlank(q) {
  var whitespace = new String(" \t\n\r");
 
  for (var i = 0; i<q.length; i++) {
    if (whitespace.indexOf(q.charAt(i)) == -1) {
      return false;
    }
  }
 
  return true;
}
 
function submitForm(){
  var d = document.questionForm;
  if (!isValidForm())
    return;
 
  d.submit();
}
 
function isValidForm(){
  var d = document.questionForm;
  if (d.question.value==defaultStr  ||  isBlank(d.question.value)) {
    return false;
  }
 
  d.action=' http://uwrf.intelliresponse.com/results.jsp';
  d.requestType.value='NormalRequest';
  return true;
}
 
function topTen(){
  var d = document.questionForm;
  d.action=' http://uwrf.intelliresponse.com/topQuestions.jsp';
  d.submit();
}
 
function clearForm(){
  var d = document.questionForm;
  d.id.value=-1;
  d.reset();
  d.question.focus();
  d.question.value='';
}
