//glimmer_text.js
//Author: Joshua Birk
//current modDate: Aug,05,1999

//glimmer.js mod for manipulating text within a layer.
//Note that all of these functions rewrite the layer content

//init function for this mod.  goes before initAll() is called.
function initGtext() {
	addMod("overwrite",layer_write);
    addMod("changeBg",layer_changeBg);
	addMod("fadeBlackWhite",layer_fadeBlackWhite);
	addMod("fadeWhiteBlack",layer_fadeWhiteBlack);
	addMod("fadeWhiteBlackAL",layer_fadeWhiteBlack);
	addMod("colorRipple",layer_colorRipple);
	}


//erase old content, replace with new HTML 
function layer_write(content,y,codette) {	
	if (!codette){codette = new Array('end');}
    if (document.all) {
	eval (this.name + '.innerHTML = ' + '"' + content + '"');
	}
    else if (document.getElementById) {
    var range = document.createRange();
    var someElement = document.getElementById(this.name);
    range.setStartAfter(someElement);
    var docFrag = range.createContextualFragment(content);
    range.deleteContents();
    var oChild = someElement.childNodes[0];
    someElement.replaceChild(docFrag,oChild);
//	alert(this.layer.innerHTML)// = content;
	}
	else if (document.layers) {
		content = "<body>" + content + "</body>";
		this.layer.document.open();
		this.layer.document.write(content);
		this.layer.document.close();
	}
	if (codette){this.runMe(codette);}
}


function layer_changeBg(color,y,codette) {
    if(document.all || document.getElementById){this.layer.backgroundColor = color} else{this.layer.bgColor = color;}
    this.refresh();
    if (codette){this.runMe(codette);}
    }


//'trick' functions - combination of other functions for canned effects
function layer_fadeBlackWhite(content,time,codette) {
	color1_text = "'<font color=#000000>"+content+"</font>'";
	color2_text = "'<font color=#4E4E4E>"+content+"</font>'";
	color3_text = "'<font color=#808080>"+content+"</font>'";
	color4_text = "'<font color=#C0C0C0>"+content+"</font>'";
	color5_text = "'<font color=#FFFFFF>"+content+"</font>'";
	func = this.obj_name + ".overwrite";
	setcodette = func+"|"+color1_text+"|"+time+"|"+pause+"|"+0+"|"+time+"|"+func+"|"+color2_text+"|"+time+"|"+pause+"|"+0+"|"+time+"|"+func+"|"+color3_text+"|"+time+"|"+pause+"|"+0+"|"+time+"|"+func+"|"+color4_text+"|"+time+"|"+pause+"|"+0+"|"+time+"|"+func+"|"+color5_text+"|"+time+"|"+pause+"|"+0+"|"+time+"|"+codette;
	this.runMe(setcodette);
	}

/*function layer_fadeWhiteBlack(content,url,img_url,time,codette) {
	color1_text = "'<font color=#FFFFFF><a href=`"+url+"`><img src=`"+img_url+"` height=28 width=106 border=0 alt=`"+content+"`></a></font>'";
	color2_text = "'<font color=#C0C0C0><a href=`"+url+"`><img src=`"+img_url+"` height=28 width=106 border=0  alt=`"+content+"`></a></font>'";
	color3_text = "'<font color=#808080><a href=`"+url+"`><img src=`"+img_url+"` height=28 width=106 border=0  alt=`"+content+"`></a></font>'";
	color4_text = "'<font color=#4E4E4E><a href=`"+url+"`><img src=`"+img_url+"` height=28 width=106 border=0  alt=`"+content+"`></a></font>'";
	color5_text = "'<font color=#4E4E4E><a href=`"+url+"`><img src=`"+img_url+"` height=28 width=106 border=0 alt=`"+content+"`></a></font>'";
	func = this.obj_name + ".overwrite";
	setcodette = func+"|"+color1_text+"|"+time+"|"+pause+"|"+0+"|"+time+"|"+func+"|"+color2_text+"|"+time+"|"+pause+"|"+0+"|"+time+"|"+func+"|"+color3_text+"|"+time+"|"+pause+"|"+0+"|"+time+"|"+func+"|"+color4_text+"|"+time+"|"+pause+"|"+0+"|"+time+"|"+func+"|"+color5_text+"|"+time+"|"+pause+"|"+0+"|"+time+"|"+codette;
	this.runMe(setcodette);
	}*/

	function layer_fadeWhiteBlack(content,url,img_url,time,codette) {
	color1_text = "'<a href=`"+url+"`><img src=`"+img_url+"` height=`100` width=`100` border=`0` alt=`"+content+".`></a>'";
	func = this.obj_name + ".overwrite";
	setcodette = func+"|"+color1_text+"|"+time+"|"+pause+"|"+0+"|"+time+"|"+codette;
	//alert(setcodette);
	this.runMe(setcodette);
	}

function layer_fadeWhiteBlackAL(content,url,img_url,time,codette) {
	color1_text = "<font color=#FFFFFF><a href="+url+"><img src="+img_url+ " height='28' width='106' border='0'></a></font>";
	color2_text = "<font color=#C0C0C0><a href="+url+"><img src="+img_url+" height='28' width='106' border='0'></a></font>";
	color3_text = "<font color=#808080><a href="+url+"><img src="+img_url+" height='28' width='106' border='0'></a></font>";
	color4_text = "<font color=#4E4E4E><a href="+url+"><img src="+img_url+" height='28' width='106' border='0'></a></font>";
	color5_text = "<font color=#000000><a href="+url+"><img src="+img_url+" height='28' width='106' border='0'></a></font>";
	func = this.obj_name + ".overwrite";
	setcodette = func+"|'"+color1_text+"|"+time+"|"+pause+"|"+0+"|"+time+"|"+func+"|"+color2_text+"|"+time+"|"+pause+"|"+0+"|"+time+"|"+func+"|"+color3_text+"|"+time+"|"+pause+"|"+0+"|"+time+"|"+func+"|"+color4_text+"|"+time+"|"+pause+"|"+0+"|"+time+"|"+func+"|"+color5_text+"|"+time+"|"+pause+"|"+0+"|"+time+"|'"+codette;
	this.runMe(setcodette);
	}

	function layer_fadeWhiteBlackAL_(content,url,img_url,time,codette) {
		//alert("hello")
	color1_text = "<a href="+url+"><img src="+img_url+ " height='28' width='106' border='0'></a>";
	color2_text = "<a href="+url+"><img src="+img_url+" height='28' width='106' border='0'></a>";
	color3_text = "<a href="+url+"><img src="+img_url+" height='28' width='106' border='0'></a>";
	color4_text = "<a href="+url+"><img src="+img_url+" height='28' width='106' border='0'></a>";
	color5_text = "<a href="+url+"><img src="+img_url+" height='28' width='106' border='0'></a>";
	func = this.obj_name + ".overwrite";
	setcodette = func+"|'"+color1_text+"|"+time+"|"+pause+"|"+0+"|"+time+"|"+func+"|"+color2_text+"|"+time+"|"+pause+"|"+0+"|"+time+"|"+func+"|"+color3_text+"|"+time+"|"+pause+"|"+0+"|"+time+"|"+func+"|"+color4_text+"|"+time+"|"+pause+"|"+0+"|"+time+"|"+func+"|"+color5_text+"|"+time+"|"+pause+"|"+0+"|"+time+"|'"+codette;
	this.runMe(setcodette);
	}

//Ripple function essentially replaces the above.  Initial code/design by Valerie Duncan.
function layer_colorRipple(colors,content,codette) {
	var setcodette;
	var thiscontent;
	setcodette = "";
	time = this.speed;
	func = this.obj_name + ".overwrite";
	local_colors = colors.split ("|");
	for (n = 0; n < local_colors.length; n++) {
		thiscontent = "'<font color="+local_colors[n]+">"+content+"</font>'";
		setcodette += func+"|"+thiscontent+"|"+time+"|"+pause+"|"+0+"|"+time+"|";
		}
	setcodette += "end";
	this.runMe(setcodette);
	} 

initGtext();