	/***********************************************
	* 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 = 6000; //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 startcolor= new Array(255,255,255); // start color (red, green, blue)
	var endcolor=new Array(0,0,0); // end color (red, green, blue)

	var fID = new Array();
	var fImage = new Array();
	var fTitle = new Array();
	var fIntro = new Array();

	var fadelinks=0;  //should links inside scroller content also fade like text? 0 for no, 1 for yes.
	var faderdelay=0;
	var index=-1;

	var content_count = 0;
	var begintag='<div class="fscrollerstyle">'; //set opening tag, such as font declarations
	var closetag='</div>';

	// =============================================================

	function addcontent(intID, imageURL, title, intro) {
		fID[content_count] = intID;
		fImage[content_count] = imageURL;
		fTitle[content_count] = title;
		fIntro[content_count] = intro;	
		content_count++;
	}

	// =============================================================

	/*Rafael Raposo edited function*/
	//function to change content
	function changecontent(){
		
		if (content_count > 0)
		{
			if (index >= content_count) index = 0;

			fadeIn("image_main",99);			
			index++;
			setTimeout("changecontent()", delay);	
		}
	}

	// =============================================================

	/*Rafael Raposo edited function*/
	var fadecounter;
	function colorfade(step) {
	  if(step<=maxsteps) {	
	    document.getElementById("image_main").style.color=getstepcolor(step);
	    if (fadelinks)
	      linkcolorchange(step);
	    step++;
	    fadecounter=setTimeout("colorfade("+step+")",stepdelay);
	  }else{
	    clearTimeout(fadecounter);
	    document.getElementById("image_main").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] + ")");
	}

	//set the opacity of an element to a specified value
	function setOpacity(id, opacity) {
	  var object = document.getElementById(id).style; 
		object.opacity = (opacity / 100);
		object.MozOpacity = (opacity / 100);
		object.KhtmlOpacity = (opacity / 100);
		object.filter = 'alpha(opacity=' + opacity + ')';
	}

	// =============================================================

	function fadeIn(id, opacity) {
		if(opacity > 0) {
			setOpacity(id, opacity);
			opacity = opacity - 3;
			setTimeout("fadeIn('" + id + "'," + opacity + ")", 10);
		} 
		else { 		
			if (index >= content_count) index = 0;

			document.getElementById("image_main").style.background = "url('images/product/" + fImage[index] + "')";
			document.getElementById("title_main").innerHTML = fTitle[index];
			document.getElementById("intro_main").innerHTML = fIntro[index];
			document.getElementById("link_main").innerHTML = "<a href='product.asp?productID=" + fID[index] + "'>More...</a>";
			
			fadeOut(id,0);
		}
	}	

	// =============================================================

	function fadeOut(id, opacity) {

		if(opacity < 98) {

			setOpacity(id, opacity);
			opacity = opacity + 3;
			setTimeout("fadeOut('" + id + "'," + opacity + ")", 40);
		
		} 
}
