// --------------------------------------------------
var whitespace = " \t\n\r";
// --------------------------------------------------
function isDate(s)
{
  if (isEmpty(s))
    return false;
  if (s.length != 10)
  	return false;  
  // There must be >= 1 character before /, so we start looking at character position 1
  // (i.e. second character)
  var i = 1;
  var sLength = s.length;
  // Look for /
  while ((i < sLength) && (s.charAt(i) != "/"))
  {
    i++
  }
  if ((i >= sLength) || (s.charAt(i) != "/"))
    return false;
  else
    i += 2;
  // Look for /
  while ((i < sLength) && (s.charAt(i) != "/"))
  {
    i++;
  }
  // There must be at least one character after the .
  if ((i >= sLength - 1) || (s.charAt(i) != "/"))
    return false;
  else
    return true;
}
// --------------------------------------------------
function isEmail(s)
{
  if (isEmpty(s))
    return false;
  // There must be >= 1 character before @, so we start looking at character position 1
  // (i.e. second character)
  var i = 1;
  var sLength = s.length;
  // Look for @
  while ((i < sLength) && (s.charAt(i) != "@"))
  {
    i++
  }
  if ((i >= sLength) || (s.charAt(i) != "@"))
    return false;
  else
    i += 2;
  // Look for .
  while ((i < sLength) && (s.charAt(i) != "."))
  {
    i++;
  }
  // There must be at least one character after the .
  if ((i >= sLength - 1) || (s.charAt(i) != "."))
    return false;
  else
    return true;
}
// --------------------------------------------------
function isEmpty(s)
{
  if (s == null)
    return true;
  else if (s.length == 0)
    return true;
  // Search through string's characters one by one until we find a non-whitespace character.
  // When we do, return false; if we don't, return true.
  else
  {
    var i;
    for (i = 0; i < s.length; i++)
    {   
      // Check that current character isn't whitespace.
      var c = s.charAt(i);
      if (whitespace.indexOf(c) == -1)
        return false;
    }
    // All characters are whitespace.
    return true;
  }
}
// --------------------------------------------------
function popup(strURL, intWidth, intHeight)
{
  window.open(strURL, "popup", "width=" + intWidth + ", height=" + intHeight + " top=" + (screen.height/2 - intHeight/2) + ", left=" + (screen.width/2 - intWidth/2) + ", location=no, menubar=no, resizable=no, scrollbars=no, titlebar=no, toolbar=no");
}
// --------------------------------------------------
function preload(imgSrc)
{
  if (document.images)
  {
    var imgObj = new Image();
    imgObj.src = imgSrc;
  }
}
// --------------------------------------------------
function roll(id, src)
{
  document.images[id].src = src;
}
// --------------------------------------------------
function showDate()
{
  var today = new Date();
  var months = new Array("enero","febrero","marzo","abril","mayo","junio","julio","agosto","septiembre","octubre","noviembre","diciembre");
  var str = today.getDate() + " de " + months[today.getMonth()] + " de " + today.getFullYear();
  document.write(str);
}
// --------------------------------------------------
