// JavaScript Document
var delay = 6000;
var maxsteps=30;
var stepdelay=40;
var startcolor= new Array(255,255,255);
var endcolor=new Array(0,0,0);

var fcontent=new Array();
begintag='<div style="font: normal 11px Tahoma; padding: 1px; color:#b9d2e0;">';
//fcontent[0]="<div style='background:url(images/box3_img6.png) right 12px no-repeat; width:154px; height:99px; float:left; padding:8px 126px 0px 15px;'><span style='color:#ff9600; font-weight:bold; line-height:18px;'>Press Release</span><br>Click <a href='pdfs/IriverPressRelease1.pdf' target='_blank'><span style='color:#fff; text-decoration:none;'>here</span></a> to read the Press Release about ATMT&#8217;s exclusive partnership with Korea&#8217;s iriver.</div>";
fcontent[0]="<div style='background:url(images/box3_img.png) right 12px no-repeat; width:154px; height:99px; float:left; padding:8px 126px 0px 15px;'><span style='color:#ff9600; font-weight:bold; line-height:18px;'>Coming soon</span><br>The ATMT <strong>Gizmo</strong> is a portable music player of the latest generation, with FM radio, video playback capability  <a href='ProductDetails.aspx?pid=14' target='_blank'><span style='color:#fff; text-decoration:none;'>...more</span></a> </div>";
fcontent[1]="<div style='background:url(images/box3_img3.png) 200px 12px no-repeat; width:154px; height:99px; float:left; padding:8px 126px 0px 15px;'><span style='color:#ff9600; font-weight:bold; line-height:18px;'>Best Seller</span><br>The Mini View, ATMT&#8217;s best-selling 7inch digital photo frame is now available in black with a brushed metal finish. <a href='ProductDetails.aspx?pid=25' target='_blank'><span style='color:#fff; text-decoration:none;'>...more</span></a></div>";
fcontent[2]="<div style='background:url(images/box3_img4.png) right 12px no-repeat; width:154px; height:99px; float:left; padding:8px 126px 0px 15px;'><span style='color:#ff9600; font-weight:bold; line-height:18px;'>Best DAB MP3</span><br>The ATMT DAB-PLAY was recently reviewed and came up trumps against the competition: 'best built-in radio in a music player that we've ever tested' said Which? magazine. <a href='ProductDetails.aspx?pid=8' target='_blank'><span style='color:#fff; text-decoration:none;'>...more</span></div>";
fcontent[3]="<div style='background:url(images/box3_img5.png) right 25px no-repeat; width:154px; height:99px; float:left; padding:8px 126px 0px 15px;'><span style='color:#ff9600; font-weight:bold; line-height:18px;'>Football Crazy</span><br>ATMT are proud to introduce the Official MP3 player for three of the biggest football clubs in the world: Manchester United, Liverpool and Arsenal. <a href='ProductDetails.aspx?pid=3' target='_blank'><span style='color:#fff; text-decoration:none;'>...more</span></a></div>";
fcontent[4]="<div style='background:url(images/box3_img6.png) right 12px no-repeat; width:154px; height:99px; float:left; padding:8px 126px 0px 15px;'><span style='color:#ff9600; font-weight:bold; line-height:18px;'>Win a DAB MP3 player</span><br>London&#8217;s Sunrise Radio are giving their listeners the chance to win the fantastic ATMT DAB MP3 player recently voted<a href='ProductDetails.aspx?pid=8' target='_blank'><span style='color:#fff; text-decoration:none;'>...more</span></a></div>";

closetag='</div>';

var fwidth='312px';
var fheight='106px';

var fadelinks=1;
var ie4=document.all&&!document.getElementById;
var DOM2=document.getElementById;
var faderdelay=0;
var index=0;

function changecontent(){
  if (index>=fcontent.length)
    index=0
  if (DOM2){
    document.getElementById("fscroller").style.color="rgb("+startcolor[0]+", "+startcolor[1]+", "+startcolor[2]+")"
    document.getElementById("fscroller").innerHTML=begintag+fcontent[index]+closetag
    if (fadelinks)
      linkcolorchange(1);
    colorfade(1, 15);
  }
  else if (ie4)
    document.all.fscroller.innerHTML=begintag+fcontent[index]+closetag;
  index++
}

function linkcolorchange(step){
  var obj=document.getElementById("fscroller").getElementsByTagName("A");
  if (obj.length>0){
    for (i=0;i<obj.length;i++)
      obj[i].style.color=getstepcolor(step);
  }
}

var fadecounter;
function colorfade(step) {
  if(step<=maxsteps) {	
    document.getElementById("fscroller").style.color=getstepcolor(step);
    if (fadelinks)
      linkcolorchange(step);
    step++;
    fadecounter=setTimeout("colorfade("+step+")",stepdelay);
  }else{
    clearTimeout(fadecounter);
    document.getElementById("fscroller").style.color="rgb("+endcolor[0]+", "+endcolor[1]+", "+endcolor[2]+")";
    setTimeout("changecontent()", delay);
	
  }   
}
function getstepcolor(step) {
  var diff
  var newcolor=new Array(3);
  for(var i=0;i<3;i++) {
    diff = (startcolor[i]-endcolor[i]);
    if(diff > 0) {
      newcolor[i] = startcolor[i]-(Math.round((diff/maxsteps))*step);
    } else {
      newcolor[i] = startcolor[i]+(Math.round((Math.abs(diff)/maxsteps))*step);
    }
  }
  return ("rgb(" + newcolor[0] + ", " + newcolor[1] + ", " + newcolor[2] + ")");
}

if (ie4||DOM2)
  document.write('<div id="fscroller" style="border:0px solid black;width:'+fwidth+';height:'+fheight+'"></div>');

if (window.addEventListener)
window.addEventListener("load", changecontent, false)
else if (window.attachEvent)
window.attachEvent("onload", changecontent)
else if (document.getElementById)
window.onload=changecontent
