function Initialize(Naeste) {
   //Save original Href in BaseHref for manipulation
   ASeq = document.getElementsByTagName("A");
   if (ASeq == null)
      return;

   for (i = 0; i < ASeq.length; ++i) {
      ASeq.item(i).setAttribute("BaseHref", ASeq.item(i).href);
   }

   return Skift(Naeste);
}

function Skift(Naeste) {
   var CurValue;

   if (Naeste != null) {
      var LastValue, FirstValue;
      var NaesteMaaned, NaesteAar, LastMaaned, LastAar, FirstMaaned, FirstAar;
      var tmp, idx;

      LastValue = document.getElementById("last_value").value;
      FirstValue = document.getElementById("first_value").value;

      tmp = Naeste.toString();
      idx = tmp.indexOf('-', 0);
      NaesteMaaned = parseInt(tmp.substring(0, idx));
      NaesteAar = parseInt(tmp.substring(idx + 1));

      tmp = LastValue.toString();
      idx = tmp.indexOf('-', 0);
      LastMaaned = parseInt(tmp.substring(0, idx));
      LastAar = parseInt(tmp.substring(idx + 1));

      tmp = FirstValue.toString();
      idx = tmp.indexOf('-', 0);
      FirstMaaned = parseInt(tmp.substring(0, idx));
      FirstAar = parseInt(tmp.substring(idx + 1));

      if ((LastAar < NaesteAar) || (LastAar == NaesteAar && LastMaaned < NaesteMaaned)) {
         return true;
      }

      if ((FirstAar > NaesteAar) || (FirstAar == NaesteAar && FirstMaaned > NaesteMaaned)) {
         return true;
      }

      CurValue = Naeste;
   }
   else {
      CurValue = document.getElementById("current_value").value;
   }

   ULSeq = document.getElementsByTagName("TABLE");
   if (ULSeq == null)
      return;

   for (i = 0; i < ULSeq.length; ++i) {
      var Attr = ULSeq.item(i).attributes;
      if (Attr.getNamedItem("id") == null)
          continue; 

      var IdVal = Attr.getNamedItem("id").nodeValue.toString();

      if (IdVal != CurValue && IdVal.length > 0)
         ULSeq.item(i).style.display = "none";
      else
         ULSeq.item(i).style.display = "block";
   }

   ASeq = document.getElementsByTagName("A");
   if (ASeq == null)
      return;

   for (i = 0; i < ASeq.length; ++i) {
      var BaseHref = ASeq.item(i).getAttribute("BaseHref").toString();

      //Only add menu information to local links on the home page
      //And don't add menu information to e-mail address links
      if (BaseHref.indexOf("norgesfjelde13.dk") == -1 ||
          (BaseHref.indexOf("mailto") != -1 && BaseHref.indexOf("@") != -1)) {
         continue;
      }
      var Delimiter;
      if (BaseHref.indexOf('?') == -1)
         Delimiter = "?";
      else
         Delimiter = "&";

      ASeq.item(i).href = BaseHref + Delimiter + "kalender='" + CurValue + "'";
   }

   return true;
}

