news = new Array();
var timer;   
    function swap_img(dir,state) {
      switch (dir) {
        case 1:
          if (state==1) {
            document.getElementById('a_left').style.backgroundImage = 'url(http://www.ultraforce.de/templates/uf1000/img/arrow_left_high.jpg)';
          } else {
            document.getElementById('a_left').style.backgroundImage = 'url(http://www.ultraforce.de/templates/uf1000/img/arrow_left_low.jpg)';
          }
        break;
        case 0:
          if (state==1) {
            document.getElementById('a_right').style.backgroundImage = 'url(http://www.ultraforce.de/templates/uf1000/img/arrow_right_high.jpg)';
          } else {
            document.getElementById('a_right').style.backgroundImage = 'url(http://www.ultraforce.de/templates/uf1000/img/arrow_right_low.jpg)';
          }
        break;
      }
    }
    
    function create_news_scroller(headline) {
      // Navigation erstellen -> news_navigate_to(dir);
      navigation = '<div style="width:188px; height:13px;">';
      navigation += '<a style="float:left; position:relative; left:5px; top:3px; width:7px; height:13px;" href="javascript:news_navigate_to(1);" onmouseover="swap_img(1,1); stop_it();" onmouseout="swap_img(1,0);"><div id="a_left" style="cursor:hand; width:7px; height:13px; background-image:url(http://www.ultraforce.de/templates/uf1000/img/arrow_left_low.jpg); background-repeat:no-repeat;"></div></a>';
      navigation += '<div style="float:left; position:relative; left:50px; top:3px; width:150px; height:13px; font-family:verdana; font-weight:normal; font-size:12px; color:#ffffff;">'+headline+'</div>';
      navigation += '<a style="float:right; position:relative; right:5px; top:3px; width:7px; height:13px;" href="javascript:news_navigate_to(0);" onmouseover="swap_img(0,1); stop_it();" onmouseout="swap_img(0,0);"><div id="a_right" style="cursor:hand; width:7px; height:13px; background-image:url(http://www.ultraforce.de/templates/uf1000/img/arrow_right_low.jpg); background-repeat:no-repeat;"></div></a>';
      navigation += '</div>';
      document.getElementById('news_scroller').innerHTML = navigation;
      
      // Sichtbaren Bereich erstellen
      viewable = '<div id="viewable" style="clear:both; overflow:hidden; margin-left:3px; margin-top:7px; width:182px; height:120px; background-color:#f7f5f6;"></div>';
      document.getElementById('news_scroller').innerHTML += viewable;
      
      // Scroll-Content-Container erstellen -> in sichtbaren Bereich
      cont = '<div id="cont" style="position:relative; left:0px; top:0px; width:2950px; height:175px; background-color:#f7f5f6;"></div>';
      document.getElementById('viewable').innerHTML = cont;
    }
  
    function add_news(id,datum,previewicon,inhalt,link) {
      news[id] = new Array();
      news[id]['datum'] = datum;
      news[id]['previewicon'] = previewicon;
      news[id]['inhalt'] = inhalt;
      news[id]['link'] = link;
    }
    
    function init_news_scroller() {
      for (var i=0; i<news.length; i++) {
        datum = '<span><img src="http://www.ultraforce.de/templates/uf1000/img/icon_arrow.jpg" border="0" /></span><span class="news_scroller_date">'+news[i]['datum']+'</span>';
        inhalt = '<div class="news_scroller_content">'+news[i]['inhalt']+'</div>';
        infocontainer = '<div id="news_'+i+'" style="float:left; width:184px; height:50px;">'+datum+'<a href="'+news[i]['link']+'" style="text-decoration:none;" onmouseover="stop_it();" onmouseout="start_it();">'+inhalt+'</a><a href="'+news[i]['link']+'" style="text-decoration:none;"><div id="img_'+i+'" style="width:182px; height:auto; text-align:center;"><img src="./'+news[i]['previewicon']+'" border="0" onmouseover="stop_it();" onmouseout="start_it();" /></div></a></div>';
        document.getElementById('cont').innerHTML += infocontainer;
      }
      document.getElementById('cont').innerHTML += '<div style="clear:both;"></div>';
      timer = window.setTimeout('go_on()',3000);
    }
    
    function news_navigate_to(dir) {
      window.clearTimeout(timer);
      switch(dir) {
        case 0: // rechter pfeil
          akt_pos = document.getElementById('cont').style.left;
          akt_pos = parseInt(akt_pos.split('px')[0]);
          if (akt_pos >= -(news.length*184)+368) {
            akt_pos -= 184;
          } else {
            akt_pos = 0;
          }
          document.getElementById('cont').style.left = akt_pos+'px';
          timer = window.setTimeout('go_on()',3000);
        break;
        case 1: // linker pfeil
          akt_pos = document.getElementById('cont').style.left;
          akt_pos = parseInt(akt_pos.split('px')[0]);
          if (akt_pos < 0) {
            akt_pos += 184;
          } else {
            akt_pos = -(news.length*184)+184;
          }
          document.getElementById('cont').style.left = akt_pos+'px';
          timer = window.setTimeout('go_on()',3000);
        break;
      }
    }
    
    function start_it() {
      timer = window.setTimeout('go_on()',3000);
    }
    
    function stop_it() {
      window.clearTimeout(timer);
    }
    
    function go_on() {
      akt_pos = document.getElementById('cont').style.left;
      akt_pos = parseInt(akt_pos.split('px')[0]);
      if (akt_pos >= -(news.length*184)+368) {
        akt_pos -= 184;
      } else {
        akt_pos = 0;
      }
      document.getElementById('cont').style.left = akt_pos+'px';
      timer = window.setTimeout('go_on()',3000);
    }
