// script.js


function w(s) { document.write(s) }


function checkEmailAddress( s ) //returns 0 if OK
{
  if ( s == ''
    || s.indexOf(" ") > -1
    || s.indexOf("@") < 1
    || s.indexOf(".") < 1
    || s.indexOf("@") == s.length - 1
    || s.indexOf(".") == s.length - 1 )
      return 1
  return 0
}


function trim(x)
{
  while (x.length > 0 && x.substring(x.length-1,x.length) == " ")
    x = x.substring(0,x.length-1)
  while (x.length > 0 && x.indexOf(" ") == 0) x = x.substring(1)
  return x
}


function getCurrentTime() //using MySQL's DATETIME format
{
  var d = new Date()
  return d.getYear() + "-" + (d.getMonth()+1) + "-" + d.getDate()
    + " " + d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds()
}


function goHome()
{
  setTimeout("top.document.location.href='http://www.sapa-gp.org/index.html'",0)
}


function compress(x)
{
  x = trim(x)
  while((i = x.indexOf(' ')) > 0) x = x.substring(0,i) + x.substring(i+1)
  while((i = x.indexOf('\t')) > 0) x = x.substring(0,i) + x.substring(i+1)
  while((i = x.indexOf('\r')) > 0) x = x.substring(0,i) + x.substring(i+1)
  while((i = x.indexOf('\n')) > 0) x = x.substring(0,i) + x.substring(i+1)
  while((i = x.indexOf('-')) > 0) x = x.substring(0,i) + x.substring(i+1)
  return x
}
