// Trims leading and trailing spaces from entry
function trim(entry)
{
  // Leading spaces
  while('' + entry.charAt(0) == ' ')
      entry = entry.substring(1, entry.length);

  // Trailing spaces
  while('' + entry.charAt(entry.length - 1) == ' ')
      entry = entry.substring(0, entry.length - 1);

  return entry;        
}
  
// Checks that a form field is non-empty
function validEntry(entry) 
{
  return (trim(entry) != ""); 
}

// Is this a valid email address?
// (TODO: maybe look up a more robust regular expression version?)
function validEmail(email) 
{
  var invalidChars = " /:,;"

  // email cannot be empty
  if (email == "") 
  {                      
    return false
  }

  // Does it contain any invalid characters?
  for (var i = 0; i < invalidChars.length; i++) 
  { 
    var badChar = invalidChars.charAt(i)

    if (email.indexOf(badChar, 0) > -1) 
    {
        return false
    }
  }

  // There must be one "@" symbol
  var atPos = email.indexOf("@", 1)       

  if (atPos == -1) 
  {
    return false
  }

  // and only one "@" symbol
  if (email.indexOf("@", atPos + 1) != -1) 
  {  
    return false
  }

  // and at least one "." after the "@"
  var periodPos = email.indexOf(".", atPos)

  if (periodPos == -1) 
  {                  
    return false
  }

  // Must be at least 2 characters after the "."
  if (periodPos + 3 > email.length)   
  {       
    return false
  }

  return true
}

function writeCopyright()
{
    document.write(' Copyright&copy; 2007-');
    var now = new Date();
    document.write(  + now.getFullYear() + '.');
    document.write(' S & G Tours. All Rights Reserved.');
}

function currentYear()
{
    var now = new Date();
    document.write(now.getFullYear());
}

function nextYear()
{
    var now = new Date();
    document.write(now.getFullYear() + 1);
}



