var letra, imgstring, i,j, tags, subTexto, url

function init(){
	document.open();
	document.write('<html><head><title>e n t r o p y - signal vs. noise</title><style>img{background: white; border: none;}</style>');
	document.write("</head><body visited='#666666' active='#666666' link='#FFFFFF' background='"+ beflix +"' leftmargin='90' marginwidth='90' topmargin='0' marginheight='0' bgcolor='#FFFFFF' onLoad='flipMagic();' onkeypress='fix()'><table height=100%><tr><td>");
	if (texto.charAt(texto.length-1) == ">") {texto = texto + " ";}
	for (i=0 ; i < texto.length; i++) { // recorre el texto completo
		letra = texto.charAt(i);     // saca una letra
		/* sacando el loading tarda 40% menos
		window.status='loading ... (' + (Math.ceil(((i*100)/texto.length))) +'%) ...cargando   '
		*/
		// parser de texto taggeado
		if (letra == "<") {
			tags = texto.substring(texto.indexOf("<",i)+1,texto.indexOf("|",i)); // veo que tags usa
			subTexto = texto.substring(texto.indexOf("|",i)+1,texto.indexOf(">",i)); // saco el texto a taggear
			j =  texto.indexOf(subTexto); // para el loop despues, la defino antes porque el tag H la redefine
			
			if (tags.indexOf("i") != -1) {  }
			if (tags.indexOf("c") != -1) { document.write("<div align='center'>\n"); } // CENTER
			if (tags.indexOf("h") != -1) { // HREF
				url = texto.substring(texto.indexOf("|",i)+1,texto.indexOf("|",i+3));
				document.write("<a href='" + url + "'>");
				j += url.length + 1;
			} //end H if
	
			for (j ; j < (subTexto.length + texto.indexOf(subTexto) ) ; j++) {
				imgstring = "<img "; // comienza a construir el tag
				if (tags.indexOf("b") != -1) { imgstring += "height='42' ";} // bold
				if (tags.indexOf("h") != -1) { imgstring += "style='background: white; ' ";} // link
				letra = texto.charAt(j);
				getLetra();
			}
	
			if (tags.indexOf("h") != -1) { document.write("</a>\n"); }
			if (tags.indexOf("c") != -1) { document.write("</div>\n"); }
		} // end if
	
		// parser de texto sin taggear
	
		if (j) {i=j+1; j = 0 ;  letra = texto.charAt(i);}
		imgstring = "<img "; // comienza a construir el tag
		getLetra();
	
	} // end main for
	document.write("</td></tr></table>");
	document.write("<SCRIPT src='helper_fx.js' type='text/javascript'></SCRIPT>");
	document.write("<script language=javascript>zxc = setInterval(function(){refreshwin("+prevId+")}, "+texto.length*300+");</script>");
	document.write("</body></html>");
	window.status = '';
	document.close();
}



function getLetra(){ // saca el src con la letra.gif
/*	// ve si es mayus o minus y escribe el tag
	testLetra = letra.toLowerCase();
	(testLetra != letra) ? (imgstring += "src='" + letra.toLowerCase() + "_.gif' ") : (imgstring += "src='" + letra + ".gif' ") 
*/  
	letra = letra.toLowerCase();  // desact if may/min	

	switch (letra) {
		case "#": imgstring = "<br>\n";
		break
		case "ñ": imgstring += "src='i/enie.gif'> "
		break 
		case " ": imgstring += "src='i/space.gif'> " 
		break
		case ".": imgstring += "src='i/punto.gif'> " 
		break
		case ",": imgstring += "src='i/coma.gif'>" 
		break
		case ":": imgstring += "src='i/dospuntos.gif'> " 
		break
		case "?": imgstring += "src='i/space.gif'> " 
		break
		case "¿": imgstring += "src='i/space.gif'> " 
		break
		case "!": imgstring += "src='i/space.gif'> " 
		break
		case "¡": imgstring += "src='i/space.gif'> " 
		break
		case ";": imgstring += "src='i/space.gif'> " 
		break
		case "á": imgstring += "src='i/a.gif'> " 
		break
		case "é": imgstring += "src='i/e.gif'> " 
		break		
		case "í": imgstring += "src='i/i.gif'> " 
		break		
		case "ó": imgstring += "src='i/o.gif'> " 
		break
		case "ú": imgstring += "src='i/u.gif'> " 
		break
		case "-": imgstring += "src='i/punto.gif'> " 
		break
		case "_": imgstring += "src='i/punto.gif'> " 
		break				
		case "@": imgstring += "src='i/punto.gif'> " 
		break	

		default:	
		imgstring += "src='i/" + letra + ".gif'>" // escribe la letra (desactivar si se activa may/min)
	} // end switch

//	if (imgstring.indexOf("img") != -1) { imgstring += "onmouseover='this.style.height=42;this.style.marginBottom=-7' onmouseout=this.style.height=58;this.style.marginBottom=-11;this.onmouseover=''>" } 
//	imgstring += ">" 
	document.write(imgstring);
} // end GetLetra




