﻿/* Rotating Testimonials */

function domticker(content, divId, divClass, delay, fadethis){
	this.content=content
	this.tickerid=divId 
	this.delay=delay 
	this.mouseoverBol=0 
	this.pointer=1
	/*Need a better way for this ... */
//	this.opacitystring=(typeof fadethis!="undefined")? "width: 100%; filter:progid:DXImageTransform.Microsoft.alpha(opacity=100); -moz-opacity: 1" : ""
	/* ... */
	if (this.opacitystring!="") this.delay+=500 
	this.opacitysetting=0.2 
	document.write('<div id="'+divId+'" class="'+divClass+'"><div style="'+this.opacitystring+'">'+content[0]+'</div></div>')
	var instanceOfTicker=this
	setTimeout(function(){instanceOfTicker.initialize()}, delay)
	}
	
	domticker.prototype.initialize=function(){
	var instanceOfTicker=this
	this.contentdiv=document.getElementById(this.tickerid).firstChild 
	document.getElementById(this.tickerid).onmouseover=function(){instanceOfTicker.mouseoverBol=1}
	document.getElementById(this.tickerid).onmouseout=function(){instanceOfTicker.mouseoverBol=0}
	this.rotatemsg()
	}
	
	domticker.prototype.rotatemsg=function(){
	var instanceOfTicker=this
	if (this.mouseoverBol==1) 
	setTimeout(function(){instanceOfTicker.rotatemsg()}, 100)
	else{
	this.fadetransition("reset") 
	this.contentdiv.innerHTML=this.content[this.pointer]
	this.fadetimer1=setInterval(function(){instanceOfTicker.fadetransition('up', 'fadetimer1')}, 100) 
	this.pointer=(this.pointer<this.content.length-1)? this.pointer+1 : 0
	setTimeout(function(){instanceOfTicker.rotatemsg()}, this.delay) 
	}
	}
	
	domticker.prototype.fadetransition=function(fadetype, timerid){
	var contentdiv=this.contentdiv
	if (fadetype=="reset")
	this.opacitysetting=0.2
	if (contentdiv.filters && contentdiv.filters[0]){
	if (typeof contentdiv.filters[0].opacity=="number") 
	contentdiv.filters[0].opacity=this.opacitysetting*100
	else 
	contentdiv.style.filter="alpha(opacity="+this.opacitysetting*100+")"
	}
	else if (typeof contentdiv.style.MozOpacity!="undefined" && this.opacitystring!=""){
	contentdiv.style.MozOpacity=this.opacitysetting
	}
	else
	this.opacitysetting=1
	if (fadetype=="up")
	this.opacitysetting+=0.2
	if (fadetype=="up" && this.opacitysetting>=1)
	clearInterval(this[timerid])
}
