
// STRING PROTOTYPES
  String.prototype.Trim = function() {return this.replace(/^\s+|\s+$/g, "");};
  String.prototype.stripHTML = function() {return this.replace(/(<([^>]+)>)/ig, "");}

  String.prototype.IsInteger = function()
  {
    var regex = /^[0-9]+$/;
    return regex.test(this);
  }
  String.prototype.IsFloat = function()
  {
    var regex = /^[0-9]+(,|\.)[0-9]+$/;
    return regex.test(this);
  }
  String.prototype.IsLetters = function()
  {
    var regex = /^[a-zA-Z]+$/;
    return regex.test(this);
  }
  String.prototype.IsDateNL = function()
  {
    var regex = /^(?:(?:(?:0?[1-9]|1\d|2[0-8])-(?:0?[1-9]|1[0-2]))-(?:(?:1[6-9]|[2-9]\d)\d{2}))$|^(?:(?:(?:31-((0)?[13578]|1[02]))|(?:(?:29|30)-(?:0?[1,3-9]|1[0-2])))-(?:(?:1[6-9]|[2-9]\d)\d{2}))$|^(?:29-0?2-(?:(?:(?:1[6-9]|[2-9]\d)(?:0[48]|[2468][048]|[13579][26]))))$/
    return regex.test(this);
  }
  String.prototype.IsFutureDateNL = function()
  {
    if (!this.IsDateNL()) return false;

    var date = this.toDateObject();
    var timestamp_datum = date.getTime();

    var today = new Date();
    var timestamp_today = today.getTime();

    return (timestamp_today < timestamp_datum);
  }
  String.prototype.toDateObject = function()
  {
    if (this.IsDateNL())
    {
      var array = this.replace(/\.|\/+/g, "-").split("-");

      var day = array[0];
      var month = array[1] - 1;
      var year = array[2];

      if (year.length == 2)
      {
        if (year >= 70) year = "19" + year;
        else year = "20" + year;
      }

      var date = new Date();
      date.setFullYear(year, month, day);
      return date;
    }
  }
  String.prototype.IsPostcode = function()
  {
    var regex = /^[1-9]{1}[0-9]{3}\ ?[A-Za-z]{2}$/;
    return regex.test(this);
  }
  String.prototype.IsTelNr = function()
  {
    var regex = /^[0-9]{2,4}-?[0-9]{2,4}-?[0-9]{6,8}$/;
    return regex.test(this);
  }
  String.prototype.IsURL = function()
  {
    var regex = /^((http|ftp|https):\/\/|www\.)[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?$/;
    return regex.test(this);
  }
  String.prototype.IsEmail = function()
  {
    var regex = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    return regex.test(this);

  }
  String.prototype.IsPrice = function()
  {
    var regex = /^[0-9]+(,|\.)?[0-9]{0,2}$/;
    return regex.test(this);
  }
  // * alle elementen worden geTRIM-ed, lege elementen worden het niet opgenomen
  String.prototype.toArray = function(delimiter)
  {
    var array = new Array();
    var new_array = new Array();

    if (typeof delimiter == "undefined") delimiter = ",";
    array = this.split(delimiter);

    for (x = 0; x < array.length; x++) array[x] = array[x].replace(/^\s+|\s+$/g,"");
    for (x = 0; x < array.length; x++) if (array[x].length > 0) new_array.push(array[x].replace(/^\s+|\s+$/g,""));

    return new_array;
  }


  // ARRAY PROTOTYPES
  // * alle elementen worden geTRIM-ed, lege elementen worden het niet opgenomen
  // * werkt niet met associatieve arrays
  Array.prototype.toString = function(delimiter)
  {
    var string = "";

    if (typeof delimiter == "undefined") delimiter = ",";

    for (x = 0; x < this.length; x++)
    {
      value = this[key].replace(/^\s+|\s+$/g, "");
      if (value.length > 0 && string.length > 0) string = string + delimiter + value;
      if (value.length > 0 && string.length == 0) string = value;
    }

    return string;
  }
  Array.prototype.merge = function(array)
  {
    var new_array = new Array();

    for (x = 0; x < this.length; x++) new_array.push(this[x]);
    for (x = 0; x < array.length; x++) new_array.push(array[x]);

    return new_array;
  }


  // DATE PROTOTYPES
  Date.prototype.toStringNL = function()
  {
    var day = this.getDate();
    var month = this.getMonth() + 1;
    var year = this.getFullYear();

    return day + "-" + month + "-" + year;
  }
  Date.prototype.toTimestamp = function()
  {
    var milliseconds = date.getTime();
    return ((milliseconds / 1000) - ((milliseconds % 1000) / 1000) - 2592000);
  }

  // OBJECT PROTOTYPES
  Object.prototype.setFocus = function()
  {
    this.focus();
    if (this.value) this.value = this.value;
  }
  