function maximize_this_alt (divname, stitle, idtag, other) {
  d=document.getElementsByTagName('div');
  for (var i = 0; i < d.length; i++) {
    var isitregio = d[i].getAttribute('name');
    if(isitregio != null) {
      if(isitregio.substr(0,6) == stitle) {
        d[i].id=other;
      }
      if(isitregio == divname) {
        d[i].id = idtag;
      }
    }
  }
}

function maximize_this (divname, stitle, idtag, other) {
}

function maximize_divs (divname, stitle, idtag, other) {
  d=document.getElementsByTagName('div');
  for (var i = 0; i < d.length; i++) {
    var isitregio = d[i].id;
    if(isitregio.substr(0,6) == stitle) {
      d[i].id=other;
    }
    if(d[i].id == idtag) {
      d[i].id = other;
    }
    if(d[i].title == divname) {
      d[i].id = idtag;
    }
  }
}

function changeFont(plusOrMinus)
{
  textzoomspan = document.getElementById('textzoom');
  elements = textzoomspan.getElementsByTagName('div');
  
  fontSizeStr = elements[0].style.fontSize;
  var Suche = /([0-9]+)px/;
  ergArr = Suche.exec(fontSizeStr);
  if (ergArr)
  {
    currentFontSize = parseInt(ergArr[1]);
    if (plusOrMinus == '+')
    {
      if (currentFontSize <= 17)
        newFontSize = currentFontSize + 1;
    }
    else
    {
      if (currentFontSize >= 9)
        newFontSize = currentFontSize - 1;
    }
    
    if(newFontSize != currentFontSize)
    {
      for (var i = 0; i < elements.length; i++)
      {
          elements[i].style.fontSize = newFontSize + 'px';
      }
    }
  }
}

function change_image(divclass, imgpath) {
  document.getElementById(divclass).src=imgpath;
}

function change_content(divcontent, divsource) {
  document.getElementById(divcontent).innerHTML=document.getElementById(divsource).innerHTML;
}

function change_imagelink (cls, link) {
  document.getElementById(cls).href = link;
}

function shortText (feld, quelle, titel, aktiv) {
  var laenge;
  if (document.getElementById(titel).innerHTML.length > 26) {
    if (aktiv == 0) {
      laenge = 30;
    } else {
      laenge = 250;
    }
  } else {
    if (aktiv == 0) {
      laenge = 60;
    } else {
      laenge = 250;
    }
  }
  document.getElementById(feld).innerHTML = text2array(document.getElementById(quelle).innerHTML, laenge, aktiv);
}

function text2array (text, maxi, aktiv) {
   var ar = text.split(' ');
  var out = '';
  var i = 0;
  var strlen = text.length;
  if (text.length < maxi) {
//    maxi = text.length;
//    alert('maxi: "'+maxi+'"');
  }
  if (aktiv == 1)
  {
    out = text;
  }
  else
  {
  while ((out.length + ar[i].length) < maxi) {
    out = out + ' ' + ar[i];
    i = i + 1;
  }
  if (out.length < text.length) {
    out = out + ' ...';
  }
  }
  return out;
}

function changeCSSClass (divname, cssclass) {
  	document.getElementById(divname).className = cssclass;
}

function topart1mouseover(thumb, alink) {
	maximize_divs('toptitle_1', 'toptit', 'topnewsart_activ', 'topnewsart_inactiv');
	change_image('topnewsimage', thumb);
	change_content('topnewscontent', 'contentsource1');
        change_content('topnewstitel', 'titelsource1');
        change_imagelink('topnews_link', alink);
	//shortText('art1_ptext', 'art1_fulltext', 'art1_titletext', 1);
	//changeCSSClass('art1_linfo', 'linfo_container');
	//shortText('art2_ptext', 'art2_fulltext', 'art2_titletext', 0);
	//changeCSSClass('art2_linfo', 'linfo_container_deac');
	//shortText('art3_ptext', 'art3_fulltext', 'art3_titletext', 0);
	//changeCSSClass('art3_linfo', 'linfo_container_deac');
        //changeCSSClass('topnewsart_aktivpfeil', 'top1_aktiv');
}

function topart2mouseover(thumb, alink) {
	maximize_divs('toptitle_2', 'toptit', 'topnewsart_activ', 'topnewsart_inactiv');
	change_image('topnewsimage', thumb);
	change_content('topnewscontent', 'contentsource2');
        change_content('topnewstitel', 'titelsource2');
        change_imagelink('topnews_link', alink); 
	//shortText('art2_ptext', 'art2_fulltext', 'art2_titletext', 1);
	//changeCSSClass('art2_linfo', 'linfo_container');
	//shortText('art1_ptext', 'art1_fulltext', 'art1_titletext', 0);
	//changeCSSClass('art1_linfo', 'linfo_container_deac');
	//shortText('art3_ptext', 'art3_fulltext', 'art3_titletext', 0);
	//changeCSSClass('art3_linfo', 'linfo_container_deac');
        //changeCSSClass('topnewsart_aktivpfeil', 'top2_aktiv');
}

function topart3mouseover(thumb, alink) {
	maximize_divs('toptitle_3', 'toptit', 'topnewsart_activ', 'topnewsart_inactiv');
	change_image('topnewsimage', thumb);
	change_content('topnewscontent', 'contentsource3');
        change_content('topnewstitel', 'titelsource3');
        change_imagelink('topnews_link', alink);	 
	//shortText('art3_ptext', 'art3_fulltext', 'art3_titletext', 1);
	//changeCSSClass('art3_linfo', 'linfo_container');
	//shortText('art2_ptext', 'art2_fulltext', 'art2_titletext', 0);
	//changeCSSClass('art2_linfo', 'linfo_container_deac');
	//shortText('art1_ptext', 'art1_fulltext', 'art1_titletext', 0);
	//changeCSSClass('art1_linfo', 'linfo_container_deac');
        //changeCSSClass('topnewsart_aktivpfeil', 'top3_aktiv');
}

function topnewsbreak(offon) {
  if(offon == 0 ) {
    timerval = window.setInterval('top_changeTimeEvent()', 3800);
  } else {
    clearInterval(timerval);
  }
}

function top_changeTimeEvent() {
  eval(topnews_array[cnt]);
  if ( cnt == 2) {
    cnt = 0;	
  } else {
    cnt++;
  }
}

function sleep(ms){
  var zeit=(new Date()).getTime();
  var stoppZeit=zeit+ms;
  while((new Date()).getTime() < stoppZeit){};
} 

function runner(funcname, functime, sleeper) {
  window.setTimeout("" + window.setInterval(funcname, functime) +"", sleeper);
}