  //Fensterbreite
  function Fensterweite()
  { if(window.innerWidth)
    { return window.innerWidth;
    }
    else if(document.body && document.body.offsetWidth)
    { return document.body.offsetWidth;
    }
    else
    { return 0;
    }
  }

  //Fenterhoehe
  function Fensterhoehe()
  { if(window.innerHeight)
    { return window.innerHeight;
    }
    else if(document.body && document.body.offsetHeight)
    { return document.body.offsetHeight;
    }
    else
    { return 0;
    }
  }

  //Bild vergroessern/verkleinern
  function resizeImg()
  { var viewportwidth;
    var viewportheight;
    var relation = 1280/340;

    //the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
    if (typeof window.innerWidth != 'undefined')
    { viewportwidth = window.innerWidth,
      viewportheight = window.innerHeight

      correction = 17;
    }
    //IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
    else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth !='undefined' && document.documentElement.clientWidth != 0)
    { viewportwidth = document.documentElement.clientWidth,
      viewportheight = document.documentElement.clientHeight

      correction = 0;
    }
    //older versions of IE
    else
    { viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
      viewportheight = document.getElementsByTagName('body')[0].clientHeight

      correction = 17;
    }

    tempHeight = (viewportwidth - correction) / relation;

    //Browserfenster kleiner als die Content-Breite
    if(viewportwidth <= 990)
    { //Bildbreite auf 1280px fixieren
      $('.testxyz1').attr('width', '1280');
      $('.header-img_desc').css('width', '990px');

      //links
      tempLeft = (1280 - 990) / 2;
      $('[id^="headerimgimage"]').css('left', -tempLeft+'px');

      //oben
      $('[id^="headerimgimage"]').css('top', '0px');
    }
    //Browserfenster groesser als die Content-Breite
    else
    { //Bildhoehe kleiner als die DIV-Hoehe
      if(tempHeight <= 340)
      { //Bildbreite auf 1280px fixieren
        $('.testxyz1').attr('width', '1280');
        //document.getElementById('headerimgdesc').style.width = '1280px';
        $('.header-img_desc').css('width', viewportwidth - 18 +'px');

        //links
        tempLeft = (1280 - viewportwidth) / 2;
        $('[id^="headerimgimage"]').css('left', -tempLeft+'px');

        //oben
        $('[id^="headerimgimage"]').css('top', '0px');
      }
      //Bildhoehe groesser als die DIV-Hoehe
      else
      { $('.testxyz1').attr('width', viewportwidth - correction);
        $('.header-img_desc').css('width', viewportwidth - correction+'px');

        //links
        $('[id^="headerimgimage"]').css('left', '0px');

        //oben
        tempTop = (tempHeight - 340) / 2;
        if(tempTop > 0)
        { $('[id^="headerimgimage"]').css('top', -tempTop+'px');
        }
      }
    }
  }

  //Fenster neu aufbauen
  function neuAufbau()
  { if (Weite != Fensterweite() || Hoehe != Fensterhoehe())
    { resizeImg();
    }
  }

  function firstArrowRightAuto()
  { window.setTimeout("arrowRightAuto()", 5000);
  }

  //auto nach rechts
  function arrowRightAuto()
  { if(count == img_max - 1)
    { count = 0;

      tmp = img_max - 1;
      tmp2 = count;
    }
    else
    { count++;

      tmp = count - 1;
      tmp2 = count;
    }

    $('#headerimgimage_'+tmp).fadeOut(1000);
    $('#headerimgdesc_'+tmp).fadeOut(1000);
    $('#headerimgimage_'+tmp2).fadeIn(1000);
    $('#headerimgdesc_'+tmp2).fadeIn(1000);

    aktiv = window.setTimeout("arrowRightAuto()", 5000);
  }

  //nach links
  function arrowLeft()
  { if(window.aktiv)
    { window.clearTimeout(aktiv);
    }

    if(count == 0)
    { count = img_max - 1;

      tmp = 0;
      tmp2 = count;
    }
    else
    { count--;

      tmp = count + 1;
      tmp2 = count;
    }

    $('#headerimgimage_'+tmp).fadeOut(1000);
    $('#headerimgdesc_'+tmp).fadeOut(1000);
    $('#headerimgimage_'+tmp2).fadeIn(1000);
    $('#headerimgdesc_'+tmp2).fadeIn(1000);

    aktiv = window.setTimeout("arrowRightAuto()", 5000);
  }

  //nach rechts
  function arrowRight()
  { if(window.aktiv)
    { window.clearTimeout(aktiv);
    }

    if(count == img_max - 1)
    { count = 0;

      tmp = img_max - 1;
      tmp2 = count;
    }
    else
    { count++;

      tmp = count - 1;
      tmp2 = count;
    }

    $('#headerimgimage_'+tmp).fadeOut(1000);
    $('#headerimgdesc_'+tmp).fadeOut(1000);
    $('#headerimgimage_'+tmp2).fadeIn(1000);
    $('#headerimgdesc_'+tmp2).fadeIn(1000);

    aktiv = window.setTimeout("arrowRightAuto()", 5000);
  }
