function ExacTime (lnk) {
	this.lnk = lnk;
	this.hh = new Array ();
	for (var i=0;i<24;i++) {
		this.hh[this.hh.length] = new Array ();
	}
	this.Add = function (hh, t) {
		for (var i=0; i<hh.length;i++) {
			this.hh[hh[i]][this.hh[hh[i]].length] = t;
		}
	}
	this.Interval = function (b, e) {
		var r = new Array ();
		if (b < e) {
			for (var i=b;i<=e;i++) {
				r[r.length] = i;
			}
		} else {
			for (var i=b;i<=23;i++) {
				r[r.length] = i;
			}
			for (var i=0;i<=e;i++) {
				r[r.length] = i;
			}
		}
		return r;
	} 
	this.get = function () {
		var a = new Array ("1","010001","065900", "2",   "070000","090000"   ,"3","090001","180000","4","180001","200000","5","200001","230000", "1","230001","070000");
		var s;
		for (var i=0; i < a.length; i+=3) {
			var b = parseInt(a[i+1].substr(0, 2).replace(/^0/,''));
			var e = parseInt(a[i+2].substr(0, 2).replace(/^0/,''));
			var interval = this.Interval (b, e);
			this.Add (interval, a[i])
			//если ноль минут
			if (interval.search (parseInt (this.lnk.exact_hh.value.replace(/^0/,''))) > -1 && this.lnk.exact_mm.value.replace(/^0/,'') == 0) {
				return new Array (a[i]);
			}
			//если больше нуля минут
			if ((s = interval.search (parseInt (this.lnk.exact_hh.value.replace(/^0/,'')))) > -1 && s +1 != interval.length) {
				return new Array (a[i]);
			}
		}
		return this.hh[parseInt (this.lnk.exact_hh.value.replace(/^0/,''))];
	}
	this.set = function () {
		res = this.get ()[0];
		for (var i=0;i<this.lnk.deltime.length;i++) {
			if (this.lnk.deltime.options[i].value == res) {
				this.lnk.deltime.options[i].selected = true
			}
		}
	} 
}

Array.prototype.search = function (val) {
  var result = new Array ();
  for (var i = 0; i < this.length; i++) {
   	if (this[i] == val) {
   		return i;
  	}
  }
  return -1;
}

