function trim(inputString) {
      if (typeof inputString != "string") { return inputString; }
   var retValue = inputString;
      var ch = retValue.substring(0, 1);
      while (ch == " ") {
            retValue = retValue.substring(1, retValue.length);
            ch = retValue.substring(0, 1);
         }
      ch = retValue.substring(retValue.length-1, retValue.length);
      while (ch == " ") {
            retValue = retValue.substring(0, retValue.length-1);
            ch = retValue.substring(retValue.length-1, retValue.length);
         }
      while (retValue.indexOf("  ") != -1) {
            retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length);
         }
      return retValue;
   }

function updateClicks(banner) {
   var theUrl = 'index.php?updateClicks='+banner;
   http.open("GET",theUrl,true);
   http.onreadystatechange = function() {
                if (http.readyState == 4) {
                        if (http.status == 200) { return true; }
                  }
                }
   http.send(null);
   }
function getHTTPObject() {
   var xmlhttp;

   /*@cc_on
   @if (@_jscript_version >= 5)
      try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }
      catch (e) {
         try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
         catch (E) { xmlhttp = false; }
      }
      @else xmlhttp = false;
   @end @*/

   if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
      try { xmlhttp = new XMLHttpRequest(); }
      catch (e) { xmlhttp = false; }
      }

   return xmlhttp;
   }

var http = getHTTPObject();

function checksearch ( form ) {
   if (trim(form.criteria.value) == "") {
      form.criteria.focus();
      return false;
      }
   return true;
   }

function checkLogin(form) {
   if (trim(form.username.value) == "") {
      form.username.focus();
      return false;
      }
   if (trim(form.password.value) == "") {
      form.password.focus();
      return false;
      }
   return true;
   }

function checkCreate(form) {
   if (trim(form.username.value) == "") {
      form.username.focus();
      return false;
      }
   if (trim(form.email.value) == "") {
      form.email.focus();
      return false;
      }
   if (form.email.value != "") {
           var email=form.email.value;
           var check_space = email.indexOf(' ');
           var check_ast = email.indexOf('@');
           var check_dot = email.indexOf('.');
           if ((check_space != -1) || (check_ast == -1) || (check_dot == -1)) {
               form.email.focus();
               return false;
               }
      }
   if (trim(form.password1.value) == "") {
      form.password1.focus();
      return false;
      }
   if (trim(form.password2.value) == "") {
      form.password2.focus();
      return false;
      }
   if (trim(form.password1.value) != trim(form.password2.value)) {
      form.password1.focus();
      return false;
      }
   return true;
   }

function checkReset(form) {
   if (trim(form.email.value) == "") {
      form.email.focus();
      return false;
      }
   if (form.email.value != "") {
           var email=form.email.value;
           var check_space = email.indexOf(' ');
           var check_ast = email.indexOf('@');
           var check_dot = email.indexOf('.');
           if ((check_space != -1) || (check_ast == -1) || (check_dot == -1)) {
               form.email.focus();
               return false;
               }
      }
   return true;
   }

function checkResetVerify(form) {
   if (trim(form.code.value) == "") {
      form.code.focus();
      return false;
      }
   if (trim(form.pwd1.value) == "") {
      form.pwd1.focus();
      return false;
      }
   if (trim(form.pwd2.value) == "") {
      form.pwd2.focus();
      return false;
      }
   if (trim(form.pwd1.value) != trim(form.pwd1.value)) {
      form.pwd1.focus();
      return false;
      }
   return true;
   }

function checkContact(form) {
   if (trim(form.email.value) == "") {
      form.email.focus();
      return false;
      }
   if (form.email.value != "") {
           var email=form.email.value;
           var check_space = email.indexOf(' ');
           var check_ast = email.indexOf('@');
           var check_dot = email.indexOf('.');
           if ((check_space != -1) || (check_ast == -1) || (check_dot == -1)) {
               form.email.focus();
               return false;
               }
      }
   if (trim(form.question.value) == "") {
      form.question.focus();
      return false;
      }
   return true;
   }

function checkTell(form) {
   if (trim(form.username.value) == "") {
      form.username.focus();
      return false;
      }
   if (trim(form.password.value) == "") {
      form.password.focus();
      return false;
      }
   return true;
   }

function characterLimit() {

/*var characters = document.newDescform.newDesc.value*/
var characters = document.addForm.newDesc.value;

/* Why are we subtracting from 9 instead of 10? 
Because this function uses the onKeyPress event handler:
a value is not generated until the key is released: 
when the 1st key is PRESSED, length is zero.
*/
if (characters.length <= 299) {
/*document.newDescform.counter.value = "Remaining characters: " + (299 - characters.length)*/
document.addForm.counter.value = "Remaining characters: " + (299 - characters.length)
}
else {
/*document.newDescform.counter.value = "Over Limit by: " + (characters.length - 299) + " characters"*/
document.addForm.counter.value = "Over Limit by: " + (characters.length - 299) + " characters"
}
			
}

