String.prototype.trim = function () 
{
  return this.replace(/^\s*/, "").replace(/\s*$/, "");
}

function validEmailAddress(strText)
{
  var blnValid;
  var re;

  if(strText == "" || strText == null)
  {
    return true;
  }
  // erhoward@prodigy.net
  re = /^[^@]+@([a-z0-9\-]+\.)+[a-z]{2,4}$/i;
  blnValid = re.test(strText);
  return blnValid;
}

function validPhoneNumber(strText)
{
  var blnValid;
  var re;

  if(strText == "" || strText == null)
  {
    return true;
  }
  // 609-882-2489 or (609) 882-2489
  re = /^((\d{3}-\d{3}-\d{4})|(\(\d{3}\)\s\d{3}-\d{4}))$/i;

  blnValid = re.test(strText);
  return blnValid;
}

function validSocialSecurityNumber(strText)
{
  var blnValid;
  var re;

  if(strText == "" || strText == null)
  {
    return true;
  }
  re = /^\d{3}-\d{2}-\d{4}$/i;  
  blnValid = re.test(strText);
  //alert(strText + " is " + (blnValid ? "valid" : "invalid"));
  return blnValid;
}

function validZipCode(strText)
{
  var blnValid;
  var re;

  if(strText == "" || strText == null)
  {
    return true;
  }
  re = /^\d{5}-\d{4}$/i;  
  blnValid = re.test(strText);
  //alert(strText + " is " + (blnValid ? "valid" : "invalid"));
  return blnValid;
}

function validChassisId(strText)
{
  var blnValid;
  var re;

  if(strText == "" || strText == null)
  {
    return true;
  }
  re = /^[A-Z]([A-Z]){0,3}[0-9]([0-9]){0,5}$/i;  
  blnValid = re.test(strText);
  //alert(strText + " is " + (blnValid ? "valid" : "invalid"));
  return blnValid;
}

function validISBN(strText)
{
  var blnValid;
  var re;

  if(strText == "" || strText == null)
  {
    return true;
  }
  re = /^\d{1}-\d{3}-\d{5}-\d{1}$/i;  
  blnValid = re.test(strText);
  //alert(strText + " is " + (blnValid ? "valid" : "invalid"));
  return blnValid;
}

function validDate(strText)
{
  var blnValid;
  var nDate;

  if(strText == "" || strText == null)
  {
    return true;
  }
  nDate = Date.parse(strText);
  blnValid = true;
  if(isNaN(nDate))
  {
    blnValid = false;    
  }

  //alert(strText + " is " + (blnValid ? "valid" : "invalid"));
  return blnValid;
}

function compareNumbers(nOne, nTwo)
{
  return nOne - nTwo;
}

function compareDates(dOne, dTwo)
{
  if(dOne < dTwo)
  {
    return -1;
  }
  else if(dOne == dTwo)
  {
    return 0;
  }
  else
  {
    return 1;
  }
}

function blink(sId, nInterval)
{
  var obj;

  if(document.getElementById)
  {
    if(document.getElementById(sId))
    {
      obj = document.getElementById(sId).style;

      if(obj.visibility == "hidden")
      {
        obj.visibility = "visible";
      }
      else
      {
        obj.visibility = "hidden";
      }
      window.setTimeout("blink('" + sId + "', " + nInterval + ");", nInterval);
    }
  }
}

function pulseFontWeight(sId, nInterval)
{
  var obj;
  if(document.layers)
  {
    obj = eval("document." + sId);
  }
  else if(document.all)
  {
    obj = eval("document.all." + sId + ".style");
  }
  else if(document.getElementById)
  {
    obj = document.getElementById(sId).style;
  }

  if(obj.fontWeight == "normal")
  {
    obj.fontWeight = "bold";
  }
  else
  {
    obj.fontWeight = "normal";
  }

  window.setTimeout("pulseFontWeight('" + sId + "', " + nInterval + ");", nInterval);
}

function checkBrowser(strHref)
{
  if(navigator.appName.indexOf("Microsoft") == -1)
  {
    window.location.href = strHref;
  }
}

function playMusic()
{
  nIndex = document.frmImgChg.selMusic.selectedIndex;
  sSong = document.frmImgChg.selMusic[nIndex].value;
  sName = document.frmImgChg.selMusic[nIndex].text;

  winMusic = window.open("", "winMusic", "height=100, width=500, toolbar=no, status=yes");
  winMusic.document.close();
  winMusic = window.open("", "winMusic", "height=100, width=500, toolbar=no, status=yes");
  winMusic.document.write("<embed src='" + sSong + "' hidden='false' autostart='true' name='midSong' controls='console' mastersound>");
  winMusic.status = sName;

}

