//scroller's width
var swidth=170;

//scroller's height
var sheight=80;


//scroller's speed 
var sspeed=2;
var restart=sspeed;
var rspeed=sspeed;

//scroller's pause 
var spause=2000;

//scroller's background
var sbcolor="#ccffcc";

//messages: set your own; use as many as you'd like; set up Hyperlinks to
//URLs as you normally do: <a target=... href="... URL ...">..message..</a>;
var singletext=new Array();

//singletext[...]='...';
//-- end Parameters and message -->

//-- begin: Scroller's Algorithm -->
var ii=0;
function goup(){if(sspeed!=rspeed*16){sspeed=sspeed*2;restart=sspeed;}}

function start(){
if(document.getElementById){ns6div=document.getElementById('iens6div');ns6div.style.top=sheight+"px";ns6div.innerHTML=singletext[0];sizeup=ns6div.offsetHeight;ns6scroll();}
else 
if(document.layers){ns4layer=document.ns4div.document.ns4div1;ns4layer.top=sheight;ns4layer.document.write(singletext[0]);ns4layer.document.close();sizeup=ns4layer.document.height;ns4scroll();}
else 
if(document.all){iediv=iens6div;iediv.style.pixelTop=sheight+"px";iediv.innerHTML=singletext[0];sizeup=iediv.offsetHeight;iescroll();}}
function iescroll(){if(iediv.style.pixelTop>0&&iediv.style.pixelTop<=sspeed){iediv.style.pixelTop=0;setTimeout("iescroll()",spause);}else 
if(iediv.style.pixelTop>=sizeup*-1){iediv.style.pixelTop-=sspeed+"px";setTimeout("iescroll()",100);}else{if(ii==singletext.length-1)ii=0;else ii++;iediv.style.pixelTop=sheight+"px";iediv.innerHTML=singletext[ii];sizeup=iediv.offsetHeight;iescroll();}}
function ns4scroll(){if(ns4layer.top>0&&ns4layer.top<=sspeed){ns4layer.top=0;setTimeout("ns4scroll()",spause);}else 
if(ns4layer.top>=sizeup*-1){ns4layer.top-=sspeed;setTimeout("ns4scroll()",100);}else{if(ii==singletext.length-1)ii=0;else ii++;ns4layer.top=sheight;ns4layer.document.write(singletext[ii]);ns4layer.document.close();sizeup=ns4layer.document.height;ns4scroll();}}
function ns6scroll(){if(parseInt(ns6div.style.top)>0&&parseInt(ns6div.style.top)<=sspeed){ns6div.style.top=0;setTimeout("ns6scroll()",spause);}else 
if(parseInt(ns6div.style.top)>=sizeup*-1){ns6div.style.top=parseInt(ns6div.style.top)-sspeed+"px";setTimeout("ns6scroll()",100);}
else{if(ii==singletext.length-1)ii=0;else ii++;
ns6div.style.top=sheight+"px";ns6div.innerHTML=singletext[ii];sizeup=ns6div.offsetHeight;ns6scroll();}}



var events, didyouknow;
var tEvents = [];
var tDidYouKnow = [];
var ctr = [];


function makelink(address,linkname)
{
    return "<a href=\"" + address + "\" target=\"_blank\">"  + linkname + "</a>";
}

function getReadyEvents()
{
    singletext[0] = makelink("http://www.fi-events.com.br/","Food Ingredients South America");
    singletext[1] = makelink("http://www.sial.fr/ExposiumCms/do/admin/visu?reqCode=accueil","SIAL 2010");
    singletext[2] = makelink("http://www.exponutfruit.com/en/index.html","Exponut & Dried Fruit");
}

function getReadyDidYouKnow()
{
    didyouknow = document.getElementById("didyouknow");
    tDidYouKnow[0] = "Hazelnuts and Filberts are the same nut.";
    tDidYouKnow[1] = "The macadamia nut has the hardest of all nut shells.";
    tDidYouKnow[2] = "The filbert was named for St. Filberts day as this is when the filbert bush blooms.";
    tDidYouKnow[3] = "An Australian has invented a car that runs on peanuts.";
    tDidYouKnow[4] = "Some jewelers use walnut shells, finely ground to polish gemstones.";
    tDidYouKnow[5] = "In ancient Rome, newlyweds were showered with almonds as a symbol of fertility.";
    tDidYouKnow[6] = "In Latin, apricot means \"precious\", a label earned because it ripens earlier than other summer fruits.";
    tDidYouKnow[7] = "Apricots originally came from China.";
    tDidYouKnow[8] = "Although considered a fruit, the fig is actually a flower that is inverted into itself.";
    tDidYouKnow[9] = "For many years the fig has been used as a coffee substitute.";
    tDidYouKnow[10] = "Figs provide more fiber than any other common fruit or vegetable.";
    tDidYouKnow[11] = "Cashews are very popular nut but their shells are poisonous.";
    didyouknow.innerHTML = tDidYouKnow[0];
}

function rotateText(i,rotatingText,rotatingTextElement) 
{
    ctr[i]++;
    if(ctr[i] >= rotatingText.length) 
    {
        ctr[i] = 0;
    }
    rotatingTextElement.innerHTML = rotatingText[ctr[i]];
}

function rotator()
{
    //rotateText(0,tEvents,events);
    rotateText(1,tDidYouKnow,didyouknow);
}





function initRotateText() 
{
    getReadyEvents();
    start();
    
    ctr[0] = 0; ctr[1] = 0;
    getReadyDidYouKnow();
    setInterval(rotator, 5000);
    
}    
    
window.onload = initRotateText;
