
function pausefader(content, divId, divClass, delay, fadesteps, fadedelay){
this.content=content //message array content
this.faderid=divId //ID of ticker div to display information
this.delay=delay //Delay between msg change, in miliseconds.
this.fadesteps= fadesteps // Number of steps for fading in/out.
this.fadedelay = fadedelay // Delay between opacity changes.
this.mouseoverBol=0 //Boolean to indicate whether mouse is currently over fader (and pause fading out it if it is).
this.contentpointer=0 //index of message array for hidden div
document.write('<div id="'+divId+'" class="'+divClass+'" style="position: relative; overflow: hidden"><div class="innerDiv" style="width: 100%" id="'+divId+'inner">'+content[0]+'</div></div>')

var faderinstance=this;

if (window.addEventListener) //run onload in DOM2 browsers
window.addEventListener("load", function(){faderinstance.initialize()}, false)
else if (window.attachEvent) //run onload in IE5.5+
window.attachEvent("onload", function(){faderinstance.initialize()})
else if (document.getElementById) //if legacy DOM browsers, just start scroller after 0.5 sec
setTimeout(function(){faderinstance.initialize()}, 500)
}

// -------------------------------------------------------------------
// initialize()- Initialize scroller method.
// -Get div objects, set initial positions, start up down animation
// -------------------------------------------------------------------

pausefader.prototype.initialize=function(){

this.faderdiv=document.getElementById(this.faderid)
this.innerdiv=document.getElementById(this.faderid+"inner")
this.currentfadestep = 0;
var faderinstance=this;

document.getElementById(this.faderid).onmouseover=function(){faderinstance.mouseoverBol=1}
document.getElementById(this.faderid).onmouseout=function(){faderinstance.mouseoverBol=0}

setopacity(this.innerdiv, 0);

if (window.attachEvent) //Clean up loose references in IE
window.attachEvent("onunload", function(){faderinstance.faderdiv.onmouseover=faderinstance.faderdiv.onmouseout=null})
setTimeout(function(){faderinstance.fadein()}, this.fadedelay)
}


pausefader.prototype.fadein =function(){


var faderinstance=this;

this.currentfadestep++;

var value = this.currentfadestep / this.fadesteps;
if(value > 1)
	value == 1;

	setopacity(this.innerdiv, value);

if(this.currentfadestep < this.fadesteps)
	setTimeout(function(){faderinstance.fadein()}, this.fadedelay);
else
	setTimeout(function(){faderinstance.fadeout()}, this.delay);
}

pausefader.prototype.fadeout =function(){

var faderinstance=this;

if (this.mouseoverBol==1)
{
	this.currentfadestep = this.fadesteps;
	setopacity(this.innerdiv, 1);
	setTimeout(function(){faderinstance.fadeout()}, this.fadedelay);
}
else
{
	this.currentfadestep--;

	var value = this.currentfadestep / this.fadesteps;
	if(value < 0)
		value == 0;

	setopacity(this.innerdiv, value);

	if(this.currentfadestep > 0)
		setTimeout(function(){faderinstance.fadeout()}, this.fadedelay);
	else
	{
		this.contentpointer++;
		this.contentpointer %= this.content.length;
		this.innerdiv.innerHTML = this.content[this.contentpointer];

		setTimeout(function(){faderinstance.fadein()}, 2 * this.fadedelay);
	}

}
}

function setopacity(obj, op)
{
	if(typeof(obj.style.filter) != "undefined") //IE
	{
		obj.style.filter = 'Alpha(opacity=' + Math.round(op* 100)+ ')';
	}
	if(typeof obj.style.opacity != "undefined") //FF
		obj.style.opacity = op;
}
