//OO Neon Lights Text II from Neon Lights Text II by G.P.F. (gpf@beta-cc.de)
//visit http://www.beta-cc.de - This notice must remain for legal use
//Visit http://www.dynamicdrive.com for TOS
//Modified in http://www.dynamicdrive.com/forums/ by jscheuer1 for multiple use

///////////// No Need To Edit Here - See Below, in the Body /////////////

/* EXPLANATION OF TERMS /*
id - id of the element containing the message
neontextcolor - Text Color of main Flashing Section
neontextcolor2 - Text Color of section trailing main Flashing Section
flashspeed - speed of flashing in milliseconds
flashingletters - number of letters flashing in neontextcolor
flashingletters2 - number of letters flashing in neontextcolor2 (0 to disable)
flashpause - the pause between flash-cycles in milliseconds
*/
//USAGE: new neoII('id', 'neontextcolor', 'neontextcolor2', flashspeed, flashingletters, flashingletters2, flashpause)
//new neoII('fuckit1', 'yellow', '#ffffa8', 100, 3, 1, 0);



function neoII(id, nc, nc2, fs, fl, fl2, fp){
	if(!document.getElementById&&!document.all) return;
	this.id=id;//
	this.el=document.getElementById? document.getElementById(id) : document.all[id];
	this.message=this.el.innerHTML;
	this.neonbasecolor=this.el.style.color;
	this.neontextcolor=nc;
	this.neontextcolor2=nc2;
	this.flashspeed=fs;
	this.flashingletters=fl;
	this.flashingletters2=fl2;
	this.flashpause=fp;
	
	this.n=0;
	
	for (var s='', m=0;m<this.message.length;m++)
		s+='<span id="'+id+m+'">'+this.message.charAt(m)+'<\/span>';
	this.el.innerHTML=s;;
	this.beginneon();
}

neoII.prototype.crossref=function(number){
	var crossobj=document.all? document.all[this.id+number] : document.getElementById(this.id+number);
	return crossobj;
}

neoII.prototype.neon=function(){
	
	//Change all letters to base color
	if (this.n==0){
		for (var m=0;m<this.message.length;m++)
		this.crossref(m).style.color=this.neonbasecolor;
	}
	
	//cycle through and change individual letters to neon color
	this.crossref(this.n).style.color=this.neontextcolor;
	
	if (this.n>this.flashingletters-1)
		this.crossref(this.n-this.flashingletters).style.color=this.neontextcolor2 ;
	if (this.n>(this.flashingletters+this.flashingletters2)-1)
		this.crossref(this.n-this.flashingletters-this.flashingletters2).style.color=this.neonbasecolor;
	
	
	if (this.n<this.message.length-1)
		this.n++;
	else{
		this.n=0;
		clearInterval(this.flashing);
		var c=this;
		for (var m=0;m<this.message.length;m++)
			this.crossref(m).style.color=this.neonbasecolor;
		setTimeout(function(){c.beginneon();},this.flashpause);
		return;
	}
}

neoII.prototype.beginneon=function(){
	var c=this;
	this.flashing=setInterval(function(){c.neon();}, this.flashspeed);
}


