﻿/***********************************************
* 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
***********************************************/
//displays employee comments
var delay = 6000; //set delay between message change (in miliseconds)
var maxsteps=100; // number of steps to take to change from start color to endcolor 
var stepdelay=10; // 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 fcontent=new Array();
begintag='<p id="testimonial-text">'; //set opening tag, such as font declarations

fcontent[0]='&ldquo;I have been here for 4 and a half years and what keeps me with the organization is the people I work with and the leadership team. The people here are the most unselfish professionals I have worked with. We constantly help each other out when there are challenges. The Owner and Manager are always available to help provide any assistance.&quot;';

fcontent[1]='&ldquo;I have been employed at Westport One for over 5 years, and can say without hesitation that it is the most rewarding job I have had in my career.&rdquo;';

fcontent[2]='&ldquo;Nowhere else are you given the freedom to run your business within a business. Earning potential is unlimited, incentives are unparalleled, there are no enemies here - everyone gets along well and takes a sincere interest in furthering the development of their peers.&rdquo;';

fcontent[3]='&ldquo;Nowhere else are you given the freedom to run your business within a business. Earning potential is unlimited, incentives are unparalleled, there are no enemies here - everyone gets along well and takes a sincere interest in furthering the development of their peers.&rdquo;';

fcontent[4]='&ldquo;Westport One is a great proactive company that positively impacts people\'s lives on a national basis.&rdquo;'; 

fcontent[5]='&ldquo;I have worked for fortune 500 companies, and although Westport One is not part of that grouping, I would work for them over any large corporation I have ever been with. The level of professional committment, integrity, strong leadership and positive culture they have created are what makes Westport One the best place I have ever worked by a long shot.&rdquo;';

fcontent[6]='&ldquo;Westport One is by far the best organization I have ever had the opportunity to work for.&rdquo;';

fcontent[7]='&ldquo;Westport One is a great place to work. Each employee is given an opportunity to make the most of their careers.&rdquo;';


fcontent[8]='&ldquo;Westport One has treated me and my family great over the past three years. I have clearly defined goals and am rewarded nicely when I exceed them. The owner is one of the nicest and most generous people I have ever met.&rdquo;';

fcontent[9]='&ldquo;I have been with Westport One for 12 years and really enjoy the work and the people I work with. Each job is publicly recognized as a key component to the success of the organization.&rdquo;';




closetag='</p>';

//var fwidth='200px'; //set scroller width

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;


function getIndex() {
	var range = fcontent.length;
	var ph = Math.floor(Math.random() * range);
	return ph;
}

/*Rafael Raposo edited function*/
//function to change content
function changecontent(){
	
  index=getIndex();

  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);
  }
  else if (ie4) {
    document.all.fscroller.innerHTML=begintag+fcontent[index]+closetag;
  }

  /*
  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);
  }
  else if (ie4) {
    document.all.fscroller.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("fscroller").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("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("colorfadeout(maxsteps)", delay);
	
  }   
}

var fadecounter2;
function colorfadeout(step) {
  if(step>=0) {	
    document.getElementById("fscroller").style.color=getstepcolor(step);
    if (fadelinks)
      linkcolorchange(step);
    step--;
    fadecounter2=setTimeout("colorfadeout("+step+")",stepdelay);
  }else{
    clearTimeout(fadecounter2);
    document.getElementById("fscroller").style.color="rgb("+endcolor[0]+", "+endcolor[1]+", "+endcolor[2]+")";
	changecontent();
    //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] + ")");
}

function fadeText() {
	if (ie4||DOM2)
	  document.write('<div id="fscroller"></div>');

	if (window.addEventListener)
	window.addEventListener("load", changecontent, false)
	else if (window.attachEvent)
	window.attachEvent("onload", changecontent)
	else if (document.getElementById)
	window.onload=changecontent
}

