// JavaScript Document
var id = 'Team,Leistungen,Kosten,Räume,Lage,Links';
var path = 'images/';
var big = null;
var waben = new Array();
var anz = 0;
var delay = 2000;
var resize = true;
var rahmen;
var box, boxSize={};

function build() {
  id = id.split(',');
  anz = id.length;
  var body = document.body;
  for ( var x=0; x<6; x++ ) {
    var name = 'wabe'+( x%2 ? '-g' : '');
    var schrift = new Element('div',{
      'class': 'schrift',
      'styles': {
        'top': -100,
        'left': -100,
        'position': 'absolute'//,
        //'border': 'solid black'
      }
    });
    schrift.inject( document.body );
    var e = new Element('img',{
      'name': name,
      'nr': x,
      'src': path+name+'-hoch.gif',
      'events': {
        'mouseenter': function() { pause(); this.src = path+this.name+'-tief.gif'; },
        'mouseleave': function() { this.src = path+this.name+'-hoch.gif'; resume(); },
        'click': function () {
          if ( big )
            big.unselect();
          else
            this.select();
        },
        'changeTo': function() {
          if ( big )
            big.unselect();
          this.select();
        },
        'select': function() {
          SqueezeBox.open( this.content, {handler: 'clone', size: boxSize });
        },
        'unselect': function() {
          $('sbox-btn-close').fireEvent('click');
        }
      }
    });
    $extend( e, {
      select: function() {
        big = this;
        big.fireEvent('select');
      },
      unselect: function() {
        big.fireEvent('unselect');
        big = null;
      },
      changeTo: function() {
        this.fireEvent('changeTo');
      }
    });
    e.inject( schrift );
    e.content = $(''+x);
    e.schrift = schrift;
    var s = new Element( 'div', {
      'events': {
        'mouseenter': function() { pause(); this.wabe.src = path+this.wabe.name+'-tief.gif'; },
        'mouseleave': function() { this.wabe.src = path+this.wabe.name+'-hoch.gif'; resume(); },
        'click': function () {
          if ( big )
            big.unselect();
          else
            this.wabe.select();
        }
      }
    } );
    s.innerHTML = id[x];
    s.inject( schrift );
    s.wabe = e;
    e.text = s;
    waben.push( e );
  }
  
  var back = new Element( 'div', { 'class': 'back' });
  back.innerHTML = $('back').innerHTML;
  for ( var x=0; x<6; x++ ) {
    back.clone().inject( $(''+x), 'bottom' );
  }
}  

function close() {
  if ( big )
    big.unselect();
}
