/**
 * Dateiname       : javascript/mainframe.js
 * Erzeugungsdatum : 12.01.2009
 * Autor           : Carsten Kube
 * Version         : 1.0
 * Letzte Akt.     : 12.06.2009 (CK)
 * 
 * (c) Copyright SECRA GmbH
 */

/*globals Calendar, Handler, exp, secra */

var allowedChars,indexKarteInit, karte;

function installCalendar() {
  var year = new Date().getFullYear();

  Calendar.setup({"inputDisplayArea":"secraanreise",
                  "inputField":"secradatum",
                  "button":"anreisebtn",
                  "range":[year,year+2]
  });
  Calendar.setup({"inputDisplayArea":"secraabreise",
                  "inputField":"secradatum",
                  "button":"abreisebtn",
                  "range":[year,year+2]
               });

allowedChars = ['0','1','2','3','4','5','6','7','8','9','.'];
  (new secra.InputFilter(allowedChars, "secraanreise"));
  (new secra.InputFilter(allowedChars, "secraabreise"));
  window.secradatum = document.getElementById("secradatum");
}

function addHoverEffect() {
  window.intkarte.onmouseover = function() {
    window.intkarte.over = true;
    this.src = window.imageKarte2.src;
    this.style.cursor = "pointer";
  };
  window.intkarte.onmouseout = function() {
    window.intkarte.over = false;
    this.src = window.imageKarte1.src;
    this.style.cursor = "";
  };
  window.intkarte.onmouseover();
}

function addClickEffect() {
  window.intkarte.onmousedown = function() {
    this.src = window.imageKarte3.src;
  };
  window.intkarte.onmouseup = function() {
    if(window.intkarte.over === true) {
      this.src = window.imageKarte2.src;
    } else {
      this.src = window.imageKarte1.src;
    }
  };
}

function imageKarteInit() {
  window.intkarte = document.getElementById("intkarte");
  window.imageKarte1 = new Image();
  window.imageKarte1.src = window.intkarte.src;
  window.imageKarte2 = new Image();
  window.imageKarte2.src = "bitmaps/karte_vs_hover.jpg";
  if(window.imageKarte2.complete) {
    addHoverEffect();
  } else {
    window.imageKarte2.onload = addHoverEffect;
  }
  window.imageKarte3 = new Image();
  window.imageKarte3.src = "bitmaps/karte_vs_down.jpg";
  if(window.imageKarte3.complete) {
    addClickEffect();
  } else {
    window.imageKarte3.onload = addClickEffect;
  }
  if(typeof indexKarteInit==="function") {
    indexKarteInit();
  }
}

function karteninit() {
  karte = new secra.Kartenmodul("innermaps", exp, imageKarteInit, window.TEST);
}

Handler.add(window,"load", installCalendar);
var includeKarte;
if(includeKarte === true) {
  Handler.add(window,"load", karteninit);
}

function printWindow() {
  Browser = parseInt(navigator.appVersion, 10);
  if(Browser >= 4) {
    window.print();
  }
}

function FontSize1 () {
  document.getElementById("content").style.fontSize = "125%";
  document.getElementById("content").style.lineHeight = "130%";
}

function FontSize0 () {
  document.getElementById("content").style.fontSize = "100%";
  document.getElementById("content").style.lineHeight = "150%";
}
