/*
Cross browser Marquee script- © Dynamic Drive (www.dynamicdrive.com)
For full source code, 100's more DHTML scripts, and Terms Of Use, visit http://www.dynamicdrive.com
Credit MUST stay intact
*/

var iedom=document.all||document.getElementById;
var arrMarquees = new Array();
var strMarqueePrefix = 'mrq';

function fPopulateAll() {
	var i;
	for (i in arrMarquees) {
		arrMarquees[i].populate();
	}
}

function fMarquee(marqueewidth, marqueeheight, marqueetop, marqueespeed, hooverspeed, marqueebgcolor, marqueecontent) {


//Attach to the DOM	
	this.index		= arrMarquees.length;
	arrMarquees[this.index] = this;
	
//PROPERTIES

	this.marqueename1	= strMarqueePrefix+'_1_'+this.index;
	this.marqueename2	= strMarqueePrefix+'_2_'+this.index;
//Specify the marquee's width (in pixels)
	this.marqueewidth 	= marqueewidth;
//Specify the marquee's height
	this.marqueeheight 	= marqueeheight;
//Specify the marquee's top
	this.marqueetop		= marqueetop;
//Specify the marquee's marquee speed (larger is faster 1-10)
	this.marqueespeed 	= marqueespeed;
//configure background color:
	this.marqueebgcolor	= marqueebgcolor;
//hooverspeed onMousever
	this.hooverspeed	= hooverspeed;
	this.marqueecontent	= marqueecontent;


//METHODS

	this.populate	= function(){
		if (iedom){
			this.cross_marquee=document.getElementById? document.getElementById(this.marqueename2) : document.all[this.marqueename2]
			this.cross_marquee.style.left=parseInt(this.marqueewidth)+8+"px"
			this.cross_marquee.innerHTML=this.marqueecontent
			this.actualwidth=document.all? document.all[this.marqueename1].offsetWidth : document.getElementById(this.marqueename1).offsetWidth
		}
		else if (document.layers){
			this.ns_marquee=document[this.marqueename1].document[this.marqueename2];
			this.ns_marquee.left=parseInt(this.marqueewidth)+8;
			this.ns_marquee.document.write(this.marqueecontent);
			this.ns_marquee.document.close();
			this.actualwidth=this.ns_marquee.document.width;
		}
		this.lefttime=setInterval("arrMarquees["+this.index+"].scrollmarquee()",20)
	}

	this.scrollmarquee = function (){
		//alert(this.cross_marquee.style.left+'.'+this.cross_marquee.style.top);
		if (iedom){
			if (parseInt(this.cross_marquee.style.left)>(this.actualwidth*(-1)+8))
				this.cross_marquee.style.left=parseInt(this.cross_marquee.style.left)-this.copyspeed+"px"
			else
				this.cross_marquee.style.left=parseInt(this.marqueewidth)+8+"px"
		
		}
		else if (document.layers){
			if (this.ns_marquee.left>(this.actualwidth*(-1)+8))
				this.ns_marquee.left-=this.copyspeed
			else
				this.ns_marquee.left=parseInt(this.marqueewidth)+8
		}
	}
	
//INITIALIZE

	this.marqueespeed=(document.all)? this.marqueespeed : Math.max(1, this.marqueespeed-1) //slow speed down by 1 for NS
	this.copyspeed=this.marqueespeed
	
	this.actualwidth	='';

	if (iedom||document.layers){
		with (document){
			if (iedom){
				write('<span id="'+this.marqueename1+'" style="visibility:hidden;position:absolute;top:-100px;left:-9000px">'+this.marqueecontent+'</span>')
				write('<div style="position:absolute;top:'+this.marqueetop+';width:'+this.marqueewidth+';height:'+this.marqueeheight+';overflow:hidden">')
				write('<div style="position:absolute;width:'+this.marqueewidth+';height:'+this.marqueeheight+';background-color:'+this.marqueebgcolor+'" onMouseover="arrMarquees['+this.index+'].copyspeed=arrMarquees['+this.index+'].hooverspeed;" onMouseout="arrMarquees['+this.index+'].copyspeed=arrMarquees['+this.index+'].marqueespeed;">')
				write('<div id="'+this.marqueename2+'" style="position:absolute;left:0px;top:5px"></div>')
				write('</div></div>')
			}
			else if (document.layers){
				write('<ilayer width='+this.marqueewidth+' height='+this.marqueeheight+' name="'+this.marqueename1+'" bgColor='+this.marqueebgcolor+'>')
				write('<layer name="'+this.marqueename2+'" left=0 top=5 onMouseover="arrMarquees['+this.index+'].copyspeed=arrMarquees['+this.index+'].hooverspeed;" onMouseout="arrMarquees['+this.index+'].copyspeed=arrMarquees['+this.index+'].marqueespeed;"></layer>')
				write('</ilayer>')
			}
		}
	}
}

window.onload=fPopulateAll;
