g = 0;
var speed_hor = 2;
function scroll_hor() {
 g = g + speed_hor;
 try {
  var div = document.getElementById("advertBox_horiz");
  div.scrollLeft = g;
  
  /*if( i > 1350) {
  alert(i+"----"+(div.scrollHeight/2 ));
  }
  */
  if( g >= div.scrollWidth / 2) {
   g = 0;
  }
  
  //alert(div.offsetHeight );
  
  if (g > div.scrollWidth - div.clientWidth ) {
   //alert(div.scrollHeight + "----" + i); 
   speed_hor = speed_hor * -1;
   clearTimeout(t2);
   t2=setTimeout("wait_hor()",1000);
  } else if ( g < 0 ) {
   speed_hor = speed_hor * -1;
   clearTimeout(t2);
   t2=setTimeout("wait_hor()",1000);
  } else {
   t2=setTimeout("scroll_hor()",50);
  }
 } 
 catch(err) {
  t2=setTimeout("wait_hor()",1000);
 }
}
function wait_hor() {
 scroll_hor();
// alert("teszt");
}

scroll_hor();
