<!--
function setKalender(event) {
  var el, tableEl, rowEl, cellEl, linkEl;
  var tmpDate, tmpDate2;
  var i, j;
  el = document.getElementById("kalenderHuvud").firstChild;
  el.nodeValue = targetDate.getMonthName() + "\u00a0" + targetDate.getFullYear();
  tmpDate = new Date(Date.parse(targetDate));
  tmpDate.setDate(1);
  while (tmpDate.getDay() != 0) {     
    tmpDate.addDays(-1);
  }

  nolla();
 tableEl = document.getElementById("kalender");
  for (i = 2; i <= 7; i++) {
    rowEl = tableEl.rows[i];
    tmpDate2 = new Date(Date.parse(tmpDate));
    tmpDate2.addDays(6);
    if (tmpDate.getMonth()  != targetDate.getMonth() &&
        tmpDate2.getMonth() != targetDate.getMonth()) {
      rowEl.style.visibility = "hidden";
      if (document.all)
        for (j = 0; j < rowEl.cells.length; j++)
          rowEl.cells[j].style.borderStyle = "none";
    }
    else {
      rowEl.style.visibility = "";
      if (document.all)
        for (j = 0; j < rowEl.cells.length; j++)
          rowEl.cells[j].style.borderStyle = "";
    }
    for (j = 0; j < rowEl.cells.length; j++) {
      cellEl = rowEl.cells[j];
      linkEl = cellEl.firstChild;
      if (tmpDate.getMonth() == targetDate.getMonth()) {
        linkEl.date = new Date(Date.parse(tmpDate));
        s = tmpDate.toString().split(" ");
        linkEl.title = s[0] + " " + s[2] + " " + s[1] + " " + s[s.length - 1];
        linkEl.firstChild.nodeValue = tmpDate.getDate();
        linkEl.style.visibility = "";
      }
      else


        linkEl.style.visibility = "hidden";
      if (cellEl.oldClass == null)
        cellEl.oldClass = cellEl.className;
      if (Date.parse(tmpDate) == Date.parse(targetDate))
        cellEl.className = cellEl.oldClass + " target";
      else
        cellEl.className = cellEl.oldClass;
	displayDate;		
      tmpDate.addDays(1);
    }
  }
}

function nolla(event) {
	document.Kalkyl.Utfalt.value = ""
	document.Kalkyl.Utfalt1.value = ""
	document.Kalkyl.Utfalt2.value = ""
	document.Kalkyl.Utfalt3.value = ""
	document.Kalkyl.Utfalt21.value = ""
	document.Kalkyl.Utfalt22.value = ""
	document.Kalkyl.Utfalt23.value = ""
}

function addMonths(event, n) {
  targetDate.addMonths(n);
  setKalender(event);
}

function addYears(event, n) {
  targetDate.addYears(n);
  setKalender(event);
}

function setTargetDate(event, link) {
  if (link.date != null) {
    targetDate = new Date(Date.parse(link.date));
    setKalender(event);
	displayDate(event);
  }
}

function displayDate(event) {
  formatDate(targetDate);
}

function formatDate() {
  var mm, dd, yyyy, berDate, berDate1;
		vDagen = new Array
			vDagen[0] = "Sunday"
			vDagen[1] = "Monday"
			vDagen[2] = "Tuesday"
			vDagen[3] = "Wednesday"
			vDagen[4] = "Thursday"
			vDagen[5] = "Friday"
			vDagen[6] = "Saturday"
			vDagen[7] = "Sunday"
		var manad = new Array()
			manad[0] = "January"
			manad[1] = "February"
			manad[2] = "March"
			manad[3] = "April"
			manad[4] = "May"
			manad[5] = "June"
			manad[6] = "July"
			manad[7] = "August"
			manad[8] = "September"
			manad[9] = "October"
			manad[10] = "November"
			manad[11] = "December";
  berDate1 = new Date(targetDate);
  berDate = new Date();
  berDate.setTime(berDate1.getTime()+ (21*24*60*60*1000));
  mm = String(manad[berDate.getMonth()]);
  dd = String(berDate.getDate());
  yyyy = String(berDate.getFullYear());
  while (yyyy.length < 4)
    yyyy = "0" + yyyy;
	document.Kalkyl.Utfalt.value = vDagen[berDate.getDay()] + " " + dd + " " + mm + " " + yyyy; 
  berDate = new Date();
  berDate.setTime(berDate1.getTime()+ (61*24*60*60*1000));
  mm = String(manad[berDate.getMonth()]);
  dd = String(berDate.getDate());
  yyyy = String(berDate.getFullYear());
  while (yyyy.length < 4)
  yyyy = "0" + yyyy;
  document.Kalkyl.Utfalt2.value = vDagen[berDate.getDay()] + " " + dd + " " + mm + " " + yyyy; 
  berDate = new Date();
  berDate.setTime(berDate1.getTime()+ (65*24*60*60*1000));
  mm = String(manad[berDate.getMonth()]);
  dd = String(berDate.getDate());
  yyyy = String(berDate.getFullYear());
  while (yyyy.length < 4)
    yyyy = "0" + yyyy;
	document.Kalkyl.Utfalt1.value = vDagen[berDate.getDay()] + " " + dd + " " + mm + " " + yyyy; 
  berDate = new Date();
  berDate.setTime(berDate1.getTime()+ (70*24*60*60*1000));
  mm = String(manad[berDate.getMonth()]);
  dd = String(berDate.getDate());
  yyyy = String(berDate.getFullYear());
  while (yyyy.length < 4)
    yyyy = "0" + yyyy;
	document.Kalkyl.Utfalt3.value = vDagen[berDate.getDay()] + " " + dd + " " + mm + " " + yyyy; 
  berDate = new Date();
  berDate.setTime(berDate1.getTime()+ (145*24*60*60*1000));
  mm = String(manad[berDate.getMonth()]);
  dd = String(berDate.getDate());
  yyyy = String(berDate.getFullYear());
  while (yyyy.length < 4)
    yyyy = "0" + yyyy;
	document.Kalkyl.Utfalt22.value = vDagen[berDate.getDay()] + " " + dd + " " + mm + " " + yyyy; 
  berDate = new Date();
  berDate.setTime(berDate1.getTime()+ (149*24*60*60*1000));
  mm = String(manad[berDate.getMonth()]);
  dd = String(berDate.getDate());
  yyyy = String(berDate.getFullYear());
  while (yyyy.length < 4)
    yyyy = "0" + yyyy;
	document.Kalkyl.Utfalt21.value = vDagen[berDate.getDay()] + " " + dd + " " + mm + " " + yyyy; 
  berDate = new Date();
  berDate.setTime(berDate1.getTime()+ (154*24*60*60*1000));
  mm = String(manad[berDate.getMonth()]);
  dd = String(berDate.getDate());
  yyyy = String(berDate.getFullYear());
  while (yyyy.length < 4)
    yyyy = "0" + yyyy;
	document.Kalkyl.Utfalt23.value = vDagen[berDate.getDay()] + " " + dd + " " + mm + " " + yyyy; 
  return dd + " " + mm + " " + yyyy;
}

Date.prototype.monthNames = new Array("January", "February", "March", "April",
  "May", "June", "July", "August", "September", "October", "November", "December");

Date.prototype.savedDate  = null;

Date.prototype.getMonthName = dateGetMonthName;

Date.prototype.getDays      = dateGetDays;

Date.prototype.addDays      = dateAddDays;

Date.prototype.addMonths    = dateAddMonths;

Date.prototype.addYears     = dateAddYears;

function dateGetMonthName() {
  return this.monthNames[this.getMonth()];
}

function dateGetDays() {
  var tmpDate, d, m;
  tmpDate = new Date(Date.parse(this));
  m = tmpDate.getMonth();
  d = 28;
  do {
    d++;
    tmpDate.setDate(d);
  } while (tmpDate.getMonth() == m);
  return d - 1;
}

function dateAddDays(n) {
  this.setDate(this.getDate() + n);
  this.savedDate = this.getDate();
}

function dateAddMonths(n) {
  if (this.savedDate == null)
    this.savedDate = this.getDate();
  this.setDate(1);
  this.setMonth(this.getMonth() + n);
  this.setDate(Math.min(this.savedDate, this.getDays()));
}

function dateAddYears(n) {
  if (this.savedDate == null)
    this.savedDate = this.getDate();
  this.setDate(1);
  this.setFullYear(this.getFullYear() + n);
  this.setDate(Math.min(this.savedDate, this.getDays()));
}
//-->
