var tags;
var index = 11;
var active = 4;
var frozen = false;
var try_to_freeze = false;
function tags(){
  var allElems = document.getElementsByTagName('div');
  var temp = new Array();
    for (var i = 0; i < allElems.length; i++) {
    var thisElem = allElems[i];
    if (thisElem.className && thisElem.className == 'startseite') {
      temp.push(thisElem);        
    };
  };
  return temp;
};

function einblenden(z, c){
  
  if(!frozen){
      c++;
      cr = c/30;
      left = z*223 + 8;
      right = z*223+223;
      cright = right + (892 - right)*cr;
      cleft = left - left*cr;
      tags[z].style.clip = 'rect( 0px '+Math.round(cright)+'px 358px '+Math.round(cleft)+'px)';

      if(c < 30){setTimeout(function() {einblenden(z,c);}, 20);};
  };
};

function ausblenden(z, c){

    c++;
    cr = c/30;

    left = z*223 + 8;
    right = z*223+223;
    cright = 892 - (892 - right)*cr;
    cleft = left*cr;    
    tags[z].style.clip = 'rect( 0px '+Math.round(cright)+'px 358px '+Math.round(cleft)+'px)';

    if(c < 30){setTimeout(function() {ausblenden(z, c);}, 20);}else{ frozen = false;};

};

function zurucksetzen(){
  if(active != 4){
    for (var i = 0; i < tags.length; i++) {
      if(i != active){
        tags[i].style.clip = 'rect( 0px '+((i+1)*223)+'px 358px '+((i*223)+8)+'px)';
      };
    };
    ausblenden(active, 0)
    active = 4;
    
  };
};

function startseite(){ 
  tags = tags();
  
  for (var i = 0; i < tags.length; i++) {
    tags[i].style.clip = 'rect( 0px '+((i+1)*223)+'px 358px '+((i*223)+8)+'px)';
    tags[i].style.zIndex = '11';

  };
  if(document.all){frozen=true;};
};

function zeige(z){ 
  if(frozen == false){
    if(active != z){ 
      index++;
      tags[z].style.clip = 'rect( 0px '+((z+1)*223)+'px 358px '+((z*223)+8)+'px)';
      tags[z].style.zIndex = index;
      active = z;
      einblenden(z,0);
    }; 
  };
};

function ie_zeige(id){ 
  for (var i = 0; i < tags.length; i++) {
    tags[i].style.clip = 'rect( 0px '+((i+1)*223)+'px 358px '+((i*223)+8)+'px)';
    tags[i].style.zIndex = '11';
  };
  if(active != id && active == 4){
    active = id;
    
    tags[id].style.clip = 'rect( 0px 892px 358px 8px)';
    tags[id].style.zIndex = '12';
  }else{
    active = 4;
  };
};

function mouse_move(e, t){
  if (!e) var e = window.event;
  var pos = e.pageX-t.offsetLeft-52;
  if(pos > 0 && pos < 215){
    zeige(0);
  };
  if(pos > 223 && pos < 438){
    zeige(1);
  }; 
  if(pos > 446 && pos < 661){
    zeige(2);
  };
  if(pos > 669 && pos < 884){
    zeige(3);
  }; 

};

function mouse_out(e, t){
  if (!e) var e = window.event;
  var pos = e.pageY-t.offsetTop ;
  if( pos < 2 || pos > 357){
    frozen = true;
    zurucksetzen(0);
  }; 
};

function mouse_click(e){
  if(!document.all){
    if(active != 4){
      frozen = true;
    };
  }else{
  
    if (!e) var e = window.event;
    var pos = e.clientX-60;
    if(pos > 0 && pos < 215){
      ie_zeige(0);
    };
    if(pos > 223 && pos < 438){
      ie_zeige(1);
    }; 
    if(pos > 446 && pos < 661){
      ie_zeige(2);
    };
    if(pos > 669 && pos < 884){
      ie_zeige(3);
    };
  
  };
};
