
 /* change() - change some text with fadeing effects - used on main-page *********************************************/

 function change() {

  if(typeof(this.wcnt)  == 'undefined') { this.wcnt  = 0; }
  if(typeof(this.lcnt)  == 'undefined') { this.lcnt  = 0; }
  if(typeof(this.s1cnt) == 'undefined') { this.s1cnt = 0; }
  if(typeof(this.s3cnt) == 'undefined') { this.s3cnt = 0; }
  if(typeof(this.wcol1) == 'undefined') { this.wcol1 = '#ffffff'; /*wtxt.style.color;*/ }
  if(typeof(this.wcol2) == 'undefined') { this.wcol2 = '#14468f'; /*wtxt.style.backgroundColor;*/ }
  if(typeof(this.lcol1) == 'undefined') { this.lcol1 = '#000000'; }
  if(typeof(this.lcol2) == 'undefined') { this.lcol2 = '#ffffff'; }

  if(typeof(this.tarr) == 'undefined') {
   this.tarr = document.getElementById('wechseltext').getElementsByTagName('span');
  }

  if(typeof(this.larr) == 'undefined') {
   this.larr = document.getElementById('left-colum').getElementsByTagName('span');
  }

  if(typeof(this.stage1) == 'undefined') {
   this.stage1 = function() {

    this.tarr[this.wcnt].style.color = fade(this.wcol1, this.wcol2, 30);
    //this.larr[this.lcnt].style.color = fade(this.lcol1, this.lcol2, 30);
    this.s1cnt++;

    //alert(this.s1cnt + ' - ' + this.tarr[this.count].style.color);

    if(this.s1cnt >= 31) {
     this.s1cnt = 0;
     this.stage2();
    }else{
     setTimeout('change_CHNGS1()', 25);
    }

   }
   window.change_CHNGS1 = this.stage1;
  }

  if(typeof(this.stage2) == 'undefined') {
   this.stage2 = function() {

    this.tarr[this.wcnt].style.display = 'none';
    //this.larr[this.lcnt].style.display = 'none';

    this.wcnt = (this.wcnt == tarr.length-1) ? 0 : this.wcnt+1;
    //this.lcnt = (this.lcnt == larr.length-1) ? 0 : this.lcnt+1;

    this.tarr[this.wcnt].style.display = 'inline';
    //this.larr[this.lcnt].style.display = 'inline';

    this.stage3();

   }
  }

  if(typeof(this.stage3) == 'undefined') {
   this.stage3 = function() {

    this.tarr[this.wcnt].style.color = fade(this.wcol2, this.wcol1, 30);
    //this.larr[this.lcnt].style.color = fade(this.lcol2, this.lcol1, 30);
    this.s3cnt++;

    //alert(this.s3cnt + ' - ' + this.tarr[this.count].style.color);

    if(this.s3cnt >= 31) {
     this.s3cnt = 0;
    }else{
     setTimeout('change_CHNGS3()', 25);
    }

   }
   window.change_CHNGS3 = this.stage3;
  }

  this.stage1();
  
 }

 /* fade(colS, colE, steps) - does the color-fadeing for change() ****************************************************/

 function fade(colS, colE, steps) {

  if(typeof(this.data) == 'undefined') {
   this.data = new Array();
  }

  colS = (colS.charAt(0) == '#') ? colS.substr(1) : colS;
  colE = (colE.charAt(0) == '#') ? colE.substr(1) : colE;

  id   = steps * Math.pow(2, 48);
  id  += Number.fromHex(colS) * Math.pow(2, 24);
  id  += Number.fromHex(colE);

  if(typeof(this.data[id]) == 'undefined') {

   this.data[id]       = new Object();

   colS                = colS.tokenSplit(2);
   colE                = colE.tokenSplit(2);

   colS                = new Array(Number.fromHex(colS[0]), Number.fromHex(colS[1]), Number.fromHex(colS[2]));
   colE                = new Array(Number.fromHex(colE[0]), Number.fromHex(colE[1]), Number.fromHex(colE[2]));

   this.data[id].colS  = colS;
   this.data[id].colE  = colE;
   this.data[id].steps = steps;
   this.data[id].step  = 0;

   colD                = new Array((colE[0] - colS[0])/steps, (colE[1] - colS[1])/steps, (colE[2] - colS[2])/steps);

   this.data[id].colD  = colD;

  }

  colR = Math.round(this.data[id].colS[0] + (this.data[id].colD[0] * this.data[id].step)).toHex();
  colR = (colR.length < 1) ? '00' : ((colR.length < 2) ? '0' + colR : colR );
  colG = Math.round(this.data[id].colS[1] + (this.data[id].colD[1] * this.data[id].step)).toHex();
  colG = (colG.length < 1) ? '00' : ((colG.length < 2) ? '0' + colG : colG );
  colB = Math.round(this.data[id].colS[2] + (this.data[id].colD[2] * this.data[id].step)).toHex();
  colB = (colB.length < 1) ? '00' : ((colB.length < 2) ? '0' + colB : colB );

  col  = '#' + colR + colG + colB;

  this.data[id].step  = (this.data[id].step == this.data[id].steps) ? 0 : this.data[id].step + 1;
    
  return col;
    
 }

 /* start() - does the onload-event handling - currently only used in main page for text fadeing *********************/

 function start() {
  window.setInterval("change()", 7000);
 }

 /* slide(id, mode, init_value) - does the box sliding used in the reference-category ********************************/

 function slide(id, mode, init_value) {

  if(typeof(this.data) == 'undefined') {
   this.data = new Array();
  }

  if(typeof(this.interval) == 'undefined') {
   this.interval = null;
  }

  if(typeof(this.slide_open) == 'undefined') {

   this.slide_open = function(id) {
    this.interval = window.setInterval("slide_SLDEOS('" + id + "')", 10);
   }

   if(typeof(this.slide_open.step) == 'undefined') {
    this.slide_open.step = function(id) {
     var itm = document.getElementById(id);
     itm.style.height = (parseInt(itm.style.height) + 5) + 'px';
     if(parseInt(itm.style.height) >= this.data[id].maxh && true) {
      window.clearInterval(this.interval);
     }
    }
    window.slide_SLDEOS = this.slide_open.step; 
   }

  }

  if(typeof(this.slide_close) == 'undefined') {

   this.slide_close = function(id) {
    this.interval = window.setInterval("slide_SLDECS('" + id + "')", 10);
   }

   if(typeof(this.slide_close.step) == 'undefined') {
    this.slide_close.step = function(id) {
     var itm = document.getElementById(id);
     itm.style.height = (parseInt(itm.style.height) - 5) + 'px';
     if(parseInt(itm.style.height) <= 0) {
      window.clearInterval(this.interval);
     }
    }
    window.slide_SLDECS = this.slide_close.step; 
   }

  }

  if(mode == 'init') {
   if(typeof(this.data[id]) == 'undefined') {
    this.data[id]       = new Object();
   }
   this.data[id].state  = init_value.split('|')[0];
   this.data[id].maxh   = init_value.split('|')[1]*1;
   var itm = document.getElementById(id);
   itm.style.height = ((this.data[id].state == 'open') ? init_value.split('|')[1]*1 : 0) + 'px';
   return;
  }

  var itm = document.getElementById(id);
  if(parseInt(itm.style.height) > 0 && parseInt(itm.style.height) < this.data[id].maxh) {
   return;
  }

  if(this.data[id].state == 'open') {
   this.slide_close(id);
   this.data[id].state = 'close'
  }else{
   this.slide_open(id);
   this.data[id].state = 'open';
  }

 }

 /* chng_link() - do some foo on links while animated gifs are changing **********************************************/

 function chng_link() {

  if(typeof(this.data) == 'undefined') {

   this.data = new Array();
   img_arr   = document.getElementsByTagName('img');
 
   for(i = 0;i < img_arr.length;i++) {

    if(img_arr[i].src.substr(0, 'http://test.mks-ag.de/fileadmin/extPHP/img_fade.gif.php'.length) != 'http://test.mks-ag.de/fileadmin/extPHP/img_fade.gif.php') {
     continue;
    }

    img_arr[i].id        = 'lci' + i;
    this.data[i] = new Object();
    
    str = img_arr[i].src.indexOf('steps=')+'steps='.length;
    end = img_arr[i].src.indexOf('&', str);
    end = (end == -1) ? img_arr[i].src.length : end;
    stp = img_arr[i].src.substr(str, end - str);
    stp = parseInt(stp);
    
    str = img_arr[i].src.indexOf('stick=')+'stick='.length;
    end = img_arr[i].src.indexOf('&', str);
    end = (end == -1) ? img_arr[i].src.length : end;
    stk = img_arr[i].src.substr(str, end - str);
    stk = parseInt(stk);

    str = img_arr[i].src.indexOf('itick=')+'itick='.length;
    end = img_arr[i].src.indexOf('&', str);
    end = (end == -1) ? img_arr[i].src.length : end;
    itk = img_arr[i].src.substr(str, end - str);
    itk = parseInt(itk);

    this.data[i].time = (itk + (stp * stk)) * 10;
    this.data[i].link = img_arr[i].parentNode;
    this.data[i].uria = this.data[i].link.id.split(';');
    this.data[i].urip = 1;

    //alert(this.data);
    window.setInterval('chng_link_CHNGS(' + i + ')', this.data[i].time);

   }

  }

  if(typeof(this.stage) == 'undefined') {
   this.stage = function(id) {
    //alert(id);
    //alert(this.data);
    //alert(this.data[id].uria[this.data[id].urip]);
    this.data[id].link.href = this.data[id].uria[this.data[id].urip];
    this.data[id].urip      = (this.data[id].urip == (this.data[id].uria.length - 1)) ? 0 : this.data[id].urip + 1;
   }
   window.chng_link_CHNGS = this.stage;
  }

 } 

 //window.load[window.load.length] = chng_link;

 /* chng_img() - same as change() but for images and not for text - also uses different html sructures ***************/

 /*function chng_img(id) {

  if(typeof(this.data)     == 'undefined') { this.data = new Array(); }

  if(typeof(this.data[id]) == 'undefined') {
   this.data[id] = new Object();
   this.data[id].lstObj  = document.getElementById(id);
   this.data[id].imgList = this.data[id].lstObj.getElementsByTagName('img');
   this.data[id].stpPImg = this.data[id].imgList[0].src.substr(this.data[id].imgList[0].src.indexOf('steps=')+'steps='.length);
   this.data[id].imgStps = this.data[id].imgList.length / this.data[id].stpPImg;
   this.data[id].imgCnt  = 0;
   this.data[id].stCnt   = 0;
  }

  if(typeof(this.stage) == 'undefined') {
   this.stage = function(id) {
    
    //alert(this.data[id].stCnt);
    this.data[id].imgList[this.data[id].stCnt].style.display = 'none';
    this.data[id].stCnt = (this.data[id].stCnt+1 >= this.data[id].imgList.length) ? 0 : this.data[id].stCnt+1;
    this.data[id].imgList[this.data[id].stCnt].style.display = 'inline';

    if(this.data[id].stCnt < (this.data[id].stpPImg*this.data[id].imgCnt)-1) {
     setTimeout('chng_img_CHNGIS(\'' + id + '\')', 50);
    }

   }
   window.chng_img_CHNGIS = this.stage;
  }

  this.data[id].imgCnt = (this.data[id].imgCnt+1 > this.data[id].imgStps) ? 0 : this.data[id].imgCnt+1;
  this.stage(id);
  
 }*/

 /* fade_img() - same as fade() but for images and not for text - wrapper for php, since js doesn't support img ******/

 //function fade_img(path, img1, img2, steps, step) {
 // return '/fileadmin/extPHP/img_fade.php?imgBG=../..' + path + img1 + '&imgFG=../..' + path + img2 + '&step=' + step + '&steps=' + steps;
 //}


