function pausescroller(divId, divClass, delay, content, animateUpSpeed) {
    this.tickerId=divId;
    this.delay=delay;
    this.mouseOverBol=0;
    this.hiddenDivPointer=1;
    this.content=content;
    if(animateUpSpeed) {
        this.animateUpSpeed=animateUpSpeed;
    } else {
        this.animateUpSpeed=50;
    }

    document.write('<div id="'+divId+'" class="'+divClass+'" style="width: 100%; position: relative; overflow: hidden;">');
    document.write('<div class="innerDiv" style="position: absolute;" id="'+divId+'1"></div>');
    document.write('<div class="innerDiv" style="position: absolute; visibility: hidden;" id="'+divId+'2"></div>');
    document.write('</div>')

    if (document.getElementById) { //perform basic DOM browser support
        this.tickerDiv=document.getElementById(this.tickerId);
        this.visibleDiv=document.getElementById(this.tickerId+"1");
        this.hiddenDiv=document.getElementById(this.tickerId+"2");
        this.visibleDivTop=parseInt(pausescroller.getCSSpadding(this.tickerDiv));

        this.visibleDiv.style.width=this.hiddenDiv.style.width=this.tickerDiv.offsetWidth-(this.visibleDivTop*2)+"px";
        this.visibleDiv.innerHTML=this.formatMessage(0);
        if(this.content.length>1) {
            this.hiddenDiv.innerHTML=this.formatMessage(1);
            this.initialize();
        }
    }
}

pausescroller.prototype.formatMessage=function(id) {
    return this.content[id];
}

pausescroller.prototype.initialize=function(){
    var scrollerInstance=this;
    this.getInLine(this.visibleDiv, this.hiddenDiv);
    this.hiddenDiv.style.visibility="visible";

    this.visibleDiv.style.width=this.hiddenDiv.style.width=this.tickerDiv.offsetWidth-(this.visibleDivTop*2)+"px";
    this.tickerDiv.onmouseover=function(){scrollerInstance.mouseOverBol=1};
    this.tickerDiv.onmouseout=function(){scrollerInstance.mouseOverBol=0};
    if (window.attachEvent) {
        window.attachEvent("onunload", function(){scrollerInstance.tickerDiv.onmouseover=scrollerInstance.tickerDiv.onmouseout=null});
    }
    setTimeout(function(){scrollerInstance.animateUp()}, 0);//this.delay);
}


pausescroller.prototype.animateUp=function(){
    var scrollerInstance=this;
    if (parseInt(this.hiddenDiv.style.top)>(this.visibleDivTop+5)) {
        this.visibleDiv.style.top=parseInt(this.visibleDiv.style.top)-5+"px";
        this.hiddenDiv.style.top=parseInt(this.hiddenDiv.style.top)-5+"px";
        setTimeout(function(){scrollerInstance.animateUp()}, this.animateUpSpeed);
    } else {
        this.getInLine(this.hiddenDiv, this.visibleDiv);
        this.swapDivs();
        setTimeout(function(){scrollerInstance.rotateMessage()}, this.delay);
    }
}

pausescroller.prototype.swapDivs=function() {
    var temp=this.visibleDiv;
    this.visibleDiv=this.hiddenDiv;
    this.hiddenDiv=temp;
}

pausescroller.prototype.getInLine=function(div1, div2) {
    div1.style.top=this.visibleDivTop+"px";
    div2.style.top=Math.max(div1.parentNode.offsetHeight, div1.offsetHeight)+"px";
}

pausescroller.prototype.rotateMessage=function() {
    var scrollerInstance=this;
    if (this.mouseOverBol==1) {
        setTimeout(function(){scrollerInstance.rotateMessage()}, 100)
    } else {
        this.hiddenDivPointer=this.hiddenDivPointer+1;
        if(this.hiddenDivPointer>=this.content.length) {
            this.hiddenDivPointer=0;
        }
        this.hiddenDiv.innerHTML=this.formatMessage(this.hiddenDivPointer);
        this.animateUp();
    }
}

// get CSS padding value, if any
pausescroller.getCSSpadding=function(tickerObj) {
    if (tickerObj.currentStyle) {
        return tickerObj.currentStyle["paddingTop"];
    } else if (window.getComputedStyle) {
        return window.getComputedStyle(tickerObj, "").getPropertyValue("padding-top");
    } else {
        return 0;
    }
}

