Object.extend(Array.prototype, {
  uniq: (function() {
    var temp = []
    for (i=0; i<this.length; ++i) {
      if (!temp.include(this[i])) {
        temp.push(this[i])
      }
    }
    return temp
  })
})

Object.extend(String.prototype, {
  cgiUnescape: function() {
    return decodeURIComponent(this.replace(/\+/g, " "))
  }
})

function notice(msg) {
  $('notice').show()
  $('notice').innerHTML = msg
}

Cookie = {
  put: function(name, value, days) {
    if (days == null) {
      days = 365
    }

    var date = new Date()
    date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000))
    var expires = "; expires=" + date.toGMTString()
    document.cookie = name + "=" + value + expires + "; path=/"
  },

  raw_get: function(name) {
    var nameEq = name + "="
    var ca = document.cookie.split(";")

    for (var i = 0; i < ca.length; ++i) {
      var c = ca[i]

      while (c.charAt(0) == " ") {
        c = c.substring(1, c.length)
      }

      if (c.indexOf(nameEq) == 0) {
        return c.substring(nameEq.length, c.length)
      }
    }

    return ""
  },
  
  get: function(name) {
    return this.unescape(this.raw_get(name))
  },
  
  remove: function(name) {
    Cookie.put(name, "", -1)
  },

  unescape: function(val) {
    return window.decodeURIComponent(val.replace(/\+/g, " "))
  }

  
}
