function PictureMoBox() {
//MoBox.initialize();
  var mb_picture;

  var mb_picture_number;
  var mb_gallery;

  var mb_stepper1;
  var mb_stepper2;

  var mb_img_height = 44;
  var mb_img_width = 44;

  var height_dif;
  var width_dif;

  var mb_new_height;
  var mb_new_width;

  var mb_dir;

  var mb_steps1 = 1;
  var mb_steps2 = 1;

//GetElementByID Vereinfachung
  getID = function(id) {
    return document.getElementById(id); }

//Initialisierung der MoBox, erstellen des Prealoaders
  this.initialize = function() {
    var self = this;
    mb_preloader = new Image();
    mb_preloader.onload=function() {
      mb_new_height = mb_preloader.height;
      mb_new_width = mb_preloader.width;

      if(mb_new_height > 600) {
        ratio = mb_new_width / mb_new_height;
        mb_new_height = 600;
        mb_new_width = 600 * ratio; }

      if(mb_picture_number > 1) {
        $('MoBox_previous_hover').style.visibility = "visible"; }
      else {
        $('MoBox_previous_hover').style.visibility = "hidden"; }

      if(mb_picture_number < (mb_picpath.length)) {
        $('MoBox_next_hover').style.visibility = "visible"; }
      else {
        $('MoBox_next_hover').style.visibility = "hidden"; }

      resize();
      if(mb_picture_number > 0) {
       $('MoBox_discription').innerHTML = mb_picdiscr[mb_picture_number-1]; }
    }
  },

//Öffnen der MoBox
  this.showpic = function(pic, index) {
    blackout('in');
    if(index != "") {
      mb_picture_number = index; }

    //if($('pixcomments')) {
    //  $('pixcomments').src = "sonst/pixcomments.php?picid=" + pic + "&gallery=" + gal; }

    $('MoBox').style.visibility = "visible";
    mb_picture = pic;
    mb_preloader.src = mb_picture;
  },

  this.previouspic = function() {
    $('MoBox_picture').src = "images/load.gif";
    mb_picture_number--;
    mb_picture = mb_picpath[mb_picture_number-1];
    mb_preloader.src = mb_picture;
    //$('pixcomments').src = "sonst/pixcomments.php?picid=" + picids[picture-1] + "&gallery=" + gallery;
  },

  this.nextpic = function() {
    $('MoBox_picture').src = "images/load.gif";
    mb_picture_number++;
    mb_picture = mb_picpath[mb_picture_number-1];
    mb_preloader.src = mb_picture;
    //$('pixcomments').src = "sonst/pixcomments.php?picid=" + picids[picture-1] + "&gallery=" + gallery;
  },

//Schließen der MoBox
  this.closepic = function() {
    blackout('out');
    $('MoBox_picture').src = "images/load.gif";
    $('MoBox').style.visibility = "hidden";
    $('MoBox_previous_hover').style.visibility = "hidden";
    $('MoBox_next_hover').style.visibility = "hidden";
  },

//Schwarze Hintergrundebene ein- und ausblenden
  blackout = function(param)
  {
    var self = this;
    mb_dir = param;

    if(mb_dir == "in") {
      $('MoBox_blackout').style.display = "block"; }

    mb_stepper1 = window.setInterval(function(){self.blackout_step(mb_dir);}, 13);
  },

  blackout_step = function(dir) {
    var mb_b = $('MoBox_blackout');
    var steps = mb_steps1;
    if(dir == "in") {
      mb_b.style.filter = "Alpha(opacity=" + (steps * 4) + ")";
      mb_b.style["opacity"] = steps * 4 / 100; }
    else {
      mb_b.style.filter = "Alpha(opacity=" + (60 - steps * 4) + ")";
      mb_b.style["opacity"] = (60 - steps * 4) / 100; }

    mb_steps1++;
    if(mb_steps1 == 15) {
      window.clearInterval(mb_stepper1);
      mb_steps1 = 1;
      if(dir == "out") {
        $('MoBox_blackout').style.display = "none"; }
    }
  },

//Größe der MoBox anpassen
  resize = function() {
    var self = this;

    height_dif = (mb_new_height - mb_img_height);
    width_dif = (mb_new_width - mb_img_width);

    mb_stepper2 = window.setInterval(function(){self.resize_step();}, 13);
  },

  resize_step = function () {
    var self = this;
    
    var new_height = mb_new_height;
    var new_width = mb_new_width;
    
    var steps = mb_steps2;

    var MoBox = $('MoBox');

    var height_step = Math.round(height_dif / 15);
    var width_step = Math.round(width_dif / 15);
    MoBox.style.height = (mb_img_height + height_step * (Math.cos((steps/15-1)*3.14)+ 1) * 7.5) + "px";
    MoBox.style.width = (mb_img_width + width_step * (Math.cos((steps/15-1)*3.14)+ 1) * 7.5) + "px";

    mb_steps2++;

    if(mb_steps2 > 15) {
      window.clearInterval(mb_stepper2);

      if(mb_picdiscr[mb_picture_number-1] != "") {
        MoBox.style.height = (mb_new_height + 20) + "px";
        $('MoBox_discription').style.display = "block"; }
      else {
        MoBox.style.width = mb_new_height + "px";
        $('MoBox_discription').style.display = "none"; }

      MoBox.style.width = mb_new_width + "px";
      mb_img_height = mb_new_height;
      mb_img_width = mb_new_width;
      $('MoBox_picture').src = mb_picture;
      picture_counter(mb_picture);
      mb_steps2 = 1;
    }
  }
};
