// JavaScript Document

// Do Not Modify Below This Line

// Scrollers width here (in pixels)
var scrollerwidth;

// Scrollers height here
var scrollerheight;

// Scrollers speed here (larger is faster 1-10)
var scrollerspeed;

// Staff Name Config
var stafffontsize;
var stafffontweight;
var stafffontfamily;
var stafffontcolor;

// Staff Title Config
var stafftitlefontsize;
var stafftitlefontweight;
var stafftitlefontfamily;
var stafftitlefontcolor;

// Quote Config
var staffquotefontsize;
var staffquotefontweight;
var staffquotefontfamily;
var staffquotefontcolor;

var scrollercontent;

var staffnames=new Array();
var stafftitles=new Array();
var staffquotes=new Array();

var copyspeed;
var iedom;
var actualheight;
var cross_scroller, ns_scroller;
var pausespeed;

function AddClientName(name) {
 staffnames.push(name);
}

function AddClientOrganization(org) {
 stafftitles.push(org); 
}

function AddClientQuote(quote) {
 staffquotes.push(quote); 
}

function SetScrollBoxWidth(width) {
 scrollerwidth = width+'px';
}

function SetScrollBoxHeight(height) {
 scrollerheight = height+'px';
}

function SetScrollSpeed(speed) {
 scrollerspeed = speed;
}

function SetClientNameStyle(family,size,weight,color) {
 stafffontfamily=family;
 stafffontsize=size;
 stafffontweight=weight;
 stafffontcolor=color;
}

function SetClientOrganizationStyle(family,size,weight,color) {
 stafftitlefontfamily=family;
 stafftitlefontsize=size;
 stafftitlefontweight=weight;
 stafftitlefontcolor=color;
}

function SetClientQuoteStyle(family,size,weight,color) {
 staffquotefontfamily=family;
 staffquotefontsize=size;
 staffquotefontweight=weight;
 staffquotefontcolor=color;
}

function ShowScrollBox() {
 scrollercontent='';
 //debugger;
 for (var i=0;i<staffnames.length;i++) {
  scrollercontent += '<span style="color:'+stafffontcolor+'; font-size:'+stafffontsize+'px; font-weight:'+stafffontweight+'; font-family:'+stafffontfamily+';">'+staffnames[i]+'</span><br>';
  scrollercontent += '<span style="color:'+stafftitlefontcolor+'; font-size:'+stafftitlefontsize+'px; font-weight:'+stafftitlefontweight+'; font-family:'+stafftitlefontfamily+';">'+stafftitles[i]+'</span><br>';
  scrollercontent += '<span style="color:'+staffquotefontcolor+'; font-size:'+staffquotefontsize+'px; font-weight:'+staffquotefontweight+'; font-family:'+staffquotefontfamily+';">'+staffquotes[i]+'</span>';
  
  if((i+1)<staffnames.length){
   scrollercontent += '<br><br><br>';
  }
 }
 
 InitializeBox();
 BuildBox();
 populate();
}

var pauseit=1;


// Change nothing below!

function InitializeBox() {
 scrollerspeed=(document.all)? scrollerspeed : Math.max(1, scrollerspeed-1); //slow speed down by 1 for NS
 copyspeed=scrollerspeed;
 iedom=document.all||document.getElementById;
 actualheight='';
 pausespeed=(pauseit==0)? copyspeed: 0;
}

function populate(){
 if (iedom)
 {
  cross_scroller=document.getElementById? document.getElementById("iescroller") : document.all.iescroller;
  cross_scroller.style.top=parseInt(scrollerheight)+8+"px";
  cross_scroller.innerHTML=scrollercontent;
  actualheight=cross_scroller.offsetHeight;
 }
 else if (document.layers)
 {
  ns_scroller=document.ns_scroller.document.ns_scroller2;
  ns_scroller.top=parseInt(scrollerheight)+8;
  ns_scroller.document.write(scrollercontent);
  ns_scroller.document.close();
  actualheight=ns_scroller.document.height;
 }
 
 lefttime=setInterval("scrollscroller()",20);
}

//window.onload=populate;

function scrollscroller()
{
 if (actualheight==0) {
  actualheight=cross_scroller.offsetHeight;
 }
 
 if (iedom){
  //alert('cross_scroller.style.top='+cross_scroller.style.top+'\r actualheight='+actualheight);
  if (parseInt(cross_scroller.style.top)>(actualheight*(-1)+8))
  {
   cross_scroller.style.top=parseInt(cross_scroller.style.top)-copyspeed+"px";
  }
  else
  {
   
   cross_scroller.style.top=parseInt(scrollerheight)+8+"px";
  }
 }
 else if (document.layers)
 {
  if (ns_scroller.top>(actualheight*(-1)+8))
  {
   ns_scroller.top-=copyspeed;
  }
  else
  {
   ns_scroller.top=parseInt(scrollerheight)+8;
  }
 }
}

function BuildBox() {
 if (iedom||document.layers){
  with (document){
   if (iedom)
   {
    write('<div style="position:relative;width:'+scrollerwidth+';height:'+scrollerheight+';overflow:hidden" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=scrollerspeed">');
    write('<div id="iescroller" style="position:absolute;left:0px;top:0px;width:100%;">');
    write('</div></div>');
   }
   else if (document.layers)
   {
    write('<ilayer width='+scrollerwidth+' height='+scrollerheight+' name="ns_scroller">');
    write('<layer name="ns_scroller2" width='+scrollerwidth+' height='+scrollerheight+' left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=scrollerspeed"></layer>');
    write('</ilayer>');
   }
  }
 }
}

