/* $Id: library.js,v 1.4 2009/02/06 14:48:10 nuitari Exp $ */
/* $Source: /home/cvs/admin/library/library.js,v $ */

/******************************************************************************
**  Programmer: Stephane Bakhos
**  Date of last revision: $Date: 2009/02/06 14:48:10 $
**  File name: library.js
**  Package: main / admin
**
**  Changelog:
**    $Log: library.js,v $
**    Revision 1.4  2009/02/06 14:48:10  nuitari
**    Isnumeric
**
**    Revision 1.3  2008/08/20 16:47:37  nuitari
**    Added remove()
**
**    Revision 1.2  2008/06/05 14:31:56  nuitari
**    New permission system and copyright
**
**    Revision 1.1  2006/12/01 21:05:46  nuitari
**    Improved the listing of purchases again
**
**
**  Copyright 2002-2008 Maximum CRM,
**                      all rights reserved.
**
**  Library to contain various useful Javascript functions
**
******************************************************************************/

function show(id) {
  if (typeof(id) == 'string') {
    var id2 = document.getElementById(id);
    if (id2)
      id2.style.display = '';
  } else if (typeof(id) == 'object') {
    id.style.display = '';
  } else {
    alert(typeof(id));
  }
}

function hide(id) {
  if (typeof(id) == 'string') {
    var id2 = document.getElementById(id);
    if (id2)
      id2.style.display = 'none';
  } else if (typeof(id) == 'object') {
    id.style.display = 'none';
  } else {
    alert(typeof(id));
  }
}

function toggle(id) {
  if (typeof(id) == 'string') {
    var id2 = document.getElementById(id);
    if (id2) {
      if (id2.style.display == '')
        id2.style.display = 'none';
      else
        id2.style.display = '';
    }
  } else if (typeof(id) == 'object') {
    if (id.style.display == '')
      id.style.display = 'none';
    else
      id.style.display = '';
  } else {
    alert(typeof(id));
  }
}

function remove(id) {
  var id = document.getElementById(id);
  id.parentNode.removeChild(id);
}

function IsNumeric(sText) {
  var ValidChars = "0123456789.";
  var IsNumber=true;
  var Char;
  for (i = 0; i < sText.length && IsNumber == true; i++) {
    Char = sText.charAt(i);
    if (ValidChars.indexOf(Char) == -1) {
      IsNumber = false;
    }
  }
  return IsNumber;
}
