/*Example message arrays for the two demo scrollers*/

var pausecontent=new Array()
pausecontent[0]='<div class="quote">"In the nearly five years we have used Roundbrix, we have developed a very close working relationship.  They have functioned like an IT partner, not like a vendor looking to bill hours. I have been extremely impressed with Roundbrix\'s ability to find solutions to problems before they occur. Ed and his staff have been very proactive in helping us utilize and safeguard our systems. Further, our staff works late nights and weekends and Roundbrix has been there for us quickly and professionally, even when we\'ve had problems at incredibly odd hours."</div> <br><div class="name">Adam B.</div> <div class="title">President and CEO, Torrance</div>'
pausecontent[1]=' <div class="quote">"Roundbrix has been by far the most professional resource that I\'ve leveraged in the past twelve years of my experience. Their wide range of offerings has made them an extension of our IT department. I can always count on them to get the job done right. I\'ve been impressed by their proactive approach and their out of the box thinking to resolve complex IT related issues."</div><br><div class="name">Arshy S.</div><div class="title">MIS Manager, Irvine CA</div>'
pausecontent[2]='<div class="quote">"It\'s time for me to step out of the muck and look at the project as a whole.  I am VERY pleased.  Your people worked their butts off to make sure we had virtually no downtime no matter what got tossed at us.  Thank them all for me."</div><br><div class="name">David V.</div><div class="title">Manager, Supply Chain & Technology, Santa Ana</div>'
pausecontent[3]='<div class="quote">"We have worked with Roundbrix for nearly ten years. In that time, we have moved twice, replaced and upgraded our voice and data infrastructure twice, and implemented an ERP system. Throughout all of these upgrades and changes, Ed and his team have been instrumental in ensuring little to no downtime allowing us to focus on our core business. Items from time to time also come up "after hours", and when they have, no matter what time or day, the Roundbrix team is on it, ensuring that a small problem doesn\'t become a big one.  You\'re in great hands with Roundbrix and their staff!" </div><br><div class="name">Tony G.</div><div class="title">COO</div>'
pausecontent[4]=' <div class="quote">"Ed and his team at Roundbrix have always done a phenomenal job of providing quality IT expertise to our company. Though Ed\'s company was hired by another individual at my company, I have more trust in him than anyone else I know of in providing IT resources. Roundbrix has implemented rack server technology and IP telephony solutions including Microsoft Exchange, Microsoft SQL, AVAYA IP Office, terminal services, thin clients, etc. They have truly provided the backbone to our company."</div><br><div class="name">Chris M.</div><div class="title">Director of Customer Service</div>'

pausecontent[5]=' <div class="quote">"I would like to share a few comments about our IT service Provider, Roundbrix.  Best Practices defines Roundbrix!  This company provides excellent and prompt service.  Their personnel are knowledgeable, efficient, and thorough! It is great to know Roundbrix is keeping us secure. Thanks for such great service!"</div><br><div class="name">Kathy H.</div><div class="title">Principal</div>'


var pausecontent2=new Array()
pausecontent2[0]='<a href="http://www.news.com">News.com: Technology and business reports</a>'
pausecontent2[1]='<a href="http://www.cnn.com">CNN: Headline and breaking news 24/7</a>'
pausecontent2[2]='<a href="http://news.bbc.co.uk">BBC News: UK and international news</a>'



function pausescroller(content, divId, divClass, delay){
this.content=content //message array content
this.tickerid=divId //ID of ticker div to display information
this.delay=delay //Delay between msg change, in miliseconds.
this.mouseoverBol=0 //Boolean to indicate whether mouse is currently over scroller (and pause it if it is)
this.hiddendivpointer=1 //index of message array for hidden div
document.write('<div id="'+divId+'" class="'+divClass+'" style="position: relative; overflow: hidden"><div class="innerDiv" style="position: absolute; width: 100%" id="'+divId+'1">'+content[0]+'</div><div class="innerDiv" style="position: absolute; width: 100%; visibility: hidden" id="'+divId+'2">'+content[1]+'</div></div>')
var scrollerinstance=this
if (window.addEventListener) //run onload in DOM2 browsers
window.addEventListener("load", function(){scrollerinstance.initialize()}, false)
else if (window.attachEvent) //run onload in IE5.5+
window.attachEvent("onload", function(){scrollerinstance.initialize()})
else if (document.getElementById) //if legacy DOM browsers, just start scroller after 0.5 sec
setTimeout(function(){scrollerinstance.initialize()}, 500)
}

// -------------------------------------------------------------------
// initialize()- Initialize scroller method.
// -Get div objects, set initial positions, start up down animation
// -------------------------------------------------------------------

pausescroller.prototype.initialize=function(){
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))
//set width of inner DIVs to outer DIV's width minus padding (padding assumed to be top padding x 2)
this.visiblediv.style.width=this.hiddendiv.style.width=this.tickerdiv.offsetWidth-(this.visibledivtop*2)+"px"
this.getinline(this.visiblediv, this.hiddendiv)
this.hiddendiv.style.visibility="visible"
var scrollerinstance=this
document.getElementById(this.tickerid).onmouseover=function(){scrollerinstance.mouseoverBol=1}
document.getElementById(this.tickerid).onmouseout=function(){scrollerinstance.mouseoverBol=0}
if (window.attachEvent) //Clean up loose references in IE
window.attachEvent("onunload", function(){scrollerinstance.tickerdiv.onmouseover=scrollerinstance.tickerdiv.onmouseout=null})
setTimeout(function(){scrollerinstance.animateup()}, this.delay)
}


// -------------------------------------------------------------------
// animateup()- Move the two inner divs of the scroller up and in sync
// -------------------------------------------------------------------

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()}, 50)
}
else{
this.getinline(this.hiddendiv, this.visiblediv)
this.swapdivs()
setTimeout(function(){scrollerinstance.setmessage()}, this.delay)
}
}

// -------------------------------------------------------------------
// swapdivs()- Swap between which is the visible and which is the hidden div
// -------------------------------------------------------------------

pausescroller.prototype.swapdivs=function(){
var tempcontainer=this.visiblediv
this.visiblediv=this.hiddendiv
this.hiddendiv=tempcontainer
}

pausescroller.prototype.getinline=function(div1, div2){
div1.style.top=this.visibledivtop+"px"
div2.style.top=Math.max(div1.parentNode.offsetHeight, div1.offsetHeight)+"px"
}

// -------------------------------------------------------------------
// setmessage()- Populate the hidden div with the next message before it's visible
// -------------------------------------------------------------------

pausescroller.prototype.setmessage=function(){
var scrollerinstance=this
if (this.mouseoverBol==1) //if mouse is currently over scoller, do nothing (pause it)
setTimeout(function(){scrollerinstance.setmessage()}, 100)
else{
var i=this.hiddendivpointer
var ceiling=this.content.length
this.hiddendivpointer=(i+1>ceiling-1)? 0 : i+1
this.hiddendiv.innerHTML=this.content[this.hiddendivpointer]
this.animateup()
}
}

pausescroller.getCSSpadding=function(tickerobj){ //get CSS padding value, if any
if (tickerobj.currentStyle)
return tickerobj.currentStyle["paddingTop"]
else if (window.getComputedStyle) //if DOM2
return window.getComputedStyle(tickerobj, "").getPropertyValue("padding-top")
else
return 0
}


