/***********************************************
* Fading Scroller- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var delay = 2000; //set delay between message change (in miliseconds)
var maxsteps=30; // number of steps to take to change from start color to endcolor
var stepdelay=100; // time in miliseconds of a single step
//**Note: maxsteps*stepdelay will be total time in miliseconds of fading effect
var startcolor= new Array(255,255,255); // start color (red, green, blue)
var endcolor=new Array(51,51,51); // end color (red, green, blue)

var fcontent=new Array();
begintag='<div>'; //set opening tag, such as font declarations
fcontent[0]="<a href='company/news.aspx'>BlackBerry Travel Apps: 10 Must-Have Downloads</a>";
fcontent[1]="<a href='company/news.aspx'>Didiom Pro Streams Your Audio Collection to Your Device</a>";
fcontent[2]="<a href='company/news.aspx'>Didiom Placeshifting connects all your music to one mobile device</a>";
fcontent[3]="<a href='company/news.aspx'>Finetunes Strikes Didiom Deal</a>";
fcontent[4]="<a href='company/news.aspx'>Didiom's PC-to-mobile streaming hits BlackBerry App World</a>";
fcontent[5]="<a href='company/news.aspx'>Didiom plays your desktop music collection through your mobile</a>";
fcontent[6]="<a href='company/news.aspx'>Didiom Mobile Music Store Adds 1,500 Labels</a>";
fcontent[7]="<a href='company/news.aspx'>Mobile Music Getting Seriously Disruptive</a>";
fcontent[8]="<a href='company/news.aspx'>Didiom Arrives on BlackBerry Bold and BlackBerry Curve 8900</a>";
fcontent[9]="<a href='company/news.aspx'>Another Time, Another Place. The Rise of the Placeshifters</a>";
fcontent[10]="<a href='company/news.aspx'>Didiom Launches Windows Mobile and BlackBerry iTunes Streaming</a>";
fcontent[11]="<a href='company/news.aspx'>Didiom brings their music service to more phones and implements cash bonus program</a>";
fcontent[12]="<a href='company/news.aspx'>Listen to iTunes Music on Your Phone with Didiom</a>";
fcontent[13]="<a href='company/news.aspx'>Take Your iTunes Music Library with You</a>";
fcontent[14]="<a href='company/news.aspx'>Gadgetell Resolution: Expand Your Musical Horizons</a>";
fcontent[15]="<a href='company/news.aspx'>Didiom Makes Music More Mobile, and Does It Wirelessly - And the Download Is Free</a>";
fcontent[16]="<a href='company/news.aspx'>Do the Didiom If You Want To</a>";
fcontent[17]="<a href='company/news.aspx'>Stream Your Tunes to Your Phone</a>";
fcontent[18]="<a href='company/news.aspx'>Didiom Streams Your Entire iTunes Library to Your BlackBerry</a>";
fcontent[19]="<a href='company/news.aspx'>Free Didiom Application Enables Remote iTunes Library Access</a>";
fcontent[20]="<a href='company/news.aspx'>Didiom Launches Mobile Music Place-Shifting Service, MP3 Store</a>";
fcontent[21]="<a href='company/news.aspx'>Time to Ditch Your iPod?</a>";
fcontent[22]="<a href='company/news.aspx'>Didiom Music Service Launches in Beta</a>";
fcontent[23]="<a href='company/news.aspx'>Pay the Price You Want For Mobile Music with Didiom</a>";
fcontent[24]="<a href='company/news.aspx'>Listen To PC Music on Mobile with Didiom</a>";
closetag='</div>';

var fwidth='850px'; //set scroller width
var fheight='30px'; //set scroller height

var fadelinks=1;  //should links inside scroller content also fade like text? 0 for no, 1 for yes.

///No need to edit below this line/////////////////


var ie4=document.all&&!document.getElementById;
var DOM2=document.getElementById;
var faderdelay=0;
var index=0;


/*Rafael Raposo edited function*/
//function to change content
function changecontent(){
  if (index>=fcontent.length)
    index=0
  if (DOM2){
    document.getElementById("newsTicker").style.color="rgb("+startcolor[0]+", "+startcolor[1]+", "+startcolor[2]+")"
    document.getElementById("newsTicker").innerHTML=begintag+fcontent[index]+closetag
    if (fadelinks)
      linkcolorchange(1);
    colorfade(1, 15);
  }
  else if (ie4)
    document.all.newsTicker.innerHTML=begintag+fcontent[index]+closetag;
  index++
}

// colorfade() partially by Marcio Galli for Netscape Communications.  ////////////
// Modified by Dynamicdrive.com

function linkcolorchange(step){
  var obj=document.getElementById("newsTicker").getElementsByTagName("A");
  if (obj.length>0){
    for (i=0;i<obj.length;i++)
      obj[i].style.color=getstepcolor(step);
  }
}

/*Rafael Raposo edited function*/
var fadecounter;
function colorfade(step) {
  if(step<=maxsteps) {	
    document.getElementById("newsTicker").style.color=getstepcolor(step);
    if (fadelinks)
      linkcolorchange(step);
    step++;
    fadecounter=setTimeout("colorfade("+step+")",stepdelay);
  }else{
    clearTimeout(fadecounter);
    document.getElementById("newsTicker").style.color="rgb("+endcolor[0]+", "+endcolor[1]+", "+endcolor[2]+")";
    setTimeout("changecontent()", delay);
	
  }   
}



/*Rafael Raposo's new function*/
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 style="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


