﻿Array.prototype.add = function(obj){
  this[this.length] = obj;
}

Array.prototype.contains = function(item){
  return this.indexOf(item) >= 0;
}
Array.prototype.remove = function(val){
  var result = null;
  for(var i = 0; i < this.length; i++){
    if(this[i] === val){
      result = this[i];
      this.splice(i, 1);
      break;
    }
  }
  return result;
}

Hash.prototype.contains = function(key){
  var val = this.get(key);
  return val != null && typeof val != 'undefined';
}

Prototype.Browser.IE6 = (Prototype.Browser.IE && (typeof window.XMLHttpRequest == 'undefined'));

String.prototype.isValidEmail = function(){
  return /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,6}$/i.test(this);
}
String.prototype.toValidUrl = function(){
  var result = '/' + this.replace(/ /g, '_').replace(/[^\w\-_æøåÆØÅ]/g, '');
  for(var i = 0; i < arguments.length; i++){
    result += '/' + arguments[i].toString().replace(/ /g, '_').replace(/[^\w\-_æøåÆØÅ]/g, '');
  }
  return result;
}