/*¹«¸æ¹ö¶¯½Å±¾
* This notice MUST stay intact for legal use
*/
function pausescroller(content, divId, divHeight, delay){
	content=this.arrayInit(content);
	if (content.length==0){
		return;
	}else if(content.length==1){
		content[1]=content[0];
	}
	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
	var o_c=document.createElement("DIV");
	o_d=document.createElement("DIV");
	o_d.id=divId;
	with(o_d.style){
		position="relative";
		overflow="hidden";
	height=divHeight+"px";
	}
	var o_d1=document.createElement("DIV");
	with(o_d1){
		id=divId+"1";
		className="innerDiv bulletin";
		style.position="absolute";
		style.textAlign="center";
		style.width="100%";
		innerHTML=content[0];
	}
	var o_d2=document.createElement("DIV");
	with(o_d2){
		id=divId+"2";
		className="innerDiv bulletin";
		style.position="absolute";
		style.textAlign="center";
		style.width="100%";
		style.visibility="hidden";
		innerHTML=content[1];
	}
	o_d.appendChild(o_d1);
	o_d.appendChild(o_d2);
	o_c.appendChild(o_d);
	document.write(o_c.innerHTML);
	var scrollerinstance=this;
	setTimeout(function(){scrollerinstance.initialize()}, 300);
}

// initialize()- Initialize scroller method.
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;
	}
};

// 
pausescroller.prototype.arrayInit=function(arr){
	if (arr.length==0 || typeof(arr[0])!="object"){
		return arr;
	}
	if (arr[0].length==3){
		for(var i=0;i<arr.length;i++){
		var c=document.createElement("DIV");
		var a=document.createElement("A");
		a.target="_blank";
		a.href=arr[i][1];
		a.innerHTML=arr[i][0];
		a.className="bulletin";
		var s=document.createElement("SPAN");
		s.className="gray";
		s.innerHTML="&nbsp; ["+ arr[i][2] +"]";
		c.appendChild(a);
		c.appendChild(s);
		arr[i] = c.innerHTML;
		}
	}else{
		for(var i=0;i<arr.length;i++){
		var c=document.createElement("DIV");
		var a=document.createElement("A");
		a.style.fontWeight="bold";
		a.target="_blank";
		a.href=arr[i][1];
		a.innerHTML=arr[i][0];
		var s=document.createElement("DIV");
		s.className="gray";
		s.style.textAlign="left";
		s.style.marginBottom="10px";
		s.innerHTML="&nbsp; ["+ arr[i][2] +"]";
		var b=document.createElement("DIV");
		b.style.textAlign="left";
		b.innerHTML=arr[i][3];
		c.appendChild(a);
		c.appendChild(b);
		c.appendChild(s);
		arr[i] = c.innerHTML;
		}
	}
	return arr;
};
-->
