var speed_a = 1;
var speed_b = 0; 
var psspee = speed_a; 
var delay = 1; 
var width; 
var height;
var ad_scroller = 'ad'; 
var slypo;
var position;
var dps = document; 
var psokbr = dps.all || dps.getElementById; 
var content = '<div id="adContent" style="float: left; width: '+width+'px; border: 0; background-color: #61AB2C;">Labas<br />Testas</div>';  


function psstrt() { 
  setInterval("psrol()",20); 
  height = document.getElementById('adContent').offsetHeight;
  psdgs(ad_scroller).height = height+'px';
  
  if (navigator.userAgent.indexOf("MSIE 6.0") > -1)
    psbepoIE();
  else
    psbepo(); 
  psdgs(ad_scroller).visibility = 'visible'; 
}

function psdgs(id) { 
  return dps.getElementById(id).style; 
}  

function psdg(id) { 
  return dps.getElementById(id); 
}
  
function scrlrGetWinWidth() { 
  var myWidth = 0; 
  if( typeof( window.innerWidth ) == 'number' ) 
    myWidth = window.innerWidth; 
  else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
    myWidth = document.documentElement.clientWidth; 
  else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
    myWidth = document.body.clientWidth; 
  return myWidth; 
} 
 
function scrlrGetWinHeight() { 
  var myHeight = 0; 
  if( typeof( window.innerWidth ) == 'number' ) 
    myHeight = window.innerHeight; 
  else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
    myHeight = document.documentElement.clientHeight; 
  else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
    myHeight = document.body.clientHeight; 
  return myHeight; 
} 
 
function scrlrGetScrollTop() { 
  var myScrollTop = 0; 
  if( typeof( window.innerWidth ) == 'number' ) 
    myScrollTop = 0; 
  else if( document.documentElement && document.documentElement.scrollTop ) 
    myScrollTop = document.documentElement.scrollTop; 
  else if( document.body && document.body.scrollTop ) 
    myScrollTop = document.body.scrollTop; 
  return myScrollTop; 
} 
 
function psbepo() { 
  psdgs(ad_scroller).left = 0; 
  if (dps.getElementById)
    psdgs(ad_scroller).top = (scrlrGetWinHeight() - height)+'px'; 
  psdgs(ad_scroller).width = scrlrGetWinWidth()+'px'; 
} 

function psbepoIE() { 
  psdgs(ad_scroller).left = 0; 
  if (dps.getElementById) 
    psdgs(ad_scroller).top = (document.documentElement.scrollTop + scrlrGetWinHeight() - height)+'px'; 
  psdgs(ad_scroller).width = scrlrGetWinWidth()+'px'; 
} 
 
function psrol() { 
  if (psokbr) { 
    slypo = parseInt(psdgs("add_block").left); 
    psdgs("add_block").left=slypo-psspee+'px'; 
    
    if (Math.abs(slypo)>=width) 
      psdgs("add_block").left = (-psspee)+'px'; 
  }  
}  

if (window.attachEvent) 
{ 
  window.attachEvent("onresize", psbepo);
  if (navigator.userAgent.indexOf("MSIE 6.0") > -1)
  {
    position = "absolute";
    window.attachEvent("onscroll", psbepoIE); 
  }
  else
    position = "fixed";
     
}
else
{ 
  window.addEventListener("resize", psbepo, 1);
  position = "fixed"; 
}
 
function scrollerStart(sContent)
{
  document.write('<div id="adContentTest" style=" white-space: nowrap; float: left; border: 0;">'+sContent+'</div>');
  width = document.getElementById('adContentTest').offsetWidth + 40;
  var remove = document.getElementById("adContentTest");
  remove.parentNode.removeChild(remove);
  
  var content = '<div id="adContent" style="float: left; width: '+width+'px; border: 0; background-color: #A9CC91;">'+sContent+'</div>';  
  
  
  repeat = scrlrGetWinWidth() / width + 3; 
  row = ''; 
  for (var i = 0; i < repeat; i++) { 
    row += content; 
  }
   
  document.write('<div id="'+ad_scroller+'" onMouseout="psspee=speed_a" onMouseover="psspee=speed_b" style="visibility: hidden; overflow: hidden; position: '+position+'; left: 0px; width:'+ scrlrGetWinWidth() +'px; top: 0px ; z-index: 10;">'); 
  document.write('<div id="add_block" style="whitespace: nowrap; position: absolute; left: 0px; top: 0px; width: '+(width*repeat)+'px">'+row+'</div>'); 
  document.write('</div>'); 
  setTimeout("psstrt()",(delay*1000));
}