// ****************************************************************************

//
// $Id: Archive.js, v. 1.0 2004/08/29 5:09 PM aselimovic Exp $
//

var ilsArchive = new ImageList();

with (ilsArchive) {
   addImage("/_gizmos/Archive/images/up-down-btn.gif");
   addImage("/_gizmos/Archive/images/up-down-btn-hover.gif");
}

function yearUpDown(value) {
   this.value = value || (new Date()).getFullYear();
   this.min = 1970;
   this.max = 2079;
   this.decrement = decrement;
   this.increment = increment;
   this.validate = validate;
}

function decrement() {
   if (this.validate() && checkRange(this.value - 1, this.min, this.max)) { return --this.value }
   return this.value;
}

function increment() {
   if (this.validate() && checkRange(Number(this.value) + 1, this.min, this.max)) { return ++this.value }
   return this.value;
}

function validate() {
   if (!/^\d{4}$/.test(this.value)) { return false }
   return true;
}

function checkRange(value, min, max) {
   if ((value < min) || (value > max)) { return false }
   return true;
}