/***********************************************
* ProHTML Ticker script- ? Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for use
* Visit http://www.dynamicdrive.com/ for full source code
* http://www.sitepoint.com/article/rotate-content-with-dhtml
***********************************************/

var startslideshow = true;
var tickspeed = 10000; //ticker speed in miliseconds (2000=2 seconds)
var enablesubject = false; //enable scroller subject? Set to 0 to hide
var selectedDiv = 0;
var startDiv = 0;
var endDiv = 10;
var totalDivs = 10;
var casedirection = "desc";
var a;
var bnumbers = false;
var prefix = '';
var oncolor = '';
var outcolor = '';

function contractall(){
  var inc = 0;
  while (document.getElementById("dropmsg"+inc)){
    document.getElementById("dropmsg"+inc).style.display = "none";
    inc++;
  }
}
function clearAll() {
  window.clearTimeout(a);
}

function showSlide(i){
  var sourceDiv = document.getElementById("dropmsg" + i);
  var destDiv = document.getElementById("dropcontentsubject");
  if(bnumbers){
    highlightNumber(prefix,i,oncolor,outcolor);
  }
  clearAll();
  
  var selectedDivObj; 
  if(document.getElementById("dropmsg" + i) != null){
    selectedDivObj = document.getElementById("dropmsg" + i);
    contractall();
  }

  if (enablesubject){
    document.getElementById("dropcontentsubject").innerHTML = selectedDivObj.getAttribute("subject");
  }

  if(destDiv != null){
    document.getElementById("dropcontentsubject").innerHTML = selectedDivObj.innerHTML;
  }
}

function expandone(){
  if(document.getElementById("dropmsg" + selectedDiv) != null){
    var selectedDivObj = document.getElementById("dropmsg" + selectedDiv);
    if(bnumbers){
      highlightNumber(prefix,selectedDiv,oncolor,outcolor);
    }
    contractall();

    if (enablesubject){
      document.getElementById("dropcontentsubject").innerHTML = selectedDivObj.getAttribute("subject");
    }

    document.getElementById("dropcontentsubject").innerHTML = selectedDivObj.innerHTML;

    if(casedirection == "desc"){
      selectedDiv = (selectedDiv>endDiv)? selectedDiv-1 : startDiv;
    } else {
      selectedDiv = (selectedDiv<endDiv)? selectedDiv+1 : startDiv;
    }

    if(tickspeed > 0){
      a = window.setTimeout("expandone()",tickspeed);
    }
  }
}

function startscroller(){
  while (document.getElementById("dropmsg" + totalDivs)!=null){
    totalDivs++;
  }

  expandone();
}

function highlightNumber(prefix,index,oncolor,outcolor){
  for (i=startDiv; i<=endDiv; i++){
    try{
      document.getElementById(prefix + i).style.backgroundColor = oncolor;
    } catch(e) {}
  }
  document.getElementById(prefix + index).style.backgroundColor = outcolor;
}

if(tickspeed > 0){
  if (window.addEventListener)
   window.addEventListener("load", startscroller, false);
  else if (window.attachEvent)
   window.attachEvent("onload", startscroller);
}