/***********************************************
* This script is mash of two scripts on Dynamic Drive by Nicholas Murray
* Based on:
* Fading Scroller- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* And:
* Gradual Element Fader- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)
* Visit http://www.dynamicDrive.com for hundreds of DHTML scripts
* This notice must stay intact for legal use
***********************************************/

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=40; // time in miliseconds of a single step
//**Note: maxsteps*stepdelay will be total time in miliseconds of fading effect
var startOpacity = 0;    // 0 = totally transparent
var endOpacity  = 1.0;    // 1 = not opacic


var fcontent=new Array();
begintag='<div style="font: normal 14px Arial; padding: 0px; position:absolute; float:left; left:0px; top:0px; border:0px; background-color:#FFFFFF;"><center><i><b>Proudly sponsored by:</b></i></center><br /><a href=\"sponsors.html\">'; //set opening tag, such as font declarations
fcontent[0]="<img src=\"img/sponsors/sportunleashed.png\" width=\"200px\" border=\"0\">";
fcontent[1]="<img src=\"img/sponsors/flagz.png\" width=\"200px\" border=\"0\">";

fcontent[2]="<img src=\"img/sponsors/ecc.png\" width=\"200px\" border=\"0\">";
fcontent[3]="<img src=\"img/sponsors/blokart.png\" width=\"200px\" border=\"0\">";
fcontent[4]="<img src=\"img/sponsors/webworld.png\" width=\"200px\" border=\"0\">";
fcontent[5]="<img src=\"img/sponsors/optn.png\" width=\"200px\" border=\"0\">";
 fcontent[6]="<img src=\"img/sponsors/tyres.jpg\" width=\"200px\" border=\"0\">";
closetag='</a></div>';

var fwidth='200px'; //set scroller width
var fheight='100px'; //set scroller height


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


var ie4=document.all&&!document.getElementById;
var DOM2=document.getElementById;
var index = 0;
var step = 0;
document.getElementById("sponsors_ns").style.visibility = 'hidden';

/*Nicholas Murray created this function
/ it is more obvious how it works than the fading scroller.*/
function sequence()  
{
 var targetDivObj =   document.getElementById("fscroller");
 var opacity;
 if( step == 0)
 {
 //change content
 changecontent(targetDivObj);
 setTimeout("sequence()", stepDelay);
 }
 else if ( step == maxSteps)
 {     //totally faded in
  setOpacity(targetDivObj, endOpacity)
  setTimeout("sequence()", delay);
 }
 else if ( step > maxSteps)
 {    //display time done. Set maxSteps negative to start fade out.
  step = -maxSteps;
  setTimeout("sequence()", stepDelay);
 }
 else
 {  //calc & apply opacity transistion effect.
  opacity = startOpacity + ((Math.abs(step)/maxSteps)*(endOpacity-startOpacity));  //% progress of steps * difference in opacity added to start Opacity. 
  setOpacity(targetDivObj, opacity )
  setTimeout("sequence()", stepDelay);
 }
 step++;
}
  
/*Rafael Raposo edited function*/
//function to change content
function changecontent(obj){
 var targetDivObj = obj;  
  if (index>=fcontent.length)
    index=0;
  if (DOM2){
    setOpacity(targetDivObj,startOpacity);
    document.getElementById("fscroller").innerHTML=begintag+fcontent[index]+closetag;
  }
  else if (ie4)
    document.all.fscroller.innerHTML=begintag+fcontent[index]+closetag;
  index++;
}
 
function setOpacity(obj, value){ //Sets the opacity of targetobject based on the passed in value setting (0 to 1 and in between)
	var targetobject=obj;
	if (targetobject && targetobject.filters && targetobject.filters[0]){ //IE syntax
		if (typeof targetobject.filters[0].opacity=="number") //IE6
			targetobject.filters[0].opacity=value*100;
		else //IE 5.5
			targetobject.style.filter="alpha(opacity="+value*100+")"
		}
	else if (targetobject && typeof targetobject.style.MozOpacity!="undefined") //Old Mozilla syntax
		targetobject.style.MozOpacity=value;
	else if (targetobject && typeof targetobject.style.opacity!="undefined") //Standard opacity syntax
		targetobject.style.opacity=value;
	targetobject.currentopacity=value;
}

//break out of iframes for easy link posting in blog.
if (top.location!=self.location)
{
  top.location = self.location.href;
}

if (ie4||DOM2)
  document.write('<div id="fscroller" style="position:absolute; top:10px; left:590px; background-color:transparent; border:0px; width:'+fwidth+';height:'+fheight+'"></div>');
  
if (window.addEventListener)
window.addEventListener("load", sequence, false)
else if (window.attachEvent)
window.attachEvent("onload", sequence)
else if (document.getElementById)
window.onload=changecontent

